Usual disclaimer: I am not a lawyer. Please do not construe this as legal advice. Etc.
But my understanding from my research and past experience is this. Oh, another disclaimer: I'm an American so my experience is with U.S. copyright law, but I think most of this is pretty much the same in all countries because copyright is controlled by a couple of big international treaties. There may well be some differences in the details, though.
If you are paid by someone else to write something for them, it is considered a "work for hire" and they normally own the copyright. It would be a very very good idea to have a contract that specifies who owns the copyright to avoid any legal or ethical ambiguity. If you as the author are retaining the copyright, clearly state what rights you are giving them. Can they print it once or an unlimited number of times? Are they licensed to publish only in their own country or anywhere in the world? Etc.
But I understand that you're saying that you sold them the copyright. Okay fine. So legally, you now have exactly the same rights to this work as someone who had nothing to do with writing it. That is, you have a limited "fair use" right to quote small sections of it, and that's it.
But regarding your discussion about program logic: A copyright gives ownership of the exact words used. It does not give ownership of the research, facts, or ideas. So if, say, you sold an article in which you explained why 2+2=4, if you sold the rights, you could not sell those exact same words again somewhere else. But you could write other articles giving the exact same explanation of why 2+2=4, using the same logic and research. You just can't use the same words.
There have been many court cases where someone took, for example, an article from a newspaper, rewrote it in their own words, and published it. The courts have routinely ruled that this did not violate copyright because they did not copy the exact words.
The courts have routinely ruled that you do not have a copyright to a fact, only to the words used to describe a fact. So when you sold your calculator program, you are not selling the rights to the fact that 2+2=4. Even if you were the first person to discover that 2+2=4, you do not own a copyright on that fact. You cannot legally prevent other people from adding 2 and 2 just because you discovered it first. The copyright covers the exact text of the program, not the underlying mathematical facts or the techniques used. (You might be able to get a PATENT for the techniques, but that's a different subject.)
In one fairly recent case, a phone company copied all the phone numbers from another phone company's directory. The first company had deliberately included some fake names in their directory to catch someone doing this, and so they sued. The courts ruled that you can't copyright the phone book. They said that the individual names and phone numbers are "facts", and so can't be copyrighted. (If they could, then it would be illegal to dial anyone's number.) One can own a copyright to a particular selection and arrangement of facts, but the court said that in this case, the idea of including all the phone numbers in a specific geographical area and arranging them in alphabetical order is so obvious that it does not rise to the level of "creative work".
RE Can you re-use the sentence, "My country is great." Here we get to an issue where the courts routinely wrestle. The fair use doctrine says that you can take quotes of reasonable length from someone else's work. But what is a "reasonable length"? The extremes are obvious: If someone wrote a 300 page book, and you copied 299 pages of it word for word and changed one page, the original writer will easily win a copyright lawsuit against you. (Every now and then someone reads about copyright law and says, "So if I change one word, then I'm not copying the original author exactly, and he can't sue me!" No. Our courts can be pretty stupid, but they're not that stupid. If that was the rule, copyrights would be worthless: you could always just tack "Copied by Bob" at the end now it's "different".) At the other end, if someone tried to sue you because he wrote a book that had the word "tomato" in it and you wrote a totally different book that also used the word "tomato" and he claims that you stole this word from his book, he will lose.
You can quote a few sentences or a paragraph or two pretty freely. So I think the short answer is, no, the person you sold rights to would not own the sentence "My country is great." You could re-use that all you like. Frankly a sentence like that is generic enough that there are probably many people in the world who have written it without having copied it from someone else, but maybe that's just a bad example. Even if the sentence was quite distinctive so it was very unlikely someone else would come up with the exact same sentence, you're still allowed to copy a sentence.
If you copy several pages, you're likely on thin ice. This all gets into judgement calls. If, say, you are critiquing another author's book, and so you print a paragraph from his book, then your rebuttal, then another paragraph, then your rebuttal, etc, so that in total you copy many pages, you'd probably get away with it as long as the amount you copy isn't a significant percentage of the whole book. But if you just copy twenty pages straight out of someone else's book, you probably would lose a copyright suit.
So all that said, my short answer is: Whatever research or brainstorming you did to write an article that you sold to someone else, you can freely re-use that. Just don't use the exact same words. Take the same information, and write a new article using the same information but different words. I'd be very careful to avoid using similar phrasing.
Sorry for the long answer, but it was a long question!