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

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

A.sort()
n = A[-1]

r_=n/2

a_before=''
for a in A[:-1]:
    if a >= r_:
        break
    a_before = a
    
if abs(r_-a) >= abs(r_-a_before):
    r = a_before
else:
    r = a
    
print(n,r)

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

A.sort()
n = A[-1]

r_=11/2

a_before=''
for a in A[:-1]:
    if a >= r_:
        break
    a_before = a
    
if abs(r_-a) >= abs(r_-a_before):
    r = a_before
else:
    r = a
    
print(n,r)
Problem p03449 (python)

Fixed submission:
N=int(input())
A1 =  list(map(int,input().split()))
A2 =  list(map(int,input().split()))

A2.reverse()

# 累積和
A1_=[]
A2_=[]

a1_=0
a2_=0
for n in range(N):
    a1_ = a1_+A1[n]
    a2_ = a2_+A2[n]
    
    A1_.append(a1_)
    A2_.append(a2_)
    
A2_.reverse()

ans=0
for n in range(N):
    if ans < A1_[n]+A2_[n]:
        ans = A1_[n]+A2_[n]
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input_[0])
A1 =  list(map(int,input().split()))
A2 =  list(map(int,input().split()))

A2.reverse()

# 累積和
A1_=[]
A2_=[]

a1_=0
a2_=0
for n in range(N):
    a1_ = a1_+A1[n]
    a2_ = a2_+A2[n]
    
    A1_.append(a1_)
    A2_.append(a2_)
    
A2_.reverse()

ans=0
for n in range(N):
    if ans < A1_[n]+A2_[n]:
        ans = A1_[n]+A2_[n]
print(ans)
Problem p03472 (python)

Fixed submission:
import math

N,H = list(map(int,input().split()))

A=[]
B=[]
for n in range(N):
    a,b = list(map(int,input().split()))
    A.append(a)
    B.append(b)
    
A.sort(reverse=True)
B.sort(reverse=True)
A,B

a_max=A[0]

B_=[]
for b in B:
    if b < a_max:
        break
    B_.append(b)
B=B_

B_sum = [0]
for b in B:
    B_sum.append(B_sum[-1]+b)

ans = 0
for b_sum_idx,b_sum in enumerate(B_sum):
    if b_sum >= H:
        ans = b_sum_idx
        break
        
    ans = b_sum_idx
H = max(0,H - b_sum)

ans += math.ceil(H/a_max)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,H = list(map(int,input().split()))

A=[]
B=[]
for n in range(N):
    a,b = list(map(int,input_[1+n].split()))
    A.append(a)
    B.append(b)
    
A.sort(reverse=True)
B.sort(reverse=True)
A,B

a_max=A[0]

B_=[]
for b in B:
    if b < a_max:
        break
    B_.append(b)
B=B_

B_sum = [0]
for b in B:
    B_sum.append(B_sum[-1]+b)

ans = 0
for b_sum_idx,b_sum in enumerate(B_sum):
    if b_sum >= H:
        ans = b_sum_idx
        break
        
    ans = b_sum_idx
H = max(0,H - b_sum)

ans += math.ceil(H/a_max)

print(ans)
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
        
def lcm(a,b):
    return int(a*b//gcd(a,b))

N=int(input())

a=int(input())

for n in range(1,N):
    b=int(input())
    a=lcm(a,b)
print(a)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    x=int(max(a,b))
    y=int(min(a,b))
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
        
def lcm(a,b):
    return int(a*b/gcd(a,b))

N=int(input())

a=int(input())

for n in range(1,N):
    b=int(input())
    a=lcm(a,b)
print(a)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
        
def lcm(a,b):
    return int(a*b/gcd(a,b))

N=int(input())

a=int(input())

for n in range(1,N):
    b=int(input())
    a=lcm(a,b)
print(a)
Problem p03696 (python)

Fixed submission:
N = int(input())
S_ = input()
s=S_

count = 0
new_left = 0
new_right = 0

for si in s:
    if si == '(':
        count += 1
    else:
        count -= 1

        if count == -1:
            count = 0
            new_left += 1

new_right = count
print('(' * new_left + s + ')' * new_right)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())

right = 0
left = 0

divid = [0]
for s_1 in range(len(S)-1):
    s_2 = s_1+1
    if S[s_1] == ')' and S[s_2] == '(':
        divid.append(s_2)
divid.append(len(S))

for s1,s2 in zip(divid[:-1],divid[1:]):
    S_temp = S[s1:s2]
    right_temp = 0
    left_temp = 0
    for s in S_temp:
        if s == '(':
            left_temp += 1
        if s == ')':
            right_temp += 1    
    
    right += max(0,right_temp - left_temp)
    left += max(0,left_temp - right_temp)
    
#     print(s1,s2,S_temp)
#     print(right,left)
print('('*right+S_+')'*left)
Problem p03846 (python)

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

check=[0]*N

for idx in range(N%2,N,2):
    check[idx]=idx+1
    check[idx+1]=idx+1

ans=0

if check == A:
    if N % 2 == 0:
        ans=(2**(N//2))%(10**9+7)
    elif N % 2 != 0:
        ans=(2**((N-1)//2))%(10**9+7)
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
    
A=check.copy()
A.sort()

check=[0]*N

for idx in range(N%2,N,2):
    check[idx]=idx+1
    check[idx+1]=idx+1

ans=0

if check == A:
    if N % 2 == 0:
        ans=(2**(N//2))%(10**9+7)
    elif N % 2 != 0:
        ans=(2**((N-1)//2))%(10**9+7)
    
print(ans)
Problem p03861 (python)

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

ans=0
if a!=b:
    A = (a-1)//x
    B = b//x

    ans = B - A
elif a==0 and b==0:
    ans=1
    
elif a==x and b==x:
    ans=1

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,x = list(map(int,input_[0].split()))

ans=0
if a!=b:
    A=(a-1)//x
    B=b//x

    ans=B-A

print(ans)
Problem p04045 (python)

Fixed submission:
from itertools import product
N,K = list(map(int,input().split()))
D = list(map(int,input().split()))

D_ = [_ for _ in range(10) if _ not in D]
D_.sort()

break_flag=False
for s_ in D_:
    if break_flag:
        break
    elif s_ == 0:
        continue
    for p in product(D_,repeat=len(str(N))-1):
        ans=int(str(s_)+''.join(map(str,p)))
        if N <= ans:
            print(ans)
            break_flag=True
            break
            
if break_flag==False:
    for s_ in D_:
        if break_flag:
            break
        elif s_ == 0:
            continue
        for p in product(D_,repeat=len(str(N))):
            ans=int(str(s_)+''.join(map(str,p)))
            if N <= ans:
                print(ans)
                break_flag=True
                break

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

D_ = [_ for _ in range(10) if _ not in D]
D_.sort()

N_=N+1
break_flag=False
for s_ in D_:
    if break_flag:
        break
    elif s_ == 0:
        continue
    for p in product(D_,repeat=len(str(N_))-1):
        ans=int(str(s_)+''.join(map(str,p)))
        if N+1 <= ans:
            print(ans)
            break_flag=True
            break
Problem p02573 (python)

Fixed submission:
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(m)]
root=[-1]*n

def find(x):
    if root[x]<0:
        return x
    else:
        root[x]=find(root[x])
        return root[x]
    
def unite(x,y):
    parent_x=find(x)
    parent_y=find(y)
    
    if parent_x==parent_y:
        return

    if parent_x>parent_y:
        parent_x,parent_y=parent_y,parent_x

    root[parent_x]+=root[parent_y]
    root[parent_y]=parent_x

def size(x):
    a=find(x)
    return -root[a]

for i in range(m):
    unite(AB[i][0]-1,AB[i][1]-1)

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

print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
group=[]
number=[0 for i in range(N)]
A,B=map(int,input().split())
group.append([A,B])
number[0]=2


for i in range(M-1):
    A,B=map(int,input().split())
    flag=0
    for j in range(len(group)):
        new=[]
        if A in group[j]:
            flag=1
            if B not in group[j]:
                group[j].append(B)
                number[j]+=1
        elif B in group[j]:
            flag=1
            if A not in group[j]:
                group[j].append(A)
                number[j]+=1
                flag=1
    if flag==0:
        group.append([A,B])
        number[len(group)]=2

print(max(number))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
group=[]
number=[0 for i in range(N)]
A,B=map(int,input().split())
group.append([A,B])
number[0]=2


for i in range(M-1):
    A,B=map(int,input().split())
    flag=0
    for j in range(len(group)):
        new=[]
        if A in group[j]:
            flag=1
            if B not in group[j]:
                group[j].append(B)
                number[j]+=1
        elif B in group[j]:
            flag=1
            if A not in group[j]:
                group[j].append(A)
                number[j]+=1
                flag=1
    if flag==0:
        group.append([A,B])
        number[len(group)]=2

print(max(number))
Problem p02614 (python)

Fixed submission:
number=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
M=[]
for i in range(H):
    tmp=list(input())
    M.append(tmp)
answer=0
for rowmask in range(1<<W):
    for cowmask in range(1<<H):
        count=0
        for x in range(H):
            for y in range(W):
                if (rowmask>>y)&1==0 and (cowmask>>x)&1==0 and M[x][y]=="#":
                    count+=1
        if count==K:
            answer+=1
print(answer)

Buggy submission (verdict: Runtime Error):
umber=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
answer=0
nums=[]
for i in range(H):
    tmp=list(str(input()))
    nums.append(tmp)
count=0
for cowmask in range(1<<H):
    for rowmask in range(1<<W):
        count=0
        for x in range(H):
            for y in range(W):
                if (cowmask>>x)&1==0 and (rowmask>>y)&1==0 and nums[x][y]=="#":
                    count+=1
        if count==K:
            answer+=1
            
print(answer)
Problem p02683 (python)

Fixed submission:
number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
if answer==[]:
    print(-1)
else:
    print(min(answer))

Buggy submission (verdict: Runtime Error):
number=list(map(int,input().split()))
n,m,x=number[0],number[1],number[2]
books=[list(map(int,input().split())) for i in range(n)]
U=[x for i in range(m+1)]
U[0]=0
pattern=[]
answer=[]


for i in range(2**n):
    tmp=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=True
    
    pattern.append(tmp)

for i in range(2**n):
    cost=0
    U=[x for i in range(m+1)]
    U[0]=0
    for j in range(n):
        if pattern[i][j]==True:
            cost+=books[j][0]
            for k in range(1,m+1):
                U[k]-=books[j][k]
                if max(U)==0:
                    answer.append(cost)
                    break
                    
print(min(answer))
Problem p03493 (python)

Fixed submission:
number=list(map(int,input()))
print(number.count(1))

Buggy submission (verdict: Runtime Error):
nums=input()
print(nums.count(1))
Problem p02717 (python)

Fixed submission:
X, Y, Z = input().split(' ')
print(' '.join([Z, X, Y]))

Buggy submission (verdict: Runtime Error):
X, Y, Z = input().split(' ')
print([Z, X, Y].join(' '))
Problem p03160 (python)

Fixed submission:
import sys

N = int(sys.stdin.readline())
h = [int(hi) for hi in sys.stdin.readline().split(' ')]

dp = [1000000 * N] * N
dp[0] = 0

for i in range(N - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    if i < N - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys

N = int(sys.stdin.readline())
h = [int(hi) for hi in sys.stdin.readline().split(' ')]

cache = {}


def cost(current):
    c = cache.get(current, None)
    if c:
        return c

    if current == N - 1:
        c = 0
    elif current == N - 2:
        c = abs(h[current] - h[current + 1]) + cost(current + 1)
    else:
        c1 = abs(h[current] - h[current + 1]) + cost(current + 1)
        c2 = abs(h[current] - h[current + 2]) + cost(current + 2)
        c = min(c1, c2)

    cache[current] = c
    return c


print(cost(0))

Buggy submission (verdict: Runtime Error):
import sys


N, his = sys.stdin.readlines()
N = int(N)
his = [int(hi) for hi in his.split(' ')]
his.append(100000)

cache = {}

def cost(frm):
    if frm == N - 1:
        return 0
    elif frm < N:
        c = cache.get(frm, None)
        if c:
            return c
        c = min(
            cost(frm + 1) + abs(his[frm] - his[frm + 1]),
            cost(frm + 2) + abs(his[frm] - his[frm + 2])
        )
        cache[frm] = c
        return c
    else:
        return 1000000

print(cost(0))
Problem p03131 (python)

Fixed submission:
K,A,B = (int(x) for x in input().split())
ans = 1

if B-A>2:
    if K>= A-1:
        ans += A - 1
        K -= A - 1
        if K >= 2:
            ans = ans + (B - A) * (K // 2)
            K = K % 2

ans += K

print(ans)

Buggy submission (verdict: Runtime Error):
K,A,B = (int(x) for x in input().split())
ans = 1

if B-A>2:
    if K>= A-1:
        ans += A - 1
        K -= A - 1
        if K >= 2:
            ans = ans + (B - A) * ((unsigned long long)(K / 2));
            K = K % 2;

ans += K

print(ans)
Problem p03292 (python)

Fixed submission:
a = list(map(int,input().split()))
a = sorted(a)
cost = 0
for i in range(len(a)-1):
  cost += a[i+1]-a[i]
print(cost)

Buggy submission (verdict: Runtime Error):
a = map(int,input().split())
cost = 0
for i in range(len(a)-1):
  cost += a[i+1]-a[i]
print(cost)

Buggy submission (verdict: Runtime Error):
a = map(int,input().split())
cost = 0
for i in range(len(a)-1):
  cost += a[i+1]-a[i]
  
print(cost)
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
x -= a
x -= b*(x//b)
print(x)

Buggy submission (verdict: Runtime Error):
x = int(input())
b = int(input())
c = int(input())
x -= a
x = x- b*(x//b)
print(x)

Buggy submission (verdict: Runtime Error):
x = int(input())
b = int(input())
c = int(input())
x -= a
x -= b*x//b
print(x)
Problem p03473 (python)

Fixed submission:
m = int(input())
print(48-m)

Buggy submission (verdict: Runtime Error):
m = input().split()
print(48-m)
Problem p03574 (python)

Fixed submission:
H,W=map(int,input().split())
S = [ input() for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]=='#':

            continue
for h in range(H):
    l = ''
    for w in range(W):
        if S[h][w] == '#':
            l += '#'
        else:
            x = 0
            for dh in [ -1, 0, 1]:
                for dw in [-1, 0, 1]:
                    if 0 <= h + dh < H and 0 <= w + dw < W and S[h+dh][w+dw] == '#':
                        x += 1
            l += str(x)
    print(l)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
S = [ int(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]=='#':

            continue
for h in range(H):
    l = ''
    for w in range(W):
        if S[h][w] == '#':
            l += '#'
        else:
            x = 0
            for dh in [ -1, 0, 1]:
                for dw in [-1, 0, 1]:
                    if 0 <= h + dh < H and 0 <= w + dw < W and S[h+dh][w+dw] == '#':
                        x += 1
            l += str(x)
    print(l)
Problem p03637 (python)

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

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

# if (c[1]==0) and (c[3]==0):
#     print('Yes')

if c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0] + 1)and(c[2] == 0):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
if c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0] + 1)and(c[2] == 0):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a_n4 = a_4 = [x for x in a if x%4!=0]
a_4 = [x for x in a if x%4==0]
a_2 = [x for x in a if x%4!=0 and x%2==0]

if (len(a_n4)<=1+len(a_4) and len(a_2)<=1) or (len(a_n4)<=len(a_4) and len(a_2)>1) ):
    print("Yes")
else:
    print("No")
Problem p03696 (python)

Fixed submission:
n = int(input())
s = list(input())


v = []


stock = 0

for i in s:
    if i=="(":
        stock+=1
        v.append("(")
    else:
        if stock ==0:
            v.insert(0,"(")
            v.append(")")
        else:
            stock -= 1
            v.append(")")

for i in range(stock):
    v.append(")")

print(*v,sep='')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
t = s[::-1]
u = s[0::]
#できるだけ左から(を追加 &右から)を追加

#右から数えて最初に(より左にある)の数　と　)より右にある(の数？
v = []
si = s.index(")")
ti = t.index("(")

stock = 0
i = 0

for i in s:
    if i=="(":
        stock+=1
        v.append("(")
    else:
        if stock ==0:
            v.insert(0,"(")
            v.append(")")
        else:
            stock -= 1
            v.append(")")

for i in range(stock):
    v.append(")")

print(*v,sep='')
Problem p03760 (python)

Fixed submission:
o = list(input())
e = list(input())

for i in range(len(e)):
        print(o[i],e[i],sep="",end="")

if len(e)<len(o):
        print(o[len(o)-1])

print("")

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())

for i in range(len(e)):
        print(o[i],e[i],sep="",end="")

if len(e)<len(o):
        print(o[len(o)])

print("")

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())

for i in range(len(o)):
    print(o[i],e[i],sep="",end="")

print("")
Problem p03844 (python)

Fixed submission:
a = input().split()
if a[1] == '+':
  print(int(a[0])+int(a[2]))
else:
  print(int(a[0])-int(a[2]))

Buggy submission (verdict: Runtime Error):
a = input().split()
if a[1] == '+':
  print(a[0]+a[2])
else:
  print(a[0]-a[2])
Problem p02630 (python)

Fixed submission:
def sum_dict(d, sum, b, c):
    val = 0
    if b in d:
        val = d[b]
        sum -= (b * val)
        del d[b]
        d[c] = d.get(c, 0) + val
        sum += (c * val)
    return sum, d
    
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
s = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    s, d = sum_dict(d, s, b, c)
    print(s)

Buggy submission (verdict: Runtime Error):
def sum_dict(d, sum, b, c):
    val = 0
    if b in d:
        val = d[b]
        sum -= (b * val)
        del d[b]
        d[c] = d.get(c, 0) + val
        sum += (c * val)
    return sum, d
    
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
s = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    s, d = sum_dict(d, b, c)
    print(s)
Problem p02641 (python)

Fixed submission:
x,n = map(int, input().split())
p = list(map(int, input().split()))
for i in range(101):
  if (x - i) not in p:
    print(x - i)
    break
  elif (x + i) not in p:
    print(x + i)
    break

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
np = [x for x in range(102) if x not in p]
mnd = 103
mnv = 103
for i in np:
	if abs(i - x) < mn:
		mnv = i
		mnd = abs(i - x)
print(mnv)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
np = [x for x in range(102) if x not in p]
mnd = 103
mnv = 103
for i in np:
  if abs(i - x) < mn:
    mnv = i
    mnd = abs(i - x)
print(mnv)
Problem p02555 (python)

Fixed submission:
S = int(input())
mod = 10 ** 9 + 7

dp = [1, 0, 0]
cnt = 0
for i in range(3, S+1):
    cnt = dp[i-1] + dp[i-3]
    cnt %= mod
    dp.append(cnt)

ans = dp[S]
print(ans)

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

def seq(n):
    if n == 0:
        return 1
    elif n == 1 or n == 2:
        return 0
    else:
        return seq(n-1) + seq(n-3)

ans = seq(S)
mod = 10 ** 9 + 7
ans %= mod
print(ans)
Problem p02582 (python)

Fixed submission:
S = input()

flag = False
ans = 0
for i in range(len(S)):
    if S[i] == 'R':
        ans += 1
        flag = True
    elif S[i] == 'S' and flag:
        break

print(ans)

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

flag = False
ans = 0
for i in range(len(S)):
    if S[i] == 'R':
        ans += 1
        flag = True
    elif S[i] == 'S' and flag:
        break

print(ans)

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

flag = False
ans = 0
for i in range(len(S)):
    if S[i] == 'R':
        ans += 1
        flag = True
    elif S[i] == 'S' ans flag:
        break

print(ans)
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))
for i in range(len(x)):
    if x[i] == 0:
        print(i+1)
        break

Buggy submission (verdict: Runtime Error):
x = list(map(int, input().split()))
for i in range(x):
    if x[i] == 0:
        print(i+1)
        break

Buggy submission (verdict: Runtime Error):
x = list(map(int, input().split()))
for i in range(x):
    if x[i] == 0:
        print(i)
        break
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

sum1 = 0
sum2 = 0
sum3 = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            if i <= j <= k:
                sum1 += gcd(i, j, k)
                if i == j == k:
                    sum2 += gcd(i, j, k)
                if (i == j != k) or (j == k != i) or (k == i != j):
                    sum3 += gcd(i, j, k)

print(sum1 * 6 - sum2 * 5 - sum3 * 3)

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

sum1 = 0
sum2 = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            if i =< j =< k:
                sum1 += gcd(i, j, k)
            if i == j == k:
                sum2 += gcd(i, j, k)

print(sum1 * 3 - sum2 * 2)
Problem p02741 (python)

Fixed submission:
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(nums[K-1])

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

N1 = min(H, W)
N2 = max(H, W)

if N1 % 2 == 0:
  count = (N1 * N2) // 2
else:
  count = (N1 * (N1 -1) + N1 + 1) // 2
  if (N2 - N1) % 2 == 0:
    count += (N1 * (N2 - N1)) // 2
  else:
    count += (N1 * (N2 - N1 - 1) + N1 - 1) // 2

print(count)
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

result = min(a) + min(b)
for i in range(M):
  x, y, c = map(int, input().split())
  sum = a[x-1] + b[y-1] - c
  if sum < result:
    result = sum

print(result)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

result = min(a) + min(b)
for i in range(M):
  x, y, c = map(int, input().split())
  sum = a[x] + b[y] - c
  if sum < result:
    result = sum

print(result)