TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b=map(int,inout().split())
if a>=0:
    print("Positive" if a!=0 else "Zero")
if a<0 and b>0:
    print("Zero")
if b<=0:
    if b==0:
        print("Zero")
    else:
        if (a-b+1)%2==0:
            print("Positive")
        else:
            print("Negative")

a,b=map(int,input().split())
if a>=0:
    print("Positive" if a!=0 else "Zero")
if a<0 and b>0:
    print("Zero")
if b<=0:
    if b==0:
        print("Zero")
    else:
        if (a-b+1)%2==0:
            print("Positive")
        else:
            print("Negative")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = tuple(map(int,input().split()))

if a=<0 and b>=0:
  print("Zero")
elif a<0 and b<0:
  if (b-a+1)%2==0:
  	print("Positive")
  else:
    print("Negative")
elif a>0 and b>0:
  print("Positive")


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

if a<=0 and b>=0:
  print("Zero")
elif a<0 and b<0:
  if (b-a+1)%2==0:
  	print("Positive")
  else:
    print("Negative")
elif a>0 and b>0:
  print("Positive")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b=map(int,input().split());print('Zero'*(a*b<=0)or'NPeogsaittiivvee'[b>=0or(b-a)%2::2])

a,b=map(int,input().split());print('NPeogsaittiivvee'[a>0or(b-a)%2::2]*(a*b>0)or'Zero')

a,b=map(int,input().split());print('Zero'*(a+b==0or abs(a+b)<abs(a)+abs(b))or'NPeogsaittiivvee'[a>0or(b-a)%2::2])

a,b=map(int,input().split());print('NPeogsaittiivvee'[a>0or(b-a)%2::2]*(a*b>0)or'Zero')

a,b=map(int,input().split());print('NPeogsaittiivvee'[a>0 or(b-a)%2::2]*(a*b>0)or'Zero')

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b=map(int,input().split())
if a<=b<0:
  if 
  print('Negative' if (-1)**(a-b-1)==-1 else 'Positive')
elif a<=0<=b:
  print('Zero')
else:
  print('Positive')

a,b=map(int,input().split())
if a<=b<0:
  print('Negative' if (-1)**(a-b-1)==-1 else 'Positive')
elif a<=0<=b:
  print('Zero')
else:
  print('Positive')

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
def main20():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    if buf[0] <= 0 or 0 <= buf[1]:
        print("Zero");
    elif buf[0] > 0:
        print("Positive");
    else:
        kazu = buf[1] - buf[0] + 1;
        if kazu % 2 == 0:
            print("Positive");
        else:
            print("Negative");


if __name__ == '__main__':
    main20()


def main20():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    if buf[0] <= 0 and 0 <= buf[1]:
        print("Zero");
    elif buf[0] > 0:
        print("Positive");
    else:
        kazu = buf[1] - buf[0] + 1;
        if kazu % 2 == 0:
            print("Positive");
        else:
            print("Negative");


if __name__ == '__main__':
    main20()

Verdicts: Wrong Answer

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = map(int,input().split())

if a<=0 or 0<=b:
  print("Zero)
elif a<0:
  print("Positive" if abs(a-b)%2==1 else "Negative")
else:
  print("Positive")

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

if a<=0 and 0<=b:
  print("Zero")
elif a<0:
  print("Positive" if abs(a-b)%2==1 else "Negative")
else:
  print("Positive")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif a<0 and (b-a)%2==0:
    print("Positive")
else:
    print("Negative")

a,b = map(int,input().split())
if(a*b<=0)
    print(Zero)
elif(a<0 and (b-a)%2==0)
    print(Positive)
else
    print(Negative)

a,b = map(int,input().split())
if(a*b<=0):
    print(Zero)
elif(a<0 and (b-a)%2==0):
    print(Positive)
else:
    print(Negative)

a,b = map(int,input().split())
if(a*b<=0)print(Zero)
elif(a<0 and (b-a)%2==0)
	print(Positive)
else
	print(Negative)

a,b = map(int,input().split())
if(a*b<=0)
	print(Zero)
elif(a<0 and (b-a)%2==0)
	print(Positive)
else
	print(Negative)

a,b = map(int,input().split())
if(a*b<=0)print(Zero)
elif(a<0 and b-a%2==0)
	print(Positive)
else
	print(Negative)

a,b = map(int,inout().split())
if(a*b<=0)print(Zero)
elif(a<0 and b-a%2==0)
	print(Positive)
else
	print(Negative)

a,b = map(int,input().split())
if(a*b<=0)print(Zero)
elif(a<0 and (b-a)%2==0)
	print(Positive)
else
	print(Negative)

a,b = map(int,input().split())
if a*b<=0:
    print(Zero)
elif a<0 and (b-a)%2==0:
    print(Positive)
else:
    print(Negative)

a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif a<0 and (b-a)%2==0:
    print("Negative")
else:
    print("Positive")

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a, b = map(int(input().split())
if a > 0:
  print("Positive")
elif a < 0 :
  if (b - a) % 2 == 0 :
      print("Positive")
  else:
      print("Negative")
else:
   print("Zero")

a, b = map(int, input().split())
if a > 0 :
  print("Positive")
elif b < 0 :
  if (b - a) % 2 == 0 :
      print("Negative")
  else:
      print("Positive")
else:
   print("Zero")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = list(map(int,input().split()))

if a<=0 and 0 <= b:
    print('Zero')
elif a <0 and b < 0:
    print('Positive')
else:
    n = abs(a-b)
    if n%2 == 0:
        print('Negative')
    else:
        print('Positive')

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

if a<=0 and 0 <= b:
    print('Zero')
elif a >0 and b > 0:
    print('Positive')
else:
    n = abs(a-b)
    if n%2 == 0:
        print('Negative')
    else:
        print('Positive')

Verdicts: Wrong Answer

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b=map(int,input().split())
if a*b<=0::
  print("Zero")
else:
  if a>0 or (b-a)%2>0:
    print("Positive")
  else:
    print("Negative")

a,b=map(int,input().split())
if a*b<=0:
  print("Zero")
else:
  if a>0 or (b-a)%2>0:
    print("Positive")
  else:
    print("Negative")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = map(int, input().split())
L = []
for i in range (a,b+1):
  L.append(i)
P = 1
for j in L:
  P *= j
if P > 0:
  print('Positive')
elif P = 0:
  print('Zero')
else:
  print('Negetive')

a,b = map(int, input().split())
if a > 0:
  print("Positive")
elif b<0:
  if((b-a)%2 == 0):
    print("Negative")
  else:
    print("Positive")
else:
  print("Zero")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a, b = map(int, input().split())
if a <= 0 or b >= 0:
    print('Zero')
elif a > 0:
    print('Positive')
elif b < 0:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
         print('Negative')


a, b = map(int, input().split())
if a <= 0 or b >= 0:
    print('Zero')
elif a > 0:
    print('Positive')
elif b < 0:
    print('Negative')


a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a > 0:
    print('Positive')
elif b < 0:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
         print('Negative')


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = str(int,input().split())
S = a+b
P = S.count("-")
if P == 1:
  print("0")
elif P == 2:
  print("Negative")
else:
  print("Positive")

a,b = map(str,input().split())
S = a+b
P = S.count("-")
if P == 1:
  print("Zero")
elif P == 2:
  if (int(b) - int(a)) % 2 ==0:
    print("Negative")
  else:
    print("Positive")
else:
  print("Positive")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b=map(int,input().split())

if a>0 and b>0:
  print('Positive')
  exit()
elif a=0 or b=0:
  print('Zero')
  exit()
elif a<0 and 0<b:
  if abs(a)%2==0:
    print('Positive')
   	exit()
  else:
    print('Negative')
    exit()
else:
  if abs(b-a)%2==0:
    print('Negative')
    exit()
  else:
    print('Positive')
    exit()

  

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

if a>0 and b>0:
    print('Positive')
    exit()

elif a<=0 and 0<=b:
    print('Zero')
    exit()
else:
    if abs(b-a)%2==0:
        print('Negative')
        exit()
    else:
        print('Positive')
        exit()

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a,b = [int(i) for i in input().split()]
if a > 0:
  print('Positive')
elif a = 0:
  print('Zero')
else:
  if b >= 0:
    print('Zero')
  elif b-a % 2 == 0:
    print('Negative')
  else:
    print('Positive')

def a_range_product(A, B):
    ans = ''
    if A * B <= 0:
        ans = 'Zero'  
    else:
        if A > 0:
            ans = 'Positive'  
        else:  
            ans = 'Negative' if abs(B - A + 1) % 2 == 1 else 'Positive'
    return ans

A, B = [int(i) for i in input().split()]
print(a_range_product(A, B))

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
#! /usr/bin/env python3

A, B = map(int, input().split())
if A < 0:
    if B < 0:
        print('Negative')
    else:
        print('Zero')
else:
    print('Positive ')

#! /usr/bin/env python3

A, B = map(int, input().split())
if A < 0:
    if B < 0:
        print('Positive' if (abs(A)-abs(B))%2 else 'Negative')
    else:
        print('Zero')
else:
    print('Positive')

Verdicts: Wrong Answer

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a, b = map(int, input().split())

if a =< 0 and b >= 0:
    ans = 'Zero'
elif a < 0 and b < 0:
    if (abs(a) - abs(b) + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
elif a > 0 and b > 0:
    ans = 'Positive'
    
print(ans)

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

if a <= 0 and b >= 0:
    ans = 'Zero'
elif a < 0 and b < 0:
    if (abs(a) - abs(b) + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
elif a > 0 and b > 0:
    ans = 'Positive'
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a, b = map(int, input().split())
c = b - a
if a <= 0 <= b:
    print("Zero")
 
elif a > 0:
    print("Positive")
 
elif b < 0:a
    if c%2 == 1:
        print("Positive")
    else:
        print("Negative")

a, b = map(int, input().split())
c = b - a
if a <= 0 <= b:
    print("Zero")
 
elif a > 0:
    print("Positive")
 
elif b < 0:
    if c % 2 == 1:
        print("Positive")
    else:
        print("Negative")

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
import sys
# import numpy as np 
 
def main():
    a, b = map(int, sys.stdin.read().split())
 
    if 0 < a:
        ans = 'Positive'
    elif 0 <= b:
        ans = 'Zero'
    else:
        if (b - a + 1) % 2 == 0:
            ans = 'Positive'
        else:
            ans = 'Negative'
    
    print(ans)
 
if __name__ == '__main__':
    main(

import sys
# import numpy as np 
 
def main():
    a, b = map(int, sys.stdin.read().split())
 
    if 0 < a:
        ans = 'Positive'
    elif 0 <= b:
        ans = 'Zero'
    else:
        if (b - a + 1) % 2 == 0:
            ans = 'Positive'
        else:
            ans = 'Negative'
    
    print(ans)
 
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: You are given two integers a and b (a≤b). Determine if the product of the integers a, a+1, …, b is positive, negative or zero.

Submission attempts (in order):
a, b = map(int,input().split())
a=int(a)
b=int(b)
if a>0:
    print("positive")
elif a ==0 or b==0:
   print(0)
elif a  <0 and b>0:
    print(0)
elif (b-a)%2==0:
    print('negative')
else:
    print("positibe")

a = input()
b = input()
a=int(a)
b=int(b)
if a>0:
    print("positive")
elif a ==0 or b==0:
   print(0)
elif a  <0 and b>0:
    print(0)
elif (b-a)%2==0:
    print('negative')
else:
    print("positibe")

a, b = map(int,input().split())
if a<= 0 <=b:
   print("Zero")   
elif a > 0:
    print("Positive")
elif a==b:
    print("Positive")
elif (b-a)%2 == 0:
    print("Negative")
elif (b-a)%2 == 1:
    print("Positive")

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
N,M = map(int,input().rstrip().split(" "))
ans = [False for _ in range(N + 1)]
balls = [1 for _ in range(N + 1)]
ans[1] = True
for i in range(M):
  q = list(map(int,input().rstrip().split(" ")))
  if ans[q[0]] == True:
    ans[q[1]] = True
  balls[q[0]] -= 1
  if balls[q[0]] == 0: ans[q[0]] = False
  balls[q[1]] += 1
ansi = 0
print(ans)
for i in range(N + 1):
  if ans[i]: ansi += 1
print(ansi)

N,M = map(int,input().rstrip().split(" "))
ans = [False for _ in range(N + 1)]
balls = [1 for _ in range(N + 1)]
ans[1] = True
for i in range(M):
  q = list(map(int,input().rstrip().split(" ")))
  if ans[q[0]] == True:
    ans[q[1]] = True
  balls[q[0]] -= 1
  if balls[q[0]] == 0: ans[q[0]] = False
  balls[q[1]] += 1
ansi = 0
for i in range(N + 1):
  if ans[i]: ansi += 1
print(ansi)

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
def main():
    N, M = map(int, input().split())
    l = []
    red = [1]
    for i in range(M):
        l.append(list(map(int, input().split())))
    for i in range(M):
        if l[i][0] in red:
            red.append(l[i][1])
            red.remove(l[i][0])
    print(len(set(red)))

main()


def main():
    N, M = map(int, input().split())
    l = []
    for i in range(M):
        l.append(list(map(int, input().split())))
    s = [1 for i in range(N)]
    r = [0 for i in range(N)]
    r[0] = 1
    for i in range(M):
        x = l[i][0] - 1
        y = l[i][1] - 1
        if r[x] == 1:
            if s[x] == 1:
                r[x] = 0
            r[y] = 1
        s[x] -= 1
        s[y] += 1
    print(sum(r))

main()


Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = 1
    if ans[x-1] == 0:
      ball[x-1] = 0
      
print(sum(cnt))

n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = 1
    if ans[x-1] == 0:
      ball[x-1] = 0
      
print(sum(ball))

Verdicts: Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, m = map(int, input().split())
    ball, can = [0]*n, [True]*n
    ball[0], can[0] = 1, 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()

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()


Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
# AGC002B - Box and Ball
import sys
input = sys.stdin.readline

def main():
    N, M = tuple(map(int, input().split()))
    X = tuple(tuple(map(int, input().split())) for _ in range(M))
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in X:
        R[y] = 1 if R[x] or R[y] else 0
        C[x] -= 1
        C[y] += 1
        R[x] = 0 if R[x] == 0 else R[x]
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

# AGC002B - Box and Ball
def main():
    N, M, *XY = map(int, open(0).read().split())
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in zip(*[iter(XY)] * 2):
        R[y] = 1 if R[x] or R[y] else 0  # red ball may move from x to y
        C[x] -= 1
        C[y] += 1
        R[x] = 0 if C[x] == 0 else R[x]  # no more ball in x
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
    n, l = (int(s) for s in input().strip().split(' '))
    an = []
for a in range(0,l):
    an.append(input().strip().split())

box=[[1,0] for i in range(n)]
box[0][1] = 1
for move in an:
    box[int(move[0])-1][0] -= 1
    box[int(move[1])-1][0]+=1
    if box[int(move[0])-1][1] == 1:
        box[int(move[1])-1][1]= 1
    if box[int(move[0])-1][0]==0:
        box[int(move[0])-1][1]=0
print(str(sum([s[1] for s in box])))

n, l = (int(s) for s in input().strip().split(' '))
an = []
for a in range(0,l):
    an.append(input().strip().split())
box=[[1,0] for i in range(n)]
box[0][1] = 1
for move in an:
    box[int(move[0])-1][0] -= 1
    box[int(move[1])-1][0]+=1
    if box[int(move[0])-1][1] == 1:
        box[int(move[1])-1][1]= 1
    if box[int(move[0])-1][0]==0:
        box[int(move[0])-1][1]=0
print(str(sum([s[1] for s in box])))

Verdicts: Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
count=[1]*(n+1)
flag=[False]*(n+1)
flag[1]=True
for a,b in arr:
  count[b]+=1
  count[a]-=1
  if flag[a]==True:
    flag[b]==True
  if count[a]==0:
    flag[a]==False
print(flag.count(True))

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
count=[1]*(n+1)
flag=[False]*(n+1)
flag[1]=True
for a,b in arr:
  count[b]+=1
  count[a]-=1
  if flag[a]==True:
    flag[b]=True
  if count[a]==0:
    flag[a]=False
print(flag.count(True))

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n, m = map(int,input().split())
f = [False for _ in range(n)]
f[0] = True
for i in range(m):
  x, y = map(int,input().split())
  f[y] = f[y] or f[x]
print(f.count(True))

n, m = map(int,input().split())
f = [False 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]
print(f.count(True))


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)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n,m=map(int,input().split())
cnt=[1]*n
res=[0]*n
res[0]=1
for i in range(m):
    x,y=map(int,input().split())
    if res[x-1]==1:
        res[y-1]=1
        if cnt[x-1]==1:
            res[x-1]=0
    cnt[x-1]-=1
    cnt[y-1]+=1
    print(cnt,res)
print(sum(res))

def main():
    n,m=map(int,input().split())
    cnt=[1]*n
    res=[0]*n
    res[0]=1
    for i in range(m):
        x,y=map(int,input().split())
        if res[x-1]==1:
            res[y-1]=1
            if cnt[x-1]==1:
                res[x-1]=0
        cnt[x-1]-=1
        cnt[y-1]+=1
    print(sum(res))
if __name__=="__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n,m=map(int,input().split())
x=[0]*n
x[0]=1
for i in range(m):
  a,b=map(int,input().split())
  if x[a-1]==1:x[b-1]=1
print(sum(x))

n,m=map(int,input().split())
ans=[False]*n
ans[0]=True
co=[1]*n
for i in range(m):
  x,y=map(int,input().split())
  ans[y-1]|=ans[x-1]
  co[x-1]-=1
  co[y-1]+=1
  if co[x-1]==0:ans[x-1]=False
print(ans.count(True))

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n,m = map(int,input().split())

possible = [0]*n
possible[0] = 1
kosuu = [1]*n

for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
        
    if kosuu[a] >= 2 and possible[a] ==1:
        possible[a] = 1 
        possible[b] = 1
        kosuu[a] -=1
        kosuu[b] +=1
    elif kosuu[a] ==1 and possible[a] ==1 : 
        possible[a] = 0
        possible[b] = 1
        kosuu[a] = 0
        kosuu[b] +=1
    if kosuu[a] >= 2 and possible[a] ==0:
        possible[a] = 0
        possible[b] = 0
        kosuu[a] -=1
        kosuu[b] +=1
    elif kosuu[a] ==1 and possible[a] == : 
        possible[a] = 0
        possible[b] = 0
        kosuu[a] = 0
        kosuu[b] +=1
    
print(sum(possible))

n,m = map(int,input().split())
possible = [0]*n
kosuu = [1]*n
possible[0] = 1

L = []

if flag == False:
    print(1)
    exit()
for i in range(m):
    x,y = L[i][0],L[i][1]
    x,y = x-1,y-1
    if kosuu[x] >=2 and possible[x] == 1:
        possible[y] = 1
        kosuu[x] -=1
        kosuu[y] +=1
    elif kosuu[x] == 1 and possible[x] == 1:
        possible[x] = 0
        possible[y] = 1
        kosuu[x] = 0
        kosuu[y] +=1
    elif kosuu[x] >=2 and possible[x] == 0:
        kosuu[x] -=1
        kosuu[y] +=1
    elif kosuu[x] == 1 and possible[x] == 0:
        kosuu[x] = 0
        kosuu[y] +=1
print(sum(possible))

n,m = map(int,input().split())
possible = [0]*n
kosuu = [1]*n
possible[0] = 1
L = []

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

for i in range(idx,m):
    x,y = L[i][0],L[i][1]
    x,y = x-1,y-1
    if kosuu[x] >=2 and possible[x] == 1:
        possible[y] = 1
        kosuu[x] -=1
        kosuu[y] +=1
    elif kosuu[x] == 1 and possible[x] == 1:
        possible[x] = 0
        possible[y] = 1
        kosuu[x] = 0
        kosuu[y] +=1
    elif kosuu[x] >=2 and possible[x] == 0:
        kosuu[x] -=1
        kosuu[y] +=1
    elif kosuu[x] == 1 and possible[x] == 0:
        kosuu[x] = 0
        kosuu[y] +=1
        
print(sum(possible))

n,m = map(int,input().split())
possible = [0]*n
kosuu = [1]*n
possible[0] = 1
L = []

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

for i in range(m):
    x,y = L[i][0],L[i][1]
    x,y = x-1,y-1
    if kosuu[x] >=2 and possible[x] == 1:
        possible[y] = 1
        kosuu[x] -=1
        kosuu[y] +=1
    elif kosuu[x] == 1 and possible[x] == 1:
        possible[x] = 0
        possible[y] = 1
        kosuu[x] = 0
        kosuu[y] +=1
    elif kosuu[x] >=2 and possible[x] == 0:
        kosuu[x] -=1
        kosuu[y] +=1
    elif kosuu[x] == 1 and possible[x] == 0:
        kosuu[x] = 0
        kosuu[y] +=1
print(sum(possible))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
def solve():
    N, M = map(int, input().split())
    
    num = []
    red = []
    for i in range(N+1):
        num.append(1)
        red.append(0)
    red[1] = 1
    
    for _ range(M):
        x, y = map(int, input().split())
        if red[x] == 1:
            red[y] = 1
        num[x] -= 1
        num[y] += 1
        if num[x] == 0:
            red[x] = 0
    
    return sum(red)

print(solve())

def solve():
    N, M = map(int, input().split())
    
    num = []
    red = []
    for i in range(N+1):
        num.append(1)
        red.append(0)
    red[1] = 1
    
    for _ in range(M):
        x, y = map(int, input().split())
        if red[x] == 1:
            red[y] = 1
        num[x] -= 1
        num[y] += 1
        if num[x] == 0:
            red[x] = 0
    
    return sum(red)

print(solve())

Verdicts: Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n, m = map(int, input().split())
boxes = [[0, 1] for _ in range(n)]
boxes[0][0] = 1
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    boxes[x][1] -= 1
    boxes[y][1] += 1
    if boxes[x][0] == 1:
        boxes[y][0] = 1
    else:
        if boxes[y][0] == 1:
            continue
        else:
            boxes[y][0] = 0  
    if boxes[x][1] == 0:
        boxes[x][0] = -1
ans = 0
for a, b in boxes:
    # print(a, b)
    if a:
        ans += 1
# print(boxes)
print(ans)


n, m = map(int, input().split())
boxes = [[0, 1] for _ in range(n)]
boxes[0][0] = 1
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    boxes[x][1] -= 1
    boxes[y][1] += 1
    if boxes[x][0] == 1:
        boxes[y][0] = 1
    else:
        if boxes[y][0] == 1:
            continue
        else:
            boxes[y][0] = 0  
    if boxes[x][1] == 0:
        boxes[x][0] = -1
ans = 0
for a, b in boxes:
    # print(a, b)
    if a > 0:
        ans += 1
# print(boxes)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
N,M = map(int, input().split())

balls_in_box = [0] + [1 for _ in range(1,N+1)]
red_ball_containable_box = set()
red_ball_containable_box.add(y)

for i in range(M):
    x,y = map(int, input().split())
    if x in red_ball_containable_box:
        balls_in_box[x] -= 1
        balls_in_box[y] += 1
        red_ball_containable_box.add(y)
        if balls_in_box[x] == 0: 
            red_ball_containable_box.remove(x)
    else:
        balls_in_box[x] -= 1
        balls_in_box[y] += 1

print(len(red_ball_containable_box))

N,M = map(int, input().split())

balls_in_box = [0] + [1 for _ in range(1,N+1)]
red_ball_containable_box = set()
red_ball_containable_box.add(1)

for i in range(M):
    x,y = map(int, input().split())
    if x in red_ball_containable_box:
        balls_in_box[x] -= 1
        balls_in_box[y] += 1
        red_ball_containable_box.add(y)
        if balls_in_box[x] == 0: 
            red_ball_containable_box.remove(x)
    else:
        balls_in_box[x] -= 1
        balls_in_box[y] += 1

print(len(red_ball_containable_box))

Verdicts: Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
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))

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))

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
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:
            ans -= 1

kotae = 0
for i in range(n):
    kotae += box[i][1]
print(kotae)




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)




Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
import numpy as np

n, m = map(int, input().split())
possibility = [0 for _ in range(n)]
ball = [1 for _ in range(n)]
possibility[0] = 1
for i in range(m):
    x, y = map(int, input().split())
    if ball[x-1] != 0:
        possibility[y-1] = 1
    ball[x-1] -= 1
    ball[y-1] += 1
print(np.sum(np.array(possibility) > 0))

import numpy as np
import math

n, m = map(int, input().split())
probability = [0 for _ in range(n)]
ball = [1 for _ in range(n)]
probability[0] = 1
for i in range(m):
    x, y = map(int, input().split())
    prob = math.ceil(probability[x-1])
    probability[x-1] = prob * (ball[x-1] - 1) / ball[x-1]
    probability[y-1] += prob / ball[x-1]
    ball[x-1] -= 1
    ball[y-1] += 1
print(np.sum(np.array(probability) > 0))


Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
import sys
input = sys.stdin.buffer.readline

n, m = map(int, input().split())
b = [False] * (n + 1)
c = [1] * (n + 1)
for i in range(m):
    x, y = map(int, input().split())
    c[x] -= 1
    c[y] += 1
    if b[x]:
        b[y] = True
    if c[x] == 0:
        b[x] = False
print(sum(b))

import sys
input = sys.stdin.buffer.readline

n, m = map(int, input().split())
b = [False, True] + [False] * (n - 1)
c = [1] * (n + 1)
for i in range(m):
    x, y = map(int, input().split())
    c[x] -= 1
    c[y] += 1
    if b[x]:
        b[y] = True
    if c[x] == 0:
        b[x] = False
print(sum(b))

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
box = [1]*(N+1)
flag = False
n1_pass = {1}
for _ in range(M):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        n1_pass = n1_pass - {x}
    if (x in n1_pass):
        n1_pass.add(y)
print(len(n1_pass))

from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
box = [1]*(N+1)
flag = False
n1_pass = set()
n1_now = 0
for _ in range(M):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        n1_pass.remove(x)
    if x == 1 and not flag:
        n1_pass.add(y)
        n1_now = y
        flag = True
    if flag and x == n1_now:
        n1_pass.add(y)
        n1_now = y
ans = 0
for i in n1_pass:
    if box[i] > 0:
        ans += 1
print(ans)

from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
box = [1]*(N+1)
flag = False
n1_pass = {1}
for _ in range(M):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        n1_pass = n1_pass - {x}
    if (x in n1_pass):
        n1_pass.add(y)
ans = 0
for i in n1_pass:
    if box[i] > 0:
        ans += 1
print(ans)

from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
box = [1]*(N+1)
red = [False]*(N+1)
red[1] = True
for _ in range(M):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    if red[x]:
        red[y] = True
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        red[x] = False
ans = 0
for i in red:
    if i:
        ans += 1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
N, M = map(int, input().split())
red = [False for i in range(N+1)]
red[1] = True
box = [1 for i in range(N+1)]

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

ans = 0
for i in range(1, N+1):
    if red[i] and box[i] > 0:
        ans += 1
print(ans)


N, M = map(int, input().split())
red = [False for i in range(N+1)]
red[1] = True
box = [1 for i in range(N+1)]

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

ans = 0
for i in range(1, N+1):
    if red[i] and box[i] > 0:
        ans += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n, m = map(int,input().split())
b_list = []

for i in range(m):
    x = []
    x = list(map(int,input().split()))
    b_list.append(x)

ans_list = [0 for i in range(10**5)]
ans_list[0] = 1
ball_list = [1 for i in range(10**5)]
print(ball_list[0])

for tmp in b_list:
    x, y = tmp[0], tmp[1]
    print(x, y)
    if ans_list[x-1] == 1 and ans_list[y-1] == 0:
        ans_list[y-1] += 1
    ball_list[y-1] += 1
    ball_list[x-1] -= 1
    if ball_list[x-1] == 0:
        ans_list[x-1] = 0

ans = 0

for i in ans_list:
    if i == 1:
        ans += 1

print(ans)


n, m = map(int,input().split())
b_list = []

for i in range(m):
    x = []
    x = list(map(int,input().split()))
    b_list.append(x)

ans_list = [0 for i in range(10**5)]
ans_list[0] = 1
ball_list = [1 for i in range(10**5)]

for tmp in b_list:
    x, y = tmp[0], tmp[1]
    if ans_list[x-1] == 1 and ans_list[y-1] == 0:
        ans_list[y-1] += 1
    ball_list[y-1] += 1
    ball_list[x-1] -= 1
    if ball_list[x-1] == 0:
        ans_list[x-1] = 0

ans = 0

for i in ans_list:
    if i == 1:
        ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n, m = map(int, input().split())
box = [0] * (n+1)
box[1] = 1
for i in range(m):
  x, y = map(int, input().split())
  if box[x]:
    box[y] = 1
print(sum(box))

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

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
n,m=map(int,input().split())
l=[0 for i in range(n)]
l[0]=1
lc=[1 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if l[a-1]==1 and lc[a-1]==1:
    lc[a-1]=0
    l[a-1]=0
    l[b-1]=1
    lc[b-1]+=1
  elif l[a-1]==1:
    lc[a-1]-=1
    l[b-1]=1
    lc[b-1]+=1
  else:
    lc[a-1]-=1
    lc[b-1]+=1
ans=0
for i in range(n):
  if l[i]==1 and lc[i]>0:
    ans+-1
print(ans)
      

n,m=map(int,input().split())
l=[0 for i in range(n)]
l[0]=1
lc=[1 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if l[a-1]==1 and lc[a-1]==1:
    lc[a-1]=0
    l[a-1]=0
    l[b-1]=1
    lc[b-1]+=1
  elif l[a-1]==1:
    lc[a-1]-=1
    l[b-1]=1
    lc[b-1]+=1
  else:
    lc[a-1]-=1
    lc[b-1]+=1
ans=0
for i in range(n):
  if l[i]==1 and lc[i]>0:
    ans+=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
N,M=map(int,input().split())
x=[0 for i in range(M)]
y=[0 for i in range(M)]
for i in range(M):
    x[i],y[i]=map(int,input().split())
    x[i]-=1
    y[i]-=1
a=[0 for i in range(N)]
a[0]=N**N
c=[0 for i in range(N)]
c[0]=1
b=[1 for i in range(N)]
for i in range(M):
    b[x[i]]-=1
    b[y[i]]+=1
    t=a[x[i]]
    a[x[i]]-=t/(b[x[i]]+1)
    a[y[i]]+=t/(b[x[i]]+1)
print(sum(c))


N,M=map(int,input().split())
x=[0 for i in range(M)]
y=[0 for i in range(M)]
for i in range(M):
    x[i],y[i]=map(int,input().split())
    x[i]-=1
    y[i]-=1
a=[0 for i in range(N)]
a[0]=N
b=[1 for i in range(N)]
for i in range(M):
    b[x[i]]-=1
    b[y[i]]+=1
    t=a[x[i]]
    a[x[i]]-=N*t/(b[x[i]]+1)
    a[y[i]]+=N*t/(b[x[i]]+1)
n=0
for i in range(N):
    if a[i]!=0:
        n+=1
print(n)


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


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.  Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.  Find the number of boxes that may contain the red ball after all operations are performed.

Submission attempts (in order):
def main():
  t = input().split(" ")
  N, M = int(t[0]), int(t[1])
  x = [1]
  for i in range(M):
    t = input().split(" ")
    fr, to = int(t[0]), int(t[1])
    if fr in x:
      x.append(to)
  print(len(x))
  
main()

def main():
  t = input().split(" ")
  N, M = int(t[0]), int(t[1])
  x = set([0])
  n = [1]*N
  for i in range(M):
    t = input().split(" ")
    fr, to = int(t[0])-1, int(t[1])-1
    if fr in x:
      x.add(to)
    n[fr] -= 1
    n[to] += 1
    if (fr in x) and n[fr] == 0:
        x.remove(fr)
  print(len(x))

main()


Verdicts: Wrong Answer

Accepted