Kozhevnikov P.

There are 2013 cards with the digit 1 written on them, and 2013 cards with the digit 2 written on them. Vasya forms a 4026-digit number from these cards. In one move, Petya can swap two cards and pay Vasya 1 ruble. The process ends when Petya gets a number that is divisible by 11. What is the maximum amount Vasya can earn if Petya aims to pay as little as possible?
Consider a 4026-digit number $A$, consisting of 2013 ones and 2013 twos. Let in this number, there are $k$ ones and $l=2013-k$ twos in the odd positions, then in the even positions there will be $k$ twos and $l$ ones (here $k$ can take any integer value from 0 to 2013). The difference between the sums of the digits in the odd positions and the even positions is $(k+2 l)-(2 k+l)=l-k=2013-2 k$. Since 2013 is divisible by 11, then $A$ is divisible by 11 if and only if $k$ is divisible by 11.

In one move, $k$ can change by no more than 1. Therefore, if Vasya initially forms the number $A$ for which, say, $k=5$ (obviously, this is possible), then Petya will need at least 5 moves to get a number for which $k$ is divisible by 11.

We will show that five moves are always enough for Petya. By swapping a one in an odd position with a two in an even position, he can decrease $k$ by 1 in one move, provided that $k \neq 0$. Similarly, by swapping a two in an odd position with a one in an even position, he can increase $k$ by 1 in one move, provided that $k \neq 2013$. Let the initial number given by Vasya give a remainder $r$ when divided by 11. If $r=0$, then the initial number is already divisible by 11, and nothing needs to be done. If $1 \leq r \leq 5$, then in $r$ operations Petya can decrease $k$ by $r$ to the nearest number divisible by 11. If $6 \leq r \leq 10$, then in $11-r \leq 5$ operations Petya can increase $k$ by $11-r$ to the nearest number divisible by 11 (this is possible because the largest possible value of $k=2013$ is divisible by 11).