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

Fixed submission:
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=int(input())
  lis=list(map(int,input().split()))
  lists.append(lis)
ans=[0]*n
for list in lists:
  for i in range(len(list)):
    ans[list[i]-1]+=1
count=0
for h in ans:
  if h==0:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  lists.append(list)
num=[0]*n
for list in lists:
  for __ in range(len(list)):
    num[list[__]-1]+=1
count=0
for nn in num:
  if nn==0:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  list.append(list)
num=[0]*n
for list in lists:
  for __ in range(len(list)):
    num[list[__]-1]+=1
count=0
for nn in num:
  if nn==0:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=int(input())
  t=input()
  if d==1:
    list=[int(t)]
  else:
    list=list(map(int,t.split()))
  lists.append(list)
ans=[0]*n
for list in lists:
  for i in range(1,len(list)+1):
    ans[i-1]+=1
count=0
for h in ans:
  if h==0:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=input()
  if d==1:
    list=[int(input())]
  else:
    list=list(map(int,input().split()))
  lists.append(list)
ans=[0]*n
for list in lists:
  for i in range(1,len(list)+1):
    ans[i-1]+=1
count=0
for h in ans:
  if h==0:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lists=[]
for _ in range(k):
  d=input()
  list=list(map(int,input().split()))
  lists.append(list)
ans=[0]*n
for list in lists:
  for i in range(1,len(list)+1):
    ans[i-1]+=1
count=0
for h in ans:
  if h==0:
    count+=1
print(count)
Problem p02689 (python)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(m)]
list=[0]*n
for a,b in ab:
  list[a-1]=max(list[a-1],h[b-1])
  list[b-1]=max(list[b-1],h[a-1])
count=0
for i in range(n):
  if list[i]<h[i]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
h=list(map(int,inpt().split()))
ab=[[] for nn in range(n)]
for mm in range(m):
  a,b=map(int,input().split())
  ab[a-1]+=b-1
  ab[b-1]+=a-1
cnt=0
for i in range(n):
  hi=0
  for ll in ab[i]:
    hi=max(hi,h[ll])
  if hi==h[i]:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(m)]
list=[0]*n
for a,b in ab:
  list[a-1]+=max(list[a-1],h[b-1])
  list[b-1]+=max(list[b-1],h[a-1])
ans=0
for i in range(n):
  if list[i]<h[i]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
h=list(map(int,input().split()))
lists=[list(map(int,input().split())) for _ in range(m)]
ans=[[]]*n
for list in lists:
  ans[list[0]-1].append(list[1])
  ans[list[1]-1].append(list[0])
new=[]
for x in range(n):
  new.append(list(set(ans[x])))
high=[[]]*n
for y in range(n):
  for z in range(len(new[y])):
    high[y].append(h[new[y][z]-1])
count=0
for x in range(n):
  if h[x]>max(high[x]):
    count+=1
print(count)
Problem p02695 (python)

Fixed submission:
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
sumlist=[]
for A in itertools.combinations_with_replacement(range(1,m+1),n):
  sum=0
  for a,b,c,d in abcd:
    if A[b-1]-A[a-1]==c:
      sum+=d
    sumlist.append(sum)
print(max(sumlist))

Buggy submission (verdict: Runtime Error):
import math
n,m,q=map(int,input().split())
abcd=[list(map(int,inpt().split())) for _ in range(q)]
sumlist=[]
for A in math.combinations_with_replacement(range(1,m+1),n)
  sum=0
  for a,b,c,d in abcd:
    if A[b-1]-A[a-1]==c:
      sum+=d
    sumlist.append(sum)
print(max(sumlist))
Problem p02699 (python)

Fixed submission:
s,w=map(int,input().split())
print('unsafe' if w>=s else 'safe')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
n=1
while c-b*n>0 and a-d*n>0:
    n+=1
if c-b*(n+1)<=a-d*(n+1):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=int(input())
w=int(input())
print('unsafe' if w>=s else 'safe')
Problem p02701 (python)

Fixed submission:
n=int(input())
lists=[input() for x in range(n)]
print(len(set(lists)))

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=[input() for x in range(n)]
print(len(set(lists))

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=[input() for x in range(n)]
listget=[]
for s in lists:
    for y in range(1,n+1):
        listget.append(s[y])
print(len(set(listget))
Problem p02707 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for aa in a:
  ans[aa-1]+=1
for an in ans:
  print(an)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for aa in a:
  ans[aa-1]+=1
print(ans sep='\n')

Buggy submission (verdict: Runtime Error):
N=input()
lista=list(map(int,input().split()))
  for _ in range(1,N+1):
  print(lista.count(_))

Buggy submission (verdict: Runtime Error):
N=input()
lista=list(map(int,input().split()))
  for _ in range(1,N+1):
print(lista.count(_))

Buggy submission (verdict: Runtime Error):
N=int(input())
lista=list(map(int,input().split()))
  for _ in range(1,N+1)
print(lista.count(_))
Problem p02773 (python)

Fixed submission:
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
common=c.most_common()
value,cnt=zip(*common)
common.sort(key=lambda x:x[0])
m=max(cnt)
for cc in common:
  if cc[1]==m:
    print(cc[0])

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.counter(s)
common=c.most_common()
value,cnt=zip(*common)
common.sort(key=lambda x:x[0])
m=max(cnt)
for cc in most_common:
  if cc[1]==max:
    print(cc[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[input() for x in range(n)]
l=list(set(s))
l.sort()
cnt=[0]*len(l)
for ss in s:
  cnt[l.index[ss]]+=1
m=max(cnt)
ans=[]
for cc in cnt:
  if cc==m:
    ans.append(cnt.index(cc))
for aa in ans:
  print(l[aa])
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
del h[:k]
print(sum(h))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
del h[5]
print(sum(h))
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
g=fractions.gcd(a,b)
print((a*b)//g)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
g=math.gcd(a,b)
print((a*b)//g)
Problem p02836 (python)

Fixed submission:
s=input()
n=len(s)
cnt=0
if n%2==0:
  for i in range(n//2):
    if s[:n//2][::-1][i]!=s[n//2:n][i]:
      cnt+=1
  print(cnt)
else:
  for i in range(n//2):
    if s[:(n-1)//2][::-1][i]!=s[(n+1)//2:n][i]:
      cnt+=1
  print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
t=s[::-1]
n=len(input())
if n%2==0:
  x=n//2
else:
  x=n//2+1
count=0
  for i in range(x):
      if s[i]!=t[i]:
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
t=s[::-1]
n=len(input())
if n%2==0:
    x=n//2
else:
    x=n//2+1
count=0
    for i in range(x):
        if s[i]!=t[i]:
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
t=s[::-1]
n=len(input())
if n%2==0:
    x=n//2
else:
    x=(n-1)//2
count=0
    for i in range(x):
        if s[i]!=t[i]:
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
t=s[::-1]
n=len(input())
if n%2==0:
    x=n//2
else:
    x=(n-1)//2
count=0
    for i in range(x):
        if s[i]!=t[i]:
            count+=1
prnt(count)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
if n%2!=0:
    lista=[]
    s1=s[0,(n-1)//2]
    s2=s[(n+1)//2,n]
    s3=s2[::-1]
    for p in range((n-1)//2):
        if s1[p]!=s3[p]:
            lista.append(p)
    print(len(lista))
else:
    listb=[]
    s4=s[0:n//2]
    s5=[n//2:n]
    s6=s5[::-1]
    for q in range(n//2):
        if s4[q]!=s6[q]:
            listb.append(q)
    print(len(listb))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
if n%2!=0:
    lista=[]
    s1=s[0,(n-1)//2]
    s2=s[(n+1)//2,n]
    s3=s2[::-1]
    for p in range((n-1)//2):
        if s1[p]!=s3[p]:
            lista.append(p)
    print(len(lista))
else:
    s4=s[0:n//2]
    s5=[n//2:n]
    s6=s5[::-1]
    for q in range(n//2):
        if s4[q]!=s6[q]:
            listb.append(q)
    print(len(listb))
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()
if s[0:n//2]==s[n//2:n]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
if n%2!=0:
  print('NO')
else:
  if s[0:n//2]==s[n//2:n]:
  print('Yes')
  else:
  print('No')
Problem p02881 (python)

Fixed submission:
n=int(input())
r=n**(1/2)
w=0
for i in range(1,int(r)+1):
  if n%i==0:
    w=i
x,y=w,n//w
if x!=1 and y!=1:
  print(x+y-2)
else:
  print(max(x,y)-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
r=n**(1/2)
w=0
for i in range(1,int(r)+1):
  if n%i==0:
    w=i
x,y=w,n//w
print(x+y-1 if x=1 or y=1 else x+y-2)
Problem p02916 (python)

Fixed submission:
n=int(input())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(2,n+1):
  if lista[i-1]==lista[i-2]+1:
    list.append(lista[i-2])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)

Buggy submission (verdict: Runtime Error):
n=int(input())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(n):
  if lista[i]==lista[i-1]+1:
    list.append(lista[i])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)

Buggy submission (verdict: Runtime Error):
n=int(input())
lista=list(map(int,input().split()))
listb=list(map(int,input().split()))
listc=list(map(int,input().split()))
list=[]
for i in range(n):
  if lista[i+1]==lista[i]+1:
    list.append(lista[i])
vonus=0
for x in list:
  vonus+=listc[x-1]
print(sum(listb)+vonus)
Problem p02935 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l.sort()
new=(l[0]+l[1])/2
if n>=3:
  for i in range(2,n):
    new=(new+l[i])/2
  print(new)
else:
  print((l[0]+l[1])/2)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,inout().split()))
l.sort()
new=(l[0]+[1])/2
if n>=3:
  for i in range(2,n):
    new=(new+l[i])/2
  print(new)
else:
  print((l[0]+l[1])/2)
Problem p02970 (python)

Fixed submission:
n,d=map(int,input().split())
if n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)

Buggy submission (verdict: Runtime Error):
import math
n,d=map(int,input().split())
print(math,ceil(n/(d*2+1)))

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
if n%(2*d+i)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input())
if n%(2*d+i)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
b=set(a)
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in b:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 in a:
    dp[i+2]=0
    continue
  dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
print(dp[j+2]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
fib=[0,1]
for i in range(n):
  fib.append(fib[i]+fib[i+1])
b=[]
for j in range(m):
  b.append(fib[a[j]-1])
ans=0
for t in range(m-1):
  ans+=(b[t]*b[t+1])%(10**9+1)
print(ans%(10**9+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
fib=[0,1]
for i in range(n):
  fib.append(fib[i]+fib[i+1])
b=[]
for j in range(m):
  b.append(fib[a[m]-1])
ans=0
for t in range(m-1):
  ans+=(b[t]*b[t+1])%(10**9+1)
print(ans%(10**9+1))
Problem p03042 (python)

Fixed submission:
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

Buggy submission (verdict: Runtime Error):
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 0<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 0<=y=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
x=int(a+b)
y=int(c+d)
if 0<=x<=12 and 0<=b<=12:
  if x==y==0:
    print('NA')
  else:
    print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')
Problem p03072 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=1
for i in range(1,n):
  if h[i]>=max(h[:i]):
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  max=max(list[:i-1])
  if listh[i-1]>=max:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=0
for i in range(2,n+1):
  if listh[i-1]>=max(listh[:i-1]):
    count+=1
print(count+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  if listh[i-1]>=max(listh[:i-1]):
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  if listh[i]>=max(listh[:i-1]):
    count+=1
print(count)
Problem p03127 (python)

Fixed submission:
n=int(input()) 
lis=list(map(int,input().split()))
m=min(lis)
new=lis
num=0
while True:
  for i in range(n+num):
    new[i]%=m
  if all(nn==0 for nn in new):
    print(m)
    exit()
  new.append(m)
  sl={m}
  for i in range(n+num):
    if new[i]!=0:
      sl.add(new[i])
  m=min(sl)
  num+=1

Buggy submission (verdict: Runtime Error):
n=int(input()) 
lis=list(map(int,input().split()))
m=min(lis)
new=lis
while True:
  for i in range(n):
    new[i]%=m
  if all(nn==0 for nn in new):
    print(m)
    exit()
  ll=[m]
  for nn in new:
    if nn!=0:
      ll.append(nn)
  new=ll
  m=min(new)
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(m-1):
  l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:n-1])
print(sum(l)-cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(n-1):
  l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:m-1])
print(x[m-1]-x[0]-cnt)
Problem p03221 (python)

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

l=[[] for j in range(n)]
for i in range(m):
  p,y=map(int,input().split())
  l[p-1].append([y,i])
for j in range(n):
  l[j].sort(key=lambda x:x[0])
lis=[]
for j in range(n):
  for t in range(len(l[j])):
    pre='0'*(6-len(str(j+1)))+str(j+1)
    y='0'*(6-len(str(t+1)))+str(t+1)
    b=pre+y
    lis.append([b,l[j][t][1]])
lis.sort(key=lambda x:x[1])
for li in lis:
  print(li[0])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
py=[list(map(int,input().split())) for i in range(m)]
l=[[] for j in range(n)]
for p,y in py:
  l[p-1].append(y)
for j in range(n):
  l[j].sort()

for j in range(n):
  for t in len(l[j]):
    pre='0'*(6-len(str(l[j][t])))+str(l[j][t])
    y='0'*(6-len(str(t+1)))+str(t+1)
    print(pre+str)
Problem p03286 (python)

Fixed submission:
n=int(input())
if n==0:
  print(0)
  exit()
if n==1:
  print(1)
  exit()
ans=[]
while n!=1:
  r=n%2
  ans.append(str(r))
  n=(n-r)//(-2)
ans.append(str(1))
ans.reverse()
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=''
while n!1:
  r=n%(-2)
  ans+=r
  n=n//(-2)
ans+=n
ans.reverse()
print(ans)
Problem p02547 (python)

Fixed submission:
N = int(input())
S = []
for j in range(N):
  S.append(input().split())
G = []
for i in range(N):
  if S[i][0] == S[i][1]:
    G.append("1")
  else:
    G.append("0")

AN = (''.join(G))

if "111" in AN:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = []
for _ in range(N):
  S.append(input().split())
G = []
for i in range(N):
  if S[i][0] == S[i][1]:
    G.append("1")
  else:
    G.append("0")

AN = (''.join(G))

if "111" in AN:
  print("Yes")
else:
  print("No")
Problem p02571 (python)

Fixed submission:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

s = input()
t = input()

a = []
for i in range(len(s) - len(t) + 1):
    cnt = 0
    for j in range(len(t)):
        if t[j] == s[i + j]:
            cnt += 1
    a.append(cnt)
print(len(t) - max(a))

Buggy submission (verdict: Runtime Error):
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

s = input()
t = input()

a = []
for i in range(len(s) - len(t)):
    cnt = 0
    for j in range(len(t)):
        if t[j] == s[i + j]:
            cnt += 1
    a.append(cnt)
print(len(t) - max(a))
Problem p02834 (python)

Fixed submission:
#!/usr/bin/python3
import sys

sys.setrecursionlimit(10 ** 5)

def search(n, total, dic):
    if dic[n] >= 0:
        return
    else:
        dic[n] = total
    for i in br[n]:
        search(i, total + 1, dic)

n, u, v = map(int, input().split())
br = {}
disu = {}
disv = {}
for i in range(n):
    br[i + 1] = []
    disu[i + 1] = -1
    disv[i + 1] = -1
for i in range(n - 1):
    a, b = map(int, input().split())
    br[a].append(b)
    br[b].append(a)

search(u, 0, disu)
search(v, 0, disv)
far = 0
for i in range(1, n + 1):
    if disv[i] < disu[i]:
        continue
    else:
        far = max(far, disv[i])

print(far - 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
import sys
import resource

sys.setrecursionlimit(10 ** 5)
resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))

def search(n, total, dic):
    if dic[n] >= 0:
        return
    else:
        dic[n] = total
    for i in br[n]:
        search(i, total + 1, dic)

n, u, v = map(int, input().split())
br = {}
disu = {}
disv = {}
for i in range(n):
    br[i + 1] = []
    disu[i + 1] = -1
    disv[i + 1] = -1
for i in range(n - 1):
    a, b = map(int, input().split())
    br[a].append(b)
    br[b].append(a)

search(u, 0, disu)
search(v, 0, disv)
far = 0
for i in range(1, n + 1):
    if disv[i] < disu[i]:
        continue
    else:
        far = max(far, disv[i])

print(far - 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

def search(n, total, dic):
    if dic[n] >= 0:
        return
    else:
        dic[n] = total
    for i in br[n]:
        search(i, total + 1, dic)

n, u, v = map(int, input().split())
br = {}
disu = {}
disv = {}
for i in range(n):
    br[i + 1] = []
    disu[i + 1] = -1
    disv[i + 1] = -1
for i in range(n - 1):
    a, b = map(int, input().split())
    br[a].append(b)
    br[b].append(a)

search(u, 0, disu)
search(v, 0, disv)
far = 0
for i in range(1, n + 1):
    if disv[i] < disu[i]:
        continue
    else:
        far = max(far, disv[i])

print(far - 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

def search(n, total, dic):
    if dic[n] >= 0:
        return
    else:
        dic[n] = total
    for i in br[n]:
        search(i, total + 1, dic)

n, u, v = map(int, input().split())
br = {}
disu = {}
disv = {}
for i in range(n):
    br[i + 1] = []
    disu[i + 1] = -1
    disv[i + 1] = -1
for i in range(n - 1):
    a, b = map(int, input().split())
    br[a].append(b)
    br[b].append(a)

search(u, 0, disu)
search(v, 0, disv)
far = 0
for i in range(1, n + 1):
    if disv[i] < disu[i]:
        next
    else:
        far = max(far, disv[i])

print(far - 1)
Problem p03307 (python)

Fixed submission:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())

if n % 2 == 1:
    print(n * 2)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

n = int(input())
a = [int(_) for _ in input().split()]

p = a[0]
q = a[1]
r = a[2]
s = 0
for i in range(3, n):
    s += a[i]

d1 = 0
d3 = 2
while s - r > a[d3]:
    d3 += 1
    r += a[d3]
    s -= a[d3]

ans = float('inf')
for d2 in range(1, n - 1):
    ans = min(ans, max(p, q, r, s) - min(p, q, r, s))
    q += a[d2 + 1]
    while q - p > a[d1]:
        if d1 + 1 == d2 + 1:
            break
        d1 += 1
        p += a[d1]
        q -= a[d1]
    r -= a[d2 + 1]
    if d2 + 1 == d3:
        d3 += 1
        r += a[d3]
        s -= a[d3]
    while s - r > a[d3]:
        if d3  == n - 1:
            break
        d3 += 1
        r += a[d3]
        s -= a[d3]

print(ans)
Problem p02622 (python)

Fixed submission:
s = input()
t = input()

count = 0

for i in range(len(s)):
  if(s[i] != t[i]):
    count+=1;
print(count)

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

int t = 0

for i in range(n):
  if(s[i] != t[i]):
    t+=1;
print(t)
Problem p02552 (python)

Fixed submission:
x=int(input())
if x==0:
  print('1')
else:
  print('0')

Buggy submission (verdict: Runtime Error):
x=int(input())
if x==0:
  print('1')
  else:
    print('0')
Problem p02627 (python)

Fixed submission:
a=input()
li=["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
if a in li:
  print("a")
else:
  print("A")

Buggy submission (verdict: Runtime Error):
a=input()
li=[q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m]
if a in li:
  print("a")
else:
  print("A")
Problem p02766 (python)

Fixed submission:
n,k=map(int,input().split())
ans=0
while n!=0:
  n=n//k
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=o
n,k=map(int,input().split())
while n!=0:
  n=n//k
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=o
n,k=map(int,input().split())
while n!=0:
  n=n//k
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
ans=o
n,k=map(int,input().split())
while True:
  n=n//k
  ans+=1
  if n==0:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
ans=o
n,k=map(int,input().split())
while True:
  n=n//k
  ans+=1
  if n==0:
    break
print(ans)
Problem p02771 (python)

Fixed submission:
A,B,C=map(int,input().split())
if A==B and B==C and C==A:
  print("No")
elif A!=B and B!=C and C!=A:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
if A==B and B==C and C==A:
  print("No")
elif A!=B and B!=C and C!=A:
  print("No")
alse:
  print("Yes")
Problem p02836 (python)

Fixed submission:
S=input()
count=0
for i in range(len(S)//2):
  if S[i]!=S[-i-1]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
S=input()
count=0
for i in range(S):
  if S[i]!=S[-i-1]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
S=input()
count=0
for i in range len(S)//2:
  if S[i]!=S[-i-1]:
    count+=1
print(count)
Problem p02860 (python)

Fixed submission:
N=int(input())
S=input()
if S[:N//2]==S[N//2:]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
if S[0:len(N)//2-1]==S[len(N)//2:-1]:
  print("Yes")
else:
  print("No")
Problem p02880 (python)

Fixed submission:
import sys
N=int(input())
for i in range(9):
  for j in range(9):
    if N==(i+1)*(j+1):
      print("Yes")
      sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
ku={}
for i in range(9):
  for j in range(9):
    ku.add((i+1)*(j+1));
if N in ku:
  print("Yes")
else:
  print("No")