Hi Yageep,
I like this question. . . It makes me think.
Let's make it simpler by figuring what happens to the integers less than 10. If you add all of the odd ones it equals 25.
If you add all the even ones including 10 you get 30. That makes sense since you're adding 5 digits each time and each even digit is one more than each odd digit. To figure the sum of the even digits less than 10, you have to subtract 10 from 30 to get a total of 20.
Now we can use the same principle for the problem of integers less than 1000. There will be 500 even integers, each being one more than the odd integers so the answer including 1000 will be S + 500.
Now we have to subtract 1000 from that sum--> S + 500 - 1000 = S - 500