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

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

A.sort(reverse=True)

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)

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

A.sort(reverse=True) #これで実行される(new_A = A.sortとかしても返り値はnon-type)

ans = 0
for i in range(1, N+1):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)

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

new_A = A.sort(reverse=True)

ans = 0
for i in range(1, N+1):
    if i % 2 == 0:
        ans += new_A[i]
    if i % 2 == 1:
        ans -= new_A[i]
print(ans)

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

new_A = A.sort(reverse=True)

ans = 0
for i in range(len(new_A)):
    if i % 2 == 0:
        ans += new_A[i]

print(ans)

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

new_A = A.sort(reverse=True)

ans = 0
for i in range(len(new_A)):
    if i % 2 == 0:
        ans += new_A[i]
    if i % 2 == 1:
        ans -= new_A[i]

print(ans)

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

A = A.sort(reverse=True)

ans = 0
for i in range(len(A)):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)

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

A = A.sort(reverse=True)

ans = 0
for i in range(len(A)):
    if i % 2 == 0:
        ans += A[i]
    elif i % 2 == 1:
        ans += -A[i]

print(ans)
Problem p03455 (python)

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

product = a*b
if(product%2 == 0):
    print('Even')
else:
    print('Odd')

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

product = a*b
if(product%2 == 0):
    print('Even')
    else:
        print('Odd')
Problem p03457 (python)

Fixed submission:
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point_a += 1

for i in range(N):
    if point_a == 0 and ((TXY[i+1][0] - TXY[i][0]) % 2 != (abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2])) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N):
    if point_a == 0 and (TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
TXY.insert(0,[0,0,0])

point = 0
for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2 :
        point += 1

if point == 0:
    print('Yes')
else:
    print('No')
Problem p03493 (python)

Fixed submission:
sss = input()
masu = list(sss)
counter = 0
if(masu[0] == '1'):
    counter += 1
if (masu[1] == '1'):
    counter += 1
if (masu[2] == '1'):
    counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
sss = input()
masu = list(sss)
counter = 0
if(masu[0] == 1):
    counter += 1
    elif (masu[1] == 1):
        counter += 1
    elif (masu[2] == 1):
        counter += 1
print(counter)
Problem p02981 (python)

Fixed submission:
n,a,b = map(int, input().split())
if a * n < b:
  print(a * n)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
if a * n < b:
  print(a * n)
else:
  printf(b)
Problem p03000 (python)

Fixed submission:
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, x = map(int, input().split())
    l = aread_int()
    current = 0
    cnt = 0
    while cnt < n and current + l[cnt] <= x :
        current += l[cnt]
        cnt += 1
    
    print(cnt + 1)

Buggy submission (verdict: Runtime Error):
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()

if __name__ == '__main__':
    n, x = map(int, input().split())
    l = aread_int()
    current = 0
    cnt = 0
    while current + l[cnt] <= x :
        current += l[cnt]
        cnt += 1
    
    print(cnt + 1)
Problem p03035 (python)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
    exit()
elif a >= 6:
    print(int(b / 2))
    exit()
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 6:
    print(0)
    return
elif a < 14:
    print(int(b / 2))
	return
else:
    print(b)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 6:
    print(0)
    exit()
elif a < 14:
    print(int(b / 2))
	exit()
else:
    print(b)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a < 6:
    print(0)
else if a < 14:
    print(int(b / 2))
else:
    print(b)
Problem p03860 (python)

Fixed submission:
def main():
    s = aread("str")
    print(s[0][0] + s[1][0] + s[2][0])

def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input().split( ))
    return ret


def scan():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
a, b, c = map(string, input().split())
name = a[0] + b[0] + c[0]
print(name)
Problem p03459 (python)

Fixed submission:
# -*- coding: utf-8 -*-      
import sys

n = int(input())
tprev = 0
tdiff = 0
pos = [0, 0]
for i in range(n):
    t, x, y = list(map(int,input().split()))
    tdiff = t - tprev
    if(tdiff>=abs(x-pos[0])+abs(y-pos[1])):
        if((tdiff-(abs(x-pos[0])+abs(y-pos[1])))%2 == 0):
            tprev = t
            pos = [x, y]
        else:
            print('No')
            sys.exit()
    else:
        print('No')
        sys.exit()
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import Counter
import numpy as np

n, k = list(map(int,input().split()))
table = np.zeros((2*k,2*k),dtype='int32')
for i in range(n):
    t = input().split()
    if(t[2]=='B'):
        table[int(t[0])%(2*k)][int(t[1])%(2*k)] += 1
    else:
        table[(int(t[0])+k)%(2*k)][int(t[1])%(2*k)] += 1
        
n_table = np.zeros((3*k,3*k),dtype='int32')
n_table[0:2*k,0:2*k] = table
n_table[2*k:3*k,0:2*k] = table[0:k,0:2*k]
n_table[0:2*k,2*k:3*k] = table[0:2*k,0:k]
n_table[2*k:3*k,2*k:3*k] = table[0:k,0:k]

i_table = np.zeros((3*k,3*k),dtype='int32')

for i in range(0,3*k):
    i_table[i][0] = n_table[i][0]
    for j in range(1,3*k):
        i_table[i][j] += i_table[i][j-1] + n_table[i][j] 
for i in range(1,3*k):
    for j in range(0,3*k):
        i_table[i][j] += i_table[i-1][j]  

ans = 0
hope1 = i_table[k-1][k-1]
hope2 = i_table[2*k-1][2*k-1] - i_table[2*k-1][k-1] - i_table[k-1][2*k-1] + i_table[k-1][k-1]
ans = max(ans,hope1+hope2)
for i in range(1,k):
    hope1 = i_table[k-1][i+k-1] - i_table[k-1][i-1]
    hope2 = i_table[2*k-1][i+2*k-1] - i_table[2*k-1][i+k-1] - i_table[k-1][i+2*k-1] + i_table[k-1][i+k-1]
    ans = max(ans,hope1+hope2)
for i in range(1,k):        
        hope1 = i_table[i+k-1][k-1]- i_table[i-1][k-1]
        hope2 = i_table[i+2*k-1][2*k-1] - i_table[i+2*k-1][k-1] - i_table[i+k-1][2*k-1] + i_table[i+k-1][k-1]
        ans = max(ans,hope1+hope2)

for i in range(1,k):
    for j in range(1,k):        
        hope1 = i_table[i+k-1][j+k-1] - i_table[i+k-1][j-1] - i_table[i-1][j+k-1] + i_table[i-1][j-1]
        hope2 = i_table[i+2*k-1][j+2*k-1] - i_table[i+2*k-1][j+k-1] - i_table[i+k-1][j+2*k-1] + i_table[i+k-1][j+k-1]
        ans = max(ans,hope1+hope2)
print(ans)
Problem p03565 (python)

Fixed submission:
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

if(len(s)<len(t)):
    flg = False
for i in range(len(s)-len(t)+1)[::-1]:
    tmpstr = s[i:i+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        uset = list(range(i,i+len(t)))
        for k in range(len(s)):
            if(k in uset):
                ansstr += t[k-i]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

for i in range(len(s)-len(t)+1)[::-1]:
    tmpstr = s[i:i+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        uset = list(range(i,i+len(t)))
        for k in range(len(s)):
            if(k in uset):
                ansstr += t[k-i]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-       

s = input()
t = input()
ansstr = []

for i in range(len(s)-len(t)+1):
    p = len(s)-len(t)-i
    tmpstr = s[p:p+len(t)]
    flg = True
    for j in range(len(t)):
        if(tmpstr[j] == '?'):
            pass
        elif(tmpstr[j] == t[j]):
            pass
        else:
            flg = False
    if(flg):
        for k in range(len(s)):
            if(p<=k and k<p+len(t)):
                ansstr += t[k-p]
            elif(s[k]=='?'):
                ansstr += 'a'
            else:
                ansstr += s[k]
        break
print(''.join(ansstr) if flg else 'UNRESTORABLE')
Problem p03713 (python)

Fixed submission:
# -*- coding: utf-8 -*-
h,w = map(int, raw_input().split())
 
area = [0,0,0]
ans = 10**15
if(h%3 == 0 or w%3 == 0):
    ans = 0
else:
    for i in range(1,h/2+1):
        area[0] = i*w
        tmp = w/2
        area[1] = tmp*(h-i)
        area[2] = (w-tmp)*(h-i)
        S = max(area)-min(area)
        if(S<ans):
            ans = S
        tmp = (h-i)/2
        area[1] = tmp*w
        area[2] = (h-i-tmp)*w
        S = max(area)-min(area)
        if(S<ans):
            ans = S
        
    for i in range(1,w/2+1):
        area[0] = i*h
        tmp = h/2
        area[1] = tmp*(w-i)
        area[2] = (h-tmp)*(w-i)
        S = max(area)-min(area)
        if(S<ans):
            ans = S
        tmp = (w-i)/2
        area[1] = tmp*h
        area[2] = (w-i-tmp)*h
        S = max(area)-min(area)
        if(S<ans):
            ans = S
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
h,w = map(int, raw_input().split())

area = [0,0,0]
ans = 999999999999
if(h%3 == 0 or w%3 == 0):
    print('0')
    exit(1)
for i in range(1,h/2+1):
    area[0] = i*w
    area[1] = (w/2)*(h-i)
    area[2] = (w-w/2)*(h-i)
    S = max(area)-min(area)
    if(S<ans):
        ans = S
    
for i in range(1,w/2+1):
    area[0] = i*h
    area[1] = (h/2)*(w-i)
    area[2] = (h-h/2)*(w-i)
    S = max(area)-min(area)
    if(S<ans):
        ans = S
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
h,w = map(int, raw_input().split())

a,b,c = 0,0,0
diff =[0,0,0]   
ans = 999999999999
if(h%3 == 0 or w%3 == 0):
    print('0')
    exit(1)
for i in range(1,h/2+1):
    a = i*w
    b = (w/2)*(h-i)
    c = (w-w/2)*(h-i)
    diff = abs(a-b),abs(a-c),abs(b-c)
    S = max(diff)-min(diff)
    if(S<ans):
        ans = S
    
    
for i in range(1,w/2+1):
    a = i*h
    b = (h/2)*(w-i)
    c = (h-h/2)*(w-i)
    diff = abs(a-b),abs(a-c),abs(b-c)
    S = max(diff)-min(diff)
    if(S<ans):
        ans = S
print(ans)
Problem p03795 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = input()
paid = 800*N
cashback = (N/15)*200
print(paid-cashback)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = input()
S = raw_input()
Ans = ''
StartString = ['SS','SW','WS','WW']
CheckFlag = 0
for i in range(4):
    Ans += StartString[i]
    for j in range(N-1):
        if(Ans[j+1]=='S' and S[j+1]=='o'):
            Ans += Ans[j]
        elif(Ans[j+1]=='S' and S[j+1]=='x'):
            if(Ans[j]=='S'):
                Ans += 'W'
            else:
                Ans += 'S'
        elif(Ans[j+1]=='W' and S[j+1]=='o'):
            if(Ans[j]=='S'):
                Ans += 'W'
            else:
                Ans += 'S'
        elif(Ans[j+1]=='W' and S[j+1]=='x'):
            Ans += Ans[j]
    if(Ans[0]==Ans[N]):
        print(Ans[:N])
        CheckFlag = 1
        break
    else:
        Ans = ''
        
if(CheckFlag == 0):
    print('-1')
Problem p02573 (python)

Fixed submission:

class unionfind():

    def __init__(self,n):
        #親番号<0なら根
        #根の場合、数値の絶対値が要素数
        self.par=[-1 for i in range(n)]
        
    def root(self,x):
        
        par=self.par
        if par[x]<0:
            return x
        else:
            self.x = self.root(par[x])
            return self.x
        
    def unite(self,x,y):
        #高いほうに低いほうをくっつける
        rx=self.root(x)
        ry=self.root(y)
        
        if rx==ry:
            return
        else:
            if self.par[rx]>self.par[ry]:
                rx,ry = ry,rx
                
            self.par[rx]+=self.par[ry]
            self.par[ry] = rx

            
    def same(self, x,y):
        return self.root(x) == self.root(y)
    
    def par_print(self):
        print(self.par)
        
    def count(self, x):
        return -self.root(x)
    
n,m = map(int,input().split())

friend = unionfind(n)

for i in range(m):
    a,b = map(int,input().split())
    friend.unite(a-1,b-1)
    # print(friend.par_print())
    
# print(friend.par_print())

ans = -min(friend.par)

print(ans)

Buggy submission (verdict: Runtime Error):
class unionfind():

    def __init__(self,n):
        #親番号<0なら根
        #根の場合、数値の絶対値が要素数
        self.par=[-1 for i in range(n)]
        
    def root(self,x):
        
        par=self.par
        if par[x]<0:
            return x
        else:
            self.root = self.root(par[x])
            return self.root
        
    def unite(self,x,y):
        #高いほうに低いほうをくっつける
        rx=self.root(x)
        ry=self.root(y)
        
        if rx==ry:
            return
        else:
            if self.par[rx]>self.par[ry]:
                rx,ry = ry,rx
                
            self.par[rx]+=self.par[ry]
            self.par[ry] = rx

            
    def same(self, x,y):
        return self.root(x) == self.root(y)
    
    def par_print(self):
        print(self.par)
        
    def count(self, x):
        return -self.root(x)
    
n,m = map(int,input().split())

friend = unionfind(n)

for i in range(m):
    a,b = map(int,input().split())
    friend.unite(a-1,b-1)
    # print(friend.par_print())
    
# print(friend.par_print())

ans = -min(friend.par)

print(ans)

Buggy submission (verdict: Runtime Error):
class unionfind():

    def __init__(self,n):
        self.par=[i for i in range(n)]
        
    def root(self,x):
        #自分自身の番号==parの番号なら根
        par=self.par
        if par[x]==x:
            return x
        else:
            self.root = self.root(par[x])
            return self.root
        
    def unite(self,x,y):
        #xにyをくっつける
        rx=self.root(x)
        ry=self.root(y)
        
        if rx==ry:
            return
        else:
            self.par[ry]=rx
            
    def same(self, x,y):
        return self.root(x) == self.root(y)
    
    def par_print(self):
        print(self.par)
    
n,m = map(int,input().split())

friend = unionfind(n)

for i in range(m):
    a,b = map(int,input().split())
    friend.unite(a-1,b-1)
    
# print(friend.par_print())

ans = max([friend.par.count(i) for i in range(n)])

print(ans)
Problem p02585 (python)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)

Buggy submission (verdict: Runtime Error):
ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)
Problem p02678 (python)

Fixed submission:
import queue
import sys
imput = sys.stdin.readline

n,m = map(int,input().split()) 

conne = [[] for _ in range(n)]
dist = [99999]*(n)
par = [0] * (n)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a-1].append(b-1)
    conne[b-1].append(a-1)
    
q=queue.Queue()
dist[0] = 0
q.put((0,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in conne[x]:
        if dist[i]==99999:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1

print("Yes")    

for i in par[1:]:
    print(i+1)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc168/tasks/abc168_d
import queue
import sys
imput = sys.stdin.readline

n,m = map(int,input().split()) 

conne = [[0]*(n+1) for _ in range(n+1)]
dist = [99999]*(n+1)
par = [0] * (n+1)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a][b] = 1
    conne[b][a] = 1
    
q=queue.Queue()
dist[1] = 0
q.put((1,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in range(len(conne[x])):
        if conne[x][i]==1 and dist[i]>d+1:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1

if max(dist[1:]) == 99999:
    print("No")
    
else:
    print("Yes")    
    
    for i in par[2:]:
        print(i)

Buggy submission (verdict: Runtime Error):
import queue
import sys
imput = sys.stdin.readline

n,m = map(int,input().split()) 

conne = [[0]*(n+1) for _ in range(m+1)]
dist = [99999]*(n+1)
par = [0] * (n+1)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a][b] = 1
    conne[b][a] = 1
    
q=queue.Queue()
dist[1] = 0
q.put((1,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in range(len(conne[x])):
        if conne[x][i]==1 and dist[i]>d+1:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1

if max(dist[1:]) == 99999:
    print("No")
    
else:
    print("Yes")    
    
    for i in par[2:]:
        print(i)

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

conne = [[0]*(n+1) for _ in range(m+1)]
dist = [99999]*(n+1)
par = [0] * (n+1)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a][b] = 1
    conne[b][a] = 1
    
q=queue.Queue()
dist[1] = 0
q.put((1,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in range(len(conne[x])):
        if conne[x][i]==1 and dist[i]>d+1:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1

if max(dist[1:]) == 99999:
    print("No")
    
else:
    print("Yes")    
    
    for i in par[2:]:
        print(i)

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

conne = [[0]*(n+1) for _ in range(m+1)]
dist = [99999]*(n+1)
par = [0] * (n+1)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a][b] = 1
    conne[b][a] = 1
    
q=queue.Queue()
dist[1] = 0
q.put((1,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in range(len(conne[x])):
        if conne[x][i]==1 and dist[i]>d+1:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1
            
for i in par[2:]:
    print(i)
Problem p02696 (python)

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

x=min(n,b-1)

ans = (int(a*x/b) - a * int(x/b))

print(ans)

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

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(max(ans))

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

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(min(ans))
Problem p02768 (python)

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

mod = 10**9+7

all_combi = pow(2,n,mod)




p = 1
q = 1

for i in range(b):
    
    p *= n-i
    p %= mod
    q *= i+1
    q %= mod
    
    if i==a-1:
        nca = p * pow(q,mod-2,mod) % mod
        
    if i==b-1:
        ncb = p * pow(q,mod-2,mod) % mod

        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)

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

mod = 10**9+7

all_combi = pow(2,n,mod)




p = 1
q = 1

for i in range(b):
    
    p *= n-i
    p %= mod
    q *= i+1
    q %= mod
    
    if i==a-1:
        nca = p * pow(q,-1,mod) % mod
        
    if i==b-1:
        ncb = p * pow(q,-1,mod) % mod

        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)
Problem p02838 (python)

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
 
mod = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   # 最大桁数は、最も大きい数値の2進数の桁数
    num_1 = np.count_nonzero((A >> n)&1)   # 1の数をカウント
    num_0 = N - num_1                      # 0の数をカウント
    mul = num_1 * num_0   # 0 XOR 1の回数
    ans += ((2 ** n)*mul) % mod
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
ans=0
for d in range(60):
    n_1 = 0
    for a in A:
        if (a>>d)&1 == 1:
            n_1 += 1
            n_0 = n-n_1
            
        ans += n_0*n_1
        ans %= 10**9+7
print(ans)