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

Fixed submission:
from collections import deque
n,m=map(int,input().split())
A=[set() for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  A[a-1].add(b)
  A[b-1].add(a)
visit=[0]*n
visit[0]=n+1
stack=deque()
stack.append(1)
while stack:
  now=stack.popleft()
  for j in A[now-1]:
    if visit[j-1]==0:
      visit[j-1]=now
      stack.append(j)
if min(visit)>0:
  print('Yes')
  for j in range(1,n):
    print(visit[j])
else:
  print('No')

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=[set() for _ in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  A[a-1].add(b)
  A[b-1].add(a)
visit=[0]*n
visit[0]=n+1
stack=deque()
stack.append(1)
while stack:
  now=stack.popleft()
  for j in A[now-1]:
    if visit[j-1]==0:
      visit[j-1]=now
      stack.append(j)
if min(visit)>0:
  print('Yes')
  for j in range(1,n):
    print(visit[j])
else:
  print('No')
Problem p02691 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
x=max(b)
if x<=0:
  print(0)
  exit()
else:
  ans=0
  b_=[0]*(x+1)
  for i in range(n):
    if 0<=b[i]<=x:
      b_[b[i]]+=1
  for i in range(n):
    if 0<=c[i]<=x:
      ans+=b_[c[i]]
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
ans=0
for i in range(n):
  b.append(i+1-a[i])
  c.append(a[i]+i+1)
c_=[0]*(max(c)+1)
b_=[0]*(max(c)+1)
for i in range(n):
  c_[c[i]]+=1
for i in range(n):
  if 0<=b[i]<=max(c)+1:
    b_[b[i]]+=1
for i in range(max(c)+1):
  ans+=b_[i]*c_[i]
print(ans)
Problem p02717 (python)

Fixed submission:
x,y,z=map(str,input().split())
a=[z,x,y]
print(' '.join(a))

Buggy submission (verdict: Runtime Error):
x,y,z=map(int,input().split())
print(z+' '+x+' '+y)
Problem p02727 (python)

Fixed submission:
x,y,a,b,c,=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
ans=p+q+r
ans.sort(reverse=True)
print(sum(ans[:x+y]))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c,=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
ans=p+q
ans.sort(reverse=True)
ans=[0]+ans
nowi=x+y
r=[0]+r
nowr=0
while nowr<=c+1 and nowi>0 and r[nowr+1]>ans[nowi]:
  nowi+=-1
  nowr+=1
ans_=0
for i in range(nowi+1):
  ans_+=ans[i]
for j in range(nowr+1):
  ans_+=r[j]
print(ans_)
Problem p02732 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
dic={}
for a in A:
  if a in dic:
    dic[a]+=1
  else:
    dic[a]=1
   

c=0
for i in dic.values():
  c+=i*(i-1)/2
for j in range(1,N+1):
  d=c-dic[A[j-1]]+1
  print(int(d))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
dic={}
for i in set(A):
  dic[i]=A.count(i) 
def ans(k,dic):
  dic[A[k-1]]+=-1
  c=0
  for i in dic.values():
    c+=i*(i-1)/2
  dic[A[k-1]]+=1  
  return int(c)
for k in range(1,N+1):
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
import math
if 4*a*b<(c-a-b)**2 and c-a-b>=0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
import math
if 4*a*b<(c-a-b)**2 and c-a-b>=0
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
import math
if 4*a*b<(c-a-b)**2
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
import math
if 4a*b<(c-a-b)**2
  print('Yes')
else:
  print('No')
Problem p02756 (python)

Fixed submission:
S=input()
S_=list(S)
Q=int(input())
F1=[]
F2=[]
Q_=[]
for i in range(Q):
  Q_.append(list(input().split()))
count=0  
for i in range(len(Q_)):
  if Q_[i]==['1']:
    count+=1
  elif Q_[i][0:2]==['2','1']:
    if count%2==0:
      F1.append(Q_[i][2])
    else:
      F2.append(Q_[i][2])
  else:
    if count%2==0:
      F2.append(Q_[i][2])
    else:
      F1.append(Q_[i][2])
SS=F1[::-1]+S_+F2                
if count%2==0:
  print(''.join(SS))
else:
  print(''.join(SS[::-1]))

Buggy submission (verdict: Runtime Error):
S=input()
S_=list(S)
Q=int(input())
F1=[]
F2=[]
Q_=[]
for i in range(4):
  Q_.append(list(input().split()))
count=0  
for i in range(len(Q_)):
  if Q_[i]==['1']:
    count+=1
  elif Q_[i][0:2]==['2','1']:
    if count%2==0:
      F1.append(Q_[i][2])
    else:
      F2.append(Q_[i][2])
  else:
    if count%2==0:
      F2.append(Q_[i][2])
    else:
      F1.append(Q_[i][2])
SS=F1[::-1]+S_+F2                
if count%2==0:
  print(''.join(SS))
else:
  print(''.join(SS[::-1]))
Problem p02761 (python)

Fixed submission:
N,M=map(int,input().split())
if M>=1:
    s=[0]*M
    c=[0]*M
    for i  in range(M):
      s[i],c[i]=map(int,input().split())

    a=0
    for i in range(M-1):
       for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
          a+=1
    if a==0:
      u_=[0,0,0]
      for i in range(M):
        u_[s[i]-1]=c[i]
      if max(s)!=3 and N==2:
        if min(s)!=1 and u_[0]==0:
          print(10+u_[1])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(u_[0]*10+u_[1])
      elif N==3:
        if min(s)!=1 and u_[0]==0:
          print(100+u_[1]*10+u_[2])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(100*u_[0]+10*u_[1]+u_[2])
      elif N==1 and max(s)==1 and min(s)==1:
        print(c[0])
      else:
        print(-1)
    else:
      print(-1)
else:
  if N==1:
    print(0)
  else:
      print(10**(N-1))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
if M>=1:
    s=[0]*M
    c=[0]*M
    for i  in range(M):
      s[i],c[i]=map(int,input().split())

    a=0
    for i in range(M-1):
       for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
          a+=1
    if a==0:
      u_=[0,0,0]
      for i in range(M):
        u_[s[i]-1]=c[i]
      if max(s)!=3 and N==2:
        if min(s)!=1 and u_[0]==0:
          print(10+u_[1])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(u_[0]*10+u_[1])
      elif N==3:
        if min(s)!=1 and u_[0]==0:
          print(100+u_[1]*10+u_[2])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(100*u_[0]+10*u_[1]+u_[2])
      elif N==1 and max(s)==1 and min(s)==1:
        print(c[0])
      else:
        print(-1)
    else:
      print(-1)
else:
  if N==1:
    print(0)
  else:
    N>=2:
      print(10**(N-1))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[0]*M
c=[0]*M
for i  in range(M):
  s[i],c[i]=map(int,input().split())

a=0
for i in range(M-1):
  for j in range(i+1,M):
    if s[i]==s[j] and c[i]!=c[j]:
      a+=1
if a==0:
  u_=[0,0,0]
  for i in range(M):
    u_[s[i]-1]=c[i]
  if max(s)!=3 and N==2:
    if min(s)!=1 and u_[0]==0:
      print(10+u_[1])
    elif min(s)==1 and u_[0]==0:
      print(-1)
    else:
      print(u_[0]*10+u_[1])
  elif N==3:
    if min(s)!=1 and u_[0]==0:
      print(100+u_[1]*10+u_[2])
    elif min(s)==1 and u_[0]==0:
      print(-1)
    else:
      print(100*u_[0]+10*u_[1]+u_[2])
  elif N==1 and max(s)==1 and min(s)==1:
    print(c[0])
  else:
    print(-1)
else:
  print(-1)
Problem p02765 (python)

Fixed submission:
N,R=map(int,input().split())
u=0
if N>=10:
  u=R
else:
  u=R+100*(10-N)
print(u)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(101):
  m=0  
  for j in range(0,len(a)):
    m+=(a[j]-i)**2
  s.append(m)
print(min(s))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
s=[]
for i in range(max(a)):
  m=0  
  for j in range(0,len(a)):
    m+=(a[j]-i)**2
  s.append(m)
print(min(s))
Problem p02882 (python)

Fixed submission:
import math
a,b,x=map(int,input().split())
s=2*x/a**2
s_=s-b
if 0<=s_<b:
  print(90-360/2/math.pi*math.atan(a/(b-s_)))
elif s_==b:
  print(0)
else:
  u=2*x/a/b
  print(90-360/2/math.pi*math.atan(u/b))

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
s=2*x/a/a
s_=s-b
print(90-360/(2*math.pi)*math.atan(a/(b-s_)))
Problem p02963 (python)

Fixed submission:
s=int(input())
if s+1<=10**9:
  b=str(s+1)
  a=['0','0',b,'1','1','1']
else:
  x2=int(s**(1/2))
  y3=int(s**(1/2))
  while x2*y3<s:
    y3+=1
  if y3>10**9:
    x2+=1
    y3=int(s**(1/2))+1
  x2=str(x2)
  y3=str(y3)
  
  y2=str(1)
  x3=str(int(x2)*int(y3)-s)
  x1=str(0)
  y1=str(0)
  a=[x1,y1,x2,y2,x3,y3]
print((' ').join(a))

Buggy submission (verdict: Runtime Error):
s=int(input())
if s+1<=10**9:
  b=str(s+1)
  a=['0','0',b,'1','1','1']
else:
  a=int(s**(1/2))
  if a**2>=s:
    a_=a
  else:
    if a*(a+1)>=s:
      a_=a+1
    else:
      if a*(a+2)>=s and a+2<=10**9:
        a_+=2
      else:
        a_+=1
        a+=1
  x2=str(a)
  y3=str(a_)
  
  y2=str(1)
  x3=str(int(x2)*int(y3)-s)
  x1=str(0)
  y1=str(0)
  a=[x1,y1,x2,y2,x3,y3]
print((' ').join(a))
Problem p03043 (python)

Fixed submission:
n,k=map(int,input().split())
d=0
for a in range(1,n+1):
  b=0
  while a<k:
    b+=1
    a=a*2
  d+=(1/2)**b
print(d/n)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
e=[0]*(k)
e[-2]=1
now=k
while now!=1:
  if now%2==0 and now!=2:
    now=now//2
    e[now-2]+=1
  elif now==2:
    now+=-1
    e[now-1]+=1
  else:
    now=now//2
    e[now-1]+=1
e_=[]
for i in range(k):
  if i==0:
    e_.append(e[k-1-i])
  else:
    e_.append(e[k-1-i]+e_[-1])   
ans=0    
if n<k:
  for i in range(n):
    ans+=((1/2)**e_[k-1-i])*(1/n)
  print(ans)  
else:
  for i in range(k):
    ans+=((1/2)**e_[k-1-i])*(1/n)
  ans+=(1/n)*(n-k)
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
e=[0]*(k)
e[-2]=1
now=k
while now!=1:
  if now%2==0 and now!=2:
    now=now//2
    e[now-2]+=1
  elif now==2:
    now+=-1
    e[now-1]+=1
  else:
    now=now//2
    e[now-1]+=1
e_=[]
for i in range(k):
  if i==0:
    e_.append(e[k-1-i])
  else:
    e_.append(e[k-1-i]+e_[-1])   
ans=0    
if n<k:
  for i in range(n):
    ans+=((1/2)**e_[k-1-i])*(1/n)
  print(ans)  
else:
  for i in range(k):
    ans+=((1/2)**e_[k-1-i])*(1/n)
  ans+=(1/n)*(n-k)
  print(ans)
Problem p03160 (python)

Fixed submission:
n=int(input())
dp=[0]*n
h=list(map(int,input().split()))
for i in range(1,n):
  if i-2>=0:
     dp[i]=min(dp[i-1]+max(h[i]-h[i-1],h[i-1]-h[i]),dp[i-2]+max(h[i]-h[i-2],h[i-2]-h[i]))
  else:
    dp[i]=dp[i-1]+max(h[i]-h[i-1],h[i-1]-h[i])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
visit=[0]*n
B=[list() for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  visit[a-1]+=1
  B[b-1].append(a)
dp=[0]*n
from collections import deque
for i in range(n):
  if visit[i]==0:
    d=deque()
    d.append(i+1)
    while d:
      now=d.pop()
      for j in B[now-1]:
        d.append(j)
        dp[j-1]=max(dp[j-1],dp[now-1]+1)
print(max(dp))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(n):
  g=[]
  for j in range(1,k+1):
    if 0<=i-j<=n-1:
       g.append(dp[i-j]+abs(h[i]-h[i-j]))
  if g!=[]:
    dp[i]=min(g)
  else:
    dp[i]=0
print(dp[n-1])
Problem p02608 (python)

Fixed submission:
from math import sqrt
N = int(input())
ans = [0] * (N+1)

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

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

Buggy submission (verdict: Runtime Error):
from math import sqrt
N = int(input())
ans = [0] * N

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

for a in ans:
    print(a)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [i for i in range(-150, 150)]
P = list(set(Q) - set(P))
P.sort()
dif = 100
for p in P:
    if abs(X-p) < dif:
        dif = abs(X-p)
        ans = p
print(ans)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [i for i in range(1, 101)]
P = list(set(Q) - set(P))
dif = 100
for p in P:
    if abs(X-p) < dif:
        dif = abs(X-p)
        ans = p
print(ans)
Problem p02683 (python)

Fixed submission:
from itertools import product

N, M, X = map(int, input().split())
inp = [list(map(int, input().split())) for _ in range(N)]

C, A = [], []
for i in range(N):
    C.append(inp[i][0])
    A.append(inp[i][1:])

#判定
z_A = list(zip(*A))
for i in range(M):
    if sum(z_A[i]) < X:
        print(-1)
        exit()

ans = sum(C)

for buy_bit in product(range(2), repeat=N):
    buy = 0
    tmp = 0
    skill = [0] * M
    for i in range(N):
        if buy_bit[i]:
            for j in range(M):
                skill[j] += A[i][j]
            buy += C[i]
    
    f = True
    for s in skill:
        if s < X:
            f = False
            break
    if f:
        ans = min(ans, buy)

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product

N, M, X = map(int, input().split())
inp = [list(map(int, input().split())) for _ in range(N)]

C, A = [], []
for i in range(N):
    C.append(inp[i][0])
    A.append(inp[i][1:])

#判定
z_A = list(zip(*A))
for i in range(N):
    if sum(z_A[i]) < X:
        print(-1)
        exit()

ans = sum(C)

for buy_bit in product(range(2), repeat=N):
    buy = 0
    tmp = 0
    skill = [0] * M
    for i in range(N):
        if buy_bit[i]:
            for j in range(M):
                skill[j] += A[i][j]
            buy += C[i]
    
    f = True
    for s in skill:
        if s < X:
            f = False
            break
    if f:
        ans = min(ans, buy)

print(ans)
Problem p02761 (python)

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

ans = [10] * N
for l in lst:
    if ans[l[0]-1] < 10 and ans[l[0]-1] != l[1]:
        print(-1)
        exit()
    ans[l[0]-1] = l[1]

if ans[0] == 10:
    if N == 1:
        ans[0] = 0
    else:
        ans[0] = 1
for i in range(1, N):
    if ans[i] == 10:
        ans[i] = 0

if N != 1 and ans[0] == 0:
    print(-1)
    exit()

ans = list(map(str, ans))
print("".join(ans))

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

ans = [10] * N
for l in lst:
    if ans[l[0]-1] < 10 and ans[l[0]-1] != l[1]:
        print(-1)
        exit()
    ans[l[0]-1] = l[1]

for i in range(M):
    if ans[i] == 10:
        ans[i] = 0

if N != 1 and ans[0] == 0:
    print(-1)
    exit()

ans = list(map(str, ans))
print("".join(ans))

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

S = C = []
for i in range(M):
    S.append(lst[i][0])
    C.append(lst[i][1])

ans = [10] * N
for l in lst:
    if ans[l[0]-1] < 10 and ans[l[0]-1] != l[1]:
        print(-1)
        exit()
    ans[l[0]-1] = l[1]

for i in range(M):
    if ans[i] == 10:
        ans[i] = 0

if N != 1 and ans[0] == 0:
    print(-1)
    exit()

ans = list(map(str, ans))
print("".join(ans))
Problem p02767 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
P = [p for p in range(1, max(X) + 1)]
min = 0
energy = 0

for x in X:
    min += (1 - x) ** 2

for p in P:
    for x in X:
        energy += (x - p) ** 2

    if energy < min:
        min = energy
    energy = 0
print(min)

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

p = X[0]
sum = 0
for x in X:
  sum += (x - p)**2
ans = sum

for p in range(X[1], X[N-1]): #Pの位置
  sum = 0
  for x in X: #Xの要素を１つずつ取得
    sum += (x - p)**2
  ans = min(sum, ans)

print(ans)
Problem p02923 (python)

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

H.append(10**10) 
r, ans = 0, 0
for l in range(N):
    while r < N and H[r] >= H[r+1]:
        r += 1
    ans = max(ans, r-l)
    if l == r:
        r += 1
        l += 1
print(ans)

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

H.append(10**10) 
r, ans = 0, 0
for l in range(N):
    while r < N and H[r] >= H[r+1]:
        r += 1
    ans = max(ans, r-l)
    if l == r:
        r += 1
        l += 1
    print(H[l:r+1])
print(ans)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())
for i in range(a, min(b, a + k - 1) + 1):
    print(i)
for i in range(max(b - k + 1, a + k), b + 1):
    print(i)

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

if (B-A+1) < 2*K:
    for i in range(A, B+1):
        print(i)
    exit()

lst = list(range(A, B+1))
x = [lst[i] for i in range(0, K)]
y = [lst[i] for i in range(-1, -K-1, -1)]

ans = list(set(x) | set(y))
ans.sort()

for i in ans:
    print(i)

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

if (B-A+1) < K:
    for i in range(A, B+1):
        print(i)
    exit()

lst = list(range(A, B+1))
x = [lst[i] for i in range(0, K)]
y = [lst[i] for i in range(-1, -K-1, -1)]

ans = list(set(x) | set(y))
ans.sort()

for i in ans:
    print(i)

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

if (B-A+1) < K:
    for i in range(A, B+1):
        print(i)
    exit()

lst = list(range(A, B+1))
lst.sort()

x = [lst[i] for i in range(0, K)]
y = [lst[i] for i in range(-1, -K-1, -1)]

ans = list(set(x) | set(y))
ans.sort()

for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):

if (B-A+1) < K:
    for i in range(A, B+1):
        print(i)
    exit()

lst = list(range(A, B+1))
lst.sort()

x = [lst[i] for i in range(0, K)]
y = [lst[i] for i in range(-1, -K-1, -1)]

ans = list(set(x) | set(y))
ans.sort()

for i in ans:
    print(i)

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

if (B-A+1) < K:
    for i in range(A, B+1):
        print(i)
    exit()

lst = list(range(A, B+1))
lst.sort()

x = [lst[i] for i in range(0, K)]
y = [lst[i] for i in range(-1, -K-1, -1)]

ans = list(set(x) | set(y))
ans.sort()

for i in ans:
    print(i)
Problem p03644 (python)

Fixed submission:
N = int(input())
max_cnt = 0
ans = 0
for n in range(1, N+1):
    cnt = 0
    for div in range(0, 7):
        if n % 2**div == 0:
            cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        ans = n
print(ans)

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

for n in range(1, N+1):
    cnt = 0
    for div in range(1, 7):
        if n % 2**div == 0:
            cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        ans = n
print(ans)
Problem p03998 (python)

Fixed submission:
S = [input() for _ in range(3)]
for i in range(3):
    S[i] = list(S[i])
p = 0 #プレイヤー
while True:
    if not S[0] and p == 0:
        print("A")
        break
    if not S[1] and p == 1:
        print("B")
        break
    if not S[2] and p == 2:
        print("C")
        break
    p_t = S[p].pop(0)
    if p_t == "a":
        p = 0
    elif p_t == "b":
        p = 1
    elif p_t == "c":
        p = 2

Buggy submission (verdict: Runtime Error):
S = [input() for _ in range(3)]
for i in range(3):
    S[i] = list(S[i])
p = 0 #プレイヤー
while True:
    if not S[0] and p == 0:
        print("A")
        break
    if not S[1] and p == 1:
        print("B")
        break
    if not S[2] and p == 3:
        print("C")
        break
    p_t = S[p].pop(0)
    if p_t == "a":
        p = 0
    elif p_t == "b":
        p = 1
    elif p_t == "c":
        p = 2
Problem p02801 (python)

Fixed submission:
n = input()
print(chr(ord(n) + 1))

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


def cmb(n, r):
    if n <= r:
        return 1
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
fmax = 0
fmin = 0
for i in range(K, N+1):
    fmax += A[i-1] * cmb(i-1, K-1)
    fmin += A[-i] * cmb(i-1, K-1)
print((fmax - fmin) % 1000000007)
Problem p03471 (python)

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

ans = '-1 -1 -1'
for x in range(0, N+1):
    y = (Y / 1000 - 9 * x - N) / 4
    if 0 <= y <= N:
        if y.is_integer():
            y = int(y)
            z = N - x - y
            if 0 <= z <= N:
                ans = " ".join([str(x), str(y), str(z)])
                break
print(ans)

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

ans = '-1 -1 -1'
for x in range(0, N+1):
    y = (Y / 1000 - 9 * x - N) / 4
    if 0 <= y <= N:
        if y.is_integer():
            y = int(y)
            z = N - x - y
            if 0 <= z <= N:
                ans = f'{x} {y} {z}'
                break
print(ans)
Problem p02630 (python)

Fixed submission:
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
S = sum(A)
 
for _ in range(int(input())):
    b, c = map(int, input().split())
    k = count[b]
    count[b] = 0
    count[c] += k
    S += (c - b) * k
    print(S)

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
S = sum(A)
 
for _ in range(int(input())):
    p, q = map(int, input().split())
    k = count[p]
    count[p] = 0
    count[q] += k
    S += (q - p) * k
    print(S)
Problem p02631 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in A:
    count ^= i
for i in range(len(A)):
    A[i] ^= count
    
    
print(*A)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in A:
    count ^= x
for i in range(len(A)):
    A[i] ^= count
    
    
    
print(*A)
Problem p02677 (python)

Fixed submission:
import math
 
A, B, H, M = map(int, input().split())
 
m = (M / 60) * 2 * math.pi
t = (H + (M / 60)) * math.pi / 6
angle = m-t
res = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle))
print(res)

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())
 
t = (H + (M / 60)) * math.pi / 6
m = (M / 60) * 2 *math.pi
totalangle = m - t
result = sqrt(A ** 2 + B ** 2 - 2 * A * B *math.cos(totalangle))
print(result)

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())

t = (H + (M / 60)) * pi / 6
m = (M / 60) * 2 *pi
totalangle = m - t
result = sqrt(A ** 2 + B ** 2 - 2 * A * B *cos(totalangle))
print(result)
Problem p02576 (python)

Fixed submission:
import math

def main():
  N, X, T = [int(i) for i in input().split(' ')]
  t = math.ceil(N/X) * T
  print(t)
 
if __name__=="__main__":
  main()

Buggy submission (verdict: Runtime Error):
import math

def main():
  N, X, T = input().split(' ')
  t = math.ceil(N/X) * T
  print(t)
 
if __name__=="__main__":
  main()
Problem p02811 (python)

Fixed submission:
k,x = list(map(int, input().split()))
print("Yes" if 500*k - x >= 0 else "No")

Buggy submission (verdict: Runtime Error):
k,x = list(map(int, input().split()))
print("Yes" if 500*k - x >= 0 "No")
Problem p02813 (python)

Fixed submission:
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
li = [i for i in range(1, n+1)]
j = 1
p_index = 1
q_index = 1
for v in itertools.permutations(li, n):
  if(list(v) == p):
    p_index = j
  if(list(v) == q):
    q_index = j
  j += 1
print(abs(p_index - q_index))

Buggy submission (verdict: Runtime Error):
import itertools
li = [1,2,3,4,5,6,7,8]
for v in itertools.combinations(li):
  print(v)