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

Fixed submission:
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if Y == 10000 * x + 5000 * y + 1000 * z:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
total = 0
for x in range(N + 1):
    for y in range(N + 1 - x):
        for z in range(N + 1 - x - y):
            if Y == 10000 * x + 5000 * y + 1000 * z:
                total = total + 1
                ans = str(x) + " " + str(y) + " " + str(z)
                print(ans)
                break
        else:
            continue
        break
    else:
        continue
    break
break
if total ==0:
    print("-1 -1 -1")
Problem p03493 (python)

Fixed submission:
s = input()
a = s.count("1")
print(a)

Buggy submission (verdict: Runtime Error):
s = int(input())
a = s.count(1)
print(a)
Problem p03494 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = []
for i in range(N):
    cnt = 0
    while A[i] % 2 == 0:
        A[i] = A[i] / 2
        cnt = cnt + 1
    ans.append(cnt)
print(min(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = []
for i in range(N):
    cnt = 0
    while A[i] % 2 == 0:
        A[i] = A[i] / 2
        cnt = cnt + 1
    ans.append(cnt)
print(min(sns))
Problem p02601 (python)

Fixed submission:
import itertools
a0,b0,c0 = map(int, input().split())
k = int(input())
p = itertools.product(range(3),repeat = k)
ans = 'No'
for i in p:
    a,b,c = a0,b0,c0
    for ii in i:
        if ii == 0:
            a = 2*a
        elif ii == 1:
            b = 2*b
        elif ii == 2:
            c = 2*c
        
        if b > a and c > b:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
a0,b0,c0 = map(int, input().split())
k = int(input())
p = itertools.product(range(3),repeat = k)
ans = 'No'
for i in p:
    a,b,c = a0,b0,c0
    if i[0] == 0:
        a = 2*a
    elif i[0] == 1:
        b = 2*b
    elif i[0] == 2:
        c = 2*c
    if b > a and c > b:
        ans = 'Yes'
        break
    if i[1] == 0:
        a = 2*a
    elif i[1] == 1:
        b = 2*b
    elif i[1] == 2:
        c = 2*c
    if b > a and c > b:
        ans = 'Yes'
        break
    if i[2] == 0:
        a = 2*a
    elif i[2] == 1:
        b = 2*b
    elif i[2] == 2:
        c = 2*c
    if b > a and c > b:
        ans = 'Yes'
        break
print(ans)
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
if n > 1:
    ns = list('1' + '0'*(n-1))
else:
    ns = list('0')

ss, cc = -1, -1
for i in range(m):
    s, c = map(int, input().split())
    if s == ss and c != cc:
        ns[0] = '-1'
        break
    ns[s-1] = str(c)
    ss, cc = s, c
    
if (len(ns) > 1 and ns[0] == '0') or ns[0] == '-1':
    ans = -1
else:
    ans = ''.join(ns)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
if n > 1:
    ns = list('1' + '0'*(n-1))
else:
    ns = list('0')

ss, cc = -1, -1
for i in range(m):
    s, c = map(int, input().split())
    if s == ss and c != cc:
        x = False
        break
    ns[s-1] = str(c)
    ss, cc = s, c
    
if (len(ns) > 1 and ns[0] == '0') or x == False:
    ans = -1
else:
    ans = ''.join(ns)
print(ans)
Problem p02783 (python)

Fixed submission:
import math 
h, a = map(int, input().split())
ans = math.ceil(h/a)
print(ans)

Buggy submission (verdict: Runtime Error):
import math 
h, a = map(int, input.split())
ans = math.ceil(h/a)
print(ans)
Problem p02802 (python)

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

ac = [False]*n
c_ac = 0
c_wa = 0
wa = [0]*n
for _ in range(m):
    pi,si = input().split()
    pi = int(pi) - 1
    
    if ac[pi] == False:
        if si == 'WA':
            wa[pi] += 1
        elif si == 'AC':
            c_ac += 1
            c_wa += wa[pi]
            ac[pi] = True

print(c_ac, c_wa)

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

ac = [False]*n
c_ac = 0
c_wa = 0

for _ in range(m):
    pi,si = input().split()
    pi = int(pi)
    
    if ac[pi] == False:
        if si == 'WA':
            c_wa += 1
        elif si == 'AC':
            c_ac += 1
            ac[pi] = True

print(c_ac, c_wa)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(n-2):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        ans += 1
        
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        ans += 1
        
print(ans)
Problem p02861 (python)

Fixed submission:
import math
import statistics
import itertools

n = int(input())
xl = []
yl = []

for i in range(n):
    x,y = map(int, input().split())
    xl.append(x)
    yl.append(y)

def d(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

dd = []
for m in itertools.permutations(range(n)):
    dsum = 0
    for i in range(n-1):
        ii = m[i]
        iii = m[i+1]
        dsum += d(xl[ii], yl[ii], xl[iii], yl[iii])
    dd.append(dsum)
ans = statistics.mean(dd)

print(ans)

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

n = int(input())
xl = []
yl = []

for i in range(n):
    x,y = map(int, input().split())
    xl.append(x)
    yl.append(y)

def d(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2 - (y1-y2)**2)

dd = []
for i in range(n):
    for j in range(i,n):
        dd.append(d(xl[i], yl[i], xl[j], yl[j]))

ans = statistics.mean(dd)
print(ans)
Problem p02886 (python)

Fixed submission:
# たこふぇす
n = int(input())
d = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    x = d[i]
    for y in d[i+1:]:
        ans += x*y
print(ans)

Buggy submission (verdict: Runtime Error):
# たこふぇす
n = int(input())
d = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    x = d[i]
    for y in d[i+1:]:
        ans += x*y
print(ans
Problem p02921 (python)

Fixed submission:
s = input()
t = input()

ans = 0
for i in range(len(s)):
    if t[i] == s[i]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
an = 1
ans = 0
while an < b:
    if ans == 0:
        an = a
    else:
        an = an - 1 + a  
    ans += 1

print(ans)
Problem p02947 (python)

Fixed submission:
n = int(input())
s = [str(input()) for i in range(n)]

ss = [''.join(sorted(i)) for i in s]
ans = 0
key_dict = {}

for i in ss:
    if i in key_dict:
        key_dict[i] += 1
    else:
        key_dict[i] = 1

a = key_dict.values()
al = [i * (i-1) / 2 if i > 1 else 0 for i in a]

ans = int(sum(al))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [str(input()) for i in range(n)]
s_sort = [sorted(i) for i in s]
ans = 0 
for i in range(n):
    for j in range(i+1,n):
        b = 0
        for k in range(10):
            if ss[i][k] != ss[j][k]:
                b = 1
                break
        if b == 0:
            ans += 1
                
print(ans)
Problem p03059 (python)

Fixed submission:
a, b, t = map(int, input().split())
ans = t // a * b
print(ans)

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

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

def gcds(nums):
    return reduce(gcd, nums)

a = int(input())
a = [int(i) for i in input().split()]

ans = 0
for i in range(len(a)):
    aa = a[:i] + a[(i+1):]
    if ans < gcds(aa):
        ans = gcds(aa)
print(ans)

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

n = int(input())
a = [int(i) for i in input().split()]

def gcd(nums):
    return reduce(fractions.gcd, nums)

ans = 0
for i in range(len(a)):
    aa = a[:i] + a[(i+1):]
    if ans < gcd(aa):
        ans = gcd(aa)
print(ans)
Problem p03061 (python)

Fixed submission:
import sys
from functools import reduce

input = sys.stdin.readline

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

n = int(input())
a = [int(i) for i in input().split()]


ans = 0
l = [0]*(n+1)
r = [0]*(n+1)
for i in range(n):
    l[i+1] = gcd(l[i], a[i])
    r[n-i-1] = gcd(r[n-i], a[n-i-1])
for i in range(n):
    ans = max(ans, gcd(l[i], r[i+1]))
print(ans)

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

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

def gcds(nums):
    return reduce(gcd, nums)

a = int(input())
a = [int(i) for i in input().split()]

ans = 0
for i in range(len(a)):
    aa = a[:i] + a[(i+1):]
    if ans < gcd(aa):
        ans = gcd(aa)
print(ans)

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

n = int(input())
a = [int(i) for i in input().split()]

def gcd(nums):
    return reduce(math.gcd, nums)

ans_l = []
for i in range(len(a)):
    aa = a[:i] + a[(i+1):]
    ans_l.append(gcd(aa))
ans = max(ans_l)
print(ans)
Problem p03102 (python)

Fixed submission:
import numpy as np
n,m,c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
ans = 0
for ii in range(n):
    a = np.array([int(i) for i in input().split()])
    if (np.dot(a,b) + c) > 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
ans = 0
for ii in range(n):
    a = np.array([int(i) for i in input().split()])
    if (a@b + c) > 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
ans = 0
for i in range(n):
    a = np.array([int(i) for i in input().split()])
    if (a@b + c) > 0:
        ans += 1
print(ans)
Problem p03145 (python)

Fixed submission:
ab, bc, ca = map(int, input().split())
print(int(ab*bc/2))

Buggy submission (verdict: Runtime Error):
ab, bc, ca = map(int, input().split())
print(int(ab*bc/2)
Problem p03612 (python)

Fixed submission:
n = int(input())
p = [int(i) for i in input().split()]
'''
i == x となる点で、i+1とスワップする
境界に注意
'''
ans = 0
for i in range(n):
    if i < n-1 and p[i] == i+1:
        p[i+1] = p[i]
        ans += 1
    elif i == n-1 and p[i] == i+1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [int(i) for i in input().split()]
'''
i == x となる点で、i+1とスワップする
境界に注意
'''
ans = 0
for i in range(n):
    if i < n and p[i] == i+1:
        p[i+1] = p[i]
        ans += 1
    elif i == n and p[i] == i+1:
        ans += 1
print(ans)
Problem p03645 (python)

Fixed submission:
import numpy as np
n,m = map(int,input().split())
A1 = np.zeros(n,dtype=bool)
Ai = np.zeros(n,dtype=bool)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        A1[b-1] = True
    if b == n:
        Ai[a-1] = True
if np.any(Ai[A1]):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
A = np.zeros((n,n),dtype=np.bool)
for i in range(m):
    a,b = map(int,input().split())
    A[a-1,b-1] = 1
    
if 1 in A[A[0] == 1,n-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
A = np.zeros((n,n),dtype=np.int8)
for i in range(m):
    a,b = map(int,input().split())
    A[a-1,b-1] = 1
    
if 1 in A[A[0] == 1,n-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
A = np.zeros((n,n),dtype=np.int8)
for i in range(m):
    a,b = map(int,input().split())
    A[a-1,b-1] = 1
    A[b-1,a-1] = 1
print(A)
if 1 in A[np.where(A[0] == 1),n-1][0]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
A = np.zeros((n,n),dtype=np.int8)
for i in range(m):
    a,b = map(int,input().split())
    A[a-1,b-1] = 1
if 1 in A[np.where(A[0] == 1),n-1][0]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
A = np.zeros((n,n),dtype=np.int8)
for i in range(m):
    a,b = map(int,input().split())
    A[a-1,b-1] = 1
if 1 in A[np.where(A[0] == 1),n-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
A = np.zeros((n,n),dtype=np.bool)
for i in range(m):
    a,b = map(int,input().split())
    A[a-1,b-1] = 1

if 1 in A[np.where(A[0] == 1),n-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Problem p03659 (python)

Fixed submission:
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
a_c = a.cumsum()
a_t = a_c[-1]
diff = np.abs(2 * a_c - a_t)
ans = diff[:-1].min()
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
a_sum = a.sum()
#y = sum - x
ans = 10**15
for i in range(1,n):
    x = a[:i].sum()
    aa = abs(2 * x - a_sum)
    ans = min(ans,aa)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
a_sum = a.sum()
ans = 10**15
for i in range(1,n):
    x = a[:i].sum()
    aa = np.abs(2 * x - a_sum)
    ans = min(ans,aa)
print(ans)
Problem p02714 (python)

Fixed submission:
N=int(input())
S=str(input())
S=list(S)
ans=S.count('R')*S.count('G')*S.count('B')
for i in range(N): #判定を簡単にするためR:=1,G:=2,B:=4と置き換えておく
    if S[i]=='R':
        S[i]=1
    elif S[i]=='G':
        S[i]=2
    elif S[i]=='B':
        S[i]=4
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k=(j-i)+j
        if k>N-1:
            continue
        if S[i]+S[j]+S[k] == 7 :
            ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=str(input())
S=list(S)
ans=S.count('R')*S.count('G')*S.count('B')

for i in range(0,N-2):
    for j in range(i+1,N-1):
        k=(j-i)+j-1
        if (S[i] != S[j]) and (S[j] != S[k]) and (S[k] != S[i]) :
            ans -= 1
print(ans)
Problem p02717 (python)

Fixed submission:
x,y,z=map(int,input().split())

p=x
x=y
y=p

p=x
x=z
z=p

print('%s %s %s' %(x,y,z))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
if n<k:
    print(n)
elif n==k:
    print('0')
else:
    a=n-k*(n//k)
    print(min(a,abs(a-k)))
Problem p02756 (python)

Fixed submission:
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
sl_list.reverse()
s_list=sl_list + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Buggy submission (verdict: Runtime Error):
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
s_list=sl_list.reverse() + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1

for i in a:
    result = result * i

    # result = np.prod(a)

    if (result > pow(10, 18)):
        result = -1
        break

print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

# for i in range(0, n):
#     result = result * a[i]

result = np.prod(a)

if result > pow(10, 18):
    result = -1

print(a)
print(result)
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m = [int(x) for x in input().split()] 
x = (h*60+m)/2  
y = 6*m   
angle = abs(x - y)  
angle = min(360 - angle, angle) 
pi = 3.14159265358979323
k = math.pi/180
if angle==180:
    print(a+b)
    
elif(angle==0):
    print(abs(a-b))
    
else:
    angle = angle*k
    p = math.cos(angle)
    if(p<-1):
        p=0
    ans=pow(a,2)+pow(b,2)- 2*a*b*p;
    ans = math.sqrt(ans);
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
a = int(input())
b = int(input())
h = int(input())
m = int(input())
x = (h*60+m)/2  
y = 6*m   
angle = abs(x - y)  
angle = min(360 - angle, angle) 
pi = 3.14159265358979323
k = math.pi/180
if angle==180:
    print(a+b)
    
elif(angle==0):
    print(0.0000000000)
    
else:
    angle = angle*k
    p = math.cos(angle)
    if(p<-1):
        p=0
    ans=pow(a,2)+pow(b,2)- 2*a*b*p;
    ans = math.sqrt(ans);
    print(ans)
Problem p02631 (python)

Fixed submission:
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	#if len(ds)==0:
	#	break
	#allxor=allxor ^ ds.pop()
	allxor=allxor ^ arr[i]

for i in range(N):
	print(allxor ^ arr[i],end='')
	print(' ',end='')

#for i in range(N):
#	if i==0 :
#		s=str(allxor ^ arr[i])
#	else:
#		s=s + ' ' + str((allxor ^ arr[i]))
#print(s)

Buggy submission (verdict: Runtime Error):
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	allxor=allxor ^ ds.pop()

for i in range(N):
	if i==0 :
		s=str(allxor ^ arr[i])
	else:
		s=s + ' ' + str((allxor ^ arr[i]))

print(s)
Problem p02608 (python)

Fixed submission:
import numpy as np

n = int(input())
max_n = int(n ** 0.5)
memo = np.zeros((max_n, max_n, max_n))

ans = [0]*(n+1)

for x in range(1, max_n):
    for y in range(1, max_n):
        for z in range(1, max_n):
            s = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if s < n+1:
                ans[s] += 1


for i in range(1, n+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())
max_n = int(n ** 0.5)
memo = np.zeros((max_n, max_n, max_n))

ans = [0]*(n+1)

for x in range(1, max_n):
    for y in range(1, max_n):
        for z in range(1, max_n):
            s = x**2+y**2+z**2+x*y+y*z+z*x
            if s <= n+1:
                ans[s] += 1


for i in range(1, n+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())
max_n = int(n ** 0.5)
memo = np.zeros((max_n, max_n, max_n))

ans = [0]*(n+1)

for x in range(1, max_n):
    for y in range(1, max_n):
        for z in range(1, max_n):
            s = x**2+y**2+z**2+x*y+y*z+z*x
            if s <= 1000:
                ans[s] += 1


for i in range(1, n+1):
    print(ans[i])
Problem p02632 (python)

Fixed submission:
def calc_inv(n, mod_n):
    inv_li = [0] * (n + 2)
    inv_li[0] = 0
    inv_li[1] = 1
    for i in range(2, n + 2):
        q, r = divmod(mod_n, i)
        inv_li[i] = -inv_li[r] * q % mod_n
    return inv_li


K = int(input())
S = input()
s_len = len(S)

MOD = 10**9 + 7
inv = calc_inv(max(K, 26) + 10, MOD)

ans = 0
p = pow(26, K, MOD)

for i in range(1, K + 2):
    ans = (ans + p % MOD) % MOD
    p = p * (s_len + i - 1) * inv[i] * 25 * inv[26] % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
def calc_inv(n, mod_n):
    inv_li = [0] * (n + 2)
    inv_li[0] = 0
    inv_li[1] = 1
    for i in range(2, n + 2):
        q, r = divmod(mod_n, i)
        inv_li[i] = -inv_li[r] * q % mod_n
    return inv_li


MOD = 10**9 + 7
inv = calc_inv(max(K, 26) + 10, MOD)

K = int(input())
S = input()
s_len = len(S)


ans = 0
p = pow(26, K, MOD)

for i in range(1, K + 2):
    ans = (ans + p % MOD) % MOD
    p = p * (s_len + i - 1) * inv[i] * 25 * inv[26] % MOD

print(ans)
Problem p02678 (python)

Fixed submission:
from collections import deque

n, m = [int(w) for w in input().split()]
links = [[] for i in range(n + 1)]
mark = [-1] * (n + 1)

for i in range(m):
    a, b = [int(w) for w in input().split()]
    links[a].append(b)
    links[b].append(a)

q = deque([1])
while q:
    now = q.popleft()
    for l in links[now]:
        if mark[l] == -1:
            q.append(l)
            mark[l] = now

if -1 in mark[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join([str(w) for w in mark[2:]]))

Buggy submission (verdict: Runtime Error):
n, m = [int(w) for w in input().split()]
links = [[] for i in range(n + 1)]
ldist = [10 ** 7] * (n + 1)
mark = [10 ** 7] * (n + 1)


def marking(node, dist, parent):
    if dist < ldist[node]:
        ldist[node] = dist
        mark[node] = parent
        for l in links[node]:
            marking(l, dist + 1, node)


for i in range(m):
    a, b = [int(w) for w in input().split()]
    links[a].append(b)
    links[b].append(a)

marking(1, 0, 0)

if 10 ** 7 in mark[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join([str(w) for w in mark[2:]]))
Problem p02888 (python)

Fixed submission:
import bisect

n = int(input())
ll = [int(w) for w in input().split()]
ll.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(ll, ll[i] + ll[j]) - (j + 1)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ll = [int(w) for w in input().split()]
ll.sort(reverse=True)

ans = 0
for ei, i in enumerate(ll):
    for ej, j in enumerate(ll[ei + 1:]):
        ans += len([w for w in ll[ei + ej + 2] if w > i - j])

print(ans)
Problem p02924 (python)

Fixed submission:
n = int(input())
s = (n*(n-1))//2
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(range(n))
print(sum(l))
Problem p03262 (python)

Fixed submission:
import math
n, x = [int(w) for w in input().split()]
la = [int(w) for w in input().split()]+[x]
la.sort()
if la[0] < 0:
    m = la[0]
    la = [w+m for w in la]

diff = [0]*n
for i in range(n):
    diff[i] = la[i+1]-la[i]
g = diff[0]
for i in diff[1:]:
    g = math.gcd(g, i)

print(g)

Buggy submission (verdict: Runtime Error):
import math
n, x = [int(w) for w in input().split()]
la = [int(w)-x for w in input().split()]
la.sort()
if la[0] < 0:
    m = la[0]
    la = [w+m for w in la]

diff = [0]*(n-1)
for i in range(n-1):
    diff[i] = la[i+1]-la[i-1]

g = diff[0]
for i in diff[1:]:
    g = math.gcd(g, i)

print(g)
Problem p03294 (python)

Fixed submission:
def gcd(a, b):
    a,b = min(a,b),max(a,b)
    while b:
	    a, b = b, a % b
    return a

#least multi
def lm(a,b):
    return a*b // gcd(a,b)

N =input()
list = input().split(" ")
int_li = [int(s) for s in list]

m = 1
for i in int_li:

    m = lm(m,i)
m-=1

ans = 0
for i in int_li:
    ans += m%i

print(ans);

Buggy submission (verdict: Runtime Error):
import math

#least multi
def lm(a,b):
    return a*b // math.gcd(a,b)

N =input()
list = input().split(" ")
int_li = [int(s) for s in list]

m = 1
for i in int_li:
    m = lm(m,i)
m-=1

ans = 0
for i in int_li:
    ans += m%i

print(ans);
Problem p03393 (python)

Fixed submission:
import collections
s = input()


cnt = collections.Counter(s)
used = set(cnt.keys())
c = -1
if len(used) < 26:
    for i in range(26):
        if not chr(i+ord("a")) in used:
            c = chr(i+ord("a"))
            break
if c != -1:
    print(s+c)
else:
    if s == "zyxwvutsrqponmlkjihgfedcba":
        print("-1")
        exit()
    i = 25
    while i > 1 and s[i-1] > s[i]:
        i -= 1
    lused = sorted(s[i-1:])
    print(s[:i-1]+lused[lused.index(s[i-1])+1])

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


cnt = collections.Counter(s)
used = set(cnt.keys())
c = -1
if len(used) < 26:
    for i in range(26):
        if not chr(i+ord("a")) in used:
            c = chr(i+ord("a"))
            break
if c != -1:
    print(s+c)
else:
    i = 25
    while s[i-1] > s[i]:
        i -= 1
        lused = sorted(s[i-1:])
        print(s[:i-1]+lused[lused.index(s[i-1])+1])
        break
    else:
        print("-1")
Problem p03400 (python)

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

n = int(input())
d, x = [int(w) for w in input().split()]

ans = x
for i in range(n):
    a = int(input())
    ans += 1 + (d - 1) // a
print(ans)

Buggy submission (verdict: Runtime Error):
5
30 44
26
18
81
18
6