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

Fixed submission:
from functools import reduce
inf = 10**10
import sys
input = sys.stdin.readline


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def gcd_list(numbers):
    return reduce(gcd,numbers)
n = int(input())
a = list(map(int,input().split()))
index = inf
if n == 2:
    print(max(a))
else:
    a.sort()
    if gcd(a[0],a[n-1]) == 1:
        print(max(gcd_list(a[1:n]),gcd_list(a[0:n-1])))
    else:
        ans = gcd(a[0],a[n-1])
        for i in range(1,n-1):
            if gcd(a[i]-a[0],a[n-1]-a[i]) <= ans:
                index = i
                ans = gcd(a[i]-a[0],a[n-1]-a[i])
        print(max(gcd_list(a[0:index]+a[index+1:n]),gcd_list(a[1:n]),gcd_list(a[0:n-1])))

Buggy submission (verdict: Runtime Error):
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from collections import Counter
from functools import reduce
inf = 10**10
import sys
input = sys.stdin.readline
def gcd_list(numbers):
    return reduce(math.gcd,numbers)
n = int(input())
a = list(map(int,input().split()))
index = inf
if n == 2:
    print(max(a))
else:
    a.sort()
    if math.gcd(a[0],a[n-1]) == 1:
        print(max(gcd_list(a[1:n]),gcd_list(a[0:n-1])))
    else:
        for i in range(1,n-1):
            ans = math.gcd(a[0],a[n-1])
            if math.gcd(a[i]-a[0],a[n-1]-a[i]) <= ans:
                index = i
                ans = math.gcd(a[i]-a[0],a[n-1]-a[i])
        print(gcd_list(a[0:i]+a[i+1:n]))

Buggy submission (verdict: Runtime Error):
from functools import reduce
inf = 10**10
import sys
input = sys.stdin.readline
def gcd_list(numbers):
    return reduce(math.gcd,numbers)
n = int(input())
a = list(map(int,input().split()))
index = inf
if n == 2:
    print(max(a))
else:
    a.sort()
    if math.gcd(a[0],a[n-1]) == 1:
        print(max(gcd_list(a[1:n]),gcd_list(a[0:n-1])))
    else:
        for i in range(1,n-1):
            ans = math.gcd(a[0],a[n-1])
            if math.gcd(a[i]-a[0],a[n-1]-a[i]) <= ans:
                index = i
                ans = math.gcd(a[i]-a[0],a[n-1]-a[i])
        print(gcd_list(a[0:i]+a[i+1:n]))

Buggy submission (verdict: Runtime Error):
from functools import reduce
inf = 10**10
import sys
input = sys.stdin.readline
def gcd_list(numbers):
    return reduce(math.gcd,numbers)
n = int(input())
a = list(map(int,input().split()))
index = inf
if n == 2:
    print(max(a))
else:
    a.sort()
    if math.gcd(a[0],a[n-1]) == 1:
        print(max(gcd_list(a[1:n]),gcd_list(a[0:n-1])))
    else:
        for i in range(1,n-1):
            ans = math.gcd(a[0],a[n-1])
            if math.gcd(a[i]-a[0],a[n-1]-a[i]) <= ans:
                index = i
                ans = math.gcd(a[i]-a[0],a[n-1]-a[i])
        print(gcd_list(a[0:i]+a[i+1:n]))
Problem p03062 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l=[]
j=0
ans = sum(a)
for i in range(n):
    if a[i] <0:
        a[i] *=-1
        j +=1
b = sum(a)
if j%2 == 0:
    print(b)
else:
    for i in range(n):
        ans=max(ans,b-2*a[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
dp = [[0]*2 for i in range(n+1)]
dp[0][1] = -inf
for i in range(n):
    dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i])
    dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i])
print(max(dp[n][0],dp[n][1]))
Problem p03078 (python)

Fixed submission:
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
C.sort(reverse=True)
E=[]
ans=[]
for i in range(X):
    for j in range(Y):
        E.append(A[i]+B[j])
E.sort(reverse=True)
for i in range(min(K,len(E))):
    for j in range(min(K,Y)):
        ans.append(E[i]+C[j])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
E=[]
ans=[]
for i in range(X):
    for j in range(Y):
        E.append(A[i]+B[j])
for i in range(K):
    for j in range(K):
        ans.append(E[i]+C[j])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

sum1 = []
sum2 = []
sum3 = []
for i in range(X):
    for j in range(Y):
        for k in range(10):
            sum1.append(A[i] + B[j] + C[k])
for i in range(X):
    for j in range(10):
        for k in range(Y):
            sum2.append(A[i] + B[j] + C[k])
for i in range(10):
    for j in range(Y):
        for k in range(Z):
            sum3.append(A[i] + B[j] + C[k])
sum1.sort(reverse=True)
sum2.sort(reverse=True)
sum3.sort(reverse=True)
if sum1<=sum2 and sum3<=sum2:
    for i in range(K):
        print(sum2[i])
elif sum2<=sum1 and sum3 <= sum1:
    for i in range(K):
        print(sum1[i])
else:
    for i in range(K):
        print(sum3[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

sum1 = []
sum2 = []
sum3 = []
for i in range(X):
    for j in range(Y):
        for k in range(10):
            sum1.append(A[i] + B[j] + C[k])
for i in range(X):
    for j in range(10):
        for k in range(Y):
            sum2.append(A[i] + B[j] + C[k])
for i in range(10):
    for j in range(Y):
        for k in range(Z):
            sum3.append(A[i] + B[j] + C[k])
sum1.sort(reverse=True)
sum2.sort(reverse=True)
sum3.sort(reverse=True)
if sum1<=sum2 and sum3<=sum2:
    for i in range(K):
        print(sum2[i])
elif sum2<=sum1 and sum3 <= sum1:
    for i in range(K):
        print(sum1[i])
else:
    for i in range(K):
        print(sum3[i])
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = (input())
cnt = [0] * (N + 1)
for i in range(N):
 if S[i:i+2] == "AC":
  cnt[i+1] = cnt[i] + 1
 else:
  cnt[i+1] = cnt[i]

for i in range(0,Q):
 l,r = map(int,input().split())
 print(cnt[r-1] - cnt[l-1])

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open("C:/Users/kazuki/Documents/python/import.txt","r")
sys.stdin = f

# -*- coding: utf-8 -*-
N,Q = map(int,input().split())
S = str(input())
ls =[]
rs = []
for i in range(0,Q):
 l,r = map(int,input().split())
 slice = S[l-1:r]
 cnt = slice.count("AC")
 print(cnt)

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = str(input())
for i in range(1,N+1):
 l,r = map(int,input().split())
 slice = S[l-1:r]
 cnt = slice.count("AC")
 print(cnt)
Problem p03112 (python)

Fixed submission:
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = 10**20

A,B,Q = map(int,input().split())
s = [-INF]+[int(input()) for _ in range(A)]+[INF]
t = [-INF]+[int(input()) for _ in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = 10**20

A,B,Q = map(int,input().split())
s = [-INF]+[int(input()) for _ in range(A)]+[INF]
t = [-INF]+[int(input()) for _ in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = float("inf")

A,B,Q = map(int,input().split())
s = [-INF]+[int(input()) for _ in range(A)]+[INF]
t = [-INF]+[int(input()) for _ in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)
Problem p03167 (python)

Fixed submission:
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

h,w = map(int,input().split())
dp = [[0]*(w+1) for i in range(h+1)]
a = list(input() for _ in range(h))
dp[0][0] = 1
#配るDP
for i in range(h):
    for j in range(w):
        if i+1 < h and a[i+1][j] ==".":
            dp[i+1][j] =(dp[i+1][j] + dp[i][j])%mod
        if j+1 < w and a[i][j+1] ==".":
            dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod
print(dp[h-1][w-1])

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
dp = [[0]*(w+1) for i in range(h+1)]
a = list(input() for _ in range(h))
dp[0][0] = 1
#配るDP
for i in range(h):
    for j in range(w):
        if i+1 < h and a[i+1][j] ==".":
            dp[i+1][j] =(dp[i+1][j] + dp[i][j])%mod
        if j+1 < w and a[i][j+1] ==".":
            dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod
print(dp[h-1][w-1])
Problem p03231 (python)

Fixed submission:
N,M = map(int,input().split())
S = input()
T = input()
#良い文字列は存在するならば長さはN,Mの最小公倍数になる
#異なる文字が同じ場所に来たらダメ
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a,b):
  return a*b //gcd(a,b)
L = lcm(N,M)
n = N//gcd(N,M)
m = M//gcd(N,M)
for k in range(gcd(N,M)):
    if S[k*n] != T[k*m]:
        print(-1)
        exit()
print(L)

Buggy submission (verdict: Runtime Error):
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
inf = 10**10
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a,b):
  return a*b //gcd(a,b)
n,m = map(int,input().split())
s = input()
t = input()
d = gcd(n,m)
l = lcm(n,m)
a = n//d 
b = m//d 
for i in range(d):
    if s[a*i]!= t[b*i]:
        print(-1)
        break
    else:
        print(l)

Buggy submission (verdict: Runtime Error):
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
inf = 10**10
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def gcd_list(numbers):
    return reduce(gcd,numbers)
def lcm(a,b):
  return a*b //gcd(a,b)
n,m = map(int,input().split())
s = input()
t = input()
d = gcd(n,m)
l = lcm(n,m)
a = n//d 
b = m//d 
for i in range(d):
    if s[a*i]!= t[b*i]:
        print(-1)
        break
    else:
        print(l)
Problem p03244 (python)

Fixed submission:
n = int(input())
V = list(map(int,input().split()))
even = [0] * 100001
odd  = [0] * 100001

for v in V[1::2]:
    even[v] += 1
for v in V[::2]:
    odd[v]  += 1
maxeven = max(even)
maxodd  = max(odd)
if(even.index(maxeven) != odd.index(maxodd)):
    print(n - maxeven - maxodd)
else:
    even.sort()
    odd.sort()
    print(min(n-even[-1]-odd[-2],n-even[-2]-odd[-1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
V = list(map(int,input().split()))
even = [0] * 100001
odd  = [0] * 100001

for v in V[1::2]:
    even[v] += 1
for v in V[::2]:
    odd[v]  += 1
maxeven = max(even)
maxodd  = max(odd)
if(even.index(maxeven) != odd.index(maxodd)):
    print(n - maxeven - maxodd)
else:
    even.sort()
    odd.sort()
    print(min(n-even[-1]-odd[-2]),n-even[-2]-odd[-1])
Problem p03260 (python)

Fixed submission:
a,b = map(int,input().split())
if a == 2 or b==2:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a == 2 or b==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))

x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(1,N):
    ans = math.gcd(ans,x[i+1]-x[i])
print(ans)
Problem p03261 (python)

Fixed submission:
N = int(input())
W = list(input() for _ in range(N))
for i in range(1,N):
    n = len(W[i-1])
    for j in range(0,i):
        if W[i] == W[j]:
            print("No")
            exit()
    if W[i-1][n-1] != W[i][0]:
        print("No")
        exit()
    else:
        continue
print("Yes")

Buggy submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))

x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(1,N):
    ans = math.gcd(ans,x[i+1]-x[i])
print(ans)
Problem p03262 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
N,X = map(int,input().split())
x = list(map(int,input().split()))

x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(1,N):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
x = list(map(int,input().split()))

x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(1,N):
    ans = math.gcd(ans,x[i+1]-x[i])
print(ans)
Problem p03281 (python)

Fixed submission:
N = int(input())
if N < 105:
    print(0)
elif N < 135:
    print(1)
elif N < 165:
    print(2)
elif N < 189:
    print(3)
elif N < 195:
    print(4)
else:
    print(5)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N < 105:
    print(0)
elif N < 135:
    print(1)
elif N < 165:
    print(2)
elif N < 188
    print(3)
elif N < 195:
    print(4)
else:
    print(5)
Problem p03282 (python)

Fixed submission:
S = list(input())
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        n = i +1
        break

if K < n:
    print(1)
else:
    print(int(S[n-1]))

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        n = i +1
        break

if K < n:
    print(1)
else:
    print(int(S[n-1])

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        break
    else:
        n += 1

if K < n-1:
    print(S[1])
else:
    print(S[n])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        break
    else:
        n += 1

if K < n-1:
    print(S[1])
else:
    print(S[n])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
index = 0
for i in range(len(S)):
    if S[i] != "1":
        break
    else:
        n += 1

if K < n-1:
    print(S[n])
else:
    print(S[n])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
n = 0
for i in range(len(S)):
    if S[i] != "1":
        break
    else:
        n += 1

if K < n:
    print(S[n])
else:
    print(S[n])
Problem p03283 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n,m,q = map(int,input().split())
c=[[0 for i in range(n+1)] for j in range(n+1)]
x=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    x[l][r] += 1
for i in range(1,n+1):
    for j in range(1,n+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(q):
    p,q = map(int,input().split())
    sum = 0
    for j in range(p,q+1):
         sum+= c[j][q] - c[j][p-1]
    print(sum)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open("C:/Users/kazuki/Documents/python/import.txt","r")
sys.stdin = f
# -*- coding: utf-8 -*-
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from collections import Counter
inf = 10**10
input = sys.stdin.readline

n,m,q = map(int,input().split())
c=[[0 for i in range(n+1)] for j in range(n+1)]
x=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    x[l][r] += 1
for i in range(1,n+1):
    for j in range(1,n+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(q):
    p,q = map(int,input().split())
    sum = 0
    for j in range(p,q+1):
         sum+= c[j][q] - c[j][p-1]
    print(sum)
Problem p03287 (python)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
b = 0
d = {0:1}
ans = 0
for a in A:
    b = (b + a)%M
    ans += d.get(b,0)
    d[b] = d.get(b,0) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

 N,M = map(int,input().split())
 A = list(map(int,input().split()))
 S = [0]*N
 sum = 0
 ans = 0
 #二項係数とその逆元テーブルを作る前処理
 Max = N+1
 fac = [0]*(Max)
 finv = [0]*(Max)
 inv = [0]*(Max)
 fac[0]=fac[1]=1
 finv[0]=finv[1]=1
 inv[1]=1
 for i in range(2,Max):
         fac[i] = fac[i-1] * i % mod
         inv[i] = mod - inv[mod%i]*(mod//i)%mod
         finv[i] = finv[i-1]*inv[i]%mod
 #O(1)でmod計算した組合せ数を計算
 def Comb(n,r):
     if n < r:
         return 0
     if n < 0 or r < 0 :
         return 0
     return fac[n]*(finv[r]*finv[n-r]%mod)%mod
 
 for i in range(N):
     sum += A[i]
     if sum % M == 0:
         ans += 1
     S[i] = sum % M
 C = Counter(S)
 for n in C.values():
     ans += Comb(n,2)
 print(ans)
Problem p03289 (python)

Fixed submission:
s = input()
ans = "WA"
tmp =""
if s[0] == 'A':
    if s[2:-1].count("C") ==1:
        tmp = s.replace("A","a").replace("C","c")
        if tmp == s.lower():
            ans = "AC"
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = "WA"
tmp =""
if s[0] == 'A':
    if s[2:-1].count("C") ==1:
        tmp = s.replace("A","a").replace("C."c)
        if tmp = s.lower():
            ans = "AC"
print(ans)
Problem p03290 (python)

Fixed submission:
d,g = map(int,input().split())
"""
PC = []
for i in range(d):
    pc = list(map(int,input().split()))
    PC.append(pc)
"""
PC =[list(map(int,input().split())) for i in range(d)]

def solve(g,i):
    if i<=0:
        return float('inf')
    n = min(int(g/(100*i)),PC[i-1][0])
    score = 100 * i * n
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if g > score:
        n += solve(g-score,i-1)
    return min(n,solve(g,i-1))

print(solve(g,d))

Buggy submission (verdict: Runtime Error):
d,g = map(int,input().split())
"""
PC = []
for i in range(d):
    pc = list(map(int,input().split()))
    PC.append(pc)
"""
PC =[list(map(int,input().split())) for i in range(d)]

def solve(g,i):
    if i<=0:
        return float('inf')
    n = min(int(G/100*i),PC[i-1][0])
    score = 100 * i * n 
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if g > score:
        n += solve(g-score,i-1)
    return min(n,solve(g,i-1))

print(solve(g,d))

Buggy submission (verdict: Runtime Error):
d,g = map(int,input().split())
"""
PC = []
for i in range(d):
    pc = list(map(int,input().split()))
    PC.append(pc)
"""
PC =[list(map(int,input().split())) for i in range(d)]

def solve(G,i):
    if i<=0:
        return float('inf')
    n = min(int(G/100*i),PC[i-1][0])
    score = 100 * i * n 
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if G > score:
        n += solve(G-score,i-1)
    return min(n,solve(G,i-1))

print(solve(G,D))
Problem p03293 (python)

Fixed submission:
def solve():
    s = input()
    t = input()
    for i in range(len(s)):
        if t == s[i:] + s[:i]:
            return True
        else:
            False
if solve():
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def solve():
    s = input()
    t = input()
    for i in range(len(s)):
        if t == s[i:] + s[:i]:
            return True
        else False
if solve():
    print("Yes")
else:
    print("No")
Problem p03294 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
m=1
sum = 0
def gcd(a, b):
 if a < b:
    a, b = b, a
 if b == 0:
    return a
 c = a % b
 return gcd(b, c)
def lcm(a,b):
    return int(a*b/gcd(a,b))
for i in range(n):
    m = m *a[i]
for i in range(n):
        sum += (m-1) % a[i]

print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
m=1
ans =0
def gcd(a, b):
 if a < b:
    a, b = b, a
 if b == 0:
    return a
 c = a % b
 return gcd(b, c)
def lcm(a,b):
    return int(a*b/gcd(a,b))
for i in range(n):
    m = lcm(m,a[i])
for i in range(m):
    sum = 0
    for j in range(n):
        sum += i % a[j]
    ans = max(ans,sum)
print(ans)
Problem p03331 (python)

Fixed submission:
inf = 10**10

n = int(input())
ans = inf
def f(x):
    cur = 0
    while x >0:
        cur += x % 10
        x = x //10
    return cur
for a in range(1,n):
    b = n-a
    ans = min(ans,f(a)+f(b))
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
inf = 10**10

n = int(input())
ans = inf
def f(x):
    cur = 0
    while x >0:
        cur += x % 10
        x = x //10
    return cur
for a in range(1,n):
    b = n-a
    ans = min(ans,f(a)+f(b))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = inf
def f(x):
    cur = 0
    while x >0:
        cur += x % 10
        x = x //10
    return cur
for a in range(1,n):
    b = n-a
    ans = min(ans,f(a)+f(b))
print(ans)
Problem p03337 (python)

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):

a,b = map(int().input().split())
print(max(a+b,a-b,a*b))
Problem p03363 (python)

Fixed submission:
n = int(input()) 
a = [int(i) for i in input().split()]
d = dict()
d[0] = 1
ans = 0
t = 0
for i in range(n):
    t += a[i]

    s = d.get(t,0)
    ans += s 
    d[t] = s+1
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
s = [0] * (n+1)
ans = 0
for i in range(n):
    s[i+1] = s[i] + a[i]
c = Counter(s)
for i in c:
    ans += int(c[i]*(c[i]-1)//2)
print(ans)