Make a WaterOverflow
Python, 217 202 176
import sys
A=sys.argv[1:]
t=A&gt;[&quot;G&quot;]
C=[[int(A[i]),i]for i in range(1,len(A))]
while C:
 c=min(C);d=1.5
 if t:d=c[0]%5&lt;2;print[&quot;P&quot;,c[1]][d],
 c[0]-=2*d;t^=1
 if[0]&gt;c:C.remove(c)

Reads input from the command line.
Strategy:

If the remaining capacity in the container with the least remaining capacity is congruent 0 or 1 modulo 5, pour 2 litres (it either overflows, or our friend pours 3 more litres into the same container, bringing us back to the same point.)
Otherwise, no move improves our position, so do nothing (note that this isn't necessarily the shortest optimal strategy.)