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

Fixed submission:
L, R = map(int, input().split())

ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    X = list(range(L, R+1))
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
X = list(range(L, R+1))
ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)
Problem p03031 (python)

Fixed submission:
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

P = 0
for i in range(m):
    if p[i] == 1:
        P += 2**(m-i-1)
    
sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(n):
    B = 0
    for j in range(m):
        if isAffectedSwitch[j][i] == True:
            B += 2**(m-j-1)
    C.append(B)

for i in range(2**n):
    A = 0
    for j in range(n):
        if ((i >> j)&1):
            A = A ^ C[j]
           
    if A == P:
        sum += 1
        
print(sum)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(N):
    B = 0
    for j in range(M):
        if isAffectedSwitch[j][i] = True:
            B += 2**(M-j-1)
    C.append(B)

for i in range(2**N):
    A = 0
    for j in range(N):
        if (i >> j):
            A = A^C[j]
    if A == p:
        sum += 1
        
print(sum)
Problem p03039 (python)

Fixed submission:
n,m,k = map(int,input().split())
mod = 10**9+7
def combination(n,r,p):
    if n < r or r < 0:
        return 0
    r = min(n-r,r)
    
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i)%p)
        inv.append((-inv[p%i]*(p//i))%p)
        factinv.append((factinv[-1]*inv[-1])%p)
    return fact[n]*factinv[r]*factinv[n-r]%p
temp = combination(n*m-2,k-2,mod)
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Buggy submission (verdict: Runtime Error):
import math
n,m,k = map(int,input().split())
mod = 10**9+7
memo = {}
def factorial(num):
    if num == 0:
        return 1
    if not num in memo:
        memo[num] = num*factorial(num-1)
    return memo[num]

temp = math.factorial(n*m-2)//(math.factorial(k-2)*math.factorial(n*m-4-k))
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
mod = 10**9+7
memo = {}
def factorial(num):
    if num == 0:
        return 1
    if not num in memo:
        memo[num] = num*factorial(num-1)
    return memo[num]

temp = factorial(n*m-2)//(factorial(k-2)*factorial(n*m-k))
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcd(b, a%b)
N = int(input())
a = list(map(int,input().split()))
g1=[0 for i in range(N)]
g2=[0 for i in range(N)]
g1[0]=a[0]
g2[N-1]=a[N-1]
for i in range(1,N):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(N-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(N-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[N-2],g2[1])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcd(b, a%b)
N = int(input())
a = map(int,input().split())
g1=[0 for i in range(N)]
g2=[0 for i in range(N)]
g1[0]=a[0]
g2[N-1]=a[N-1]
for i in range(1,N):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(N-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(N-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[N-2],g2[1])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcd(b, a%b)
N = int(input())
A = map(int,input().split())
g1=[0 for i in range(N)]
g2=[0 for i in range(N)]
g1[0]=a[0]
g2[N-1]=a[N-1]
for i in range(1,N):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(N-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(N-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[N-2],g2[1])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcb(b, a%b)
N = int(input())
A = map(int,input().split())
g1=[0 for i in range(N)]
g2=[0 for i in range(N)]
g1[0]=a[0]
g2[N-1]=a[N-1]
for i in range(1,N):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(N-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(N-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[N-2],g2[1])
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    return gcb(b, a%b)
  
N = int(input())
A = map(int,input().split())
g1=[0 for i in range(n)]
g2=[0 for i in range(n)]
g1[0]=a[0]
g2[n-1]=a[n-1]
for i in range(1,n):
  g1[i]=gcd(g1[i-1],a[i])
for i in range(n-2,-1,-1):
  g2[i]=gcd(g2[i+1],a[i])
ans=1
for i in range(n-2):
  a=gcd(g1[i],g2[i+2])
  ans=max(ans,a)
ans=max(ans,g1[n-2],g2[1])
print(ans)
Problem p03110 (python)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u = 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u = 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = map(int,input().split())
    if u == 'BTC':
        x = float(x)
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
sum = float(sum)
for i in range(N):
    x,u = map(float,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
for i in range(N):
    x,u = map(float,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
for i in range(N):
    x,u = map(int,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = map(int,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = map(int,input().split())
    if u = 'BTC':
        x *= 380000.0
    sum += x
print(sum)
Problem p03165 (python)

Fixed submission:
import numpy as np
 
t = np.array(list(input()), dtype='U1')
s = np.array(list(input()), dtype='U1')
 
ls = len(s)
lt = len(t)
 
eq = s[:, None] == t[None, :]
dp = [np.zeros(lt+1, dtype=np.int16)]
 
# solve
for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out = prev[1:])
    np.maximum.accumulate(prev, out = prev)
    dp.append(prev)
 
# print([list(line) for line in dp])
 
# restore
l = dp[-1][-1]
res = ''
i, j = ls, lt
while i > 0 and j > 0:
    if eq[i-1][j-1]:
        res += s[i-1]
        i, j = i-1, j-1
        continue
    
    if dp[i-1][j] > dp[i][j-1]:
        i -= 1
    else:
        j -= 1
 
print(res[::-1])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
dp - [[0 for _ in rannge(len(s)+1)] for i in range(len(t)+1)]
for i in range(len(s)+1):
    dp[i][0] = 0
for j in range(len(t)+1):
    dp[0][j] = 0
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1] == t[i-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[len(s)][len(t)])
Problem p03166 (python)

Fixed submission:
from collections import deque
 
N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    indegs[y-1] += 1
 
dp = [0] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        dp[v2] = max(dp[v2], dp[vNow] + 1)
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)
 
print(max(dp))

Buggy submission (verdict: Runtime Error):
import collections
n,m = map(int,input().split())
d = {}
indegree = [0]*n
for _ in range(m):
    x,y = map(int,input().split())
    d[x-1] = d.get(x-1,[]) + [y-1]
    indegree[y-1] += 1
dp = [0]
q = collections.deque([i for i in range(n) if indegree[i] == 0])
while q:
    node = q.popleft()
    for nei in d.get(node,[]):
        indegree[nei] -= 1
        dp[nei] = max(dp[nei],dp[node]+1)
        if indegree[nei] == 0:
            q.append(nei)
return max(dp)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
d = {}
for _ in range(m):
    x,y = map(int,input().split())
    d[x-1] = d.get(x-1,[]) + [y-1]
memo = {}
def dp(i):
    if i not in d:
        return 0
    if i not in memo:
        memo[i] = 0
        for nei in d.get(i,[]):
            memo[i] = max(memo[i],dp(nei)+1)
    return memo[i]
ans = 0
for i in range(n):
    ans = max(ans,dp(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
d = {}
for _ in range(m):
    x,y = map(int,input().split())
    d[x-1] = d.get(x-1,[]) + [y-1]
memo = {}
def dp(i):
    if i not in d:
        return 0
    if i not in memo:
        memo[i] = 0
        for nei in d[i]:
            memo[i] = max(memo[i],dp(nei)+1)
    return memo[i]
ans = 0
for i in range(n):
    ans = max(ans,dp(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
res ={}
for _ in range(m):
    x,y = map(int,input().split())
    res[x] = res.get(x,[]) + [y]
memo = {} #nodeを始点としたパスの最長長さ
def dfs(node):
    if node in memo:
        return memo[node]
    a = 0
    for n in res.get(node,[]):
        a = max(a,dfs(n)+1)
    memo[node] = a
    return memo[node]

ans = 0
for i in range(1,n+1):
    ans = max(ans,dfs(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
res ={}
for _ in range(m):
    x,y = map(int,input().split())
    res[x] = res.get(x,[]) + [y]
memo = {} #nodeを始点としたパスの最長長さ
def dfs(node):
    if node in memo:
        return memo[node]
    a = 0
    for n in res.get(node,[]):
        a = max(a,dfs(n)+1)
    memo[node] = a
    return memo[node]

ans = 0
for i in range(n):
    ans = max(ans,dfs(i))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
res ={}
for _ in range(m):
    x,y = input().split()
    res[x] = res.get(x,[]) + [y]
memo = {} #nodeを始点としたパスの最長長さ
def dfs(node):
    if node in memo:
        return memo[node]
    a = 0
    for n in res.get(node,[]):
        a = min(a,dfs(n)+1)
    memo[node] = a
    return memo[node]

ans = 0
for i in range(n):
    ans = max(ans,dfs(i))
return ans
Problem p03168 (python)

Fixed submission:
import numpy as np
n=int(input())
s=list(map(float,input().split()))
a=np.zeros(n+1,dtype="float")
a[0]=1
for i in range(n):
    k=s[i]
    p=a*(1-k)
    p[1:]+=a[:-1]*k
    a=p
print(sum(a[n//2+1:]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
s=list(map(float,input().split()))
a=[0 for _ in range(n+1)]
p = [0 for _in range(n+1)]
a[0]=1
for i in range(n):
    k=s[i]
    for j in range(len(a)):
        p[j] = a[j]*(1-k)
    for j in range(1,len(a)):
        p[j] += a[j-1]*k
    a = p
print(sum(a[n//2+1:]))
Problem p03281 (python)

Fixed submission:
import math
N = int(input())

ans = 0
for i in range(3,N+1):
    if i < 105:
        continue
    elif i%2 == 0:
        continue
    counter = 1
    n = math.floor(math.sqrt(i))
    for j in range(2,n+1):
        a = 0
        while i%j == 0:
            a += 1
            i /= j
        if a > 0:
            counter *= (a+1)
    if counter == 8:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = math.floor(math.sqrt(N))
L = [0 for i in range(a-1)]
ans = []
for i in range(N):
    if i%2 ==0:
        continue
    counter = 0
    for j in range(2,a+1):
        while i%j == 0:
            L[j] += 1
            i /= j
    if sum(L) == 3 or sum(L) == 4:
        ans.append(i)

print(len(ans))
Problem p03545 (python)

Fixed submission:
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break

Buggy submission (verdict: Runtime Error):
def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval('{}{}{}{}{}{}{}'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                )) == 7:
                    return '{}{}{}{}{}{}{}=7'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                    )
 
 S = input()
print(solve(S))

Buggy submission (verdict: Runtime Error):
def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval(
                        S[0]+ a+ S[1]+ b+ S[2]+ c+ S[3]
                ) == 7:
                    return S[0]+ a+ S[1]+ b+ S[2]+ c+ S[3]+ '=7'
                       
                    
 
 S = input()
solve(S)

Buggy submission (verdict: Runtime Error):
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]') == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break
 
S = input()
print(solve(S))

Buggy submission (verdict: Runtime Error):
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]) == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break

S = input()
print(solve(S))
Problem p02946 (python)

Fixed submission:
a,b = [int(i) for i in input().split()]
for x in range(b-a+1,a+b):
	if x>=-1000000 and x<=1000000:
		print(x,end = " ")

Buggy submission (verdict: Runtime Error):
a,b = [int(i) for i in input().split()]
	for x in range(b-a+1,a+b):
		if x>=-1000000 and x<=1000000:
			print(x,end = " ")
Problem p02952 (python)

Fixed submission:
import math
n = int(input())
total = 0
word = str(n)
val1 = len(word)
ans = 0
if val1==1:
	ans = n
elif val1==2:
    ans = 9
elif val1==3:
	ans = 9+n-99
elif val1==4:
	ans = 909
elif val1==5:
	ans = 909+n-9999
else:
	ans = 90909
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
total = 0
val1 = int(math.ceil(math.log(n,10)))
ans = 0
if val1==1:
	ans = n
elif val1==2:
    ans = 9
elif val1==3:
	ans = 9+n-99
elif val1==4:
	ans = 909
elif val1==5:
	ans = 909+n-9999
else:
	ans = 90909
if val1==math.log(n,10) and val1%2:
	print(ans-1)
else:
	print(ans)
Problem p02574 (python)

Fixed submission:
import math

def sieve_of_erastosthenes(num):
    is_prime = [True for i in range(num+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(num**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, num + 1, i):
            is_prime[j] = False
    return [i for i in range(num + 1) if is_prime[i]]

N = int(input())
A = [int(i) for i in input().split()]
ans = math.gcd(A[0], A[1])
tmp = math.gcd(A[0], A[1])
for i in range(2, N):
    ans = math.gcd(ans, A[i])
if ans > 1:
    print('not coprime')
    exit()
maxA = max(A)
l = sieve_of_erastosthenes(maxA)
B = [False for i in range(maxA+1)]
for i in range(N):
    B[A[i]] = True
flag = False
for each in l:
    tmp = each
    counter = 0
    while True:

        if B[tmp]:
            counter += 1
        tmp += each
        if tmp > maxA:
            break
    if counter > 1:
        flag = True
        break


if flag:
    print('setwise coprime')
else:
    print('pairwise coprime')

Buggy submission (verdict: Runtime Error):
import math

def sieve_of_erastosthenes(num):
    print(num)
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num+1)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

N = int(input())
A = [int(i) for i in input().split()]
ans = math.gcd(A[0], A[1])
tmp = math.gcd(A[0], A[1])
for i in range(2, N):
    ans = math.gcd(ans, A[i])
if ans > 1:
    print('not coprime')
    exit()
maxA = max(A)
l = sieve_of_erastosthenes(maxA)
B = [False for i in range(maxA+1)]
for i in range(N):
    B[A[i]] = True
flag = False
for i in range(len(l)):
    # 素数の時
    if l[i]:
        tmp = i
        counter = 0
        while True:

            if B[tmp]:
                counter += 1
            tmp += i
            if tmp > maxA:
                break
        if counter > 1:
            flag = True
            break


if flag:
    print('setwise coprime')
else:
    print('pairwise coprime')
Problem p02690 (python)

Fixed submission:
X = int(input())
# Xの素因数分解をうまくつかう
# A^5 - B^5 =(A-B)(A^4+A^3B+A^2B^2+AB^3+B^4)
# どっちが正負かは決まらない
# AB(A^2+B^2)+(A^2+B^2)^2-A^2B^2
# AB((A-B)^2+2AB)+((A-B)^2+2AB)^2 - A^2B^2
# A-B = P
# AB = Q
# A^5-B^5 = P(Q(P^2+2Q)+(P^2+2Q)^2-Q^2) = P(P^4+5P^2Q+5Q^2) = P(5Q^2+5P^2Q+P^4)
# Qは整数解なので
# 5Q^2+5P^2Q+P^4が整数解を持つ楽な方法は(Q+P)^2の形の時、つまり2P = P^2+2, 
# X = PRとする
# R-P^4は5の倍数になる

#Aの上限を求める
# X<10^9
# A-B = 1がAを最大にできる

maxA = 126
maxX = pow(10, 9)

flag = 0
for A in range(-126, 126):
    for B in range(-127, A):
        result = pow(A, 5) - pow(B, 5)
        if result > maxX:
            next
        if result == X:
            print(A, B)
            flag = 1
            break
    if flag == 1:
        break

Buggy submission (verdict: Runtime Error):
X = int(input())
print(X)
# Xの素因数分解をうまくつかう
# A^5 - B^5 =(A-B)(A^4+A^3B+A^2B^2+AB^3+B^4)
# どっちが正負かは決まらない
# AB(A^2+B^2)+(A^2+B^2)^2-A^2B^2
# AB((A-B)^2+2AB)+((A-B)^2+2AB)^2 - A^2B^2
# A-B = P
# AB = Q
# A^5-B^5 = P(Q(P^2+2Q)+(P^2+2Q)^2-Q^2) = P(P^4+5P^2Q+5Q^2) = P(5Q^2+5P^2Q+P^4)
# Qは整数解なので
# 5Q^2+5P^2Q+P^4が整数解を持つ楽な方法は(Q+P)^2の形の時、つまり2P = P^2+2, 
# X = PRとする
# R-P^4は5の倍数になる

#Aの上限を求める
# X<10^9
# A-B = 1がAを最大にできる

maxA = 126
maxX = pow(10, 9)

flag = 0
for A in range(-126, 126):
    for B in range(-127, A):
        result = pow(A, 5) - pow(B, 5)
        if result > maxX:
            next
        if result == X:
            print(A, B)
            flag = 1
            break
    if flag == 1:
Problem p02630 (python)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
al_sum = sum(al)
q = int(input())

num = [0]*100001
for a in al:
    num[a] += 1


for _ in range(q):
    bi, ci = map(int, input().split())

    al_sum += num[bi]*(ci - bi)
    num[ci] += num[bi]
    num[bi] = 0

    print(al_sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))
al_sum = sum(al)
q = int(input())

num = [0]*10001
for a in al:
    num[a] += 1


for _ in range(q):
    bi, ci = map(int, input().split())

    al_sum += num[bi]*(ci - bi)
    num[ci] += num[bi]
    num[bi] = 0

    print(al_sum)
Problem p02690 (python)

Fixed submission:
x = int(input())
for i in range(-120, 120):
    for j in range(-120, 120):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            exit()

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

for a in range(1, 1001001001):
    b = (x - a**5)
    if b != 0:
        if b > 0 and b ** 0.2 == int(b ** 0.2):
            print(a, int(b ** 0.2))
            break
        else:
            b = -1*b
            if b ** 0.2 == int(b ** 0.2):
                print(a, -1*int(b ** 0.2))
                break
Problem p02713 (python)

Fixed submission:
k = int(input())

import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        for c in range(b+1, k+1):
            if c != b:
                ans += math.gcd(n, c)*6

# for i in range(1, k-1):
#     for j in range(i+1, k):
#         for k in range(j+1, k+1):
#             d = math.gcd(i, j)
#             ans += math.gcd(d, k)*6

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        # print(a, b, n)

for i in range(1, k-1):
    for j in range(i+1, k):
        for k in range(j+1, k+1):
            d = math.gcd(i, j)
            ans += math.gcd(d, k)*6
            # print(i, j, k)

        #
        #
        # for c in range(b+1, k+1):
        #     ans += math.gcd(n, c)*3
        # print(a, b, c)

print(int(ans))
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
m = n%k
print(min(m, abs(m-k)))

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

def func(n, k):
    if n == k:
        return print(0)
    elif n > k:
        if n % k == 0:
            return print(0)
        else:
            func(n%k, k)
    else:
        if k % n == 0:
            print((k-n)//n)
        else:
            print(k//n)

func(n, k)
Problem p02780 (python)

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

dp = [0] * (n + 1)

for i in range(n):
    dp[i+1] = dp[i] + (pl[i] + 1)/2

ans = 0
for i in range(k, n+1):
    ans = max(ans, dp[i] - dp[i-k])

print(ans)

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

def cal_p(x):
    return x*(x+1)/2/x

tmp = []
tmp_sum = []
# ans = 0
for i in range(n):
    tmp. append(cal_p(pl[i]))
    if i >= k:
        tmp_sum.append(sum(tmp[i+1-k:i+1]))

print(max(tmp_sum))
Problem p02784 (python)

Fixed submission:
h, n = map(int, input().split())
al = list(map(int, input().split()))
al_s = sorted(al, reverse=True)

count = 0
for a in al_s:
    h -= a

if h <= 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
al = list(map(int, input().split()))
al_s = sorted(al, reverse=True)

if al_s[0] + al_s[1] >= h:
    print('Yes')
else:
    print('No')
Problem p02818 (python)

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

if (a + b) >= k:
    if a >= k:
        a = a - k
    else:
        b = b - (k-a)
        a = 0
else:
    a, b = 0, 0

print(a, b)

Buggy submission (verdict: Runtime Error):
if (a + b) > k:
    if a < k:
        b = b - (k - a)
        a = 0
    else:
        a = k - a
else:
    a, b = 0, 0

print(a, b)
Problem p02899 (python)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
    ans[al[i] - 1] = i + 1
print(*ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    print(index(i) + 1)