2012 USAJMO Problem 5 For distinct positive integers $a, b < 2012$, define $f(a, b)$ to be the number of integers $k$ with $1 \le k<2012$ such that the remainder when $ak$ divided by 2012 is greater than that of $bk$ divided by 2012. Let $S$ be the minimum value of $f(a, b)$, where $a$ and $b$ range over all pairs of distinct positive integers less than 2012. Determine $S$. 
There is a solution at AOPS, however, I have some difficulty when trying to understand it.
1) It claims that if $ak > bk$ then $a(2012 - k) < b(2012 - k)$. Is this in the $(mod \space 2012)$ context?
2) The solution also claims the above statement does not hold "at $2 (mod \space 4)$ residules", does it mean $a \equiv 2(mod \space 4) $, $b \equiv 2(mod \space 4) $, or their remainder $\equiv 2(mod \space 4) $?
3) How can this help reduce number of counts required? I've written a computer program which tells me the number of $k$'s for which the remainder of $a >$ remainder of $b$ is not balanced with that of $a < b$, and there are very few equal ones.
Can someone give me a more insightful explaination?
Thanks!
 A: That solution is incomplete. 
The minimum is $502$ times. Here's my solution:
Let $ak \equiv r_a \pmod {2012}$ and $bk \equiv r_b \pmod {2012}$. Note that $a(2012 - k) \equiv 2012 - r_a \pmod {2012}$ and similarly with $b(2012 - k)$. Thus, when $ak, bk \not\equiv 0 \pmod {2012}$, those cases will be split up 50-50 into $ak > bk$ and $ak < bk$ -- there's a bijection between the two cases. 
This is because if $ak > bk$, then $a(2012 - k) < b(2012 - k)$, and vice versa, so for every case where $ak > bk$, there is a case where $ak < bk$, and for every case where $ak < bk$ there corresponds a case where $ak > bk$. (Talking $\pmod {2012}$ here).
So we want to maximize the times where $ak \equiv 0 \pmod {2012}$ or $ak \equiv bk \pmod {2012}$
If $k$ is even, then if $a \equiv 0 \pmod {1006}$ or $ak \equiv bk \pmod {1006} \to a - b \equiv 0 \pmod {1006}$ we have a desired solution. So, we can make $a = b + 1006$ or $a = 1006$ to satisfy the second congruence for all even numbers. There are $1005$ such even $k$.
Next consider the odd case for $k$. If $k = 503$ or $3*503$ we just require $a \equiv 0 \pmod 4$ or $a - b \equiv 0 \pmod 4$, which we can easily satisfy. For all other $k$, we must have either $ak \equiv 0 \pmod {2012}$  or $a - b \equiv 0 \pmod {2012}$ which is impossible with the domain. Thus, $2$ odd $k$ work.
The minimum is then $\frac{1}{2}(2011 - 1005 - 2) = \boxed{502}$. One value this is achieved at is $f(1006, 1010)$, though it works for all $f(1006, 4k+2)$ provided that the domain is considered.
