Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s= map.input()
if(s == "ABC"):
  print("ARC")
else:
  print("ABC")

Fixed submission:
s= input()
if(s == "ABC"):
  print("ARC")
else:
  print("ABC")

Buggy python submission (verdict: Runtime Error):
s = input().split()
if(s = 'ABC'):
  print("ARC")
else:
  print("ABC")

Fixed submission:
s= input()
if(s == "ABC"):
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
S= int(input())
W= int(input())
if(W>=S):
  print("unsafe")
else:
  print("safe")

Fixed submission:
S,W =map(int,input().split())
if(W>=S):
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Runtime Error):
R = int,input()
print(float(R * 3.14 * 2))


Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R = input()
print( float(R * 3.14 * 2))


Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R = int,input()
print( float(R * 3.14 * 2))

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R = int,input()
print( 3.14*2*R )

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R = int,input()
print( R * 3.14 * 2)

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
float R = input()
S = R * 3.14*2
print(S)

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R = input()
S = R*3.14*2
print(S.float)

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R = input()
S = R*3.14*2
print(S)

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)

Buggy python submission (verdict: Runtime Error):
R= input()
print(R*3.14*2)

Fixed submission:
import math
R = int(input())
print(2*math.pi*R)
Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int,input().split()))

def swap(x,y):
  tmp=x
  x=y
  y=temp
  return(x,y)

a,b = swap(a,b)
a,c = swap(a,c)
print(x,b,c)


Fixed submission:
x,y,z = list(map(int,input().split()))
 
def swap(a,b):
    tmp = a
    a = b
    b = tmp
    return (a,b)
 
x,y = swap(x,y)
x, z = swap(x, z)
print(x,y,z)

Buggy python submission (verdict: Runtime Error):
A,B,C = list(map(int,input().split()))
def swap(x,y):
  tmp=x
  x=y
  y=temp
  return(x,y)
A,B = swap(A,B)
A,C = swap(A,C)
print(X,Y,Z)

Fixed submission:
x,y,z = list(map(int,input().split()))
 
def swap(a,b):
    tmp = a
    a = b
    b = tmp
    return (a,b)
 
x,y = swap(x,y)
x, z = swap(x, z)
print(x,y,z)
Buggy python submission (verdict: Runtime Error):
S = str(input()) 
print('YES' if S[2] ==S[3] and 'NO' if S[4]==S[5] 

Fixed submission:
S = str(input())

print('Yes' if S[2]==S[3] and S[4]==S[5] else 'No')
Buggy python submission (verdict: Runtime Error):
S = input().length()
if S == S[::-1]:
  print("Yes")
else:
  print("No")


Fixed submission:
s = input()
n = len(s)
left = s[:(n-1)//2]
print('Yes' if left == left[::-1] == s[(n+3)//2 - 1:]  else 'No')

Buggy python submission (verdict: Runtime Error):
S = String(input().length())
if S == S[::-1]:
  print("Yes")
else:
  print("No")


Fixed submission:
s = input()
n = len(s)
left = s[:(n-1)//2]
print('Yes' if left == left[::-1] == s[(n+3)//2 - 1:]  else 'No')

Buggy python submission (verdict: Runtime Error):
S = input().length()
if S == S[::-1]:
  print("Yes")
else:
  print("No")


Fixed submission:
s = input()
n = len(s)
left = s[:(n-1)//2]
print('Yes' if left == left[::-1] == s[(n+3)//2 - 1:]  else 'No')
Buggy python submission (verdict: Runtime Error):
S = input()
if len(S)==3 and S.count('A')==2 or S.count('B')==2:
  print('Yes')
else
print('No')

Fixed submission:
S = input()
if len(S)==3 and S.count('A')==2 or S.count('B')==2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N,R = map(int,input().split())
ans = 100*(10-N)+R
if N>=10:
  print(R)
 else:
  print(ans)

Fixed submission:
N,R = map(int, input().split())
ans = 100*(10-N)+R
if N>=10:
  print(R)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
A = map(int, input().split())
if len(set(A) == 2):
  print("yes")
else:
  print("No")

Fixed submission:
A = map(int,input().split())
if len(set(A) ) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,M=map(int.input().split())
print("yes"if N==M else"no")

Fixed submission:
N,M=map(int,input().split())
print("Yes" if N==M else "No")
Buggy python submission (verdict: Runtime Error):
[K, X] = [int(x) for x in input().split()]
if K * 500 >= X:
    print('Yes')
else:
    print('No')

Fixed submission:
[K, X] = [int(x) for x in input().split()]
if K * 500 >= X:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
num, bricks, count, smash = int(input()), [int(x) for x in input().split("")], 1, 0
for x in bricks:
  if count == x: count += 1
  else: smash +=1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

Fixed submission:
num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: count += 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 0
for i in range(1, n):
    for j in range(1, i+1):
        if (i % j) == 0:
            ans += 1
print(ans)


Fixed submission:
n = int(input())
ans = 0
for i in range(1, n):
  ans += (n - 1) // i
print(ans)
Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if(A+V*T>=B+W*T):
    print("YES")
elif(A>=B):
    print("YES")
else:
    print("NO")

Fixed submission:
S = input()
print(S[:3])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N=int(input())
A = tuple(map(int,input().split(" ")))
ans = 0

for pair in itertools.combinations(A, 2):
    ans += pair[0] * pair[1]


print(ans % (10**9+7))

Fixed submission:
N=int(input())
A = tuple(map(int,input().split(" ")))
ans = 0

sum_ = sum(A)
for i in range(N):
    sum_ -= A[i]
    ans += sum_ * A[i]

print(ans % ( (10**9)+7) )
Buggy python submission (verdict: Runtime Error):
from functools import reduce
n = input()

sum_ = reduce(lambda x,y:int(x)+int(y),n)
if sum_%9 == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
N = input()

sum_=0
for ni in N:
    sum_ += int(ni)

if sum_%9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

args = sys.argv

# print(args)

def f(arg_list):
    even_arg_list = []
    for i in arg_list:
        if i % 2 == 0:
            even_arg_list.append(i/2)
        else:
            return False
    return even_arg_list


counter = 0
_list = map(lambda x:int(x),args[1:])
while True:
    _list = f(_list)
    if _list == False:
        print(counter)
        sys.exit()
    counter+=1
    # print(_list)
    

Fixed submission:
import sys

N = int(input())
Ai = map(lambda x:int(x),input().split(" "))
 
def f(arg_list):
    even_arg_list = []
    for i in arg_list:
        if i % 2 == 0:
            even_arg_list.append(i/2)
        else:
            return False
    return even_arg_list


counter = 0
while True:
    Ai = f(Ai)
    if Ai == False:
        print(counter)
        sys.exit()
    counter+=1
    # print(Ai)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

args = sys.argv

print(args)

def f(arg_list):
    even_arg_list = []
    for i in arg_list:
        if i % 2 == 0:
            even_arg_list.append(i/2)
        else:
            return False
    return even_arg_list


counter = 0
_list = map(lambda x:int(x),args[1:])
while True:
    _list = f(_list)
    if _list == False:
        print(counter)
        sys.exit()
    counter+=1
    print(_list)
    

Fixed submission:
import sys

N = int(input())
Ai = map(lambda x:int(x),input().split(" "))
 
def f(arg_list):
    even_arg_list = []
    for i in arg_list:
        if i % 2 == 0:
            even_arg_list.append(i/2)
        else:
            return False
    return even_arg_list


counter = 0
while True:
    Ai = f(Ai)
    if Ai == False:
        print(counter)
        sys.exit()
    counter+=1
    # print(Ai)
Buggy python submission (verdict: Runtime Error):
N = int(input("N--->"))
A = int(input("A--->"))

b = n%500

if A > b:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
A = int(input())

b = N%500

if A >= b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
r = int(input())
g = int(input())
b = int(input())


s = 100*r+10*b+g

if s%4 == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
r, g, b = (int(x) for x in input().split())


s = 100*r+10*g+b

if s%4 == 0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
r = int(input("r--->"))
g = int(input("g--->"))
b = int(input("b--->"))

if r < 0 and r > 9:
    print("0<=r<=9")
if g < 0 and g > 9:
    print("0<=g<=9")
if b < 0 and b > 9:
    print("0<=b<=9")

s = 100*r+10*b+g

if s%4 == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
r, g, b = (int(x) for x in input().split())


s = 100*r+10*g+b

if s%4 == 0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
r = int(input("r--->"))
g = int(input("g--->"))
b = int(input("b--->"))

if r < 0 and r > 9:
    print("0<=r<=9")
if g < 0 and g > 9:
    print("0<=g<=9")
if b < 0 and b > 9:
    print("0<=b<=9")

s = 100*r+10*b+g

if r%4 == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
r, g, b = (int(x) for x in input().split())


s = 100*r+10*g+b

if s%4 == 0:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
r = int(input("r--->"))
g = int(input("g--->"))
b = int(input("b--->"))

s = r+b+g

if r%4 == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
r, g, b = (int(x) for x in input().split())


s = 100*r+10*g+b

if s%4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a = int(input())
p = 100
c = 0
while p != a:
    p = p + int(p/100)
    c += 1
print(c)

Fixed submission:
x = int(input())
p = 100
t , si= 0, 0
while(p < x):
    si = p//100
    p += si
    t += 1
print(t)
Buggy python submission (verdict: Runtime Error):
import math
n  int(input())
print(math.ceil(n/2))

Fixed submission:
import math
n = int(input())
print(math.ceil(n/2))
Buggy python submission (verdict: Runtime Error):
n, m = int(input())
if n == m:
  print("Yes")
else("No")

Fixed submission:
n,m = map(int, input().split())
print("Yes") if n == m else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(x) for x in input().split()]
if 0 in ls:
    print(0)
    exit()
res = 1
for x in ls:
    res *= x
print(res if res <= 1000000000000000000 else -1)

Fixed submission:
n = int(input())
ls = [int(x) for x in input().split()]
if 0 in ls:
    print(0)
    exit()
res = 1
for x in ls:
    if res <= 1000000000000000000:
        res *= x
    else:
        break

print(res if res <= 1000000000000000000 else -1)
Buggy python submission (verdict: Runtime Error):
n,m=int(input()).split()
if n==m:
  print("Yes")
else:
  print("No")

Fixed submission:
n,m=input().split()
if n==m:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b=input().split
print a+b

Fixed submission:
a,b=input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a,b=str(input()).split()
print(lower(a+b))

Fixed submission:
a,b=input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a,b=str(input().split())
print(a+b)

Fixed submission:
a,b=input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
print(a+b)

Fixed submission:
a,b=input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a=str(raw_input())
b=str(raw_input())
print(a+b)

Fixed submission:
a,b=input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a=str(input())
b=str(input())
print(a+b)

Fixed submission:
a,b=input().split()
print(b+a)

Buggy python submission (verdict: Runtime Error):
a=str(raw_input())
b=str(raw_input())
print(a+b)

Fixed submission:
a,b=input().split()
print(b+a)
Buggy python submission (verdict: Time Limit Exceeded):
def findProductSum(A): 
    n=len(A)
    product = 0
    for i in range (n): 
        for j in range ( i+1,n): 
            product = product + A[i]*A[j] 
    return (product)%(1000000007) 
b=int(input())
A=list(map(int,input().split()))
print(findProductSum(A))

Fixed submission:
def sumproductsofpairs(lst):
    total = 0
    psum = 0
    for x in lst:
        total += psum * x
        psum += x
    return total%(1000000007) 
b=int(input())
A=list(map(int,input().split()))
print(sumproductsofpairs(A))
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())

print(a*b)


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

print(a*b)
Buggy python submission (verdict: Runtime Error):


s = int(input())
 
if (s[-1]==2,4,5,7,9):
  print（"hon")
elif (s[-1]==0,1,6,8):
  print("pon")
else:
  print("bon")


Fixed submission:
s = input()
if (s[-1]=="2" or s[-1]=="4" or s[-1]=="5" or s[-1]=="7" or s[-1]=="9"):
  print("hon")
elif (s[-1]=="0" or s[-1]=="1" or s[-1]=="6" or s[-1]=="8"):
  print("pon")
else:
  print("bon")

Buggy python submission (verdict: Runtime Error):

s = input()
 
if (s[-1]==2,4,5,7,9):
  print（"hon")
elif (s[-1]==0,1,6,8):
  print("pon")
else:
  print("bon")







Fixed submission:
s = input()
if (s[-1]=="2" or s[-1]=="4" or s[-1]=="5" or s[-1]=="7" or s[-1]=="9"):
  print("hon")
elif (s[-1]=="0" or s[-1]=="1" or s[-1]=="6" or s[-1]=="8"):
  print("pon")
else:
  print("bon")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
ab = str(a)+str(b)
import math
s = math.sqrt(int(ab))
if (s.is_integer() == True or isinstance(s, int) == True):
  print("yes")
else:
  print("no")

Fixed submission:
a,b = input().split()
import math
s = math.sqrt(int(a+b))
if (s.is_integer() == True or isinstance(s, int) == True):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = list(map(int, input().split()))

newlist = []

for i in range(a):
  newlist.append(1)
for i in range(b):
  newlist.append(0)
for i in range(c):
  newlist.append(-1)
  
ans = 0
for i in range(k):
  ans = ans + newlist[i]
  
print(ans)

Fixed submission:
a, b, c, k = list(map(int, input().split()))

ans = 0

if k > a:
  ans = a * 1
  k = k - a
  if k > b:
    ans += b * 0
    k = k - b
    ans += k * -1
    print(ans)
  elif k <= b:
    ans += k * 0
    print(ans)
elif k <= a:
  ans = k * 1
  print(ans)
Buggy python submission (verdict: Runtime Error):
n =list(map(int, input().strip()))
if 7 in n:
  print(‘Yes’)
else:
  print(‘No’)

Fixed submission:
n =list(map(int, input().strip()))

if 7 in n:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n = input().strip()
m = int(n)
a = int(len(m))
for i in range(a):
  if i == 7:
    print('Yes')
  else:
    print('No')

Fixed submission:
n =list(map(int, input().strip()))

if 7 in n:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

tmp = 0
for i in range(n):
  tmp += l[i]
  if tmp > x:
    ans = i + 1
    break
print(ans)

Fixed submission:
n = list(map(int, input().split()))
m = list(map(int, input().split()))

ans = 0
new_list = [0]
for i in range(n[0]):
  ans = ans + m[i]
  if ans <= n[1]:
    new_list.append(ans)
  elif ans > n[1]:
    break
    
print(len(new_list))
Buggy python submission (verdict: Runtime Error):
import numpy as np

x,k,d = np.array(list(map(int,input().split())))
#偶数回前後に移動したら0
#偶数回一方向に移動したら2D

for i in range(k):
  x = np.abs(x) - d

  if x < 0:
    break



if (k-i+1) % 2 == 0:
  #そのまま
  ans = np.abs(x)
else:
  ans = np.min(np.abs(x-d),np.abs(x+d))

print(ans)

Fixed submission:

x,k,d = list(map(int,input().split()))
#偶数回前後に移動したら0
#偶数回一方向に移動したら2D

if x >= 0:
  capa_iter = x // d
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(x - capa_iter*d)
    else:
      print(min([abs(x - capa_iter*d-d),x - capa_iter*d+d]))
    exit()

  ans =x-d*k
  print(ans)

if x < 0:
  capa_iter = abs(-x // d)
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(abs(x + capa_iter*d))
    else:
      print(min([abs(x + capa_iter*d+d),abs(x + capa_iter*d -  d)]))
    exit()

  ans =abs(x+d*k)
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = list(map(int,input().split()))
#偶数回前後に移動したら0
#偶数回一方向に移動したら2D

for i in range(k):
  x = abs(x) - d

  if x < 0:
    break



if (k-i+1) % 2 == 0:
  #そのまま
  ans = abs(x)
else:
  ans = min(abs(x-d),abs(x+d))

print(ans)

Fixed submission:

x,k,d = list(map(int,input().split()))
#偶数回前後に移動したら0
#偶数回一方向に移動したら2D

if x >= 0:
  capa_iter = x // d
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(x - capa_iter*d)
    else:
      print(min([abs(x - capa_iter*d-d),x - capa_iter*d+d]))
    exit()

  ans =x-d*k
  print(ans)

if x < 0:
  capa_iter = abs(-x // d)
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(abs(x + capa_iter*d))
    else:
      print(min([abs(x + capa_iter*d+d),abs(x + capa_iter*d -  d)]))
    exit()

  ans =abs(x+d*k)
  print(ans)
Buggy python submission (verdict: Runtime Error):

def Msol_B():
    a,b,c = np.array(list(map(int,input().split())))
    K = int(input())

    #a,b,c=[7,2,5]
    #K = 3

    import math

    if a > b:
        b_a = abs(math.log2(b/a))+1
        #まずは切りさげ
        b *= math.pow(2,math.floor(b_a))
        if b > c:
            c_b = abs(math.log2(c/b))+1
            if math.floor(b_a)+math.floor(c_b) <= K:
                print("Yes")
            else:
                print("No")
        else:
            print("Yes")
    else:
        print("Yes")




Msol_B()


Fixed submission:

def Msol_B_():
    a,b,c = list(map(int,input().split()))
    K = int(input())

    for i in range(8):
        if K==0:
            print('No')
            return 
        if a >= b:
            b *= 2
            K -= 1
        if a < b:
            break
    for i in range(8):
        if  K ==0:
            print('No')
            return
        if b >= c:
            c *= 2
            K -= 1
        if b < c:
            print('Yes')
            return
    print('No')



Msol_B_()
Buggy python submission (verdict: Runtime Error):
def abc173_b():
    N = int(input())

    #AC WA TLE RE
    l = [0 for i in range(N)]

    for i in range(N):
        Inp = input()
        if Inp == "AC":
            l[0] += 1
        if Inp == "WA":
            l[1] += 1
        if Inp == "TLE":
            l[2] += 1
        if Inp== "RE":
            l[3] += 1

    print("AC x "+str(l[0]))
    print("WA x "+str(l[1]))
    print("TLE x "+str(l[2]))
    print("RE x "+str(l[3]))



abc173_b()


Fixed submission:

def abc173_b():
    N = int(input())

    #AC WA TLE RE
    l = [0 for i in range(4)]

    for i in range(N):
        Inp = input()
        if Inp == "AC":
            l[0] += 1
        if Inp == "WA":
            l[1] += 1
        if Inp == "TLE":
            l[2] += 1
        if Inp== "RE":
            l[3] += 1

    print("AC x "+str(l[0]))
    print("WA x "+str(l[1]))
    print("TLE x "+str(l[2]))
    print("RE x "+str(l[3]))



abc173_b()
Buggy python submission (verdict: Runtime Error):
import math
N = input()
print(N*math.pi)

Fixed submission:
import math
N = input()
M = 2*float(N)*math.pi
print(M)

Buggy python submission (verdict: Runtime Error):
import math
N = input()
print(N*math.pi)

Fixed submission:
import math
N = input()
M = 2*float(N)*math.pi
print(M)
Buggy python submission (verdict: Runtime Error):
n,i=map(int,input.split())
print(n-i+1)

Fixed submission:
def ABC107_A():
    n,i=map(int,input().split())
    print(n-i+1)

ABC107_A()
Buggy python submission (verdict: Runtime Error):
n,yen = map(int,input().split())

bol = False
for x in range(n+1):
    for y in range(n+1-x):
        for z in range(n+1-x-y):
            if 10000*x+5000*y+1000*z==yen:
                bol = True
                ans = [x,y,z]
                break
        if bol is True:
            break
    if bol is True:
        break

print(ans[0],ans[1],ans[2])

Fixed submission:
n,yen = map(int,input().split())
ans = [-1,-1,-1]

for x in range(n+1):
    for y in range(n+1-x):
        z= int(yen/1000) - 10*x - 5*y
        if (0<= z) and (z == n-x-y):
            #print(x,y,n-x-y,z)
            bol = True
            ans = [x,y,z]
            break

print(ans[0],ans[1],ans[2])
'''
        if 0<= yen/1000 + 12*x + 5*y <= n+1-x-y:
            print(x,y,z)
            break
'''
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
a = np.array([int(input()) for i in range(N)])


#回数i,インデックスn
def button(i,n):
    if i == N:
        return

    n_new = a[n-1]
    if n_new == 2:
        print(i)
        return 
    else:
        return button(i+1,n_new)

button(1,1)

Fixed submission:
import numpy as np
import sys
sys.setrecursionlimit(500000)


N = int(input())
a = np.array([int(input()) for i in range(N)])


#回数i,インデックスn
def button(i,n):
    n_new = a[n-1]
    
    if i == N:
        if n != 2:
            print(-1)
            return
    if n_new == 2:
        print(i)
        return 
    else:
        return button(i+1,n_new)

button(1,1)