Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03288 (python)

Fixed submission:
R=int(input())
0<=R and R<=4208
if R>=0 and R<1200:
   print('ABC')
elif R>=1200 and R<2800:
   print('ARC')
elif R>=2800 and R<=4208:
   print('AGC')

Buggy submission (verdict: Runtime Error):
R=input()
0<=R and R<=4208
if R>=1 and R<1200
   print('ABC')
elif R>=1200 and R<2800
   print('ARC')
elif R>=2800 and R<=4208
   print('AGC')

Buggy submission (verdict: Runtime Error):
R=input()
0<=R and R<=4208
if R>=1 and R<1200
print('ABC')
elif R>=1200 and R<2800
print('ARC')
elif R>=2800
print('AGC')
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
for c in range(1, 4):
  if a*b*c % 2 == 1:
    print('Yes')
    break
  else:
    if c == 3:
      print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
ls = []
flag = True
for n in range(0, N):
  char = raw_input()
  if n == 0:
    ls.append(char)
  else:
    if char in ls:
      flag = False
    else:
      ls.append(char)
if flag == True:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
ls = []
flag = True
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if char in ls:
      flag = False
    else:
      ls.append(char)
if flag == True:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
list = []
flag = True
for n in range(0, N):
  char = input()
  if n == 0:
    list.append(char)
  else:
    if char in list:
      flag = False
    else:
      list.append(char)
if flag == True:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
list = []
flag = True
for n in range(0, N):
  input = input()
  if n == 0:
    list.append(input)
  else:
    if input in list:
      flag = False
    else:
      list.append(input)
if flag == True:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
list = []
flag = true
for n in range(0, N):
  input = input()
  if n == 0:
    list.append(input)
  else:
    if input in list:
      flag = false
    else:
      list.append(input)
if flag == true:
  print('Yes')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
for n in range(1, 4):
  if a*b*c % 2 == 1:
    print('Yes')
    break
  else:
    if n == 3:
      print('No')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
for n in range(1, 4):
  if a*b*c % 2 == 1:
    return 'Yes'
return 'No'
Problem p03261 (python)

Fixed submission:
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  ch = input()
  if n == 0:
    ls.append(ch)
  else:
    if (ch in ls) or (bChar[-1:] != ch[0:1]):
      flag = False
  ls.append(ch)
  bChar = ch
if flag == True:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
list = []
for n in range(0, N):
  input = input()
  if n == 0:
    list.append(input)
  else:
    if input in list:
      print('No')
      break
    else:
      list.append(input)
  if n == N-1:
    print('Yes')
Problem p03260 (python)

Fixed submission:
a,b=map(int,input().split())
flag=0
for i in range(1,4):
    if a*b*i%2==1:
        flag=1
if flag==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    a.append(input())
flag=0
for i in range(n):
    s=a[i]
    
   if i==0:
       continue
   else:
       if last!=a[i][len(a[i])-1]:
           flag=1
           
   last=a[i][len(a[i])-1]
if flag==1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
flag=0
for i in range(1,4):
    if a*b*c%2==1:
        flag=1
if flag==1:
    print("Yes")
else:
    print("No")
Problem p03261 (python)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
b=[]
flag=0
for i in range(n):
    s=a[i]
    if i!=0:
        if s[0]!=last:
            flag=1
    last=s[len(s)-1]
    if s in b:
        flag=1
        break
    b.append(s)
    
    
if flag==1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    a.append(input())
flag=0
for i in range(n):
   s=a[i]
    
   if i==0:
       continue
   else:
       if last!=a[i][len(a[i])-1]:
           flag=1
           
   last=a[i][len(a[i])-1]
if flag==1:
    print("No")
else:
    print("Yes")
Problem p03417 (python)

Fixed submission:
L,M=map(int,input().split())
count=0
if L==1 and M==1:
    print(1)
elif L==1 or M==1:
    print(L+M-3)
if L==2 or M==2:
    print(0)
if L>=3 and M>=3:
    print((L-2)*(M-2))

Buggy submission (verdict: Runtime Error):
L,M=map(int,input().split())
import numpy as np
a=np.zeros((L,M))
count=0
for i in range(L):
    for j in range(M):
        if L>=3 and M>=3:
            if i>=1 and i<=L-2 and j>=1 and j<=M-2:
                count+=1
                continue
        syuui=0
        a=[[i-1,j-1],[i-1,j],[i-1,j+1],[i,j-1],[i,j],[i,j+1],[i+1,j-1],[i+1,j],[i+1,j+1]]
        for k in a:
            if 0<=k[0] and k[0]<L and k[1]>=0 and k[1]<M:
                syuui+=1
        if syuui%2==1:
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
L,M=map(int,input().split())
import numpy as np
a=np.zeros((L,M))
count=0
for i in range(L):
    for j in range(M):
        syuui=0
        a=[[i-1,j-1],[i-1,j],[i-1,j+1],[i,j-1],[i,j],[i,j+1],[i+1,j-1],[i+1,j],[i+1,j+1]]
        for k in a:
            if 0<=k[0] and k[0]<L and k[1]>=0 and k[1]<M:
                syuui+=1
        if syuui%2==1:
            count+=1
print(count)
Problem p03423 (python)

Fixed submission:
N=int(input())
print(int(N/3))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[]
for i in range(N):
    a.append(input())

import numpy as np
s=np.zeros(5)

for i in a:
    if i[0]=="M":
        s[0]+=1
    elif i[0]=="A":
        s[1]+=1
    elif i[0]=="R":
        s[2]+=1
    elif i[0]=="C":
        s[3]+=1
    elif i[0]=="H":
        s[4]+=1
    else:
        continue
b=np.unique(s)
c=0
if len(b)<3:
    print(0)
else:
    for i in range(0,3):
        for j in range(i+1,4):
            for k in range(j+1,5):
                c+=s[i]*s[j]*s[k]
    print(c)
Problem p03493 (python)

Fixed submission:
s=input()
c=0
for i in s:
    if i=='1':
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
s=input()
c=0
for i in range(s):
    if i=='1':
        c+=1
print(c)
Problem p03591 (python)

Fixed submission:
s=input()
if(len(s)>=4):
    if(s[0]=="Y" and s[1]=="A" and s[2]=="K" and s[3]=="I"):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input().split()
n=int(s[0])
m=int(s[1])
k=int(s[2])
import numpy as np
a=np.zeros((n,m))

b=int(n/2)+1
c=int(m/2)+1
x=[]
for i in range(b):
    a[i,:]=1
    x.append(np.count_nonzero(a))
for j in range(c):
    a[:,j]=1-i
    x.append(np.count_nonzero(a))
if k in x:
    print("Yes")
else:
    print("No")
Problem p03260 (python)

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

if (a * b) % 2 == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#!/bin/evn python
# -*- coding: utf-8 -*-

n = int(input())
words = [input() for _ in range(n)]

last = ''
success = True

if len(set(words)) != len(words):
    success = False

if success:
    for word in words:
        if last[-1] != word[0]:
            success = False 
            break

if success:
    print('Yes')
else:
    print('No')
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

N, X = map(int, input().split())
xi = map(int, input().split())

dist = [abs(X - x) for x in xi]
print(reduce(gcd, dist))

Buggy submission (verdict: Runtime Error):
import math
#from functools import reduce

N, X = map(int, input().split())
xi = map(int, input().split())

dist = [abs(X - x) for x in xi]
print(reduce(math.gcd, dist))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N, X = map(int, input().split())
xi = map(int, input().split())

dist = [abs(X - x) for x in xi]
print(reduce(math.gcd, dist))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
import math
from functools import reduce

N, X = map(int, input().split())
xi = map(int, input().split())

dist = [abs(X - x) for x in xi]
print(reduce(math.gcd, dist))
Problem p03280 (python)

Fixed submission:
A, B = map(int, input().split())
area = (A - 1) * (B - 1)
print(area)

Buggy submission (verdict: Runtime Error):
import math
S = input()
K = int(input())

ps = []

for s in S:
    i = int(s)
    if(i == 1):
        p = -1
    else:
        p = 5*(10**15) * math.log(i)
    ps.append(p)

sum = 0
index = 0
    
if K == 1:
    print(S[0])
else:
    for p in ps:

        if not p == -1:
            sum += p
        else:
            K -= 1

        if math.log(K) < sum:
            #print(index)
            print(S[index])
            break
        index += 1
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

for i, k in enumerate(range(K)):
    if S[k] != '1':
        print(S[k])
        break
    if i == K - 1:
        print('1')

Buggy submission (verdict: Runtime Error):
# import math

S = input()
K = int(input())

ps = []

for s in S:
    i = int(s)
    if(i == 1):
        p = -1
    else:
        p = 5*(10**15) * math.log2(i)
    ps.append(p)

sum = 0
index = 0
    
if K == 1:
    print(S[0])
else:
    for p in ps:

        if not p == -1:
            sum += p
        else:
            K -= 1

        if math.log2(K) < sum:
            #print(index)
            print(S[index])
            break
        index += 1

Buggy submission (verdict: Runtime Error):
import math

S = input()
K = int(input())

ps = []

for s in S:
    i = int(s)
    if(i == 1):
        p == -1
    else:
        p = 5*(10**15) * math.log2(i)
    ps.append(p)

sum = 0
index = 0
for p in ps:
    if not p == -1:
        sum += p
    else:
        K -= 1
        
    if math.log2(K) < sum:
        print(S[index])
        break
        
    index += 1
Problem p03260 (python)

Fixed submission:
# -*- coding: utf-8 -*-

A, B = map(int, input().split())
AB = A * B

exists = False
# 1から３までループ
for C in range(1, 4):
    if (AB * C % 2 == 1):
        exists = True
        break

if (exists):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys

# 引数の取得
argv = sys.argv
argc = len(argv)

A = int(argv[1])
B = int(argv[2])

AB = A * B
exists = False

# 1から３までループ
for C in range(1, 4):
    if (AB * C % 2 == 1):
        exists = True
        break


if (exists):
    print("Yes")
else:
    print("No")
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
if (a * b) % 2 == 1:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a * b) % == 1:
  print('Yes')
else:
  print('No')
Problem p03693 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys

x = input()
num = int(''.join(x.split()))
if num % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

args = sys.argv
num = args[1] * 100 + args[2] * 10 + args[3]
if num % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

args = sys.argv
num = int(args.split())
if num % 4 == 0:
    print('YES')
else:
    print('NO')
Problem p03694 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(map(int, an.split())))
print(s[-1] - s[0])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(int(an.split())))
print(sum(s))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
s = sorted(set(an.split()))
print(sum(s))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()

s = set(sorted(an.split()))
print(sum(s))
Problem p03695 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
lit = sorted(map(int, an.split()))
color = {}

for i in range(400, 3201, 400):
    color[i] = list(filter(lambda x: i-400 <= x <i , lit))
rainbow = list(filter(lambda x: x>=3200, lit))
label = 0

for v in color.values():
    if len(v) != 0:
        label += 1
        
if label == 0 and len(rainbow) > 0:
    print('1 {}'.format(len(rainbow)))
else:
    print('{} {}'.format(label, label + len(rainbow)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
an = input()
lit = sorted(map(int, an.split()))
color = {}

for i in range(400, 3199, 399):
    color[i] = filter(lambda x: i-400 < x <i , lit)
color[3200] = filter(lambda x: x>=3200, lit)

c = len(color)
if color.has_key(3200):
    c -= - 1

if c >= 8:
    print('8 8')
else:
    rainbow = len(color[3200])
    mini = c
    c += rainbow
    maxi = 8 if c >= 8 else c
    print('{} {}'.format(mini, maxi))
Problem p03696 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys, re

N = input()
S = input()
# pattern = re.compile(r'\)\(')
sentence = ''
left, right = 0, 0
# lit = []
for s in S:
    sentence += s
    if s == '(':
        left += 1
    else:
        right += 1
    if left - right < 0:
        sentence = '(' + sentence
        left += 1
if left - right > 0:
    sentence = sentence + ')' * (left - right)
print(sentence)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N = input()
S = input()

res = ''
left, right = 0, 0
lit = S.split(')(')
for i, l in enumerate(lit):
    if len(lit) > 1:
        kakko = l + ')' if i % 2 == 0 else '(' + l
    j = 0
    while True:
        if len(kakko)-1 < j:
            break
        if kakko[j] == '(':
            if len(kakko) - 2 > j:
                if kakko[j+1] == ')':
                    res += '()'
                    j += 2
                else:
                    left += 1
                    j += 1
            else:
                left += 1
                j += 1
        else:
            if left != 0:
                left -= 1
            res = '(' + res + ')'
            j += 1
    part = '(' * left + ')' * left
    res  += part
print(res)
Problem p03697 (python)

Fixed submission:
# -*- coding:utf-8 -*-

n = input()
n = n.split(' ')
res = int(n[0]) + int(n[1])
if res > 9:
    print('error')
else:
    print(res)

Buggy submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import sys, itertools

N = int(input())
Sn = sorted([int(input()) for i in range(N)])

total = sum(Sn)
if total % 10 != 0:
    print(total)
    sys.exit()

sub_set = set(Sn)
for i in range(2, N):
    comb = [sum(l) for l in itertools.combinations(Sn, i)]
    for c in comb:
        sub_set.add(c)

for sub in sorted(sub_set):
    if (total - sub) % 10 != 0:
        print(total - sub)
        break
else:
    print(0)
Problem p03262 (python)

Fixed submission:
def gcd (a,b):
    if b == 0:
        return a
        
    return gcd(b, a % b)

inp = input().split()
inp = [int(x) for x in inp]

p = input().split()
p = [int(x) for x in p]

ans = gcd(abs(inp[1]-p[0]), abs(inp[1]-p[0]))
for i in range(len(p)):
    ans = gcd(ans, abs(inp[1]-p[i]))

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd (a,b):
    if b == 0:
        return a
        
    return gcd(b, a % b)

inp = input().split()
inp = [int(x) for x in inp]

p = input().split()
p = [int(x) for x in p]

ans = gcd(abs(inp[1]-p[0]), abs(inp[1]-p[1]))
for i in range(len(p)):
    ans = gcd(ans, abs(inp[1]-p[i]))

print(ans)
Problem p03296 (python)

Fixed submission:
N = input()

v = map(int, raw_input().split(' '))

found = 0

i = 0
while i < N:
	j = i
	while j < N - 1 and v[i] == v[j + 1]:
		j += 1

	found += (j - i + 1) / 2

	i = j + 1

print found

Buggy submission (verdict: Runtime Error):
test_cases = input()

for test_case in range(test_cases):
	A, B, C, D = map(int, raw_input().split(' '))

	last_take = max(1, (A - C + B - 1) // B)
	A -= last_take * B

	if A < 0 or B > D:
		print "No"
	elif B == D or B <= C: 
		print "Yes"
	else:
		printed = False

		for i in range(10000):
			x = (C - A) // (D - B) + 1
			A += (D - B) * x
			last_take = max(1, (A - C + B - 1) // B)
			A -= last_take * B

			if A < 0:
				print "No"
				printed = True
				break
			
		if printed is False:
			print "Yes"
Problem p03363 (python)

Fixed submission:
n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

if sum in dict:
	res += dict[sum]

sum += v[0]

for i in range(1, n):
	sum += v[i]
	dict[sum] -= 1
	res += dict[sum]

print res

Buggy submission (verdict: Runtime Error):
n = input()

v = map(int, raw_input().split(' '))

dict = {}

sum = 0

for i in range(n):
	sum += v[i]
	if sum not in dict:
		dict[sum] = 0

	dict[sum] += 1

res = 0

sum = 0

for i in v:
	res += dict[sum]
	sum += i
	dict[sum] -= 1

print res
Problem p03636 (python)

Fixed submission:
s = input()

n=len(s) - 2
print(s[0], end="")
print(n, end="")
print(s[-1])

Buggy submission (verdict: Runtime Error):
s = input()

n=len(s)
print(s[0] + n + s[-1])
Problem p03637 (python)

Fixed submission:
n= int(input())

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

k = len(list(filter(lambda x: x%4 == 0, a)))
j = len(list(filter(lambda x: x%2 == 0, a)))-k
i = len(a)-j-k

if (j > 0) and (i <= k):
    print("Yes")
elif (j == 0) and (i-1 <= k):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n= int(input())

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

k = len(filter(lambda(x, x%4), a))
j = len(filter(lambda(x, x%2), a))-k
i = len(a)-j-k

if (j > 0) and (i+1 <= k):
    print("Yes")
if (j == 0) and (i-1 <= k):
    print("Yes")
else:
    print("No")
Problem p03657 (python)

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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

Buggy submission (verdict: Runtime Error):
    a, b = map(int, input().split(" "))
     
    if (a%3 ==0) or (b%3 ==0) or ((a+b)%3 ==0):
        print("Possible")
    else:
        print("Impossible")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split(" "))

if (a%3 ==0) or (b%3 ==0) or ((a+b)%3 ==0)):
    print("Possible")
else:
    print("Impossible")

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))
ls = list(map(int, input().split(" ")))

ls.sort()

print(ls[:k].sum())

Buggy submission (verdict: Runtime Error):
a, b = input().split()

if (a+b) %3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

Buggy submission (verdict: Runtime Error):
a, b = input().split(" ")

if (a+b) %3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")
Problem p03658 (python)

Fixed submission:
n, k = map(int, input().split(" "))

l = list(map(int, input().split(" ")))
l.sort()

sum = 0
for i in range(n-k, n):
    sum = sum + l[i]

print(sum)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k-1, n-1):
    sum = sum + l[i]

print(sum)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k,n):
    sum = sum + l[i]

print(sum)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split(" "))

l = map(int, input().split(" "))
l.sort()

sum = 0
for i in range(n-k,n):
    sum += l[i]

print(sum)
Problem p03672 (python)

Fixed submission:
s = input()
n = len(s)
def iseven(str, n):
    for i in range(0, n//2):
        if str[i] != str[i+n//2]:
            return False
    else:
        return True


for i in range(2, n, 2):
    if iseven(s, n-i):
        print(n-i)
        break

Buggy submission (verdict: Runtime Error):
s = input()

def iseven(str, n):
    for i in range(0, n/2):
        if str[i] != str[i+n/2]:
            return False
    else:
        return True


for i in range(2, n, 2):
    if iseven(s, n-i):
        print(i)
Problem p03673 (python)

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

b1=[]
b2=[]
b=[]
for i in range(0, n-1, 2):
    b1.append(a[i])
    b2.append(a[i+1])

if n%2 == 1:
    b1.append(a[n-1])
    b1.reverse()
    b.extend(b1)
    b.extend(b2)
else:
    b2.reverse()
    b.extend(b2)
    b.extend(b1)

for item in b:
    print(item, end=" ")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split(" ")))

b=[]
for item in a:
    b.append(item)
    b.reverse()
    print(item,b)

for item in b:
    print(item, end=" ")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split(" "))

b=[]
for item in a:
    b.append(item)
    b.reverse

for item in b:
    print(item, end=" ")
Problem p03680 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input())-1)
 
light=0
 
for i in range(1,n+1):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
 
light=0
 
for i in range(n):
    light=a[light]
    if light == 1:
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

light=1

for i in range(n):
    light=a[light]
    if light == 2:
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

light=1

for i in range(n):
    light=a[light]
    if light = 2:
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input())

light=1

for i in range(n):
    light=a[light]
    if light = 2:
        print(i)
        break
else:
    print(-1)
Problem p03681 (python)

Fixed submission:
n, m = map(int, input().split(" "))
(n, m) = (n, m) if n>m else (m, n)
M=1000000007

def newfact(n):
    ans=1
    for i in range(1, n+1):
        ans = (ans*i)%M
    return ans

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split(" "))
(n, m) = (n, m) if n>m else (m, n)
M=1000000007

def newfact(n):
    
    return ((n * newfact(n-1)) % M if n > 1 else 1)

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split(" "))
n, m = n, m if n>m else m, n
M=1000000007

def newfact(n):
    return (n * newfact(n-1)) % M

if n > m+1:
    print(0)
elif n == m:
    print((2 * newfact(n) * newfact(m)) % M)
else:
    print((newfact(n) * newfact(m)) % M)