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

Fixed submission:
print(6-int(input())-int(input()))

Buggy submission (verdict: Runtime Error):
import fractions
A,B = map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))
Problem p02831 (python)

Fixed submission:
import fractions
A,B = map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
print(int(A*B/math.gcd(A,B)))
Problem p02835 (python)

Fixed submission:
print("win") if sum(list(map(int, input().split()))) < 22 else print("bust")

Buggy submission (verdict: Runtime Error):
print("win") if sum(map(int,input())) < 22 else print("bust")
Problem p02847 (python)

Fixed submission:
d = {"SUN":1,"MON":2,"TUE":3,"WED":4,"THU":5,"FRI":6,"SAT":7}
print(8-d[input()])

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
syo = -1
dai = 10**9+1
ans = 0
while abs(dai-syo)!=1:
    n = (dai+syo)//2
    en = a*n+b*len(str(int(n)))
    if en > x:
        dai = n
    else:
        ans = syo = n
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = ""
for m in input():
    s += chr((ord(m)+n-ord("A"))%26+ord("A"))
print(s)
Problem p02970 (python)

Fixed submission:
m = input()
m = m.split(' ')
n = int(m[0])
d = int(m[1])
s = 0
q = 0
while s < n:
    s += (d * 2 + 1)
    q += 1

print(q)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = int(input())
s = 0
q = 0
while s < n:
    s += (d * 2 + 1)
    q += 1

print(q)
Problem p02688 (python)

Fixed submission:
N,K = map(int,input().split(' '))

sunuke = [1] * N

for i in range(K):
    di = int(input())
    tmp = map(int, input().split())
    for t in tmp:
        sunuke[t - 1] = 0

print(sum(sunuke))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split(' '))
d = int(input())
lst = [map(int,input().split(' ')) for i in range(K+1)]
lst1 = [0]*N
decision_flag = True
for i in lst:
    if decision_flag == True:
        decision_flag = False
        for i1 in i:
            lst1[i1-1] = 1

    else:
        decision_flag = True
print(lst1.count(0))
Problem p02847 (python)

Fixed submission:
S = input()
lst = {"MON":0,"TUE":1,"WED":2,"THU":3,"FRI":4,"SAT":5,"SUN":6}

ans = lst[S]
if ans == 6:
    print(7)
else:
    print(7-ans-1)

Buggy submission (verdict: Runtime Error):
 = input()
lst = {"MON":0,"TUE":1,"WED":2,"THU":3,"FRI":4,"SAT":5,"SUN":6}

ans = lst[S]
if ans == 6:
    print(7)
else:
    print(7-ans-1)
Problem p03072 (python)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
count,ans = 0,0
for i in H:
    if count <= i:
        count = i
        ans = ans + 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
sum = 1
result = 0
if H[0] <= H[1]:
    result = H[1]
else:
    result = H[0]
for i in range(1,len(H)):
    if H[i-1] <= H[i] and result <= H[i]:
        sum += 1

print(sum)
Problem p03137 (python)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N >= M: #設置できるコマが座標よりも大きければ終了
    print(0)
    exit()
diff = []
for i in range(1,len(X)):           #座標の差の最大可
    diff.append(X[i]-X[i-1])
diff.sort(reverse=True)
total = sum(diff)
for i in range(N-1):                #移動範囲が広い座標間をショートカット
    total -= diff[i]
print(total)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N >= M: #設置できるコマが座標よりも大きければ終了
    print(0)
    exit()
diff = []
for i in range(1,len(X)):           #座標の差の最大可
    diff.append()(X[i]-X[i-1])
diff.sort(reverse=True)             
total = sum(diff)
for i in range(N-1):                #移動範囲が広い座標間をショートカット
    total -= diff[i]
print(total)
Problem p02682 (python)

Fixed submission:
A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)

Buggy submission (verdict: Runtime Error):
A, B, C, K =map(input().split())
if A <= K:
    print(K)
    
elif A+B <= K:
    print(A)
    
elif A+B+C <= K:
    print(A-C)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
K = input()
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)

Buggy submission (verdict: Runtime Error):
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)

Buggy submission (verdict: Runtime Error):
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)
Problem p02693 (python)

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

flag = False

for i in range(a, b + 1):
    if i % k == 0:
        flag = True
        break

if flag:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input('k: '))
a, b = int(input('a: ')), int(input('b: '))

res = False

for i in range(a, b + 1):
    if i % k == 0:
        res = True
        break

if res == True:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input('k = '))
a = int(input('a = ')); b = int(input('b = '))

res = False

for i in range(a, b + 1):
    if i % k == 0:
        res = True
        break

if res == True:
    print('OK')
else:
    print('NG')
Problem p02682 (python)

Fixed submission:
abck = input().split(" ")
a = int(abck[0])
b = int(abck[1])
k = int(abck[3])

if k < a:
	print(k)
elif k <= a + b:
	print(a)
else:
	c = k - (a + b)
	print(a - c)

Buggy submission (verdict: Runtime Error):
abck = input().split(" ")
a = abck[0]
b = abck[1]
c = abck[2]
k = abck[3]

if k < a:
	print(a)
elif k < a + b:
	print(a)
else:
	print(a - (k - (a + b)))
Problem p02682 (python)

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

cnt_a = 0
cnt_b = 0
cnt_c = 0

if (a > 0) & (a > k):
    cnt_a = k
    k = 0
else:
    cnt_a = a
    k = k - cnt_a

if (b > 0) & (b > k):
    cnt_b = k
    k = 0
else:
    cnt_b = b
    k = k - cnt_b

if c > 0:
    cnt_c = k

result = cnt_a * 1 + cnt_b * 0 + cnt_c * (-1)
print(result)

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

li_a = [1] * a
li_b = [0] * b
li_c = [-1] * c

li_a.extend(li_b)
li_a.extend(li_c)
li_k = li_a.copy()

print(sum(li_k[:k]))
Problem p02693 (python)

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

for i in range(A,B+1):
    if i % K == 0:
        print("OK")
        exit()
print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A,B = map(int,input().split())

if K - A % K <= B-A:
    print("OK")
elif k == 1:
    print("OK")
else:
    print("NG")
Problem p02831 (python)

Fixed submission:

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

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

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b = map(int,input().split())
print(lcm(a, b))
Problem p02712 (python)

Fixed submission:
k = 0
n = int(input())
for i in range(n+1):
  if i % 3 != 0 and i % 5 != 0:
    k += i
 
print(k)

Buggy submission (verdict: Runtime Error):
k = 0
int n = int(input())
for i in range(n):
  if i % 3 != 0 and i % 5 != 0:
    k += i

print(k)
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())

c1 = (N // (A + B))

c2 = (N % (A + B))
c3 = A if c2 > A else c2

print(c1*A + c3)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

C = (N // (A + B)) + 1
S = ''
for i in range(C):
  S += 'b'*A + 'r'*B
  
print(S[:N].count('b'))
Problem p02688 (python)

Fixed submission:
n,k=map(int,input().split())
hashmap=dict()
for _ in range(k):
  d=int(input())
  arr=[int(p) for p in input().split()]
  for key in arr:
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=int(input())
  for j in range(d):
    key=int(input())
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=int(input())
  for i in range(d):
    key=int(input())
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=int(input())
  for i in range(d):
    key=int(input())
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(key)==None:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=input()
  for i in range(d):
    key=int(input())
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(key)==None:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=input()
  for i in range(d):
    key=int(input())
    hashmap[key]=d

count=0
for i in range(1,n+1):
  if hashmap.get(key)==None:
    count+=1
print(count)
Problem p02735 (python)

Fixed submission:

def IsvalidStep(arr,row1,col1,row2,col2):
    if arr[row2][col2]=="#" and arr[row1][col1]==".":
        return 1
    return 0    

def solve(arr,matrix,n,m):
    maxx=0
    if n>0:
        if arr[0][0]=="#":
            matrix[0][0]=1
        for col in range(1,m):
            matrix[0][col]=matrix[0][col-1]
            if arr[0][col]=="#" and arr[0][col-1]==".":
                matrix[0][col]+=1

        for row in range(1,n):    
            matrix[row][0]=matrix[row-1][0]
            if arr[row][0]=="#" and arr[row-1][0]==".":
                matrix[row][0]+=1
          
        for row in range(1,n):
            for col in range(1,m):
                matrix[row][col]=min(matrix[row-1][col]+IsvalidStep(arr,row-1,col,row,col),matrix[row][col-1]+IsvalidStep(arr,row,col-1,row,col))
        return matrix[n-1][m-1]        



n,m=map(int,input().split())
arr=[int(0) for i in range(n)]
matrix=[int(0) for i in range(n)]
for i in range(n):
    arr[i]=list(input())
    matrix[i]=[int(0) for _ in range(m)]



print(solve(arr,matrix,n,m))       


"""
def solve(arr,n,m,row,col,count):
    if row>=n or col>=m:
        return 1e9
    elif row==n-1 and col==m-1:
        if arr[row][col]=="#":
            count+=1
        return count
    else:
        if arr[row][col]=="#":
            count+=1
        return min(solve(arr,n,m,row+1,col,count),solve(arr,n,m,row,col+1,count))        
"""

Buggy submission (verdict: Runtime Error):

def solve(arr,matrix,n,m):
    maxx=0
    if n>0:
        if arr[0][0]=="#":
            matrix[0][0]=1
        maxx=max(maxx,matrix[0][0])
        for col in range(1,m):
            matrix[0][col]=matrix[0][col-1]
            if arr[0][col]=="#":
                matrix[0][col]+=1
            maxx=max(maxx,matrix[0][col])

        for row in range(1,n):    
            matrix[row][0]=matrix[row-1][0]
            if arr[row][0]=="#":
                matrix[row][0]+=1
            maxx=max(maxx,matrix[row][0])

        for row in range(1,n):
            for col in range(1,m):
                matrix[row][col]=min(matrix[row-1][col],matrix[row][col-1])
                if arr[row][col]=="#":
                    matrix[row][col]+=1
                maxx=max(maxx,matrix[row][col])
        return matrix[n-1][m-1]        



n,m=map(int,input().split())
arr=[int(0) for i in range(n)]
matrix=[int(0) for i in range(n)]
for i in range(m):
    arr[i]=list(input())
    matrix[i]=[int(0) for _ in range(m)]



print(solve(arr,matrix,n,m))

Buggy submission (verdict: Runtime Error):


def solve(arr,n,m,row,col,count):
    if row>=n or col>=m:
        return 1e9
    elif row==n-1 and col==m-1:
        if arr[row][col]=="#":
            count+=1
        return count
    else:
        if arr[row][col]=="#":
            count+=1
        return min(solve(arr,n,m,row+1,col,count),solve(arr,n,m,row,col+1,count))        

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



#print(arr)
print(solve(arr,n,m,0,0,0))
Problem p03127 (python)

Fixed submission:
import fractions 

n = int(input())
monsters = list(map(int, input().split()))

for i in range(1,n):
    monsters[i] = fractions.gcd(monsters[i],monsters[i-1])
print(monsters[n-1])

Buggy submission (verdict: Runtime Error):
import math 

n = int(input())
monsters = list(map(int, input().split()))

for i in range(1,n):
    monsters[i] = math.gcd(monsters[i],monsters[i-1])
print(monsters[n-1])
Problem p02682 (python)

Fixed submission:
t=list(map(int,input().split()))
l=[1,0,-1]
k=t[3]
s=0
i=0
while(k!=0):
  if(k>t[i]):
    s+=l[i]*t[i]
    k-=t[i]
  else:
    s+=l[i]*k
    k=0
  i+=1
print(s)

Buggy submission (verdict: Runtime Error):
t=int(input().split())
l=[1,0,-1]
k=t[3]
s=0
i=0
while(k!=0):
  if(k>t[i]):
    s+=l[i]*t[i]
    k-=t[i]
  else:
    s+=l[i]*k
    k=0
  i+=1
print(s)
Problem p02693 (python)

Fixed submission:
K = int(input())
A,B = map(int,input().split())
flag=0
for i in range(A,B+1):
    if i%K==0:
        flag=1

if flag==1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A,B = map(int,input().split())

for i in range(A,B+1):
    if i%K=0:
        return print("OK")
return print("NG")
Problem p02915 (python)

Fixed submission:
x = int(input())

print(x*x*x)

Buggy submission (verdict: Runtime Error):
x = int.input()

print(x*x*x)
Problem p02987 (python)

Fixed submission:
x = input()
 
def Combination(x):
  if x[0] == x[1] and x[2] == x[3] and x[0] != x[2]:
      return "Yes"
  elif x[0] == x[2] and x[1] == x[3] and x[0] != x[1]:
      return "Yes"
  elif x[0] == x[3] and x[1] == x[2] and x[0] != x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))

Buggy submission (verdict: Runtime Error):
x = input()
 
def Combination(x):
  if x[0] == x[1]　and x[2] == x[3]:
      return "Yes"
  elif x[0] == x[2]　and x[1] == x[3]:
      return "Yes"
  elif x[0] == x[3] and x[1] == x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))

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

def Combination(x):
  if x[0] = x[1]:
    if x[2] = x[3]:
      return "Yes"
  elif x[0] = x[2]:
    if x[1] = x[3]:
      return "Yes"
  elif x[0] = x[3]:
    if x[1] = x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))
Problem p02682 (python)

Fixed submission:
a, b, c, k = [int(x) for x in input().split()]
a_x = min(a, k)
k -= a_x
b_x = min(b, k)
k -= b_x
c_x = min(c, k)
ans = a_x - c_x
print(ans)

Buggy submission (verdict: Runtime Error):
a_1, b_0, c_m1, k = map(int, input().split())

def dfs(n, a_n, b_n, c_n, max_):
	#print(n, a_n, b_n, c_n, max_)
	#print(type(n), type(a_n), type(b_n), type(c_n), type(max_))
	if (a_n > a_1 or b_n > b_0 or c_n > c_m1):
		return max_
	if (n == 0):
		max__ = int(a_n) - int(c_n) 
		if (max__ > max_):
	#		print(max__, type(max__), "***")
			return max__
		else:
			return max_
	m1 = dfs(n-1, a_n+1, b_n, c_n, max_)
	#print(m1, type(m1), "+++")
	m2 = dfs(n-1, a_n, b_n+1, c_n, m1)
	m3 = dfs(n-1, a_n, b_n, c_n+1, m2)
	return m3
            
max_ = dfs(k, 0, 0, 0, -99999)
print(max_)
Problem p02682 (python)

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

if k <= a:
  print(k)
elif a < k <= a+b:
  print(a)
elif a+b < k <= a+b+c:
  print(2*a + b - k)

Buggy submission (verdict: Runtime Error):
a = int(input())
b,c = map(int, input().split())
k = int(input())
n = 0

for s in range(k):
  if a > 0:
    n += 1
  elif b > 0:
    n += 0
  else:
    n -= 1
    
print(n)

Buggy submission (verdict: Runtime Error):
a = int(input())
b,c = map(int, input().split())
k = int(input())
n = 0

for _ in range(k):
  if a > 0:
    n += 1
  elif b > 0:
    n += 0
  elif c > 0:
    n -= 1
    
print(n)
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
a = []

for _ in range(k):
  d = int(input())
  a += [int(m) for m in input().split()]

print(n - len(set(a)))

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

for _ in range(k):
  d = int(input())
  a += [int(m) for m in input().split(" ")]

print(n - len(a))

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

for _ in range(k):
  d = int(input())
  a += (int(m) for m in input().split())

print(n - len(a))

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

for _ in range(k):
  d = int(input())
  a += [int(m) for m in input().split()]

print(n - len(a))

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

for _ in range(k):
  d = int(input())
  a.add(list((map(int, input().split())))

print(n - len(a))

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

for _ in range(k):
  d = int(input())
  a.append(map(int, input().split()))

print(n - len(a))

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

for _ in range(k):
  d = int(input())
  while m <= d:
    l = int(input())
    a.append(l)
    m += 1

print(n - len(a))

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

for _ in range(k):
  d = int(input())
  while m <= d:
    a.append(int(input()))
    m += 1

print(n - len(a))

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

for m in range(k):
  d = int(input())
  print(d)
  for l in range(d):
    a.append(range(n))
  print(a)

Buggy submission (verdict: Runtime Error):
import random
n = int(input())
k = int(input())
l = 0

while l <= k:
  d = random.randint(1, n)
  print(d)
  for m in range(d):
    print(random.randint(1, n))
  l += 1

Buggy submission (verdict: Runtime Error):
import random
n = list(x for x in range(input()))
k = int(input())
l = 0

while l <= k:
  d = random.randint(1, n)
  print(d)
  for m in range(d):
    print(random.choice(n))
  l += 1

Buggy submission (verdict: Runtime Error):
import random
n = list(range(1, int(input())))
k = int(input())
i = 0
m = 0

while i == k:
  for d in random.randint(1, k+1):
    for m in range(d)
      print(random.choice(n))
  i += 1
Problem p02682 (python)

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

if K >= A:
    result = A
    K -= A
else:
    result = K
    K = 0

if K >= B:
    K -= B

if K > 0:
    result -=K
print(result)

Buggy submission (verdict: Runtime Error):
A , B, C, K = map(int, input().split())
result = 0
for i in range(K):
    if A > 0:
        result +=1
        A -= 1
    elif B > 0:
        B -= 1
    else:
        result -= 1
        c -= 1
print(result)
Problem p03135 (python)

Fixed submission:
input_str = input("")
T = int(input_str.split(" ")[0])
X = int(input_str.split(" ")[1])

if T < 1 or T > 100:
    exit()
if X < 1 or X > 100:
    exit()
print(T/X)

Buggy submission (verdict: Runtime Error):
T = int(input(""))
X = int(input(""))

if T < 1 or T > 100:
    exit()
if X < 1 or X > 100:
    exit()
print(T/X)
Problem p03137 (python)

Fixed submission:
try:
    N, M = map(int, input().split())
    Xi = [int(x) for x in input().split()]

    if N < 1 or N > 10**5:
        exit()
    if M < 1 or M > 10**5:
        exit()
    if M != len(Xi):
        exit()
    for i in Xi:
        if i < -10**5 or i > 10**5:
            exit()
    Xi = sorted(Xi)

    a = []
    for i in range(M-1):
        a.append(Xi[i+1]-Xi[i])

    a = sorted(a, reverse=True)
    s = 0
    # print(a)
    for i in range(N-1):
        # print(a[0])
        a.pop(0)

    for i in a:
        s += abs(i)
    print(s)
except ValueError:
    exit()
except IndexError:
    print(0)

Buggy submission (verdict: Runtime Error):
try:
    N, M = map(int, input().split())
    Xi = [int(x) for x in input().split()]

    if N < 1 or N > 10**5:
        exit()
    if M < 1 or M > 10**5:
        exit()
    if M != len(Xi):
        exit()
    for i in Xi:
        if Xi[i] < -10**5 or Xi[i] > 10**5:
            exit()
    
except ValueError:
    exit()
Problem p02987 (python)

Fixed submission:
s = input()
sr = s.replace(s[0], '')
if len(sr) == 2 and sr.count(sr[0]) == 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
sr = s.replace(s[0], '')
srr = sr.replace(sr[0], '')
if len(sr) == 2 and len(srr) == 0:
    print('Yes')
else:
    print('No')
Problem p02989 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
i = int(n / 2)

d.sort()
print(d[i] - d[i - 1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split())).sort()
i = int(n / 2)

print(d[i] - d[i - 1])
Problem p02833 (python)

Fixed submission:
N = int(input())
if N%2==1:
    print(0)
    exit(0)
ans = 0
tmp = N
for i in range(1, 100):
    ans += tmp//pow(5, i)//2
print(ans)

Buggy submission (verdict: Runtime Error):
def f(n):
    if n<2:
        return 1
    return n*f(n-2)

N = int(input())
if N%2==1:
    print(0)
    exit(1)
ans = 0
tmp = N//50//2
for i in range(1, len(str(N))):
    # if i != len(str(N))-1:
    #     ans+=(10**(i))
    ans += N//5//2
    N //= 10
print(ans+tmp)

Buggy submission (verdict: Runtime Error):
def f(n):
    if n<2:
        return 1
    return n*f(n-2)

N = int(input())
if N%2==1:
    print(0)
    exit(1)
ans = 0
for i in range(1, len(str(N))):
    # if i != len(str(N))-1:
    #     ans+=(10**(i))
    ans += N//5//2
    N //= 10
ans = list(str(ans))
ans2 = []
for i in range(len(ans)):
    i = int(i)
    if i==len(ans)-1:
        res = 0
    elif i==len(ans)-2:
        res = 1
    elif i==len(ans)-3:
        res = 3
    elif i==0:
        res = 4
    else:
        res = 8
    ans2.append(str(res+int(ans[i])))
ans2.reverse()
ans2 = int(''.join(ans2))
print(ans2)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
r = int(input())
print(r**2
Problem p02862 (python)

Fixed submission:
import sys

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def comb_num_mod(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def solver(x, y):


    if (x, y) == (0, 0):
        return 0
    if (x+y)%3 != 0:
        return 0
    k = (x+y)//3
    (xi, yi) = (k, 2*k)
    for i in range(k+1):
        if (xi, yi) == (x, y):
            return comb_num_mod(k, i) 
        else:
            (xi, yi) = (xi+1, yi-1)
    return 0

x, y = map(int, input().split())
res = solver(x, y)
print(res)

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache

sys.setrecursionlimit(10000)

INF = 10**9+7

@lru_cache(maxsize=1000)
def c(n,k):
    return 1 if (k<=0 or n<=k) else (c(n-1,k-1)+c(n-1,k))%INF

# for i in range(5):
#     print([c(i, j) for j in range(i+1)])

def solver(x, y):
    if (x, y) == (0, 0):
        return 0
    if (x+y)%3 != 0:
        return 0
    k = (x+y)//3
    (xi, yi) = (k, 2*k)
    for i in range(k+1):
        if (xi, yi) == (x, y):
            return c(k, i)
        else:
            (xi, yi) = (xi+1, yi-1)
    return 0

x, y = map(int, input().split())
res = solver(x, y)
print(res)