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

Fixed submission:
import sys
def sample_code():
    n = int(input())
    if n == 1 or n == 2:
        print(0)
        sys.exit(0)
    # print('# 素因数')
    fct = factorize(n)
    # print(fct, num(fct))
    answer = 0
    # print('# 約数')
    for div in divisorize(fct):
        if num(div)-1 > n//num(div):
            answer += num(div) - 1
    print(answer)


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    sample_code()

Buggy submission (verdict: Runtime Error):
def sample_code():
    n = int(input())
    
    # print('# 素因数')
    fct = factorize(n)
    # print(fct, num(fct))
    answer = 0
    # print('# 約数')
    for div in divisorize(fct):
        if num(div) > n//num(div):
            answer += num(div) - 1
    print(answer)


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


if __name__ == '__main__':
    sample_code()
Problem p03074 (python)

Fixed submission:
N,K = map(int,input().split())
S = input()
one = [0]
zero = [0]
if S[0] == '0':
    one.append(0)
cnt = 1
for i in range(1,len(S)):
    if S[i] != S[i-1]:
        if S[i-1] == '1':
            one.append(cnt+one[-1])                
        else:
            zero.append(cnt+zero[-1])                
        cnt = 1
    else:
        cnt += 1
else:
    if S[-1] == '1':
        one.append(cnt+one[-1])                
    else:
        zero.append(cnt+zero[-1])                
        one.append(one[-1])                
window_size = min(len(zero)-1,K)
MAX = 0
for i in range(len(zero)-window_size):
    if MAX < (zero[i+window_size] - zero[i]) + (one[i+window_size+1] - one[i]):
        MAX = (zero[i+window_size] - zero[i]) + (one[i+window_size+1] - one[i])

print(MAX)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = list(map(int,input()))
blobs = []
if S[0] == 0:
    blobs.append(0)
cnt = 0
past_i = 0
for i in range(len(S)):
    if i == 0:
        past_i = S[i]
    if past_i == S[i]:
        cnt += 1
        past_i = S[i]
        
    else:
        blobs.append(cnt)
        cnt = 1
        past_i = S[i]
    if i == len(S)-1:
        blobs.append(cnt)

if S[-1] == 0:
    blobs.append(0)
print(blobs)
sums = []
for i in range(len(blobs)//2-K+1):
    temp_sum = sum(blobs[2*i:min(2*(i+K)+1,len(blobs))])
    sums.append(temp_sum)
    if temp_sum == N:
        break
print(max(sums))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = list(map(int,input()))
blobs = []
if S[0] == 0:
    blobs.append(0)
cnt = 0
past_i = 0
for i in range(len(S)):
    if i == 0:
        past_i = S[i]
    if past_i == S[i]:
        cnt += 1
    else:
        blobs.append(cnt)
        cnt = 1
        past_i = S[i]
if S[-1] == 0:
    blobs.append(0)
sums = []
for i in range(len(blobs)//2):
    sums.append(sum(blobs[2*i:2*(i+K+1)]))
print(max(sums))
Problem p03160 (python)

Fixed submission:
N = int(input())
h_s = list(map(int,input().split()))
INF = 10^3
dp = [INF]*N

dp[0] = 0
dp[1] = abs(h_s[1] - h_s[0]) + dp[0]
for i in range(2,len(h_s)):
    dp[i] = min((dp[i-1] + abs(h_s[i] - h_s[i-1])),(dp[i-2] + abs(h_s[i] - h_s[i-2])))
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h_s = list(map(int,input().split()))
INF = 10000000000
dp = [INF]*N
dp[0] = 0
K = min(K,N-1)
for i in range(1,N):
    for j_j in range(min(K,i)):
        j = j_j + 1
        dp[i] = min((dp[i-j] + abs(h_s[i] - h_s[i-j])),dp[i])
print(dp)
Problem p03161 (python)

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

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h_s = list(map(int,input().split()))
INF = 1000000
dp = [INF]*N
dp[0] = 0
K = min(K,N-1)
for i in range(1,K):
    for j_j in range(i):
        j = j_j + 1
        dp[i] = min((dp[i-j] + abs(h_s[i] - h_s[i-j])),dp[i])
    print(dp)
for i in range(K,N):
    for j_j in range(K):
        j = j_j + 1
        dp[i] = min((dp[i-j] + abs(h_s[i] - h_s[i-j])),dp[i])
    print(dp)
print(dp[-1])
Problem p03200 (python)

Fixed submission:
S = list(input().strip())
is_irrversible = 0
answer = 0
position_key_sum = 0
number_of_white = 0
sigma = 0
for i in range(len(S)):
    if S[i] == 'W':
        position_key_sum += (i+1)
        number_of_white += 1
        sigma += number_of_white
answer = position_key_sum - sigma
print(answer)

Buggy submission (verdict: Runtime Error):
S = array(input())
print(S)
Problem p03363 (python)

Fixed submission:
from collections import Counter
N = int(input())
A_s = list(map(int,input().split()))
ruiseki = [0]
for i,a in enumerate(A_s):
    ruiseki.append(ruiseki[i]+a)
counter = Counter(ruiseki)


answer = 0
for k,v in counter.items():
    if v > 1:
        answer += v * (v-1)//2
print(answer)

Buggy submission (verdict: Runtime Error):
# ruiseki
from collections import Counter
F = open("/Users/yamataku/Downloads/subtask_1_09.txt")
# N = int(input())
# A_s = list(map(int,input().split()))
N = int(F.readline())
A_s = list(map(int,F.readline().split()))
ruiseki = [0]
for i,a in enumerate(A_s):
    ruiseki.append(ruiseki[i]+a)
counter = Counter(ruiseki)

answer = 0
for k,v in counter.items():
    if v > 1:
        answer += v * (v-1)//2
print(answer)

Buggy submission (verdict: Runtime Error):
# ruiseki
from collections import Counter
N = int(input())
A_s = list(map(int,input().split()))
ruiseki = [0]
for i,a in enumerate(A_s):
    ruiseki.append(ruiseki[i]+a)
counter = Counter(ruiseki)
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination((2*10**5))

answer = 0
for k,v in counter.items():
    if v > 1:
        answer += comb(v, 2)
print(answer)
Problem p03610 (python)

Fixed submission:
S = list(input())
for i, s in enumerate(S):
  if i % 2 == 0:
    print(s, end='')

Buggy submission (verdict: Runtime Error):
S = list(input())
for i in range(S):
  if i % 2 == 0:
    print(S[i], end='')
Problem p03720 (python)

Fixed submission:
N,M = map(int,input().split())
bucket = {}
for i in range(N):
  bucket[i] = 0
for m in range(M):
  tempa,tempb = map(int,input().split())
  bucket[tempa-1] += 1
  bucket[tempb-1] += 1
for i in range(N):
  print(bucket[i])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input())
bucket = {}
for i in range(N):
  bucket[i] = 0
for m in range(m):
  tempa,tempb = map(int,input())
  bucket[tempa-1] += 1
  bucket[tempb-1] += 1
for i in range(N):
  print(bucket[i])
Problem p03944 (python)

Fixed submission:
W,H,N = map(int,input().split())
limit = {'top': H, 'right': W, 'down': 0, 'left': 0}
for _ in range(N):
  x,y,a = map(int,input().split())
  if a == 1:
    if x > limit['left']:
      limit['left'] = x
  elif a == 2:
    if x < limit['right']:
      limit['right'] = x
  elif a == 3:
    if y > limit['down']:
      limit['down'] = y
  elif a == 4:
    if y < limit['top']:
      limit['top'] = y
height = limit['top'] - limit['down']
width = limit['right'] - limit['left']
if (height > 0) and (width > 0):
  print(height * width)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
W,H,N = map(int,input().split())
limit = {'top': H, 'right': W, 'down': 0, 'left': 0}
for _ in range(N):
  x,y,a = map(int.input().split())
  if a == 1:
    if x > limit['left']:
      limit['left'] = x
  elif a == 2:
    if x < limit['right']:
      limit['right'] = x
  elif a == 3:
    if y > limit['down']:
      limit['down'] = y
  elif a == 4:
    if y < limit['top']:
      limit['top'] = y
height = limit['top'] - limit['down']
width = limit['right'] - limit['left']
if (height > 0) and (width > 0):
  print(height * width)
else:
  print(0)
Problem p04001 (python)

Fixed submission:
S = input()
power = 0
answer = 0
temps = int(S)
while True:
    if temps < 10:
        break
    temps = temps/10
    power += 1

SS = list(S)

for i in range(1 << power):
    output = []
    for j in range(power):
        if (i>>j)&1 == 1:
            output.append(SS[j])
            output.append('+')
        else:
            output.append(SS[j])
    output.append(SS[power])
    temp_string = ''.join(output)
    answer += eval(temp_string)
    
print(answer)

Buggy submission (verdict: Runtime Error):
S = input()
power = 0
answer = 0
temps = int(S)
while True:
    temps = temps/10
    power += 1
    if temps < 10:
        break

SS = list(S)

for i in range(1 << power):
    output = []
    for j in range(power):
        if (i>>j)&1 == 1:
            output.append(SS[j])
            output.append('+')
        else:
            output.append(SS[j])
    output.append(SS[power])
    temp_string = ''.join(output)
    answer += eval(temp_string)
    output.clear()
    
print(answer)

Buggy submission (verdict: Runtime Error):
S = input()
power = 0
answer = 0
temps = int(S)
while True:
    temps = temps/10
    power += 1
    if temps < 10:
        break

SS = list(S)

for i in range(1 << power):
    output = []
    for j in range(power):
        if (i>>j)&1 == 1:
            output.append(SS[j])
            output.append('+')
        else:
            output.append(SS[j])
    output.append(SS[power])
    temp_string = ''.join(output)
    answer += eval(temp_string)
    
print(answer)
Problem p02645 (python)

Fixed submission:
s=input()
print(s[:3])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*(n+2)
S=sum(a)
for i in range(k):
    s=S
    S=0
    for j in range(n):
        if j<a[j]:
            b[0]+=1
        else:
            b[j-a[j]+1]+=1
        if n-1-j<a[j]:
            b[n+1]-=1
        else:
            b[j+a[j]+2]-=1
    for j in range(n):
        if j==0:
            a[j] = b[j]+b[j+1]
        else:
            a[j] = a[j-1]+b[j+1]
        b[j]=0
        S+=a[j]
    b[-2]=0
    b[-1]=0
    if S==s:
        break
for i in a:
    print(i,end=" ")
Problem p02706 (python)

Fixed submission:
n,m = map(int,input().split())
li=list(map(int,input().split()))
g=n-sum(li)
if g>=0:
    print(g)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li=list(map(int,input().split()))
g=n-sum(li)
if g>=0:
    print g
else:
    print -1

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li=list(map(int,input().split()))
g=n-sum(li)
if g>=0:
  return g
else:
  return -1
Problem p02713 (python)

Fixed submission:
import math
n=int(input())
ans=0
d={}
for a in range(1,n+1):
    for b in range(1,n+1):
        p=math.gcd(a,b)
        if d.get(p)!=None:
            d[p]+=1
        else:
            d[p]=1
for c in range(1,n+1):
    for e in range(1,n+1):
        p=math.gcd(c,e)
        ans+=d[e]*p
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
d={}
if n==1:
    print(1)
for a in range(1,n+1):
    for b in range(1,n+1):
        p=math.gcd(a,b)
        if d.get(p)!=None:
            d[p]+=1
        else:
            d[p]=1
for c in range(1,n+1):
    for e in range(1,n+1):
        p=math.gcd(c,e)
        ans+=d[e]*p
print(ans)
Problem p02982 (python)

Fixed submission:
import numpy as np
n,d = map(int,input().split())
ans=0
g=[]
if d==1:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
    ans=n*(n-1)//2
    print(ans)
else:
    for _ in range(n):
        lis = np.array(list(map(int,input().split())))
        for i in range(len(g)):
            u = g[i]-lis
            z=np.linalg.norm(u)
            if z==int(z):
                ans+=1
        g.append(lis)
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,d = map(int,input().split())
ans=0
g=[]
if d==1:
  ans=n*(n-1)//2
  print(ans)
else:
  for _ in range(n):
    for i in range(len(g)):
	    lis = np.array(list(map(int,input().split())))
    	u = g[i]-lis
        z=np.linalg.norm(u)
        if z-int(z)==0:
          ans+=1
    g.append(lis)
print(ans)
Problem p03005 (python)

Fixed submission:
a,b = map(int,input().split())
if b==1:
  print(0)
else:
  print(a-b)

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

if a[0]>=0:
    g=sum(a[1:])-a[0]
    print(g)
    for i in range(n-1):
        if len(a)>2:
            print(str(a[0])+" "+str(a[-1]))
            a[0]-=a[-1]
            a.remove(a[-1])
        else:
            print(str(a[1])+" "+str(a[0]))
    
elif a[-1]<=0:
    g=a[-1]-sum(a[:-1])
    print(g)
    for i in range(n-1):
        print(str(a[-1])+" "+str(a[0]))
        a[-1]-=a[0]
        a.remove(a[0])
else:
    g=0 
    for i in range(n):
        g+=abs(a[i])
    print(g)
    for _ in range(n-1):
        if a[-2]>=0:
            print(str(a[0])+" "+str(a[-1]))
            a[0]-=a[-1]
            a.remove(a[-1])
        else:
            print(str(a[-1])+" "+str(a[0]))
            a[-1]-=a[0]
            a.remove(a[0])
Problem p03136 (python)

Fixed submission:
n = int(input())
li = map(int,input().split())
li = list(li)
li.sort()
s=0
for i in range(n-1):
  s+=li[i]
if s<=li[-1]:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
li.sort()
s=0
for i in range(n-1):
  s+=li[i]
if s<=li[-1]:
  print(No)
else:
  print(Yes)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = map(int,input().split())
li = list(li)
li.sort()
s=0
for i in range(n-1):
  s+=li[i]
if s<=li[-1]:
  print(No)
else:
  print(Yes)
Problem p03148 (python)

Fixed submission:
from operator import itemgetter
n,k = map(int,input().split())
li=[]
s=[]
t=[]
g=0
ans=[]
retu=[0]*n
p=0
q=0
for _ in range(n):
    a,b=map(int,input().split())
    li.append([a,b])
li=sorted(li,key=itemgetter(1),reverse=True)
for i in range(k):
    g+=li[i][1]
    if retu[li[i][0]-1]==0:
        retu[li[i][0]-1]+=1
        p+=1
    else:
        t.append(li[i][1])
        q+=1
g+=p**2
ans.append(g)
for i in range(k,n):
    if q==0:
        break
    if retu[li[i][0]-1]==0:
        g=g-t[q-1]+li[i][1]+2*p+1
        p+=1
        q-=1
        ans.append(g)
        retu[li[i][0]-1]+=1
print(max(ans))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n,k = map(int,input().split())
li=[]
s=[]
t=[]
g=0
ans=[]
for _ in range(n):
    a,b=map(int,input().split())
    li.append([a,b])
sorted(li,key=itemgetter(1),reverse=True)
for i in range(k):
    g+=li[i][1]
    if li[i][0] not in s:
        s.append(li[i][0])
    else:
        t.append(li[i][1])
g+=len(s)**2
ans.append(g)
for i in range(k,n):
    if t==0:
        break
    if li[i][0] not in s:
        g=g-t[-1]+li[i][1]+2*len(s)+1
        ans.append(g)
        s.append(li[i][0])
print(max(ans))
Problem p03150 (python)

Fixed submission:
s=input()
for i in range(8):
    ans=s[:i]+s[-7+i:]
    if ans=="keyence":
        ans=0
        print("YES")
        break
if ans!=0:
    print("NO")

Buggy submission (verdict: Runtime Error):
s=input()
if "k" in s and "y" in s and "n" in s and "c" in s and k.count("e")>=3:
    print("YES")
else:
    print("NO")
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    a=abs(a)
    b=abs(b)
    if a<b:
        c=a
        a=b
        b=c
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)
n,x = map(int,input().split())
xlist= list(map(int,input().split()))
ans=x-xlist[0]
for i in xlist:
    ans=gcd(ans,x-i)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,x = map(int,input().split())
xlist= list(map(int,input().split()))
ans=x-xlist[0]
for i in xlist:
    ans=math.gcd(ans,x-i)
print(ans)
Problem p02555 (python)

Fixed submission:
s = int(input())
l = 10**9+7
list_1 = [0, 1, 1, 1]
list_2 = [0, 1, 2]
for i in range(3, s):
  list_2.append((list_2[i-1] + list_1[i])%l)
  list_1.append(list_2[i-2])
if s == 1 or s == 2:
  print(0)
else:
  print(list_1[s-1])

Buggy submission (verdict: Runtime Error):
s = int(input())
l = 10**9+7
list_1 = [0, 1, 1, 1]
list_2 = [0, 1, 2]
for i in range(3, s):
  list_2.append((list_2[i-1] + list_1[i])%l)
  list_1.append(list_2[i-2])
if s = 1 or s = 2:
  print(0)
else:
  print(list_1[s-1])
Problem p02582 (python)

Fixed submission:
a = input()
s = 0
if a == "RRR":
  s = 3
elif a == "RRS" or a == "SRR":
  s = 2
elif a == "SSS":
  s = 0
else:
  s = 1
print(s)

Buggy submission (verdict: Runtime Error):
a = input()
s = 0
if a == "RRR":
  s = 3
elif a == "RRS" or a == "SRR":
  s = 2
elif a = "SSS":
  s = 0
else:
  s = 1
print(s)
Problem p02608 (python)

Fixed submission:
n = int(input())
list = [0]*n
if n ==1:
  m = 1
else:
  m = int((n-2)**0.5)
for i in range(1, m):
  for j in range(i, m):
    for k in range(j, m):
      if i*i + j*j + k*k + i*j + j*k + k*i <= n:
        if i==j and j == k:
          list[i*i + j*j + k*k + i*j + j*k + k*i-1] += 1
        elif i == j or j == k:
          list[i*i + j*j + k*k + i*j + j*k + k*i-1] += 3
        else:
          list[i*i + j*j + k*k + i*j + j*k + k*i-1] += 6
      else:
        break
for i in range(n):
  print(list[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
list = [0]*n
m = int((n-2)**0.5)
for i in range(1, m):
  for j in range(i, m):
    for k in range(j, m):
      if i*i + j*j + k*k + i*j + j*k + k*i <= n:
        if i==j and j == k:
          list[i*i + j*j + k*k + i*j + j*k + k*i-1] += 1
        elif i == j or j == k:
          list[i*i + j*j + k*k + i*j + j*k + k*i-1] += 3
        else:
          list[i*i + j*j + k*k + i*j + j*k + k*i-1] += 6
      else:
        break
for i in range(n):
  print(list[i])
Problem p02613 (python)

Fixed submission:
n = int(input())
a, b, c, d = 0, 0, 0, 0
for i in range(n):
  s = input()
  if s == 'AC':
    a+=1
  elif s== 'WA':
    b+=1
  elif s=='TLE':
    c+=1
  else:
    d+=1
print("AC x {}".format(a))
print("WA x {}".format(b))
print("TLE x {}".format(c))
print("RE x {}".format(d))

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b, c, d = 0, 0, 0, 0
for i in range(n):
  s = input()
  if s == 'AC':
    a+=1
  elif s== 'WA':
    b+=1
  elif s=='TLE':
    c+=1
  else:
    d+=1
print("AC x "a)
print("WA x "b)
print("TLE x "c)
print("RE x "d)
Problem p02658 (python)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
a = 1
flag = True
for i in range(n):
  a *= x[i]
  if a > 10**18:
    if 0 in x:
      print(0)
    else:
      print('-1')
    flag = False
    break
if flag:
  print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
import math
a = 0
b = 1
for i in range(n):
  a += math.log(x[i], 10)
if a > 18:
  print('-1')
else:
  for i in range(n):
    b *= x[i]
  print(b)
Problem p02678 (python)

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

#グラフをリストにする
#リストの第i番目の集合は、頂点iが繋がっている頂点の集合である
l = [[] for _ in range(n+1)]
for _ in range(m):
  a, b = map(int, input().split())
  l[a].append(b)
  l[b].append(a)
  
#解（道しるべとなる点）を保存するリストを作る
ans = [-1] * (n+1)
ans[1] = 0

#解（道しるべとなる点）を書き込んでいく
#深さdの点の集合をxに、d＋１の集合をyとする
#yの要素は、l[i]と一致する
x = [1]
y = []
while x != []:
  for i in x:
    for j in l[i]:
      if ans[j] == -1:
        ans[j] = i
        y.append(j)
  x = y
  y = []
print('Yes')
for i in range(2, n+1):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [[] for i in range(n)]
for i in range(m + 1):
  a, b = map(int, input().split())
  l[a].append(b)
  l[b].append(a)
ans = [-1] * (n+1)
ans[0] = 0
x = [1]
y = []
count = 1
while x != []:
  for i in x:
    for j in l[i]:
      if ans[j] == -1:
        ans[j] = i
        y.append(j)
        count += 1
  x = y
  y = []
print('Yes')
for i in range(2, n+1):
    print(ans[i])
Problem p02681 (python)

Fixed submission:
s = input()
t = input()
u = s + t[-1]
if u == t:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
c = list(map(int, input().split()))
x = 1
for i in range(k):
  x = c[x-1]
print(x)
Problem p02555 (python)

Fixed submission:
S = int(input())
 
A = [0,0,1]
if S == 1 or S == 2:
  print(0)
elif S == 3:
  print(1)
else:
  for i in range(3,S):
    A += [A[i-1] + A[i-3]]
  print(A[i] % (10 ** 9 + 7))

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

A = [0,0,1]
if S == 1 or S == 2:
  print(0)
elif S == 3:
  print(1)
else:
  for i in range(3,S):
    A += [A[i-1] + A[i-3]]
print(A[i] % (10 ** 9 + 7))

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

A = [0,0,1]
for i in range(3,S):
  A += [A[i-1] + A[i-3]]
print(A[i] % (10 ** 9 + 7))

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

A = [0,0,1]
for i in range(3,S):
  A += [A[i-1] + A[i-3]]
print(A[i]%(10 ** 9 + 7))

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

A = [0,0,1]
for i in range(3,S):
  A += [A[i-1] + A[i-3]]
print(A[i])

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

def retu(n):
  if n == 0 or n == 1 or n == 2:
    return 0
  elif n == 3:
      return 1
  else:
    a = retu(n-1) + retu(n-3)
    return a
print(retu(S))
Problem p02607 (python)

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]
 
c = 0

for i in range(N):
  if i % 2 == 0 and a[i] % 2 ==1:
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
ai = [int(x) for x in input().split()]


c = 0

for i in range(N):
  if i % 2 == 1 and a[i] % 2 ==1:
    c += 1
  
print(c)
Problem p02606 (python)

Fixed submission:
l,r,d=map(int,input().split())
c=0

for i in range(l,r+1):
    if i%d==0:
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
aa
Problem p02658 (python)

Fixed submission:
n=int(input())
seq=list(map(int,input().split()))
p=1
f=1
c=int(1e18)
if 0 in seq:
    print(0)
else:
    for i in range(n):
        p*=seq[i]
        if p>c:
            print(-1)
            f=0
            break
            
    if f==1:
        print(p)

Buggy submission (verdict: Runtime Error):
n=int(input())
seq=list(map(int,input().split()))
p=1
f=1
for i in range(n):
	p*=seq[i]
    if(p>=10**18):
		print(-1)
        f=0
        break
if f==1:
  print(p)