Mathematics, Competitive Programming, Philosophy, Discrete Mathematics.
of the Figure 2 type and m-c strokes of the Figure 1 type, we have at most 3*c+m-c=2*c+m segment births and hence the same bound on segment deaths. The number of repaintings exceed the number of segment deaths by at most 2*(m-c). The total number of repaintings is thus at most 2*c+m+2*(m-c)=3*m.