[code]
The effect is - Upper ball moved, moving ball bounced back
[/code]
Yes. There is something wrong with your code.
If the incoming ball just collide with the upper one, it should move into the direction to collide with the second ball. (The incoming ball should not bounced back???).

In real life,usually, the incoming ball will hit one of the ball first then collide with the second one.
If you want to simulate the incomng ball collide with the other two balls at the same time:
Assume the incoming ball with initial valocity v_0,
Since the size of the balls are the same, and they all have the same mass.
If the incoming ball hit the other two balls at the same time, the interactive force between incoming ball and any one of the ball are in the direction connect two center of the ball.
So the direction is 45 degree or -45 degree. It means that the force is the same in x direction and in y direction. So the momentum change in x/y diretion are the same.
So the velocity for the other two balls just after the collision are
\vec{v_a}=v \hat{x} + v\hat{y} and    \vec{v_b}=v \hat{x} - v\hat{y}
and assume the velocity for the incoming ball after the collision is v'

Conservation of momentum: v_0= 2 v+v'
Conservation of energy: \tfrac{1}{2}mv_0^2= \tfrac{1}{2}m v_a^2+\tfrac{1}{2}m v_b^2+\tfrac{1}{2}m v'^2=2mv^2+\tfrac{1}{2}m v'^2
which imply v_0^2=4 v^2+v'^2
So the result are: v'=0, v_0=2v
which mean that the incoming ball with initial velocity v_0 will be stopped (v'=0) just after the collision, and the other two balls will move with velocity
\vec{v_a}=\tfrac{1}{2}v_0 \hat{x} + \tfrac{1}{2} v_0\hat{y}
and    
\vec{v_b}=\tfrac{1}{2}v_0 \hat{x} - \tfrac{1}{2}v_0 \hat{y}

However, this kind of situation normally will not happened in real life.