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

Fixed submission:
#coding: utf-8
string = str(input())
X = 0
li = []
for a in range(len(string)):
    if string[a] == " ":
        li.append(string[X:a])
        X = a+1
li.append(string[X:])
for aa in range(len(li)):
    li[aa] = int(li[aa])
h1 = li[0]
m1 = li[1]
h2 = li[2]
m2 = li[3]
k = li[4]
Time = (h2 * 60 + m2) - (h1 * 60 + m1) - k
print(int(Time))

Buggy submission (verdict: Runtime Error):
#coding: utf-8
string = str(input())
X = 0; li = []
for a in range(len(string)):
  if a = " ":
    li.append(string[X:a])
    X = a
h1 = li[0];m1 = li[1];h2 = li[2];m1 = li[3];k = li[4]
Time = (h1 * 60 + m1) - (h2 * 60 + m2) - K
print(int(Time))

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

h1 = int(input("H₁＝"))
m1 = int(input("M₁＝"))
h2 = int(input("H₂＝"))
m1 = int(input("H₂＝"))
k = int(input("k＝"))

Time = (h1 * 60 + m1) - (h2 * 60 + m2) - K
print(int(Time))

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

H1 = int(input("H₁="))
M1 = int(input("M₁="))
H2 = int(input("K₂="))
M2 = int(input("M₂="))
K = int(input("K="))

T = (60 * H1 + M1) - (60 * H2 + M2) - K

print(int(T))
Problem p02664 (python)

Fixed submission:
# -*- coding: utf-8 -*-
S = str(input());l = len(S);Str = ""
for num in range(l):
    if S[num] != "?":
        Str += S[num]
    else:
        Str += "D"
print(Str)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = str(input());l = len(S);Str = ""
for num in range(l):
    if S[num] != "?":
        Str += S[num]
    else:
        if num == 0:
            Str += "D"
        else:
            if Str[num-1] == "P":
                Str += "D"
            else:
                if S[num+1] == "P":
                    Str += "D"
                else:
                    Str += "P"
print(Str)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = str(input());l = len(S);Str = ""
for num in range(l):
    if S[num] != "?":
        Str += S[num]
    else:
        if num == 0:
            Str += "D"
        else:
            if Str[num-1] == "P":
                Str += "D"
            else:
                if S[num+1] == "P":
                    Str += "D"
                else:
                    Str += "D"
print(Str)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = str(input());l = len(S);Str = ""
for num in range(l):
    if S[num] != "?":
        Str += S[num]
    else:
        if num == 0:
            Str += "D"
        else:
            if Str[num-1] == "P":
                Str += "D"
            else:
                if S[num+1] == "P":
                    Str += "D"
                else:
                    Str += "P"
print(Str)
Problem p02801 (python)

Fixed submission:
n = input()
data = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(0,len(data)-1):
  if data[i]  == n:
    print(data[i+1])

Buggy submission (verdict: Runtime Error):
n = input()
data = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
for i in range(0,len(data)-1):
  if data[i]  == n:
    print(data[i+1])
Problem p03060 (python)

Fixed submission:
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv
print(mouke)

Buggy submission (verdict: Runtime Error):
N=int(input())
V=list(map(int,input().split))
C=list(map(int,input().split))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv
print(mouke)

Buggy submission (verdict: Runtime Error):
N=int(input())
V=list(map(int,input().split))
C=list(map(int,input().split))
mouke=0
for i in range(N):
    adv=V[i]-C[i]
    if adv>0:
        mouke+=adv:
print(mouke)
Problem p03844 (python)

Fixed submission:
A,op,B=(x for x in input().split())
A1=int(A)
B1=int(B)
if(op=="+"):
    print(A1+B1)
else:
    print(A1-B1)

Buggy submission (verdict: Runtime Error):
N=int(input())
T=[int(x) for x in input().split()]
M=int(input())
P=[]
X=[]
for i in range(M):
    p1,x1=(int(d) for d in input().split())
    P.append(p1)
    X.append(x1)
sum1=0
for i in range(N):
    sum1+=T[i]
for i in range(M):
    temp=sum1
    temp=temp-T[P[i]-1]+X[i]
    print(temp)

Buggy submission (verdict: Runtime Error):
A,op,B=(int(x) for x in input().split())
if(op=="+"):
    print(A+B)
else:
    print(A-B)
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m=map(int,input().split())
dg = (60*h+m)/2.0 - 6*m
x2 = a**2+b**2-2*a*b*math.cos(math.radians(dg))
print(math.sqrt(x2))

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input())
dg = (60*h+m)/2.0 - 6*m
x2 = a**2+b**2-2*a*b*math.cos(math.radians(dg))
print(math.sqrt(x2))
Problem p02684 (python)

Fixed submission:
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis_ti=[-1]*n
vis_at=[0]
now=0
for i in range(1,k+1):
  now=a[now]-1
  if vis_ti[now]>=0:
    bgn=vis_ti[now]
    print(vis_at[bgn+(k-bgn)%(i-bgn)]+1)
    sys.exit()
  vis_ti[now]=i
  vis_at.append(now)
print(vis_at[-1]+1)

Buggy submission (verdict: Runtime Error):
import sys
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
vis={0:0}
now=0
for i in range(1,k+1):
  now=a[now]-1
  if now in vis:
    bgn=vis.index(now)
    print(vis[bgn+((k-bgn)%(len(vis)-bgn))]+1)
    sys.exit()
  else:
    vis[i]=now
print(vis[-1]+1)
Problem p02690 (python)

Fixed submission:
import sys
x=int(input())
for a in range(-200,200):
  for b in range(-200,200):
    if a**5-b**5 ==x:
      print(a,b)
      sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
x=int(input())
b=0
while True:
  if ((b**5+x)**(1/5)).is_integer():
    print(int((b**5+x)**(1/5)),b)
    sys.exit()
  elif ((x-b**5)**(1/5)).is_integer():
    print(int((x-b**5)**(1/5)),-1*b)
    sys.exit()
  else:
    b+=1
Problem p02718 (python)

Fixed submission:
import sys,math
n,m=[int(x) for x in input().split()]
a = [int(x) for x in input().split()]
total = sum(a)
cnt = n
for i in range(0, n):
  if a[i] < math.ceil(total / (4 * m)):
    cnt -= 1
  if cnt < m:
    print("No")
    sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
a = [int(x) for x in input().split()]
total = sum(a)
cnt = n
for i in range(0, n):
  if a[i] < int(total / (4 * m)):
    cnt -= 1
  if cnt < m:
    print("No")
    return
print("Yes")
Problem p02761 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
for i in range(10**n):
  if len(str(i)) < n:
    continue
  for j in range(m):
    sti = str(i)
    if sti[sc[j][0]-1] != str(sc[j][1]):
      break
  else:
    print(i)
    sys.exit()
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
for i in range(10**n):
  for j in range(m):
    sti = str(i)
    if sti[sc[j][0]-1] != str(sc[j][1]):
      break
  else:
    print(i)
    sys.exit()
print(-1)
Problem p02801 (python)

Fixed submission:
abc='abcdefghijklmnopqrstuvwxyz'
x=input()
print(abc[abc.index(x)+1])

Buggy submission (verdict: Runtime Error):
import math
inp = input().split()
n,k = int(inp[0]),int(inp[1])
a = [int(x) for x in input().split()]
a.sort()
ans =0
for ini in range(0,n-k+1):
  for end in range(ini+k-1,n):
    m = end-ini-1
    r = k-2
    combi = math.factorial(m) // (math.factorial(m - r) * math.factorial(r))
    ans += (a[end]-a[ini])*combi

ans = ans % (10**9+7)
print(ans)

Buggy submission (verdict: Runtime Error):
inp = input().split()
n,k = int(inp[0]),int(inp[1])
a = [int(x) for x in input().split()]
a.sort()
ans =0
for ini in range(0,n-k+1):
  for end in range(ini+k-1,n):
    m = end-ini-1
    r = k-2
    combi = math.factorial(m) // (math.factorial(m - r) * math.factorial(r))
    ans += (a[end]-a[ini])*combi

ans = ans % (10**9+7)
print(ans)
Problem p02804 (python)

Fixed submission:

def pre_combi1(n, p):
  fact = [1]*(n+1)  # fact[n] = (n! mod p)
  factinv = [1]*(n+1)  # factinv[n] = ((n!)^(-1) mod p)
  inv = [0]*(n+1)  # factinv 計算用
  inv[1] = 1
  # 前処理
  for i in range(2, n + 1):
    fact[i]= fact[i-1] * i % p
    inv[i]= - inv[p % i] * (p // i) % p
    factinv[i]= factinv[i-1] * inv[i] % p
  return fact, factinv

def combi1(n, r, p, fact, factinv):
  """
  k<n<10**7でpが素数のときのnCr % pを求める
   """
  # 本処理
  if r < 0 or n < r:
    return 0
  r = min(r, n-r)
  return fact[n] * factinv[r] * factinv[n-r] % p
 
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
sfs=0
p=1000000007
fact,factinv=pre_combi1(n,p)
for i in range(1,n+1):
  sfs+=a[i-1]*combi1(i-1,k-1,p,fact,factinv)
  sfs-=a[i-1]*combi1(n-i,k-1,p,fact,factinv)
  sfs %= p
  #print(i,a[i-1],n-i,k-1,sfs)
print(sfs%p)

Buggy submission (verdict: Runtime Error):
from itertools import permutations, combinations,combinations_with_replacement,product
inp = input().split()
n,k = int(inp[0]),int(inp[1])
a = [int(x) for x in input().split()]
a.sort()
ans =0
for ini in range(0,n-k+1):
  for end in range(ini+k-1,n):
    combi = combinations(end-ini-1,k-2)
    ans += (a[end]-a[ini])*combi

ans = ans % (10**9+7)
print(ans)
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
n,k=map(int,input().split())
CONST=10**9+7
path={i:list() for i in range(n)}
for i in range(n-1):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
used=[0]*n
used[0]=1
  
def bfs(pos, parent):
  res=k-parent
  if parent>0:
    deg=2
  else:
    deg=1
  for nex in path[pos]:
    if used[nex]:
      continue
    used[nex]=1
    res *= bfs(nex,deg)
    res = res%CONST
    deg += 1
  return res%CONST
    
print(bfs(0, 0))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
CONST=10**9+7
path={i:list() for i in range(n)}
for i in range(n-1):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
used=[0]*n
used[0]=1
  
def bfs(pos, parent):
  res=k-parent
  if parent>0:
    deg=2
  else:
    deg=1
  for nex in path[pos]:
    if used[nex]:
      continue
    used[nex]=1
    res *= bfs(nex,deg)
    res = res%CONST
    deg += 1
  return res%CONST
    
print(bfs(0, 0))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
CONST=10**9+7
path={i:list() for i in range(n)}
for i in range(n-1):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
used=[0]*n
used[0]=1
  
def bfs(pos, parent):
  res=k-parent
  if parent>0:
    deg=2
  else:
    deg=1
  for nex in path[pos]:
    if used[nex]:
      continue
    used[nex]=1
    res *= bfs(nex,deg)
    res = res%CONST
    deg += 1
  return res%CONST
    
print(bfs(0, 0))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
CONST=10**9+7
path={i:list() for i in range(n)}
for i in range(n-1):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
used=[0]*n
used[0]=1
  
def bfs(pos, parent):
  res=k-parent
  deg=2 if parent else 1
  for next in path[pos]:
    if used[next]:
      continue
    #print(pos,next,res)
    used[next]=1
    res *= bfs(next,deg)
    res %= CONST
    deg += 1
  return res%CONST
    
print(bfs(0, 0))
Problem p03001 (python)

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

print(w*h/2.0,1 if 2*x==w and 2*y==h else 0)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
candi=[x,y,w-x,h-y]
cnt=0
if min(candi)==x:
  res= x*h
  cnt+=1
if min(candi)==y:
  res= w*y
  cnt+=1
if min(candi)==w-x:
  res=(w-x)*h
  cnt+=1
if min(candi)=h-y:
  res=w*(h-y)
  cnt+=1
if cnt>0:
  cnt=1
print(res,cnt)
Problem p03037 (python)

Fixed submission:
n,m=map(int,input().split())
l=1
r=n
for i in range(m):
  li,ri=map(int,input().split())
  l = max(l,li)
  r = min(r,ri)
print(max(r-l+1,0))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=1
r=n
for i in range(m):
  li,ri=map(int,input().split())
  l = max(l,li)
  r = min(r,ri)
print(max(r-l,0)
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
table={
  1:2,
  2:5,
  3:5,
  4:4,
  5:5,
  6:6,
  7:3,
  8:7,
  9:6,
}
dp=[-1]*(n+1)
dp[0]=0
for i in range(1,n+1):
  mx=-1
  for j in a:
    if not 0 <= i-table[j] < n+1:
      continue
    #print(i,i-table[j],dp[i-table[j]],j)
    if dp[i-table[j]]<0:
      continue
    if mx < dp[i-table[j]]*10+j:
      mx =dp[i-table[j]]*10+j
  dp[i]=mx
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
table={
  1:2,
  2:5,
  3:5,
  4:4,
  5:5,
  6:6,
  7:3,
  8:7,
  9:6,
}
dp=[-1]*(n+1)
dp[0]=0
for i in range(1,n+1):
  mx=-1
  for j in a:
    #print(i,i-table[j],dp[i-table[j]],j)
    if dp[i-table[j]]<0:
      continue
    if mx < dp[i-table[j]]*10+j:
      mx =dp[i-table[j]]*10+j
  dp[i]=mx
print(dp[n])
Problem p03657 (python)

Fixed submission:
import sys
a,b=map(int, input().split())
s=[a,b,a+b]
for si in s:
  if si%3==0:
    print('Possible')
    sys.exit()

print('Impossible')

Buggy submission (verdict: Runtime Error):
import sys
a,b=map(int, input().split())
s=[a,b,a+b]
for si in s:
  if si%3==0:
  	print('Possible')
    sys.exit()    
print('Impossible')
Problem p03759 (python)

Fixed submission:
a,b,c =map(int, input().split())
if a+c==2*b:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b,c =map(int, input().split())
if a+c=2*b:
  print('YES')
else:
  print('NO')
Problem p03844 (python)

Fixed submission:
inp = input().split()
a=int(inp[0])
b=int(inp[2])
if inp[1]=='+':
  print(a+b)
else:
  print(a-b)

Buggy submission (verdict: Runtime Error):
inp = input().split()
a=inp[0]
b=inp[2]
if inp[1]=='+':
  print(a+b)
else:
  print(a-b)
Problem p03854 (python)

Fixed submission:
import sys
s=''.join(reversed(list(input())))
t=''
text = ['maerd', 'esare', 'resare', 'remaerd']
while len(t) < len(s):
  for tx in text:
    if t + tx == s[:len(t+tx)]:
      t += tx
      break
  else:
    print('NO')
    sys.exit()
print('YES')

Buggy submission (verdict: Runtime Error):
s=input()
text=['dream','dreamer','erase','eraser']

def bfs(t):
  if t == s:
    return 1
  if len(t) >= len(s):
    return 0
  if t != s[:len(t)]:
    return 0
  ans = 0
  for tx in text:
    ans += bfs(t+tx)
  return ans

if bfs('') > 0:
  print('YES')
else:
  print('NO')
Problem p03998 (python)

Fixed submission:
s={i:list(input())for i in'abc'}
i='a'
while s[i]:i=s[i].pop(0)
print(i.upper())

Buggy submission (verdict: Runtime Error):
s={i:list(input())for i in'abc'}
i='a'
while d[i]:i=s[i].pop(0)
print(i.upper())

Buggy submission (verdict: Runtime Error):
import sys
sa=input()
sb=input()
sc=input()
ss={'a':sa,'b':sb,'c':sc}
t='a'
while True:
  t=ss[t][0]
  if len(ss[t])==0:
    print(t.upper())
    sys.exit()
  ss[t]=ss[t][1:]
Problem p02582 (python)

Fixed submission:
st = input()
if st[0] == st[1] and st[0] == st[2] and st[0] == "R":
  print(3)
elif (st[0] == st[1] and st[0] == "R") or (st[1] == st[2] and st[1] == "R"):
  print(2)
elif "R" in st:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
st = input()
if st[0] == st[1] and st[0] == st[2] and st[0] == "R":
  print(3)
elif (st[0] == st[1] == "R") OR (st[1] == st[2] == "R"):
  print(2)
else:
  print(1)
Problem p02778 (python)

Fixed submission:
s = input()
m = ""
for i in s:
    m = m + i.replace(i, 'x')
print(m)

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split())
c,d = map(int,input().split())
n = input()
if n == a:
    print(str(c-1)+" "+str(d))
else:
    print(str(c) + " " + str(d-1))
Problem p02687 (python)

Fixed submission:
s = input()

if s == "ABC":
  print("ARC")
else:
  print("ABC")

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

if s = "ABC":
  print("ARC")
else:
  print("ABC")
Problem p02690 (python)

Fixed submission:
x = int(input())

m = 2*10**9
l = []

a = 0
b = 0
p = 0
#while b <= m:
while p < 1000:
  b = a**5
  l.append(b)
  a += 1
  p += 1


flg = 0
for i in range(len(l)):
  
  if flg == 1:
    break
  for j in range(i+1,len(l)):
    if l[i] + l[j] == x:
      res = [i,-j]
      flg = 1
      break
    elif l[i] - l[j] == x:
      res = [i,j]
      flg = 1
      break
    elif -l[i] + l[j] == x:
      res = [-i,-j]
      flg = 1
      break
    elif -l[i] - l[j] == x:
      res = [-i,j]
      flg = 1
      break
      
      
print(res[0],res[1])

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

m = 2*10**9
l = []

a = 0
b = 0
while b <= m:
  b = a**5
  l.append(b)
  a += 1
  
flg = 0
for i in range(len(l)):
  if flg == 1:
    break
  for j in range(i+1,len(l)):
    if l[i] + l[j] == x:
      res = [i,-j]
      flg = 1
      break
    elif l[i] - l[j] == x:
      res = [i,j]
      flg = 1
      break

print(res[0],res[1])
Problem p02732 (python)

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

b = a[:]
b.sort()

c = [[ 0 for _ in range(3)] for _ in range(n+1)]

ct = 1
tmp = b[1]
sum = 0
for j in range(1,n):
  if b[j] == b[j-1]:
    ct += 1
  else :  
    c[tmp][0] = ct
    cm = int(ct*(ct-1)/2)
    c[tmp][1] = cm
    cm1 = int((ct-1)*(ct-2)/2)
    c[tmp][2] = cm1
    sum += cm
    tmp = b[j]
    ct = 1

c[tmp][0] = ct
cm = int(ct*(ct-1)/2)
c[tmp][1] = cm
cm1 = int((ct-1)*(ct-2)/2)
c[tmp][2] = cm1
sum += cm      

for k in a:
  print(sum-c[k][1] + c[k][2])

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

b = a[:]
b.sort()

c = [[]for _ in range(n+1)]

ct = 1
tmp = b[1]
sum = 0
for j in range(1,n):
  if b[j] == b[j-1]:
    ct += 1
  else :  
    c[tmp].append(ct)
    cm = int(ct*(ct-1)/2)
    c[tmp].append(cm)
    cm1 = int((ct-1)*(ct-2)/2)
    c[tmp].append(cm1)
    sum += cm
    tmp = b[j]
    ct = 1

c[tmp].append(ct)
cm = int(ct*(ct-1)/2)
c[tmp].append(cm)
cm1 = int((ct-1)*(ct-2)/2)
c[tmp].append(cm1)
sum += cm      

for k in a:
  print(sum-c[k][1] + c[k][2])
Problem p02996 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(list(map(int,input().split())))

a.sort(key=lambda x: x[1])

q = 0
w = 0
flg = 0
for j in a:
  q += j[0]
  w = j[1]
  if q > w :
    flg = 1
    break

if flg == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.append(list(map(int,input().split())))

a.sort(key=lambda x: x[1])

q = 0
w = 0
flg = 0
for j in range(n):
  q += j[0]
  w += j[1]
  if q > w :
    flg = 1
    break

if flg == 0:
  print('Yes')
else:
  print('No')
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
root = [-1] * n

def find_root(x):
    if root[x] < 0:
        return x
    else:
        root[x] = find_root(root[x])
        return root[x]

def unite(x, y):
    x = find_root(x)  
    y = find_root(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find_root(x)
    return -root[x]

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x, y)

max_size = max(map(size, range(n)))

print(max_size)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
root = [-1] * n

def find_root(x):
    if root[x] < 0:
        return x
    else:
        root[x] == find_root(root[x])
        return root[x]

def unite(x, y):
    x = find_root(x)  
    y = find_root(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find_root(x)
    return -root[x]

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x, y)

max_size = max(map(size, range(n)))

print(max_size)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
root = [-1] * n

def find_root(x):
    if root[x] < 0:
        return x
    else:
        root[x] == find_root(root[x])
        return root[x]

def unite(x, y):
    x = find_root(x)  
    y = find_root(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find_root(x)
    return -root[x]

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x, y)

max_size = max(map(size, range(n)))

print(max_size)
Problem p02603 (python)

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

money = 1000
kabu = 0

a = []
for kabuka in given_a:
    if len(a) > 0 and a[-1] == kabuka:
        continue
    else:
        a.append(kabuka)

n = len(a)
if n == 1:
    print(money)
    exit()


for i in range(n):
    if i == 0:
        if a[i+1] < a[i]:
            continue
        else:
            kabu += money // a[i]
            money %= a[i]
    elif i == n-1:
        money += kabu * a[i]
        kabu = 0
    else:
        if a[i-1] < a[i] and a[i] > a[i+1]:
            money += kabu * a[i]
            kabu = 0
        if a[i-1] > a[i] and a[i] < a[i+1]:
            kabu += money // a[i]
            money %= a[i]

print(money)

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

money = 1000
kabu = 0

a = []
for kabuka in given_a:
    if len(a) > 0 and a[-1] == kabuka:
        continue
    else:
        a.append(kabuka)

n = len(a)
for i in range(n):
    if i == 0:
        if a[i+1] < a[i]:
            continue
        else:
            kabu += money // a[i]
            money %= a[i]
    elif i == n-1:
        money += kabu * a[i]
        kabu = 0
    else:
        if a[i-1] < a[i] and a[i] > a[i+1]:
            money += kabu * a[i]
            kabu = 0
        if a[i-1] > a[i] and a[i] < a[i+1]:
            kabu += money // a[i]
            money %= a[i]

print(money)
Problem p02608 (python)

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

n=int(input())
ans=[0]*n
tmp=[]
for x in range(1,int(n**0.5)+1): #可能なすべてのx,y,zについてx^2+y^2+z^2+xy+yz+zxの値を求める
   for y in range(1,int(n**0.5)+1):
       for z in range(1,int(n**0.5)+1):
           tmp.append(x**2+y**2+z**2+x*y+y*z+z*x)
cnt=collections.Counter(tmp) #x^2+y^2+z^2+xy+yz+zxの値の個数を数える
for i in range(1,n+1): #各iについて、x^2+y^2+z^2+xy+yz+zxの値がiであるものの個数が答えとなる
   print(cnt[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = [0]*n
tmp = []

for x in range(1, int(n**0.5) +1):
    for y in range(1, int(n**0.5)+1):
        for z in range(1, int(n**0.5)+1):
            tmp.append(x**2+y**2+z**2+x*y+y*z+z*x)

cnt = collections.Counter(tmp)

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

Fixed submission:
from itertools import permutations
from math import sqrt, pow, factorial

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

def calc(a, b):
    [x1, y1] = a
    [x2, y2] = b
    return sqrt(pow(x1 - x2, 2) + pow(y1 -y2, 2))
ans = 0
for order in permutations(range(N)):
    tmp = 0
    for i in range(1, N):
        tmp += calc(l[order[i]], l[order[i-1]])
    ans += tmp
print(ans/factorial(N))

Buggy submission (verdict: Runtime Error):
import numpy as np
from itertools import combinations
from itertools import permutations
from math import factorial


N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
L = np.array(list(permutations(a,3)))
cnt = 0
for i, j, k in L:
    cnt += sum(diff**2 for diff in i -j)**.5 + sum(diff**2 for diff in j -k)**.5
print(cnt/len(L))

Buggy submission (verdict: Runtime Error):
import numpy as np
from itertools import combinations
from itertools import permutations
from math import factorial


N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
print(a)
print(list(permutations(a,3)))
L = np.array(list(permutations(a,3)))
print(L)
cnt = 0
for i, j, k in L:
    cnt += sum(diff**2 for diff in i -j)**.5 + sum(diff**2 for diff in j -k)**.5
print(cnt/len(L))
Problem p03068 (python)

Fixed submission:
N = input()
S = input()
k = int(input())

for s in S: print(s if s == S[k-1] else "*", end="")

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

for s in S: print(s if s ==  S[K-1] else "*". end = "")
Problem p03796 (python)

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
print(math.factorial(int(input))%(10**9 + 7))

Buggy submission (verdict: Runtime Error):
import math
print(math.factorial(int(input)))