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

Fixed submission:
x=int(input())
if x%2==0:
  print(x)
else:print(x*2)

Buggy submission (verdict: Runtime Error):
x=input()
if x%2==0:
  print(x)
else:print(x*2)
Problem p03803 (python)

Fixed submission:
a,b=map(int, input().split())
if a==b:
  print("Draw")
elif a==1 or (a>b and b!=1):
  print("Alice")
else:
  print("Bob")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
i1=[input() for _ in range(n)]
i2=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        if i1[i][j:m+j]==i2[0] and i1[i+1][j:j+m]==i2[1]:
            ans="Yes"
print(ans)
Problem p03804 (python)

Fixed submission:
n,m=map(int,input().split())
i1=[input() for _ in range(n)]
i2=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        count=0
        for k in range(m):
            if i1[i+k][j:m+j]==i2[k]:
                count+=1
                if count==m:
                    ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
i1=[input() for _ in range(n)]
i2=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        if i1[i][j:m+j]==i2[0] and i1[i+1][j:j+m]==i2[1]:
            ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
i1=[input() for _ in range(n)]
i2=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for j in range(n-m+1):
        if i1[i][j:m+j]==i2[0] and i1[i+1][j:j+m]==i2[1]:
            ans="Yes"
print(ans)
Problem p02793 (python)

Fixed submission:
# coding: utf-8
import re
import math
import fractions
#import numpy as np

mod=int(10**9+7)


def lcm(a,b):
    ab=a*b
    return ab//fractions.gcd(a,b)

#main
N=int(input())
A=list(map(int,input().split()))
l=A[0]
for a in range(1,N):
    l=lcm(l,A[a])
l%=mod

ans=0
for a in A:
    ans+=l*pow(a,mod-2,mod)
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import re
import math
#import numpy as np

mod=int(10**9+7)

def lcm(a,b):
    return a*b//math.gcd(a,b)

#main
N=int(input())
A=list(map(int,input().split()))
l=A[0]
for a in A:
    l=lcm(l,a)

ans=0
for a in A:
    ans+=l//a
    ans%=mod
print(ans)
Problem p02990 (python)

Fixed submission:
# coding: utf-8
import re
import math
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)

def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main

N,blue=map(int,input().split())
fac=fac_list(N,mod)
red=N-blue
for a in range(1,blue+1):
    if red+1<a:
        num=0
    else:
        num=fac[red+1]*pow(fac[red+1-a]*fac[a],mod-2,mod)
        num*=fac[blue-(a-1+1)+a-1]*pow(fac[blue-(a-1+1)]*fac[a-1],mod-2,mod)
    print(num%mod)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import time
import re
import math
import fractions

def main():
    N,K=map(int,input().split())
    for i in range(1,K+1):
        if N-K+1-i>0:
            l=math.factorial(N-K+1)/(math.factorial(i)*math.factorial(N-K+1-i))
            r=math.factorial(K-i+i-1)/(math.factorial(K-i)*math.factorial(i-1))
            print(int(l*r%(1e9+7)))
        else:
            print(1)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import time
import re
import math
import fractions

def main():
    N,K=map(int,input().split())
    for i in range(1,K+1):
        if N-K+1-i>0:
            l=math.factorial(N-K+1)/(math.factorial(i)*math.factorial(N-K+1-i))
            r=math.factorial(K-i+i-1)/(math.factorial(K-i)*math.factorial(i-1))
            print(int(l*r%1e9))
        else:
            print(1)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp
Problem p03018 (python)

Fixed submission:
# coding: utf-8
import os
import time
import re
import math

def main():
    s=input().replace("BC","D")
    max=0
    acount=0
    for a in s:
        if a=='D':
            max+=acount
        elif a=='A':
            acount+=1
        else:
            acount=0
    print(max)
start=time.time();
main()
#print(time.time()*1000-start*1000)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import os
import time
import re
import math

def main():
    s=input().replace("BC","D")
    max=0
    acount=0
    for a in len(s):
        if s[a]=='D':
            max+=acount
        elif s[a]=='A':
            acount+=1
        else:
            acount=0
    print(max)



start=time.time();
main()
#print(time.time()*1000-start*1000)
Problem p03186 (python)

Fixed submission:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#############################################
A,B,C=map(int,input().split())
if A+B>=C-1:
  print(C+B)
else:
  print(B+A+B+1)

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
if A+B>=C-1
  print(C+B)
else:
  print(A+A+B+1)
Problem p03208 (python)

Fixed submission:
import math
n,k = map(int,input().split())
hList = [int(input()) for a in range(n)]
hList.sort()
mn = 10**10
for a in range(n - k + 1):
    mn=min([mn,hList[a+k-1]-hList[a]])
print(mn)

Buggy submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
hList=[int(input()) for a in range(n)]
hList.sort()
min=100000000
for a in range(n-k+1):
    min=min([min,hList[a+k-1]-hList[a]])
print(min)
Problem p03242 (python)

Fixed submission:
s = input()
s_list=list(s)
for i in range(len(s)):
  if s[i] == "1":
    s_list[i]='9'
  elif s[i]=="9":
    s_list[i]='1'
str_changed="".join(s_list)
print(str_changed)

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
  if s[i] == "1":
    s[i]="9"
  elif s[i]=="9":
    s[i]="1"
print(s)
Problem p03250 (python)

Fixed submission:
import os
l = list(map(int,input().split()))
l.sort()
a =l[2]*10+l[1]+l[0]
print(a)

Buggy submission (verdict: Runtime Error):
l = list(map(int,input().split()))
l.sort()
a =list[2]*10+list[1]+list[2]
print(a)
Problem p03201 (python)

Fixed submission:
import collections
import math
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=collections.Counter(a)
ans=0
for i in a:
  j=int(math.log2(i))+1
  k=2**j-i
  if k in c.keys():
    if i==k and c[i]>1:
      c[i]-=2
      ans+=1
    elif i!=k and c[i]>0 and c[k]>0:
      c[i]-=1
      c[k]-=1
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
 
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=collections.Counter(a)
ans=0
for i in a:
  for j in range(30):
    if(2**j>i):
      k=2**j-i
      break
  if k in c.keys():
    if i==k and c[i]>1:
      c[i]-=2
      ans+=1
    elif i!=k and c[i]>0 and c[k]>0:
      c[i]-=1
      c[k]-=1
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
 
n=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
c=collections.Counter(a)
ans=0
for i in a:
  for j in range(20):
    if(2**j>i):
      k=2**j-i
      break
  if k in c.keys():
    if i==k and c[i]>1:
      c[i]-=2
      ans+=1
    elif i!=k and c[i]>0 and c[k]>0:
      c[i]-=1
      c[k]-=1
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
 
n=int(input())
a=list(map(int, input().split()))
a.sort()
a.reverse()
c=collections.Counter(a)
ans=0
for i in a:
  for j in range(20):
    if(2**j>i):
      k=2**j-i
      break
  if k in c.keys():
    if i==k and c[i]>1:
      c[i]-=2
      ans+=1
    elif i!=k and c[i]>0 and c[k]>0:
      c[i]-=1
      c[k]-=1
      ans+=1
print(ans)
Problem p03345 (python)

Fixed submission:
a,b,c,k=map(int,input().split())
print((a-b)*(-1)**k)

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().input())
print((a-b)*(-1)**k)
Problem p03745 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
t=1
p=a[0]
m=0
for i in a:
  if(p==i):
    continue
  if(m>0):
    if(i<p):
      t+=1
      m=0
  elif(m<0):
    if(i>p):
      t+=1
      m=0
  else:
    if(i>p):
      m=1
    elif(i<p):
      m=-1
  p=i
print(t)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input()))
t=1
p=a[0]
m=0
for i in a:
  if(p==i):
    continue
  if(m>0):
    if(i<p):
      t+=1
      m=0
  elif(m<0):
    if(i>p):
      t+=1
      m=0
  else:
    if(i>p):
      m=1
    elif(i<p):
      m=-1
  p=i
print(t)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input()))
t=1
p=a[0]
m=0
for i in a:
  if(p==i):
    continue
  if(m>0):
    if(i<p):
      t+=1
      m=0
  elif(m<0):
    if(i>p):
      t+=1
      m=0
  else:
    if(i>p):
      m=1
    eif(i<p):
      m=-1
  p=i
print(t)
Problem p03821 (python)

Fixed submission:
c=list(reversed([list(map(int,input().split())) for _ in [0]*int(input())]))
t=0
for i in c:
  a=i[0]
  b=i[1]
  t+=b-1-(a+t-1)%b
print(t)

Buggy submission (verdict: Runtime Error):
n=int(input())
c=[list(map(int,unput().split())) for _ in [0]*n].reverse()
t=0
for i in c:
  a=c[0]
  b=c[2]
  t+=b-1-(a+t-1)%b
print(t)
Problem p02623 (python)

Fixed submission:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N, M, K = next(it), next(it), next(it)

    A = [0] * (N+1)
    B = [0] * (M+1)
    ans = 0
    for i in range(1, N+1):
        A[i] = A[i-1] + next(it)
    for i in range(1, M+1):
        B[i] = B[i-1] + next(it)

    lo = 0
    hi = 2*(N+M)+1
    while lo < hi:
        mid = (lo+hi)//2
        for j in range(max(0, mid-M), min(mid, N)+1):
            if A[j] + B[mid-j] <= K:
                lo = mid+1
                break
        else:
            hi = mid

    print(lo-1)


if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from bisect import bisect


def resolve():
    it = map(int, sys.stdin.read().split())
    N, M, K = next(it), next(it), next(it)

    A = [0] * (N+1)
    B = [0] * (M+1)
    ans = 0
    for i in range(1, N+1):
        A[i] = A[i-1] + next(it)
    for i in range(1, M+1):
        B[i] = B[i-1] + next(it)

    NM = N + M
    for i in range(1, N+1):
        for j in range(i+1):
            if A[j] + B[i-j] <= K:
                ans = i
                break
        else:
            break
    k = K - A[N]
    if k > 0:
        i = bisect(B, K-A[N])
        ans = max(ans, i + N -1)

    print(ans)


if __name__ == "__main__":
    resolve()
Problem p02679 (python)

Fixed submission:
#!python3

import sys
from collections import defaultdict
from math import gcd

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = input()
    it = map(int, sys.stdin.read().split())
    mod = 10**9 + 7

    d1 = [defaultdict(int), defaultdict(int)]
    z0 = 0
    for ai, bi in zip(it, it):
        if ai == 0 and bi == 0:
            z0 += 1
            continue

        ci = gcd(ai, bi)
        ai, bi = ai // ci, bi // ci

        t = ai * bi < 0
        if ai < 0:
            ai, bi = -ai ,-bi
        elif ai == 0:
            bi = -1
            t = 1

        d1[t][(ai, bi)] += 1


    a1, a2 = d1
    ans = 1
    for (ai, bi), v in a1.items():
        k2 = (bi, -ai)
        if k2 in a2:
            v2 = a2[k2]
            ans *= pow(2, v, mod) + pow(2, v2, mod) - 1
        else:
            ans *= pow(2, v, mod)
        ans %= mod

    for (ai, bi), v in a2.items():
        k2 = (-bi, ai)

        if k2 in a1: continue

        ans *= pow(2, v, mod)
        ans %= mod

    print((ans-1+z0) % mod)



if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

import sys
from collections import defaultdict
from math import gcd
from fractions import Fraction

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = input()
    it = map(int, sys.stdin.read().split())
    mod = 10**9 + 7

    d1 = [defaultdict(int), defaultdict(int)]
    for i, (ai, bi) in enumerate(zip(it, it)):
        val = Fraction(ai, bi)
        d1[0 if val >= 0 else 1][val] += 1

    a1, a2 = d1
    ans = 1
    for k, v in a1.items():
        ik = -1/k
        if ik in a2:
            v2 = a2[ik]
            ans *= pow(2, v+v2, mod) - (pow(2, v, mod)-1)*(pow(2, v2, mod)-1)
        else:
            ans *= pow(2, v, mod)
        ans %= mod

    for k, v in a2.items():
        ik = -1/k
        if not ik in a1:
            ans *= pow(2, v, mod)
            ans %= mod

    print(ans-1)



if __name__ == "__main__":
    resolve()
Problem p02757 (python)

Fixed submission:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, P = iim()
    S = list(map(int, input().rstrip()))

    if P == 2 or P == 5:
        cnt = 0
        for i, si in enumerate(S):
            if si % P == 0:
                cnt += i + 1
        print(cnt)
        return

    T = [0] * P
    T[0] = 1

    ss, p10 = 0, 1
    for s1 in S[::-1]:
        ss += p10 * s1
        ss %= P
        T[ss] += 1
        p10 = 10 * p10 % P

    ans = 0
    for i in T:
        ans += i*(i-1)//2
    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, P = iim()
    S = list(map(int, input().rstrip()))

    if P == 2:
        cnt = N * (N + 1) // 2
        for i, si in enumerate(S):
            if si & 1:
                cnt -= i + 1
        print(cnt)
        return

    i = j = 1
    while j < P:
        i += 1
        j *=10
    keta = i - 2
    cnt = 0
    for i in range(N):
        ans = 0
        if S[i] == 0:
            cnt += 1
        for j in range(i, i+keta):
            ans = 10*ans + S[j]
        for j in range(i+keta, N):
            sj = S[j]
            ans = 10*ans + sj
            #print(ans, ans % P)
            if ans % P == 0:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    resolve()
Problem p02781 (python)

Fixed submission:
#!python3

from math import factorial

iim = lambda: map(int, input().rstrip().split())

def cmb(a, b):
    c = a - b
    if c < b:
        b = c
    if b == 0: return 1

    ans = 1
    for i in range(b):
        ans *= a - i

    return ans // factorial(b)

def cnt(N, K):
    if K == 0:
        return 1

    n10 = 10 ** (K-1)
    if N < n10:
        return 0

    n10 *= 10
    n9 = 9 ** K

    ans = 0
    a = n10
    i = 0
    while a < N:
        a *= 10; i += 1
    a //= 10; i -= 1
    if i >= 0:
        ans = cmb(i+K, K) * n9
        #print(f"{i+K}C{K}", ans)

    n, b = divmod(N, a)
    if n > 1:
        ans += (n - 1) * cnt(a-1, K - 1)
    ans += cnt(b, K - 1)


    return ans

def resolve():
    N = int(input())
    K = int(input())

    print(cnt(N, K))

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3


iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = list(map(int, input()))
    K = int(input())
    size = len(N)

    dp = [[[0]*(size+1) for j in range(2)] for i in range(size+1)]

    dp[0][0][0] = 1
    for i in range(size):
        for less in range(2):
            for k in range(size):
                for x in range(10 if less else N[i] + 1):
                    #print((i, less, k), x, (i+1, int(less or x < N[i]), k + (1 if x else 0)))
                    dp[i+1][less or x < N[i]][k + (1 if x else 0)] += dp[i][less][k]
        #print(dp[i+1])

    print(dp[-1][0][K] + dp[-1][1][K])

if __name__ == "__main__":
    resolve()
Problem p02790 (python)

Fixed submission:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    a, b = iim()

    if a > b:
        a, b = b, a
    print("{0}".format(a)*b)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    a, b = iim()

    if a > b:
        a, b = b, a
    print(f"{a}"*b)

if __name__ == "__main__":
    resolve()
Problem p02820 (python)

Fixed submission:
#!python3

def resolve():
    N, K = map(int, input().rstrip().split())
    R, S, P = map(int, input().rstrip().split())
    T = list(input().rstrip())

    score = {"r":  P, "s": R, "p": S}

    s = 0
    for i in range(K):
        s += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            T[i] = ""
            continue
        s += score[T[i]]

    print(s)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

def resolve():
    N, K = map(int, input().rstrip().split())
    R, S, P = map(int, input().rstrip().split())
    T = input().rstrip().split()

    score = {"r":  P, "s": R, "p": S}

    s = 0
    for i in range(i, K):
        s += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            continue
        s += score[T[i]]

    print(s)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

def resolve():
    N, K = map(int, input().rstrip().split())
    R, S, P = map(int, input().rstrip().split())
    T = input().rstrip().split()

    score = {"r":  P, "s": R, "p": S}

    s = 0
    for i in range(i, K):
        s += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            continue
        s += score[T[i]]

    print(s)

if __name__ == "__main__":
    resolve()
Problem p02834 (python)

Fixed submission:
#!python3

def resolve():
    N, u, v = map(int, input().rstrip().split())
    N1 = N + 1

    d = [[] for _ in range(0, N1)]
    for i in range(1, N):
        a, b = map(int, input().rstrip().split())

        d[a].append(b)
        d[b].append(a)

    from collections import deque

    def f(x):
        q = deque()
        q.append(x)
        X = [-1] * N1

        X[x] = 0
        while q:
            x = q.popleft()
            for i in d[x]:
                if X[i] == -1:
                    X[i] = X[x] + 1
                    q.append(i)
        return X

    U = f(u)
    V = f(v)

    m = 0
    for uu, vv in zip(U, V):
        if uu < vv:
            if vv > m:
                m = vv
    print(m-1)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
#!python3

def resolve():
    N, u, v = map(int, input().rstrip().split())
    N1 = N + 1

    d = [[] for _ in range(1, N1)]
    for i in range(1, N):
        a, b = map(int, input().rstrip().split())

        d[a].append(b)
        d[b].append(a)

    from collections import deque

    def f(x):
        q = deque()
        q.append(x)
        X = [-1] * N1

        while q:
            x = q.popleft()
            for i in d[x]:
                if X[i] == -1:
                    X[i] = X[x] + 1
                    q.append(i)
        return q

    U = f(u)
    V = f(v)

    m = 0
    for uu, vv in zip(U, V):
        if uu < vv:
            if vv > m:
                m = vv
    print(m-1)

if __name__ == "__main__":
    resolve()
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()
ans = "Yes"
if N % 2 != 0:
    ans = "No"
else:
    N = int(N/2)
    for i in range(0, N):
        if S[i] != S[i+N]:
            ans = "No"
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = "Yes"
if N % 2 != 0:
    ans = "No"
else:
    N = int(N/2)
    for i in range(0, N):
        if S[i] != S[i+3]:
            ans = "No"
            break
print(ans)
Problem p02829 (python)

Fixed submission:
ans = 0
for _ in range(2):
    a = int(input())
    ans += a
print(6 - ans)

Buggy submission (verdict: Runtime Error):
ans = 6
for _ in rangr(2):
    a = int(input())
    ans += a
print(6 - ans)