ZhenlongDai/ACPR huggingface dataset:
Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(M)]

red = set([1])
n_ball = [1]*(N+1)

for x,y in XY:
  n_ball[x] -= 1
  n_ball[y] += 1
  if x in red:
    red.add(y)
    if n_ball[x]==0:
      red.remove(x)
  print(red)
  print(n_ball)
print(len(red))

Failing test case input:
6 2
0 4
2 3

Expected output:
1


Actual output:
{1}
[0, 1, 1, 1, 2, 1, 1]
{1}
[0, 1, 0, 2, 2, 1, 1]
1


Fixed submission (verdict: Accepted):
N,M = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(M)]

red = set([1])
n_ball = [1]*(N+1)

for x,y in XY:
  n_ball[x] -= 1
  n_ball[y] += 1
  if x in red:
    red.add(y)
    if n_ball[x]==0:
      red.remove(x)
print(len(red))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = list(map(int,input().split()))
x = []
y = []

for i in range(M):
    u,v = map(int,input().split())
    x.append(u-1)
    y.append(v-1)


red = [0]
mas = [1 for i in range(N)]

for j in range(M):
    mas[x[j]] -= 1
    mas[y[j]] += 1
    if x[j] in red:
        red.append(y[j])
        if mas[x[j]] == 0:
            red.remove(x[j])
print(len(red))

Failing test case input:
4 4
1 1
0 3
4 1
3 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N,M = list(map(int,input().split()))
x = []
y = []
red = [0 for i in range(N)]
mas = [1 for i in range(N)]
red[0] = 1

for i in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    mas[x] -= 1
    mas[y] += 1
    if red[x] == 1:
        if red[y] == 0:
            red[y] = 1
        if mas[x] == 0:
            red[x] = 0

print(sum(red))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
aru=1
a=[1]*n
ans=set([1])
for i in range(m):
  x,y=map(int,input().split())
  if a[x-1]==0:continue
  else:
    a[x-1]-=1
    a[y-1]+=1
    if aru==x:
      aru=y
      if a[x-1]!=0:
        ans.add(x)
      elif a[x-1]!=0 and x in ans:ans.remove(x)
print(len(ans))

Failing test case input:
7 4
1 2
2 2
7 0
0 0

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
a=[1]*n
ans=set([1])
for i in range(m):
  x,y=map(int,input().split())
  if a[x-1]==0:continue
  else:
    a[x-1]-=1
    a[y-1]+=1
    if x in ans:
      ans.add(y)
      if a[x-1]==0:ans.remove(x)
print(len(ans))
Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
N = [1]*n
P = [True] + [False]*(n-1)
for i in range(m):
    x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))
    P[y] = True if P[x]==True else False
    N[x] -= 1; N[y] += 1
    P[x] = False if N[x]==0 else P[x]
print(sum(P))

Failing test case input:
4 4
2 1
0 3
4 1
3 4

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
N = [1]*n
P = [True] + [False]*(n-1)
for i in range(m):
    x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))
    P[y] = True if P[x]==True else P[y]
    N[x] -= 1
    N[y] += 1
    P[x] = False if N[x]==0 else P[x]
print(sum(P))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int, input().split())
r = 1
b0 = [1]*(n+1)
rb = [0]*(n+1)
for i in range(m):
    x,y = map(int, input().split())
    b0[x] -= 1
    b0[y] += 1
    if x == r:
        r = y
        rb[r] = 1
ans = 0
for j in range(n+1):
    if rb[j] == 1 and b0[j] >0:
        ans += 1
print(ans)

Failing test case input:
6 2
0 2
2 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
r = [0]*(n+1)
r[1] = 1
b0 = [1]*(n+1)
for i in range(m):
    x,y = map(int, input().split())
    b0[x] -= 1
    b0[y] += 1
    if r[x]:
        r[y] = 1
    if b0[x]==0:
        r[x]=0
ans = 0
for j in range(n+1):
    if r[j]:
        ans += 1
print(ans)

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int, input().split())
n = [1]*a
r = [0]*a
r[1] = 1

for i in range(b):
    ta,tb = map(int, input().split())
    ta-=1
    tb-=1
    if r[ta] == 1:
        r[tb] = 1
    n[ta] -=1
    n[tb] +=1
    if n[ta] ==0:
        r[ta] = 0
print(sum(r)) 


Failing test case input:
4 4
2 2
2 3
4 1
3 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
a,b = map(int, input().split())
n = [1]*a
r = [0]*a
r[0] = 1

for i in range(b):
    ta,tb = map(int, input().split())
    ta-=1
    tb-=1
    if r[ta] == 1:
        r[tb] = 1
    n[ta] -=1
    n[tb] +=1
    if n[ta] ==0:
        r[ta] = 0
print(sum(r))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
check=[False]*n
check[0]=True
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if check[x]:
        check[y]=True
    else:
        continue

ans=0

for i in range(n):
    if check[i]:
        ans+=1

print(ans-1)


Failing test case input:
4 4
2 2
2 3
4 1
3 4

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
check=[False]*n
check[0]=True
ball=[1]*n
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if check[x]:
        check[y]=True

    ball[y]+=1
    ball[x]-=1
    if ball[x]==0:
        check[x]=False

print(check.count(True))
Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
r=[False]*n
l=[1]*n
r[0]=True
for i in range(m):
  x,y=map(int,input().split())
  x-=1;y-=1
  if r[x]:
    r[y]=True
  l[x]-=1
  l[y]+=1
s=0
for i in range(n):
  if r[i]:
    if l[i]:
      s+=1
print(s)

Failing test case input:
5 3
1 2
2 3
1 3

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
r=[False]*n
l=[1]*n
r[0]=True
for i in range(m):
  x,y=map(int,input().split())
  x-=1;y-=1
  if r[x]:
    r[y]=True
  l[x]-=1
  l[y]+=1
  if l[x]==0:
    r[x]=False
s=0
for i in range(n):
  if r[i]:
    if l[i]:
      s+=1
print(s)

Problem: p04034
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, m = map(int, input().split())
    ball, can = [1]*n, [True]*n
    can[0] = True
    for _ in range(m):
        x, y = map(int, input().split())
        if can[x-1] == True:
            can[y-1] = True
        ball[x-1] -= 1
        ball[y-1] += 1
        if ball[x-1] == 0:
            can[x-1] = False
    print(can.count(True))
    return 0

if __name__ == "__main__":
    solve()


Failing test case input:
6 2
1 3
2 6

Expected output:
1


Actual output:
4


Fixed submission (verdict: Accepted):
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, m = map(int, input().split())
    ball, can = [1]*n, [False]*n
    can[0] = True
    for _ in range(m):
        x, y = map(int, input().split())
        if can[x-1] == True:
            can[y-1] = True
        ball[x-1] -= 1
        ball[y-1] += 1
        if ball[x-1] == 0:
            can[x-1] = False
    print(can.count(True))
    return 0

if __name__ == "__main__":
    solve()

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
stack = [1]*n
p = [1]

for i in range(m):
    x, y = map(int, input().split())
    stack[x-1] -= 1
    stack[y-1] += 1
    if x in p:
        p.append(y)

p.remove(1)
ps = list(set(p))
ans = 0
for i in ps:
    if stack[i-1] != 0:
        ans += 1
print(ans)


Failing test case input:
15 2
0 6
3 3

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
stack = [1]*n
p = [False]*n
p[0] = True

for i in range(m):
    x, y = map(int, input().split())
    stack[x-1] -= 1
    stack[y-1] += 1
    p[y-1] = p[x-1] or p[y-1]
    if stack[x-1] == 0:
        p[x-1] = False

ans = 0
for i in p:
    if i:
        ans += 1
print(ans)
Problem: p04034
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int,input().split())
f = [True] * n
num = [1] * n

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1

    num[x] -= 1
    num[y] += 1

    if num[x] == 0:
        f[x] = False
    else:
        f[y] = True

cnt = 0
for i in range(n):
    if f[i]:
        cnt += 1

print(cnt)


Failing test case input:
4 4
1 1
-1 3
4 0
3 4

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
n, m = map(int,input().split())
f = [False] * n
f[0] = True
num = [1] * n

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1

    num[x] -= 1
    num[y] += 1

    if f[x]:
        f[y] = f[x]

    if num[x] == 0:
        f[x] = False

cnt = 0
for i in range(n):
    if f[i]:
        cnt += 1

print(cnt)

Problem: p04034
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m=map(int, input().split())
xy=[list(map(int, input().split())) for _ in range(m)]

ball=[1]*n
red=[False]*n
red[True]=1
for i in range(m):
    x=xy[i][0]-1
    y=xy[i][1]-1
    if red[x]==1:
        red[y]=True
        if ball[x]==1:
            red[x]=False
    ball[y]+=1
    ball[x]-=1
print(red.count(True))


Failing test case input:
3 2
2 -1
2 3

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,m=map(int, input().split())
xy=[list(map(int, input().split())) for _ in range(m)]

ball=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
    x=xy[i][0]-1
    y=xy[i][1]-1
    ball[y]+=1
    ball[x]-=1
    if red[x]:
        red[y]=True
        if ball[x]==0:
            red[x]=False
print(red.count(True))

Problem: p04034
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
xy = [list(map(int,input().split())) for _ in range(m)]

cnt = [1] * n
r = [1] + [0] * (n-1)
for x, y in xy:
    cnt[x-1] -= 1
    cnt[y-1] += 1
    
    if cnt[x-1] == 0:
        r[x-1] = 0
        
    if r[x-1] == 1:
        r[y-1] = 1
        
print(sum(r))

Failing test case input:
4 4
1 2
2 3
4 1
0 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
xy = [list(map(int,input().split())) for _ in range(m)]

cnt = [1] * n
r = [1] + [0] * (n-1)
for x, y in xy:
    cnt[x-1] -= 1
    cnt[y-1] += 1
       
    if r[x-1] == 1:
        r[y-1] = 1
        
    if cnt[x-1] == 0:
        r[x-1] = 0
    
print(sum(r))

Problem: p04034
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m=map(int,input().split())
dp=[0]*(1+n)
dp[1]=1
b=[1]*(1+n)
for i in range(m):
    x,y=map(int,input().split())
    dp[y]=dp[x]
    b[y]+=1
    b[x]-=1
    if b[x]==0:
        dp[x]=0
print(sum(dp))


Failing test case input:
7 4
1 2
2 0
4 1
1 0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
dp=[0]*(1+n)
dp[1]=1
b=[1]*(1+n)
for i in range(m):
    x,y=map(int,input().split())
    dp[y]=max(dp[x],dp[y])
    b[y]+=1
    b[x]-=1
    if b[x]==0:
        dp[x]=0
print(sum(dp))
Problem: p04034
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int,input().split())
xy = [[int(i) for i in input().split()] for _ in range(m)]
num = [1]*n
red = [False]*n
red[0] = True
flag = True
for i in range(m):
    p = xy[i][0]
    q = xy[i][1]
    num[p-1] -= 1
    num[q-1] += 1
    if red[p-1]==True:
        red[q-1] = True
    if i==0:
        red[0] = False

count = 0
for i in range(n):
    if num[i]>0 and red[i]:
        count += 1
print(count)

Failing test case input:
6 2
0 5
5 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
xy = [[int(i) for i in input().split()] for _ in range(m)]
num = [1]*n
red = [False]*n
red[0] = True
flag = True
for i in range(m):
    p = xy[i][0]
    q = xy[i][1]
    num[p-1] -= 1
    num[q-1] += 1
    if red[p-1]==True:
        red[q-1] = True
    
    if num[p-1]==0:
        red[p-1] = False
        

count = 0
for i in range(n):
    if num[i]>0 and red[i]:
        count += 1
print(count)

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
XY = list(map(int, input().split()) for _ in range(m))

Ball = [1] * n
Done = [False] * n

flg = True
for i in range(m):
	x, y = XY[i]
	x -= 1
	y -= 1
	if Ball[x] >= 1:
			Ball[x] -= 1
			Ball[y] += 1
			if x == 0 and flg:
				Done[y] = True
				flg = False
			elif Done[x]:
				Done[y] = True
				
res = 0
for i in range(n):
	if Ball[i] != 0 and Done[i]:
		res += 1

print(res)


Failing test case input:
6 2
2 0
3 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
XY = list(map(int, input().split()) for _ in range(m))

Ball = [1] * n
Done = [False] * n
Done[0] = True

for i in range(m):
	x, y = XY[i]
	x -= 1
	y -= 1
	if Done[x]:
		Done[y] = True
	
	Ball[x] -= 1
	Ball[y] += 1
	
	if Ball[x] == 0:
		Done[x] = False
				
res = 0
for i in range(n):
	if Done[i]:
		res += 1

print(res)

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
r=[0]*n
w=[1]*n
r[0]=1
w[0]=0
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if w[x]==0:
        r[x]=0
        r[y]=1
    elif r[x]:
        w[x]-=1
        r[y]=1
print(sum(r))

Failing test case input:
6 4
1 2
2 3
4 1
1 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
w=[1]*n
p=[0]*n
p[0]=1
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if p[x]:
        p[y]=1
    w[x]-=1
    w[y]+=1
    if w[x]==0:
        p[x]=0
print(sum(p))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,*l=map(int,open(0).read().split());a=[0,1]+[0]*n;b=[1]*-~n
for i,j in zip(l[1::2],l[2::2]):a[j]|=a[i];b[i]-=1;b[j]+=1;a[i]&=b[i]
print(sum(a))

Failing test case input:
7 4
1 2
2 2
7 0
0 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,*l=map(int,open(0).read().split());a=[0,1]+[0]*n;b=[1]*-~n
for i,j in zip(l[1::2],l[2::2]):a[j]|=a[i];b[i]-=1;b[j]+=1;a[i]&=(b[i]>0)
print(sum(a))
Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())
flg=[0]*(N+1)
flg[1]=1
flg2=[1]*(N+1)
for _ in range(M):
    xy=list(map(int,input().split()))
    flg[xy[1]]=flg[xy[0]]
    flg2[xy[1]]+=1
    flg2[xy[0]]-=1
    if flg2[xy[0]] == 0:
        flg[xy[0]]=0
print(sum(map(lambda x:x>0,flg)))

Failing test case input:
5 2
1 0
2 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
flg=[0]*(N+1)
flg[1]=1
flg2=[1]*(N+1)
for _ in range(M):
    xy=list(map(int,input().split()))
    if flg[xy[0]]==1:
        flg[xy[1]]=1
    flg2[xy[1]]+=1
    flg2[xy[0]]-=1
    if flg2[xy[0]]==0:
        flg[xy[0]]=0
print(sum(map(lambda x:x>0,flg)))

Problem: p04034
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, M = map(int, input().split())
ans = [0] * N
ans[0] = 1
w = [1] * N
w[0] = 0

for i in range(M):
  x, y = map(int, input().split())
  if ans[x-1] == 1:
    if w[x-1] > 0:
      ans[y-1] = 1
      w[x-1] -= 1
    else:
      ans[y-1] = 1
      ans[x-1] = 0
  else:
    w[x-1] -= 1
    w[y-1] += 1
    
print(sum(ans))

Failing test case input:
4 4
1 1
0 3
4 1
3 4

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
ans = [0] * N
ans[0] = 1
w = [1] * N

for i in range(M):
  x, y = map(int, input().split())
  w[x-1] -= 1
  w[y-1] += 1
  if ans[x-1] == 1:
    ans[y-1] = 1
    if w[x-1] == 0:
      ans[x-1] = 0
    
print(sum(ans))

Problem: p04034
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m = map(int,input().split())
x_y = [list(map(int,input().split())) for _ in range(m)]

start = 1
aka_list = [1]
for i in range(m):
    if x_y[i][0] == start:
        if start == 1:
            aka_list.remove(1)
        aka_list.append(x_y[i][1])
        start = x_y[i][1]
balls = [1]*n
for i in range(m):
    balls[x_y[i][0]-1] -= 1
    balls[x_y[i][1]-1] += 1

count = 0
for i in range(len(aka_list)):
    if balls[aka_list[i]-1]:
        count += 1
print(count)

Failing test case input:
7 4
1 2
2 2
7 0
0 0

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
x_y = [list(map(int, input().split())) for _ in range(m)]

aka_list = [True]
for i in range(1, n):
    aka_list.append(False)
balls = [1] * n

for i in range(m):
    if aka_list[x_y[i][0] - 1]:
        aka_list[x_y[i][1]-1] = True
    balls[x_y[i][0] - 1] -= 1
    balls[x_y[i][1] - 1] += 1
    if balls[x_y[i][0] - 1] == 0:
        aka_list[x_y[i][0] - 1] = False

print(sum([1 for i in range(len(aka_list)) if aka_list[i]]))
Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=[int(x) for x in input().split()]
b=[1]*(N+1)
lst=[1]
for i in range(M):
    x,y=[int(j) for j in input().split()]
    b[x]-=1
    b[y]+=1
    if x in lst:
        lst.append(y)
lst=set(lst[1:])
ans=0
for i in range(1,N+1):
    if(b[i]!=0 and i in lst):
        ans+=1

print(ans)


Failing test case input:
6 2
2 0
2 6

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N,M=[int(x) for x in input().split()]
b=[1]*(N+1)
lst={1}
for i in range(M):
    x,y=[int(j) for j in input().split()]
    b[x]-=1
    b[y]+=1
    if x in lst:
        lst.add(y)
        if b[x]==0 :
            lst.remove(x)


    
        

print(len(lst))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
check=[False]*n
check[0]=True
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if check[x]:
        check[y]=True
    else:
        continue

ans=0
check[0]=False
for i in range(n):
    if check[i]:
        ans+=1

print(ans)


Failing test case input:
6 2
1 4
1 6

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
check=[False]*n
check[0]=True
ball=[1]*n
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if check[x]:
        check[y]=True

    ball[y]+=1
    ball[x]-=1
    if ball[x]==0:
        check[x]=False

print(check.count(True))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
f = lambda: list(map(int,input().split()))
f_ = lambda: [int(x)-1 for x in input().split()]

n,m = f()
sus = set()
conf = [0]
num = [1 for _ in range(n)]
for _ in range(m):
    x,y = f_()
    if x in conf:
        if num[y]==0:
            conf = [y]
        else:
            conf = []
            sus.add(y)
    elif y in conf:
        conf = []
        sus.add(y)
    elif x in sus:
        sus.add(y)
    num[x] -= 1; num[y] += 1
print(max(len(sus),1))

Failing test case input:
3 3
1 2
2 3
2 3

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
f = lambda: list(map(int,input().split()))
f_ = lambda: [int(x)-1 for x in input().split()]

n,m = f()
sus = set()
conf = [0]
num = [1 for _ in range(n)]
for _ in range(m):
    x,y = f_()
    num[x] -= 1; num[y] += 1
    if x in conf:
        if num[y] == 1:
            conf = [y]
        else:
            conf = []
            sus.add(y)
    elif y in conf:
        conf = []
        sus.add(y)
    elif x in sus:
        sus.add(y)
        if num[x] == 0:
            sus.remove(x)
print(max(len(sus),1))
Problem: p04034
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M=map(int, input().split())
c=[1]*(N+1)
p=[0]*(N+1)
p[1]=1
for _ in range(M):
    x,y=map(int, input().split())
    p[y]=p[x]
    c[x]-=1
    c[y]+=1
    if c[x]==0: p[x]=0
print(sum(p))

Failing test case input:
5 2
1 0
3 0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N,M=map(int, input().split())
c=[1]*(N+1)
p=[0]*(N+1)
p[1]=1
for _ in range(M):
    x,y=map(int, input().split())
    p[y]=1 if p[x]==1 else p[y]
    c[x]-=1
    c[y]+=1
    if c[x]==0: p[x]=0
print(sum(p))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



N, M = map(int, input().split())
x, y = [], []

for i in range(M):
    x_tmp, y_tmp = map(int, input().split())
    x.append(x_tmp)
    y.append(y_tmp)

box = [1] * N 
ball_set = set()
ball_set.add(1)
start_flg = True
for i in range(len(x)):
    ball_set.add(y[i])
    box[x[i] - 1] -= 1
    box[y[i] - 1] += 1
    if box[x[i] - 1] == 0:
        ball_set.discard(x[i])

print(len(ball_set))



Failing test case input:
6 2
2 0
2 6

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):



N, M = map(int, input().split())
x, y = [], []

for i in range(M):
    x_tmp, y_tmp = map(int, input().split())
    x.append(x_tmp)
    y.append(y_tmp)

box = [1] * N 
ball_set = set()
ball_set.add(1)
start_flg = True
for i in range(len(x)):
    if x[i] in ball_set:
        ball_set.add(y[i])
    box[x[i] - 1] -= 1
    box[y[i] - 1] += 1
    if box[x[i] - 1] == 0:
        ball_set.discard(x[i])

print(len(ball_set))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = (int(i) for i in input().split())  

class Box:
      def __init__(self):
         self.ball = 1
         self.pos = False
box = [] 
for i in range(N):
    box.append(Box())
box[1].pos = True

for i in range(M):
    x,y = (int(i) for i in input().split())  
    if box[x - 1].pos:
       box[y - 1].pos = True
    box[x - 1].ball -= 1
    box[y - 1].ball += 1
    if box[x - 1].ball == 0:
       box[x - 1].pos = False
cnt = 0;
for i in range(N):
   if box[i].pos:
      cnt += 1
print(cnt)

Failing test case input:
4 4
1 1
2 3
1 1
3 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N,M = (int(i) for i in input().split())  

class Box:
      def __init__(self):
         self.ball = 1
         self.pos = False
box = [] 
for i in range(N):
    box.append(Box())
box[0].pos = True

for i in range(M):
    x,y = (int(i) for i in input().split())  
    if box[x - 1].pos:
       box[y - 1].pos = True
    box[x - 1].ball -= 1
    box[y - 1].ball += 1
    if box[x - 1].ball == 0:
       box[x - 1].pos = False
cnt = 0;
for i in range(N):
   if box[i].pos:
      cnt += 1
print(cnt)
Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=list(map(int,input().split()))
W=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
BOX=[[1,1]]
BOX.extend([[1,0] for _ in range(N)])
for i in range(M):
    BOX[W[i][0]][0]=BOX[W[i][0]][0]-1
    BOX[W[i][1]][0]=BOX[W[i][1]][0]+1
    if(BOX[W[i][0]][1]==1):
        BOX[W[i][1]][1]=1
        if(BOX[W[i][0]][0]==1):
            BOX[W[i][0]][1]=0
print(sum(list(map(lambda x:x[:][1],BOX))))
    


Failing test case input:
6 2
1 4
2 3

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N,M=list(map(int,input().split()))
W=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
BOX=[[1,1]]
BOX.extend([[1,0] for _ in range(N)])
for i in range(M):
    BOX[W[i][0]][0]=BOX[W[i][0]][0]-1
    BOX[W[i][1]][0]=BOX[W[i][1]][0]+1
    if(BOX[W[i][0]][1]==1):
        BOX[W[i][1]][1]=1
        if(BOX[W[i][0]][0]==0):
            BOX[W[i][0]][1]=0
print(sum(list(map(lambda x:x[:][1],BOX))))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
balls=[1 for i in range(n)]
pro=[False for i in range(n)]
pro[0]=True

for inp in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    balls[a]-=1
    balls[b]+=1
    if pro[a]:
        pro[b]=True
    
for i in range(n):
    if balls[i]==0:
        pro[i]=False


print(pro.count(True))

Failing test case input:
4 3
1 2
2 3
4 1
1 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
balls=[1 for i in range(n)]
pro=[False for i in range(n)]
pro[0]=True

for inp in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    balls[a]-=1
    balls[b]+=1
    if pro[a]:
        pro[b]=True
    if balls[a]==0:
        pro[a]=False



print(pro.count(True))

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
array = [1] * N
red = 0
cnt = 0

for i in range(M):
    x, y = map(int, input().split())
    if red == x - 1:
        red = y - 1
        array[x-1] -= 1
        array[y-1] += 1
        cnt += 1
    else:
        array[x-1] -= 1
        array[y-1] += 1

null = array.count(0)
ans = min(cnt, N - null)

print(ans)

Failing test case input:
4 4
1 1
2 3
1 1
3 4

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
box = [1] * N
red = [False] * N
red[0] = True

for i in range(M):
    x, y = map(int, input().split())
    if red[x-1] == True:
        red[y-1] = True
        box[x-1] -= 1
        box[y-1] += 1
    else:
        box[x-1] -= 1
        box[y-1] += 1
    if box[x-1] == 0:
        red[x-1] = False

ans = red.count(True)
print(ans)
Problem: p04034
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int,input().split())
f = [False] * n
f[0] = True
num = [1] * n

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1

    num[x] -= 1
    num[y] += 1

    f[y] = f[x]

    if num[x] == 0:
        f[x] = False

cnt = 0
for i in range(n):
    if f[i]:
        cnt += 1

print(cnt)

Failing test case input:
4 4
1 1
2 3
4 1
3 4

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int,input().split())
f = [False] * n
f[0] = True
num = [1] * n

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1

    num[x] -= 1
    num[y] += 1

    if f[x]:
        f[y] = f[x]

    if num[x] == 0:
        f[x] = False

cnt = 0
for i in range(n):
    if f[i]:
        cnt += 1

print(cnt)

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int,input().split())
f = [False for _ in range(n)]
c = [1 for _ in range(n)]
f[0] = True
for i in range(m):
  x, y = map(int,input().split())
  f[y - 1] = f[y - 1] or f[x - 1]
  c[y - 1] += 1
  c[x - 1] -= 1
ans = 0
for i in range(n):
  if f[i] and c[i] > 0:
    ans += 1
print(ans)


Failing test case input:
6 4
1 2
2 3
4 1
1 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n, m = map(int,input().split())
f = [False for _ in range(n)]
c = [1 for _ in range(n)]
f[0] = True
for i in range(m):
  x, y = map(int,input().split())
  f[y - 1] = f[y - 1] or f[x - 1]
  c[y - 1] += 1
  c[x - 1] -= 1
  if c[x - 1] == 0:
    f[x - 1] = False
ans = 0
for i in range(n):
  if f[i] and c[i] > 0:
    ans += 1
print(ans)

Problem: p04034
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int,input().split())
box = [[1,0] for i in range(n)]
box[0][1] = 1
ans = 1

for i in range(m):
    x, y = map(int,input().split())
    box[x-1][0] -= 1
    box[y-1][0] += 1
    if box[x-1][1] == 1:
        if box[y-1][1] == 0:
            box[y-1][1] = 1
            ans += 1
        if box[x-1][0] == 0:
            ans -= 1

print(ans)


Failing test case input:
6 4
1 2
2 0
4 1
1 0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, m = map(int,input().split())
box = [[1,0] for i in range(n)]
box[0][1] = 1
ans = 1

for i in range(m):
    x, y = map(int,input().split())
    if box[x-1][0] == 0:
        continue
    box[x-1][0] -= 1
    box[y-1][0] += 1
    if box[x-1][1] == 1:
        if box[y-1][1] == 0:
            box[y-1][1] = 1
            ans += 1
        if box[x-1][0] == 0:
            box[x-1][1] = 0
            ans -= 1


print(ans)
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,K = (int(x) for x in input().split())

cnt = 0

while cnt < K:
    if A % 2 !=0:
        A -= 1
    A = A/2
    B += A
    cnt += 1

    if B % 2 !=0:
        B -= 1
    B = B/2
    A += B
    cnt += 1

A = int(A)
B = int(B)
print(A,B)

Failing test case input:
18 6 3

Expected output:
8 15


Actual output:
15 7


Fixed submission (verdict: Accepted):
A,B,K = (int(x) for x in input().split())

while K != 0:
    if A % 2 !=0:
        A -= 1
    A = A/2
    B += A
    K -= 1

    if K ==0:
        break
    if B % 2 !=0:
        B -= 1
    B = B/2
    A += B
    K -= 1

A = int(A)
B = int(B)
print(A,B)

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = (int(x) for x in input().split())

cnt = 0

while cnt < k:
    if a % 2 !=0:
        a -= 1
    a = a/2
    b += a
    cnt += 1

    if b % 2 !=0:
        b -= 1
    b = b/2
    a += b
    cnt += 1

a = int(a)
b = int(b)
print(a,b,k)


Failing test case input:
7425724 2844927 157

Expected output:
3423546 6847092


Actual output:
6847092 3423546 157


Fixed submission (verdict: Accepted):
A,B,K = (int(x) for x in input().split())

while K != 0:
    if A % 2 !=0:
        A -= 1
    A = A/2
    B += A
    K -= 1

    if K ==0:
        break
    if B % 2 !=0:
        B -= 1
    B = B/2
    A += B
    K -= 1

A = int(A)
B = int(B)
print(A,B)

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


A, B, K = map(int, input().split())

is_odd = K % 2

for k in range(K):
    if k % 2 == is_odd:
        if A % 2 == 1:
            A -= 1
        B = B + A * 0.5
        A = A * 0.5

    else:
        if B % 2 == 1:
            B -= 1
        A = A + B * 0.5
        B = B * 0.5

print(int(A), int(B))


Failing test case input:
6594215 1833502 111

Expected output:
2809232 5618464


Actual output:
5618468 2809234


Fixed submission (verdict: Accepted):


A, B, K = map(int, input().split())

flag = K % 2

for k in range(K):
    if k % 2 == 0:
        if A % 2 == 1:
            A -= 1
        B = B + A * 0.5
        A = A * 0.5

    else:
        if B % 2 == 1:
            B -= 1
        A = A + B * 0.5
        B = B * 0.5

print(int(A), int(B))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def abk(x,y):
  if x%2==1:
    x = x-1
  y = y + x/2
  x = x/2
  return (x,y)

a,b,k = map(int, input().split())
for _ in range(k):
  if _%2==0:
    a,b = abk(a,b)
  else:
    b,a = abk(b,a)
    
print(a,b)

Failing test case input:
12976053 1833502 111

Expected output:
4936515 9873030


Actual output:
4936515.0 9873030.0


Fixed submission (verdict: Accepted):
def abk(x,y):
  if x%2==1:
    x = x-1
  y = y + x/2
  x = x/2
  return (x,y)

a,b,k = map(int, input().split())
for _ in range(k):
  if _%2==0:
    a,b = abk(a,b)
  else:
    b,a = abk(b,a)
    
a = int(a)
b = int(b)
print(a,b)
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
            turn ^= 1
        K -= 1


    print(A," ",B)
            


        

if __name__ == '__main__':
    solve()


Failing test case input:
29665 387 100

Expected output:
20028 10014


Actual output:
20028.0   10014.0


Fixed submission (verdict: Accepted):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
            turn ^= 1
        K -= 1

    A = (int)(A)
    B = (int)(B)
    print(A,B)
            


        

if __name__ == '__main__':
    solve()

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = [int(i) for i in input().split(" ")]

for i in range(k):
  if a % 2 == 1:
    a -= 1

  b += (a / 2)
  a = a / 2

  if b % 2 == 1:
    b -= 1

  a += (b / 2)
  b = b / 2

print("{} {}".format(int(a), int(b)))

Failing test case input:
23758036 1833502 111

Expected output:
8530508 17061016


Actual output:
17061016 8530508


Fixed submission (verdict: Accepted):
a, b, k = [int(i) for i in input().split(" ")]

for i in range(int(k / 2)):
  if a % 2 == 1:
    a -= 1

  b += (a / 2)
  a = a / 2

  if b % 2 == 1:
    b -= 1

  a += (b / 2)
  b = b / 2

if k % 2 == 1:
    if a % 2 == 1:
        a -= 1

    b += (a / 2)
    a = a / 2

print("{} {}".format(int(a), int(b)))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += a
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif a%2 == 1:
            b -= 1
            b /= 2
            a += b
print(int(a),int(b))


Failing test case input:
12976053 1447180 111

Expected output:
4807739 9615478


Actual output:
4656171 9767029


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += a
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif b%2 == 1:
            b -= 1
            b /= 2
            a += b
print(int(a),int(b))
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int,input().split())

for i in range(k):
    if(i%2==0):
        if(a%2==0):
            b = b+(a/2)
            a = a-(a/2)
        else:
            a = a-1
            b = b+(a/2)
            a = a-(a/2)
    else:
        if(b%2==0):
            a = a+(b/2)
            b = b-(b/2)
        else:
            b = b-1
            a = a+b/2
            b = b-(b/2)
        
print(a,b)

Failing test case input:
8 4 1

Expected output:
4 8


Actual output:
4.0 8.0


Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())

for i in range(k):
    if(i%2==0):
        if(a%2==0):
            b = b+(a/2)
            a = a-(a/2)
        else:
            a = a-1
            b = b+(a/2)
            a = a-(a/2)
    else:
        if(b%2==0):
            a = a+(b/2)
            b = b-(b/2)
        else:
            b = b-1
            a = a+b/2
            b = b-(b/2)
        
print(int(a),int(b))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))

A = a[0]; B = a[1]; K = a[2]

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        cokkie = A / 2
        A -= cokkie
        B += cokkie
    else:
        if B % 2 == 1:
            B -= 1
        cokkie = B / 2
        B -= cokkie
        A += cokkie

print(str(A) + " " + str(B))

Failing test case input:
833725 280 110

Expected output:
555994 277997


Actual output:
555994.0 277997.0


Fixed submission (verdict: Accepted):
a = list(map(int,input().split()))

A = a[0]; B = a[1]; K = a[2]

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        cokkie = A / 2
        A -= cokkie
        B += cokkie
    else:
        if B % 2 == 1:
            B -= 1
        cokkie = B / 2
        B -= cokkie
        A += cokkie

print(str(int(A)) + " " + str(int(B)))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K= map(int, input().split())


for i in range(int(K)):
	if A % 2 != 0 :	
		A += -1
	B += A/2
	A -= A/2
	if B % 2 != 0 :	
		B+= -1
	A += B/2
	B -= B/2
print(int(A) , int(B))

Failing test case input:
15 8 25

Expected output:
7 14


Actual output:
14 7


Fixed submission (verdict: Accepted):
A, B, K= map(int, input().split())

for i in range(int(K)):
	if i % 2 == 0:
		if A % 2 != 0 :	A += -1
		B += A/2
		A -= A/2
	else:
		if B % 2 != 0 :	B+= -1
		A += B/2
		B -= B/2
print(int(A) , int(B))
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int,input().split())
cnt = 0
while True:
    if cnt==k:
        break
    if a%2!=0:
        a-=1
    b+=a/2
    a = a/2
    cnt+=1
    if cnt==k:
        break
    if b%2!=0:
        b-=1
    a+=b/2
    b = b/2
    cnt+=1


Failing test case input:
43821 640 001

Expected output:
21910 22550


Actual output:

Fixed submission (verdict: Accepted):
a, b, k = map(int,input().split())
cnt = 0
while True:
    if cnt==k:
        break
    if a%2!=0:
        a-=1
    b+=a/2
    a = a/2
    cnt+=1
    if cnt==k:
        break
    if b%2!=0:
        b-=1
    a+=b/2
    b = b/2
    cnt+=1

print(int(a),int(b))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split(' '))
for i in range(k):
    if i%2 == 1:
        if a%2 == 1:
            a = (a-1)
        a = int(a/2)
        b += a
    else:
        if b%2 == 1:
            b -= 1
        b = int(b/2)
        a += b
print(str(b) + " " + str(a))
    


Failing test case input:
172 139 111

Expected output:
102 204


Actual output:
101 202


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split(' '))
for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        a = a/2
        b += (a)
    else:
        if b%2 == 1:
            b -= 1
        b = b/2
        a += (b)
print(str(int(a)) + " " + str(int(b)))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int,input().split())
for i in range(k):
  if i%2 == 0:
    if a%2 != 0 :
      a -=1
    a /= 2
    b += a
  else :
    if b%2 != 0:
      b -= 1
    b /= 2
    a += b
print(a,b)

Failing test case input:
5424339 4524498 53

Expected output:
3316274 6632548


Actual output:
3316274.0 6632548.0


Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())
for i in range(k):
  if i%2 == 0:
    if a%2 != 0 :
      a -=1
    a /= 2
    b += a
  else :
    if b%2 != 0:
      b -= 1
    b /= 2
    a += b
print(int(a),int(b))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,K = map(int,input().split())
count = 0
for i in range(100):
  if count ==K:
    break
  else:
    if A%2 == 1:
      A = A-1
    B = B + A/2
    A = A/2
    count += 1
  if count == K:
    break
  else:
    if B%2 == 1:
      B = B-1
    A = A+ B/2
    B = B/2
    count += 1
print(A,B)

Failing test case input:
7181461 2366517 110

Expected output:
6365308 3182654


Actual output:
6365308.0 3182654.0


Fixed submission (verdict: Accepted):
A,B,K = map(int,input().split())
count = 0
for i in range(100):
  if count ==K:
    break
  else:
    if A%2 == 1:
      A = A-1
    B = B + A/2
    A = A/2
    count += 1
  if count == K:
    break
  else:
    if B%2 == 1:
      B = B-1
    A = A+ B/2
    B = B/2
    count += 1
print(int(A),int(B))
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

print(int(A), int(B))


Failing test case input:
455 139 101

Expected output:
196 392


Actual output:
392 196


Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


a,b,k = map(int, input().split())
print(a,b,k)

for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += int(a/2)
        a = int(a/2)
    
    else:
        if b%2 == 1:
            b -= 1
        a += int(b/2)
        b = int(b/2)



print(a,b)

Failing test case input:
12976053 1833502 111

Expected output:
4936515 9873030


Actual output:
12976053 1833502 111
4936515 9873030


Fixed submission (verdict: Accepted):


a,b,k = map(int, input().split())


for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += int(a/2)
        a = int(a/2)
    
    else:
        if b%2 == 1:
            b -= 1
        a += int(b/2)
        b = int(b/2)



print(a,b)

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())

for i in range(K):
    if (A == 0 or B == 0):
        break
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

print(int(A), int(B))

Failing test case input:
172 139 111

Expected output:
102 204


Actual output:
204 102


Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1
    A /= 2
    A, B = B + A, A

if K % 2 == 1:
    A, B = B, A
print(int(A), int(B))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,K = (int(x) for x in input().split())

cnt = 0

while cnt < K:
    if A % 2 !=0:
        A -= 1
    A = A/2
    B += A
    cnt += 1

    if B % 2 !=0:
        B -= 1
    B = B/2
    A += B
    cnt += 1

A = int(A)
B = int(B)
print(A,B,K)

Failing test case input:
455 222 101

Expected output:
224 448


Actual output:
448 224 101


Fixed submission (verdict: Accepted):
A,B,K = (int(x) for x in input().split())

while K != 0:
    if A % 2 !=0:
        A -= 1
    A = A/2
    B += A
    K -= 1

    if K ==0:
        break
    if B % 2 !=0:
        B -= 1
    B = B/2
    A += B
    K -= 1

A = int(A)
B = int(B)
print(A,B)
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
        K -= 1


    print(A," ",B)
            


        

if __name__ == '__main__':
    solve()


Failing test case input:
7181461 1930392 010

Expected output:
6075647 3036202


Actual output:
9101065.0   10783.0


Fixed submission (verdict: Accepted):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
            turn ^= 1
        K -= 1

    A = (int)(A)
    B = (int)(B)
    print(A,B)
            


        

if __name__ == '__main__':
    solve()

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += 2
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif a%2 == 1:
            b -= 1
            b /= 2
            a += 2
print(int(a),int(b))


Failing test case input:
30 6 4

Expected output:
23 11


Actual output:
11 6


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a /= 2
            b += a
        elif a%2 == 1:
            a -= 1
            a /= 2
            b += a
    elif i%2 == 1:
        if b%2 == 0:
            b /= 2
            a += b
        elif b%2 == 1:
            b -= 1
            b /= 2
            a += b
print(int(a),int(b))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


A, B, K = map(int,input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1

    B += A / 2
    A -= A / 2
    
    if B % 2 == 1:
        B -= 1
    
    A += B / 2
    B = B / 2

print(A, B)




Failing test case input:
43821 640 001

Expected output:
21910 22550


Actual output:
33185.0 11275.0


Fixed submission (verdict: Accepted):


A, B, K = map(int,input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1

        B += A / 2
        A -= A / 2
        
    else:
        if B % 2 == 1:
            B -= 1
    
        A += B / 2
        B = B / 2

print(int(A),int(B))
Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = input().split()

a = int(a)
b = int(b)
c = int(c)

for i in range(c):
    if (a%2 == 1):
        a = a-1
    if (b%2 == 1):
        b = b - 1
    ac = a
    bc = b
    if(i%2 == 0):
        a = a/2 
        b = b + ac/2
    else:
        a = a+bc/2
        b = b/2 

print(int(a), int(b))




Failing test case input:
48849 222 011

Expected output:
16363 32703


Actual output:
16360 32696


Fixed submission (verdict: Accepted):

a, b, c = input().split()

a = int(a)
b = int(b)
c = int(c)

for i in range(c):
    if (a%2 == 1 and i %2 == 0):
        a = a - 1
    if (b%2 == 1 and i % 2 == 1):
        b = b - 1
    if(i%2 == 0):
        ac = a
        a = a/2 
        b = b + ac/2
    else:
        bc = b
        a = a+bc/2
        b = b/2 

print(int(a), int(b))

Problem: p03228
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k =  map(int, input().split())
turn_a = 1
for i in range(k):
  if turn_a == 1:
    if a % 2 == 1:
      b = b + (a-1)/2
      a = (a-1)/2
    else:
      b = b + a/2
      a = a/2
    turn_a = 0
  else:
    if b % 2 == 1:
      a = a + (b-1)/2
      b = (b-1)/2      
    else:
      a = a + b/2
      b = b/2 
    turn_a = 1
print(a, b)

Failing test case input:
7425724 65000432 157

Expected output:
24142046 48284092


Actual output:
24142046.0 48284092.0


Fixed submission (verdict: Accepted):
a, b, k =  map(int, input().split())
turn_a = 1
for i in range(k):
  if turn_a == 1:
    if a % 2 == 1:
      b = b + (a-1)/2
      a = (a-1)/2
    else:
      b = b + a/2
      a = a/2
    turn_a = 0
  else:
    if b % 2 == 1:
      a = a + (b-1)/2
      b = (b-1)/2      
    else:
      a = a + b/2
      b = b/2 
    turn_a = 1
print(int(a), int(b))

Problem: p03228
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a,b,k = map(int, input().split())
while True:
    if k == 0:
        break

    if (a % 2) == 1:
        a = a - 1
    b = b + (a / 2)
    a = a / 2
    k = k - 1

    if k == 0:
        break

    if (b % 2) == 1:
        b = b - 1
    a = a + (b / 2)
    b = b / 2
    k = k - 1

a = int(a)
b = int(b)

Failing test case input:
5 4 1

Expected output:
2 6


Actual output:

Fixed submission (verdict: Accepted):
a,b,k = map(int, input().split())
while True:
    if k == 0:
        break

    if (a % 2) == 1:
        a = a - 1
    b = b + (a / 2)
    a = a / 2
    k = k - 1

    if k == 0:
        break

    if (b % 2) == 1:
        b = b - 1
    a = a + (b / 2)
    b = b / 2
    k = k - 1

a = int(a)
b = int(b)

print("{0} {1}".format(str(a), str(b)))