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

Fixed submission:
import itertools
import numpy as np
import math

n, p = map(int, input().split())
if n != 1:
    table = [0] * (int(math.sqrt(p)) + 1)

    pl = []
    ans = 1

    for i in range(2, int(math.sqrt(p)) + 1):
        if table[i] == 0:
            pl.append(i)
            for j in range(i + i, int(math.sqrt(p)) + 1, i):
                table[j] = 1

    a = 0

    for i in range(len(pl)):
        q = p
        while q % pl[i] == 0:
            a += 1
            q = q / pl[i]
        ans = ans * (pl[i] ** (int(a//n)))
        a = 0
else:
    ans = p

print(ans)

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

n, p = map(int, input().split())
if n != 1:
    table = [0] * (math.sqrt(p) + 1)

    pl = []
    ans = 1

    for i in range(2, math.sqrt(p)+1):
        if table[i] == 0:
            pl.append(i)
            for j in range(i + i, math.sqrt(p)+1, i):
                table[j] = 1

    a = 0

    for i in range(len(pl)):
        q = p
        while q % pl[i] == 0:
            a += 1
            q = q / pl[i]
        ans = ans * (pl[i] ** (int(a//n)))
        a = 0
else:
    ans = p
print(ans)

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

n, p = map(int, input().split())
if n != 1:
    table = [0] * (math.sqrt(p) + 1)

    pl = []
    ans = 1

    for i in range(2, math.sqrt(p)+1):
        if table[i] == 0:
            pl.append(i)
            for j in range(i + i, p + 3, i):
                table[j] = 1

    a = 0

    for i in range(len(pl)):
        q = p
        while q % pl[i] == 0:
            a += 1
            q = q / pl[i]
        ans = ans * (pl[i] ** (int(a//n)))
        a = 0
else:
    ans = p
print(ans)
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
ans = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t > T:
        continue
    if ans > c:
        ans = c

if ans == 1001:
    print('TLE')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
ans = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t > T:
        continue
    if ans > c:
        ans = c

if ans = 1001:
    print('TLE')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
ans = 1001
for i in range(n):
    c, t = map(int, input().split())
    if t > T:
        continue
    if ans > c:
        ans = c

if ans = 1001:
    print('TLE')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
ans = 1000
for i in range(n):
    c, t = map(int, input().split())
    if t > T:
        continue
    if ans > c:
        ans = c

print(ans)
Problem p03243 (python)

Fixed submission:
n = int(input())
for i in range(n, 1000):
  if i % 111 == 0:
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n, 1000):
  if i % 111 = 0:
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n, 1000):
  if i % 111 = 0:
    print(i)
    break
Problem p03309 (python)

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

for i in range(N):
    B.append(A[i] - i - 1)

B = sorted(B)
M = B[int((N - 1)/2)]
ans = 0

for i in range(N):
    t = B[i] - M
    if t < 0:
        t = (-1) * t
    ans += t

print(ans)

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

for i in range(N):
    B.append(A[i] - i - 1)

B = sorted(B)
M = B[int((N + 1)/2)]
ans = 0

for i in range(N):
    t = B[i] - M
    if t < 0:
        t = (-1) * t
    ans += t

print(ans)

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

for i in range(N):
    B.append(A[i] - i)

B = sorted(B)
M = B[int((N + 1)/2)]
ans = 0

for i in range(N):
    t = B[i] - M
    if t < 0:
        t = (-1) * t
    ans += t

print(ans)

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

for i in range (N):
    B[i] = A[i]- i

B = sorted(B)
M = B[int((N + 1)/2)]
ans = 0

for i in range(N):
    t = B[i] - M
    if t < 0:
        t = (-1) * t
    ans += t

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
M = int((N + 1)/2)
ans = 0

for i in range(N):
    t = A[i] - A[M]
    if t < 0:
        t = (-1) * t
    ans += t

print(ans)
Problem p03347 (python)

Fixed submission:
N = int(input())
ans = 0
bool1 = False

a0 = int(input())
if N == 1:
    if a0 != 0:
        print(-1)
    else:
        print(0)

else:
    for i in range(N-1):
        a1 = int(input())
        if i == 0 and a0 != 0:
            bool1 = True
            break
        if a1 - a0 > 1:
            bool1 = True
            break
        elif a1 - a0 == 1:
            a0 = a1
            continue
        else:
            ans += a0
            a0 = a1

    if bool1 == True:
        print(-1)
    else:
        print(ans + a1)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
bool1 = False

a0 = int(input())

for i in range(N-1):
    a1 = int(input())
    if i == 0 and a0 != 0:
        bool1 = True
        break
    if a1 - a0 > 1:
        bool1 = True
        break
    elif a1 - a0 == 1:
        a0 = a1
        continue
    else:
        ans += a0
        a0 = a1
       
if bool1 == True:
    print(-1)
else:
    print(ans + a1)
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
a_sum = 0

a_sum += b[0]

for i in range(n-2):
    if b[i] >= b[i+1]:
        a_sum += b[i+1]
    if b[i+1] > b[i]:
        a_sum += b[i]

a_sum += b[n-2]
print(a_sum)

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

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  if b[i+1]==b[i]:
    a = a + b[i]
  a = a + b[n-1] + b[0]
print(a)

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

for i in range(n-2):
  if b[i] >= b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  a = a + b[n-1] + b[0]
print(a)

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

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  a = a + b[n-1] + b[0]
print(a)

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

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
  a = a + b[n-1]
print(a)

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

for i in range(n-2):
  if b[i] > b[i+1]:
    a = a + b[i+1]
  if b[i+1] > b[i]:
    a = a + b[i]
    a = a + b[n-1]
print(a)
Problem p03408 (python)

Fixed submission:
n = int(input())
s_list = [input() for i in range(n)]
m = int(input())
t_list = [input() for j in range(m)]


def list_diff(list1, list2):
    result = list1.copy()
    for val in list2:
        if val in result:
            result.remove(val)
    return result


def count_max(diff_list):
    cnt_list = [diff_list.count(ele) for ele in set(diff_list)]
    if len(cnt_list) != 0:
        return max(cnt_list)
    else:
        return 0


lst = list_diff(s_list, t_list)
print(count_max(lst))

Buggy submission (verdict: Runtime Error):
n = int(input())
s_list = [input() for i in range(n)]
m = int(input())
t_list = [input() for j in range(m)]


def list_diff(list1, list2):
    result = list1.copy()
    for val in list2:
        if val in result:
            result.remove(val)
    return result


def count_max(diff_list):
    cnt_list = [diff_list.count(ele) for ele in set(diff_list)]
    return max(cnt_list)


lst = list_diff(s_list, t_list)
print(count_max(lst))
Problem p03470 (python)

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

print(len(set(list_d)))

Buggy submission (verdict: Runtime Error):
n = int(input())
list_d = [int(input()) for i int range(n)]

print(len(set(lst)))

Buggy submission (verdict: Runtime Error):
n = int(input())
list_d = [int(input()) for i int range(n)]

print(len(set(lst)))

Buggy submission (verdict: Runtime Error):
N = int(input())
list_d = [int(input()) for i int range(n)]

print(len(set(lst)))
Problem p03049 (python)

Fixed submission:
N=int(input())
A=0
B=0
AB=0
ans=0

for i in range(N):
  s=input()
  for j in range(len(s)-1):
    if s[j]=="A" and s[j+1]=="B":
      ans+=1
      
  if s[0]=="B" and s[-1]=="A":
    AB+=1
  elif s[0]=="B":
    B+=1
  elif s[-1]=="A":
    A+=1
  else:
    continue

if AB==0:
  ans+=min(A,B)
else:
  if A==0 and B==0:
    ans+=(AB-1)
  else:
    ans+=(AB+min(A,B))
    
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=0
B=0
AB=0
ans=0

for i in range(N):
  s=input()
  for j in range(len(s)-1):
    if s[j]=="A" and s[j+1]=="B":
      ans+=1
      
  if s[0]=="B" and s[-1]=="A":
    AB+=1
  elif s[0]=="B":
    B+=1
  elif s[-1]=="A":
    A+=1
  else:
    continue
  
ans+=min(A,B)
tmp=abs(A-B)

if AB <= tmp:
  ans+=AB
else:
  ans+=AB//tmp*tmp
  ans+=AB%temp
  
print(ans)
Problem p03128 (python)

Fixed submission:
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
num=[2,5,5,4,5,6,3,7,6]

#最小本数で作成可能な数字をリスト化
creat_A=[]
for n in A:
  creat_A.append(num[n-1])

#dp[N]:N本のマッチ棒を使って作ることのできる最大桁数
dp=[-1 for _ in range(N+1)]
for i in range(M):
  if creat_A[i] <= N:
    dp[creat_A[i]]=1

for i in range(N):
  if dp[i]>0:
    for j in range(M):
      if i+creat_A[j] <= N:
        dp[i+creat_A[j]]=max(dp[i+creat_A[j]],dp[i]+1)

#dp[N]から使用した数字の数を算出。
ans=[0 for _ in range(10)]

now=N
while dp[now] > 0:
  res=-1
  temp_i=-1
  for i in range(M):
    if now-creat_A[i] >0 and dp[now-creat_A[i]]==dp[now]-1:
      if res < A[i]:
        res=A[i]
        temp_i=i
  if res==-1:
    break
  else:
    ans[res]+=1
    now-=creat_A[temp_i]
    
temp2=0
for i in range(M):
  if creat_A[i]==now:
    temp2=max(temp2,A[i])
ans[temp2]+=1

#答えの出力。最小から加えて逆向きに読めばOK
ansans=""
for i in range(10):
  if ans[i]>0:
    ansans+=(str(i)*ans[i])
ansans=ansans[::-1]
print(ansans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
num=[2,5,5,4,5,6,3,7,6]

#最小本数で作成可能な数字をリスト化
creat_A=[]
for n in A:
  creat_A.append(num[n-1])
mA=min(creat_A)

#dp[N]:N本のマッチ棒を使って作ることのできる最大桁数
dp=[-1 for _ in range(N+1)]
for i in range(M):
  if creat_A[i] <= N:
    dp[creat_A[i]]=1

for i in range(mA,N):
  for j in range(M):
    if i+creat_A[j] <= N and dp[i] > 0:
      dp[i+creat_A[j]]=max(dp[i+creat_A[j]],dp[i]+1)

#dp[N]から使用した数字の数を算出。
ans=[0 for _ in range(10)]

now=N
while dp[now] > 0:
  res=-1
  temp_i=-1
  for i in range(M):
    if dp[now-creat_A[i]]==dp[now]-1:
      if res < A[i]:
        res=A[i]
        temp_i=i
  if res==-1:
    break
  else:
    ans[res]+=1
    now-=creat_A[temp_i]
temp2=0
for i in range(M):
  if creat_A[i]==now:
    temp2=max(temp2,A[i])
ans[temp2]+=1

#答えの出力。最小から加えて逆向きに読めばOK
ansans=""
for i in range(10):
  if ans[i]>0:
    ansans+=(str(i)*ans[i])
ansans=ansans[::-1]
print(ansans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
num=[2,5,5,4,5,6,3,7,6]

#最小本数で作成可能な数字をリスト化
creat_A=[]
deff_A=[]
for n in A:
  creat_A.append(num[n-1])
mA=min(creat_A)

#dp[N]:N本のマッチ棒を使って作ることのできる最大桁数
dp=[-1 for i in range(N+1)]
for i in range(M):
  dp[creat_A[i]]=1

for i in range(mA,N):
  for j in range(M):
    if i+creat_A[j] <= N and dp[i] > 0:
      dp[i+creat_A[j]]=max(dp[i+creat_A[j]],dp[i]+1)

#dp[N]から使用した数字の数を算出。
ans=[0 for x in range(10)]

now=N
while dp[now] > 0:
  res=-1
  temp_i=-1
  for i in range(M):
    if dp[now-creat_A[i]]==dp[now]-1:
      if res < A[i]:
        res=A[i]
        temp_i=i
  if res==-1:
    break
  else:
    ans[res]+=1
    now-=creat_A[temp_i]
temp2=0
for i in range(M):
  if creat_A[i]==now:
    temp2=max(temp2,A[i])
ans[temp2]+=1

#答えの出力。最小から加えて逆向きに読めばOK
ansans=""
for i in range(10):
  if ans[i]>0:
    ansans+=(str(i)*ans[i])
ansans=ansans[::-1]
print(ansans)
Problem p03219 (python)

Fixed submission:
X,Y=map(int,input().split())

print(X+Y//2)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N,M=map(int,input().split())

A=defaultdict(list)
Q=[]

for i in range(M):
  P,Y=map(int,input().split())
  Q.append([P,Y])
  A[P].append(Y)
  
for a,b in A.items():
  A[a].sort()

for l in Q:
  s=str(l[0]).zfill(6)
  num=A[l[0]].index(l[1])
  s+=str(num+1).zfill(6)
  print(s)
Problem p03280 (python)

Fixed submission:
A,B=map(int,input().split())
print(A*B-(A+B-1))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
print(A*B-(A+B-1))
Problem p03302 (python)

Fixed submission:
a,b=map(int,input().split())
if a+b==15:
  print("+")
elif a*b==15:
  print("*")
else:
  print("x")

Buggy submission (verdict: Runtime Error):
import heapq
from collections import defaultdict

N,m,s,t=map(int,input().split())

V=defaultdict(set)
V2=defaultdict(set)
for i in range(m):
  a,b,c,d=map(int,input().split())
  V[a-1].add((b-1,c))
  V[b-1].add((a-1,c))
  V2[a-1].add((b-1,d))
  V2[b-1].add((a-1,d))

def dijkstra(n,v,dedic):
  d=[float('inf')]*n
  d[v]=0
  
  hq=[(0,v)]
  
  while hq:
    u = heapq.heappop(hq)[1]
    for nv,c in dedic[u]:
      if d[nv]>d[u]+c:
        d[nv]=d[u]+c
        heapq.heappush(hq,(d[u]+c,nv))
        
  return d

ans=dijkstra(N,s-1,V)
ans2=dijkstra(N,t-1,V2)

ans3=[(ans[x]+ans2[x]) for x in range(N)]

for i in range(N):
  print(10**15-min(ans3[i:]))
Problem p03359 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
if a<=b:
  print(a)
else:
  print(a-1)
Problem p03385 (python)

Fixed submission:
s=input()
ans=[0,0,0]
for i in range(3):
  if s[i]=='a':
    ans[0]+=1
  elif s[i]=='b':
    ans[1]+=1
  else:
    ans[2]+=1
if ans[0]==1 and ans[1]==1 and ans[2]==1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
ans=[0,0,0]
for i in range(3):
  if s[i]=='a':
    ans[0]+=1
  elif s[i]=='b':
    ans[1]+=1
  else:
    ans[2]+=1
if ans[0]==1 and ans[1]==1 and ans[2]==1:
  print("Yes")
else:
  print("No)
Problem p03394 (python)

Fixed submission:
N=int(input())

if N == 3:
    print("2 5 63")
    import sys
    sys.exit()
    
ans=[]
for i in range(3,30001):
  if len(ans)==N-1:
    break
  if i%2==0 or i%3==0 or i%5==0:
    ans.append(i)

s=sum(ans)

if s%2==1:
  ans[0]=2
  s=sum(ans)

ans.append(30000 - s%30)

print(*ans)

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

def solve(n):
  cnt_len=0
  cnt_fact=2
  cnt_sum=0
  ans=[]

  while cnt_len < n:
    if cnt_fact%2==0 or cnt_fact%3==0:
      ans.append(cnt_fact)
      cnt_len+=1
      cnt_sum+=cnt_fact
    cnt_fact+=1
    
  res = cnt_sum % 6
  cnt_fact=((cnt_fact)//6+1)*6
  
  if res==0:
    return ans
  elif res==1:
    ans[2]=cnt_fact+3
    return ans
  elif res==2:
    ans[4]=cnt_fact
    return ans
  elif res==3:
    ans[3]=cnt_fact+3
    return ans
  elif res==4:
    ans[4]=cnt_fact+4
    return ans
  else:
    cnt[4]=cnt_fact+3
    return ans
  
if N==3:
  print(2,5,63)
elif N==4:
  print(2,5,20,63)
elif N==5:
  print(2,3,4,6,9)
else:
  A=solve(N)
  print(*A)
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200002)

N,M=map(int,input().split())
mp=[[] for i in range(N+1)]
for i in range(M):
  L,R,D=map(int,input().split())
  mp[L].append([R,D])
  mp[R].append([L,-D])

dist=[None]*(N+1)

def dfs(n):
  for np,nd in mp[n]:
    if dist[np] is None:
      dist[np]=dist[n]+nd
      if not dfs(np):
        return False
    else:
      if dist[np]!=dist[n]+nd:
        return False
  return True
ans=True
for i in range(1,N+1):
  if dist[i] is None:
    dist[i]=0
    if not dfs(i):
      ans=False
      break
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mp=[[] for i in range(N+1)]
for i in range(M):
  L,R,D=map(int,input().split())
  mp[L].append([R,D])
  mp[R].append([L,-D])

dist=[None]*(N+1)

def dfs(n):
  for np,nd in mp[n]:
    if dist[np] is None:
      dist[np]=dist[n]+nd
      if not dfs(np):
        return False
    else:
      if dist[np]!=(dist[n]+nd):
        return False
  return True
ans=True
for i in range(1,N+1):
  if dist[i] is None:
    dist[i]=0
    if not dfs(i):
      ans=False
      break
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mp=[[] for i in range(N+1)]
for i in range(M):
  L,R,D=map(int,input().split())
  mp[L].append([R,D])
  mp[R].append([L,-D])

dist=[None]*(N+1)

def dfs(n):
  for np,nd in mp[n]:
    if dist[np] is None:
      dist[np]=dist[n]+nd
      if not dfs(np):
        return False
    else:
      if dist[np]!=dist[n]+nd:
        return False
  return True
ans=True
for i in range(1,N+1):
  if dist[i] is None:
    dist[i]=0
    if not dfs(i):
      ans=False
      break
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mp=[[] for i in range(N+1)]
for i in range(M):
  L,R,D=map(int,input().split())
  mp[L].append([R,D])
  mp[R].append([L,-D])

dist=[None]*(N+1)

def dfs(n):
  for np,nd in mp[n]:
    if dist[np] is None:
      dist[np]=dist[n]+nd
      if not dfs(np):
        return False
    else:
      if dist[np]!=dist[n]+nd:
        return False
  return True

ans=True
for i in range(1,N+1):
  if dist[i] is None:
    dist[i]=0
    if not dfs(i):
      ans=False
      break
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mp=[[] for i in range(N+1)]
for i in range(M):
  L,R,D=map(int,input().split())
  mp[L].append([R,D])
  mp[R].append([L,-D])

dist=[None]*(N+1)

def dfs(n):
  for np,nd in mp[n]:
    if dist[np]==None:
      dist[np]=dist[n]+nd
      if not dfs(np):
        return False
    elif dist[np]!=dist[n]+nd:
      return False
  return True

ans=True
for i in range(1,N+1):
  if dist[i]==None:
    dist[i]=0
    if not dfs(i):
      ans=False
      break
if ans:
  print("Yes")
else:
  print("No")
Problem p03564 (python)

Fixed submission:
N=int(input())
K=int(input())
cnt=1
for i in range(N):
  if cnt <= K:
    cnt*=2
  else:
    cnt+=K
print(cnt)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
cnt=1
for i in range(N):
  if cnt <= K:
    cnt*=2
  else:
    cnt+=K
print(cnt)
Problem p03597 (python)

Fixed submission:
N=int(input())
A=int(input())

print(N*N-A)

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

print(N*N-A)
Problem p03674 (python)

Fixed submission:
N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
c=sum(A)-N*(N+1)/2
for i in range(len(A)):
  if A[i]==c:
    se.append(i)
l=se[0]
r=se[1]

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(l+N-r,i-1))%mod)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
c=sum(A)-N*(N+1)/2:
for i in range(len(A)):
  if A[i]==c:
    se.append(i)
l=se[0]
r=se[1]

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(l+N-r,i-1))%mod)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
for i in range(len(A)):
  if A[i]==sum(A)-N*(N+1)/2:
    se.append(i)

mod=10**9+7
 
#階乗計算
factorial=[1]
for i in range(1,N+2):
    factorial.append(factorial[i-1]*i %mod)
#逆元計算
inverse=[0]*(N+2)
inverse[N+2-1] = pow(factorial[N+2-1], mod-2,mod)
for i in range(N+2-2, -1, -1):
    inverse[i] = inverse[i+1] * (i+1) % mod
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
if N==1:
  print(N)
else:
  for i in range(1,N+1):
    ans = nCr(N+1, i+1)
    if if se[0] + N -se[1] >= i:
      ans-=nCr(se[0]+N-se[1],i)
      print(int(ans))
Problem p03740 (python)

Fixed submission:
X,Y=map(int,input().split())
if max(X,Y)-min(X,Y) > 1:
  print("Alice")
else:
  print("Brown")

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input())
if max(X,Y)-min(X,Y) > 1:
  print("Alice")
else:
  print("Brown")
Problem p03746 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)

from collections import defaultdict
N, M = [int(_) for _ in input().split()]
V = defaultdict(list)
for i in range(M):
    A, B = [int(_) for _ in input().split()]
    V[A].append(B)
    V[B].append(A)

def solve(N, M, V):
    result = [1, V[1][0]]
    used = [False] * (N + 1)
    for x in result:
        used[x] = True

    def check_edge(i):
        for e in V[result[i]]:
            if not used[e]:
                if i == -1:
                    result.append(e)
                else:
                    result.insert(i, e)
                used[e] = True
                return True
        return False

    while True:
        if check_edge(0): continue
        if check_edge(-1): continue
        return result

result = solve(N, M, V)
print(len(result))
print(*result)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

ans=[]
V=defaultdict(set)

N,M=map(int,input().split())

a,b=map(int,input().split())
V[a].add(b)
V[b].add(a)
ans.append(a)
ans.append(b)

for i in range(1,M):
  a,b=map(int,input().split())
  V[a].add(b)
  V[b].add(a)

def solve(li):
  s=li[0]
  e=li[-1]
  for v in V[s]:
    if not(v in li):
      return solve([v]+li)
  for v in V[e]:
    if not(v in li):
      return solve(li+[v])
  print(len(li))
  print(*li)
  return

solve(ans)
Problem p03760 (python)

Fixed submission:
o=input()
e=input()
ans=[]
for i in range(len(o)):
  ans.append(o[i])
  if i<len(e):
    ans.append(e[i])
print("".join(ans))

Buggy submission (verdict: Runtime Error):
o=input()
e=input()
ans=[]
for i in range(len(0)):
  ans.append(o[i])
  if i<len(e):
    ans.append(e[i])
print("".join(ans))
Problem p03780 (python)

Fixed submission:
N,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
su=0
ans=0
for a in A:
  if su+a < K:
    su+=a
    ans+=1
  else:
    ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort()

def solve(a,K):
  if A[a]>=K:
    return False
  bits=1
  for i in range(len(A)):
    if i!=a:
      bits|= bits<<A[i]
  cnt = (1<<A[a])-1
  bits >>= (K-A[a])
  if bits&cnt:
    return False
  else:
    return True

for i in range(N-1,-1,-1):
  if solve(i,K):
    ans=bisect.bisect_right(A, A[i])
    break
print(ans)