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

Fixed submission:
N = int(input())
Xs = input()
Xlist = Xs.split(' ')
Xlist.sort()
anslist = []
if len(set(Xlist)) != 1:
    for P in range(int(Xlist[0]),int(Xlist[N - 1])+1):
        ans = 0
        for i in range(len(Xlist)):
            ans = ans + (int(Xlist[i]) - P)**2
        anslist.append(ans)
    print(min(anslist))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
Xs = input()
Xlist = Xs.split(' ')
anslist = []
for P in range(int(Xlist[0]),int(Xlist[N - 1])+1):
    ans = 0
    for i in range(len(Xlist)):
        ans = ans + (int(Xlist[i]) - P)**2
    anslist.append(ans)
print(min(anslist))
Problem p02772 (python)

Fixed submission:
N = int(input())
Ai = input()
Ai = Ai.split(' ')
ans = 'APPROVED'
for moji in Ai:
    moji = int(moji)
    if moji % 2 != 0:
        pass
    else:
        if (moji % 3 == 0) or (moji % 5 == 0):
            pass
        else:
            ans = 'DENIED'
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
Ai = input()
Ai = Ai.split(' ')
ans = 'APPROVED'
for moji in Ai:
    if moji % 2 != 0:
        pass
    else:
        if (moji % 3 == 0) or (moji % 5 == 0):
            pass
        else:
            ans = 'DENIED'
            break
print(ans)
Problem p02705 (python)

Fixed submission:
r = int(input())
pi = 22/7
print(2*pi*r)

Buggy submission (verdict: Runtime Error):
r = int(input())
p = 22/7
print(2*pi*r)
Problem p02924 (python)

Fixed submission:
N=int(input())
print((N*(N-1)//2))

Buggy submission (verdict: Runtime Error):
N=int(input())
print((N*(N-1)//2)
Problem p02995 (python)

Fixed submission:
import fractions

def LCM(a,b):
    return int(a*b/fractions.gcd(a,b))

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print(int(result))

Buggy submission (verdict: Runtime Error):
import math

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

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print(int(result))

Buggy submission (verdict: Runtime Error):
import math

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

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print('{}'.format((int(result))))

Buggy submission (verdict: Runtime Error):
import math

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

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print('{}'.format((int(result))))
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
Di=0
result=0

while Di<=X:
    result+=1
    if result==N+1:
        break
    Di+=L[result-1]

print(result)

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

while Di<=X:
    result+=1
    Di+=L[result-1]
    
print(result)
Problem p03050 (python)

Fixed submission:
import math

N=int(input())
result=0
if N==1:
    print(0)
else:
    for i in range(1,int(math.sqrt(N))+1):
        if N%i==0:
            if i>1 and N%(i-1)==N//(i-1):
                result+=i-1
            if N%i!=N//i:
                if N%(N//i-1)==N//(N//i-1):
                    result+=N//i-1
    print(result)

Buggy submission (verdict: Runtime Error):
import math

N=int(input())
result=0

for i in range(1,int(math.sqrt(N))+1):
    if N%i==0:
        if i>1 and N%(i-1)==N//(i-1):
            result+=i-1
        if N%i!=N//i:
            if N%(N//i-1)==N//(N//i-1):
                result+=N//i-1
print(result)
Problem p02995 (python)

Fixed submission:
# import numpy as np
import fractions

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def undivided_under(N, C, D):
    dived_C = N // C
    dived_D = N // D
    dived_lcm = N // lcm(C, D)

    # print(dived_C, dived_D, dived_lcm)

    return(N - dived_C - dived_D + dived_lcm)

# print(A,B,C,D)
# print(undivided_under( B, C, D ))
# print(undivided_under( A-1, C, D ))

print( int( undivided_under(B, C, D) - undivided_under(A-1, C, D)) )

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

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def undivided_under(N, C, D):
    dived_C = N // C
    dived_D = N // D
    dived_lcm = N // lcm(C, D)

    # print(dived_C, dived_D, dived_lcm)

    return(N - dived_C - dived_D + dived_lcm)

# print(A,B,C,D)
# print(undivided_under( B, C, D ))
# print(undivided_under( A-1, C, D ))

print( int( undivided_under(B, C, D) - undivided_under(A-1, C, D)) )
Problem p02628 (python)

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

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split)
l=list(map(int,input().split))
l.sort()
print(sum(l[:k]))
Problem p02639 (python)

Fixed submission:
l=list(map(int ,input().split()))
print(l.index(0)+1)

Buggy submission (verdict: Runtime Error):
x,n=map(int, input().split())
l=list(map(int ,input().split()))
i=0
while(True):
    if (x-i) not in l:
        print(x-i)
        break
    if(x+i) not in l:
        print(x+i)
        break
    i+=1

Buggy submission (verdict: Runtime Error):
l=list(map(input().split()))
print(l.index(0)+1)

Buggy submission (verdict: Runtime Error):
l=list(map(input().split()))
print(l.index(0))
Problem p02683 (python)

Fixed submission:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m,x=n1()
ca=n3(n)
ca

import itertools
book=list(itertools.product([0,1], repeat=n))
price=[]
for line in book:
    p=0
    for i in range(n):
        if line[i]==1:
            p+=ca[i][0]
            
    price.append(p)
A=[[book[i],price[i]] for i in range(len(book))]
A.sort(key=lambda x:x[1])

for line in A:
    t=line[0]
    s=[0]*m
    for i in range(n):
        if t[i]==1:
            s=[s[j]+ca[i][j+1] for j in range(m)]
    if len([i for i in s if i>=x])==m:
        print(line[1])
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m,x=n1()
ca=n3(n)
ca
ans=9999999999

import itertools
book=list(itertools.product([0,1], repeat=n))
price=[]
for line in book:
    p=0
    for i in range(n):
        if line[i]==1:
            p+=ca[i][0]
            
    price.append(p)
for i in range(len(book)):
    t=book[i]
    s=[0]*m
    for j in t:
        if t[j]==1:
            s=[s[k]+ca[j][k+1] for k in range(m)]
    if len([y for y in s if y>=x])==m:
        ans=min(ans,price[i])
if ans==9999999999:
    print(-1)
else:
    print(ans)
Problem p02691 (python)

Fixed submission:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

from collections import defaultdict
n=n0()
a=[0]
a.extend(n1())

m1=[i+a[i] for i in range(n+1)]
m2=[j-a[j] for j in range(n+1)]

d1=defaultdict(list)
d2=defaultdict(list)
for i in range(1,n+1):
    d1[m1[i]].append(i)
    d2[m2[i]].append(i)

ans=0
for i in d1:
    ans+=len(d1[i])*len(d2[i])
            
print(ans)

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

ans=0
for i in range(n):
    h=a[i]
    B=list(range(-i,-i+n))
    C=[0]*n
    for j in n:
        C[j]=abs(B[j])-A[j]-h
    ans+=C.count(0)
print(ans//2)

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

import numpy as np
n=n0()
a=n1()
A=np.array(a)

ans=0
for i in range(n):
    h=A[i]
    B=np.array(range(-i,-i+n))
    C=abs(B)-A-h
    ans+=n-np.count_nonzero(C)
print(ans//2)
Problem p02708 (python)

Fixed submission:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()

down=[0]*(n+1)
up=[0]*(n+1)
up[0]=n
ans=0 if k>1 else n+1
for i in range(1,n+1):
    down[i]=down[i-1]+i
    up[i]=up[i-1]+(n-i)
    if i>=k-1:
        ans+=up[i]-down[i]+1
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
c=n1()
ab=[(x[0],x[1]) for x in n3(n-1)]

import networkx as nx
G = nx.Graph()

G.add_nodes_from(range(1,n+1))
G.add_edges_from(ab)

path=[[x] for x in range(1,n+1)]
for i in range(1,n+1):
    path.extend(list(nx.all_simple_paths(G, source=i, target=[x for x in range(i+1,n+1)])))
path_color = [[c[x-1] for x in line] for line in path]
dict_color={i:0 for i in range(1,n+1)}
for x in path_color:
    for i in set(x):
        dict_color[i]+=1
for i in dict_color:
    print(dict_color[i])
Problem p02714 (python)

Fixed submission:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

# from math import comb
def comb(n,r):
    if r==2:
        return n*(n-1)//2
    else:
        return n*(n-1)*(n-2)//6
n=n0()
s=s0()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=0
for i in range(1,(n-1)//2+1):
    for j in range(0,n-2*i):
        ans+=1
        if s[j]==s[j+i]==s[j+2*i]:
            ans-=1
        elif s[j]==s[j+i] or s[j]==s[j+2*i] or s[j+i]==s[j+2*i]:
            ans-=1
            
ans+=comb(r,3)+comb(g,3)+comb(b,3)+comb(r,2)*(g+b)+comb(g,2)*(r+b)+comb(b,2)*(r+g)
print(comb(n,3)-ans)

Buggy submission (verdict: Runtime Error):
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

from math import comb

n=n0()
s=s0()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=0
for i in range(1,(n-1)//2+1):
    for j in range(0,n-2*i):
        ans+=1
#         print(j,j+1,j+i*2)
        if s[j]==s[j+i]==s[j+2*i]:
            ans-=1
        elif s[j]==s[j+i] or s[j]==s[j+2*i] or s[j+i]==s[j+2*i]:
            ans-=1
            
ans+=comb(r,3)+comb(g,3)+comb(b,3)+comb(r,2)*(g+b)+comb(g,2)*(r+b)+comb(b,2)*(r+g)
print(comb(n,3)-ans)
Problem p02717 (python)

Fixed submission:
a,b,c=[int(x) for x in input().split()]

print(c,a,b)

Buggy submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

a.sort()
a.reverse()

ans="Yes"
for i in range(m):
    if a[i]<sum(a)/(4*m):
        ans="No"
        break;
print(ans)
Problem p02718 (python)

Fixed submission:
n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

a.sort()
a.reverse()

ans="Yes"
for i in range(m):
    if a[i]<sum(a)/(4*m):
        ans="No"
        break;
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

a.sort()
a.reverse()

ans="Yes"
for i in range(m+1):
    if a[i]<sum(a)/(4*m):
        ans="No"
        break;
print(ans)
Problem p02732 (python)

Fixed submission:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

def comb(n):
    if n<=1:
        return 0
    if n==2:
        return 1
    return (n*(n-1))//2

from collections import Counter
c=Counter(a)
# print(c)
d={i:comb(j) for i,j in c.items()}
# print(d)
s=sum(d.values())
# print(s)

for i in a:
    print(s-d[i]+comb(c[i]-1))

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

def main()
    n=n0()
    a=n1()

    from math import factorial
    def comb(n):
        if n<=1:
            return 0
        if n==2:
            return 1
        return factorial(n)//(factorial(2)*factorial(n-2))

    c=[a.count(i) for i in range(1,n+1)]
    d=[comb(m) for m in c]
    s=sum(d)

    for i in range(n):
        print(s-d[a[i]-1]+comb(c[a[i]-1]-1))
if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

def main()
    n=n0()
    a=n1()

    from math import factorial
    def comb(n):
        if n<=1:
            return 0
        if n==2:
            return 1
        return factorial(n)//(factorial(2)*factorial(n-2))

    c=[a.count(i) for i in range(1,n+1)]
    d=[comb(m) for m in c]
    s=sum(d)

    for i in range(n):
        print(s-d[a[i]-1]+comb(c[a[i]-1]-1))
if __name__ == '__main__':
  	main()

Buggy submission (verdict: Runtime Error):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

def main()
    n=n0()
    a=n1()

    from math import factorial
    def comb(n):
        if n<=1:
            return 0
        if n==2:
            return 1
        return factorial(n)//(factorial(2)*factorial(n-2))

    c=[a.count(i) for i in range(1,n+1)]
    d=[comb(m) for m in c]
    s=sum(d)

    for i in range(n):
        print(s-d[a[i]-1]+comb(c[a[i]-1]-1))
if __name__ == '__main__':
Problem p02747 (python)

Fixed submission:
s=input()
 
ans="No"
if len(s)%2==0:
  if s=="hi"*(len(s)//2):
    ans="Yes"

print(ans)

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

ans="No"
if len(s)%2==0:
  if s=="hi"*(len(s)//2):
    ans="Yes"

print(ans
Problem p02801 (python)

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

Buggy submission (verdict: Runtime Error):
c=input()
l="qwertyuioplkjhgfdsazxcvbnm"
l.sort()
print(l[l.index(c)+1])
Problem p02811 (python)

Fixed submission:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right

k,x=n1()
print("Yes" if k*500>=x else "No")

Buggy submission (verdict: Runtime Error):


k,x=n1()
print("Yes" if k*500>=x else "No")
Problem p02909 (python)

Fixed submission:
s=input()
 
if s=="Sunny":
  a="Cloudy"
elif s=="Cloudy":
  a="Rainy"
else:
  a="Sunny"
print(a)

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

Sunny, Cloudy, Rainy

if s=="Sunny":
  a="Cloudy"
elif s=="Cloudy":
  a="Rainy"
else:
  a="Sunny"
print(a)
Problem p02922 (python)

Fixed submission:
a,b=[int(x) for x in input().split()]
 
c=1
ans=0
while True:
  if c>=b:
    break
  else:
    c+=a-1
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=[int(x) for x in input().split()]
 
c=1
ans=0:
while True:
  if c>=b:
    break
  else:
    c+=a-1
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=[int(x) for x in input().split()]

c=1
ans=0:
while True:
  if c>=b:
    break
  else:
    c+=a
    ans+=1
Problem p02934 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
 
ans=0
for i in a:
  ans+=1/i
print(1/ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]

ans=0
for i in range(a):
  ans+=1/i
print(1/ans)
Problem p02945 (python)

Fixed submission:
a,b=[int(x) for x in input().split()]
 
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a.b=[int(x) for x in input().split()]

print(max(a+b,a-b,a*b))
Problem p02995 (python)

Fixed submission:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
from fractions import gcd
# from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
a,b,c,d=n1()
a1=b//c
a2=(a-1)//c
b1=b//d
b2=(a-1)//d
l=lcm(c,d)
c1=b//l
c2=(a-1)//l
ans=a1-a2+b1-b2-c1+c2
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
# from fractions import gcd
from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
a,b,c,d=n1()
a1=b//c
a2=(a-1)//c
b1=b//d
b2=(a-1)//d
l=lcm(c,d)
c1=b//l
c2=(a-1)//l
ans=a1-a2+b1-b2-c1+c2
print(b-a+1-ans)
Problem p03455 (python)

Fixed submission:
a,b = [int(x) for x in input().split()]

if (a*b)%2==0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 and ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))
Problem p03457 (python)

Fixed submission:
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 or ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))

Buggy submission (verdict: Runtime Error):
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N+1):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 or ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))
Problem p03854 (python)

Fixed submission:
S=input()

l=len(S)

while True:
    if S[-7:]=="dreamer":
        S=S[:-7] 
    elif S[-6:]=="eraser":
        S=S[:-6]
    elif S[-5:]=="dream":
        S=S[:-5]
    elif S[-5:]=="erase":
        S=S[:-5]

    if l==len(S):
        break
    else:
        l=len(S)


if l==0:
    print("YES")
else:
    print("NO")

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

def func(S):
    if S[:7]=="dreamer":
        return min(func(S[5:]),func(S[7:]))
    elif S[:6]=="eraser":
        return min(func(S[5:]),func(S[6:]))
    elif S[:5]=="dream":
        return func(S[5:])
    elif S[:5]=="erase":
        return func(S[5:])
    
    return len(S) 
    

if func(S)==0:
    print("YES")
else:
    print("NO")
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if a*b%2==0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a*b%2==0:
    print("Even")
else:
    print("Odd")
Problem p02630 (python)

Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(a) for a in input().split()])
ans = sum(A)
lst = np.zeros(10**5+1)
for a in A:
    lst[a] += 1
   
for q in range(int(input())):
    B,C = map(int,input().split())
    ans += (C - B) * lst[B]
    print(int(ans))
    lst[C] += lst[B]
    lst[B] = 0

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

N = int(input())
A = np.array([int(a) for a in input().split()])
ans = sum(A)
lst = np.zeros(10**5)
for a in A:
    lst[a] += 1
   
for q in range(int(input())):
    B,C = map(int,input().split())
    ans += (C - B) * lst[B]
    print(int(ans))
    lst[C] += lst[B]
    lst[B] = 0

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

N = int(input())
A = np.array([int(a) for a in input().split()])
ans = sum(A)
lst = np.zeros(10**5)
for a in A:
    lst[a] += 1
   
for q in range(int(input())):
    B,C = map(int,input().split())
    ans += (C - B) * lst[B]
    print(int(ans))
    lst[C] += lst[B]
    lst[B] = 0
Problem p02647 (python)

Fixed submission:
from itertools import accumulate
#from operator import add

N,K = map(int,input().split())
A = map(int,input().split()) 
for k in range(K):
    B = [0] * N
    for i,x in enumerate(A):
        L = max(0, i-x)
        R = min(N-1, i+x)
        B[L] += 1
        if R+1 != N:
            B[R+1] -= 1
    #L = accumulate(B,add) 
    L = list(accumulate(B))[:]
    if L == A:
        break
    A = L
print(*A)

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

N,K,*A = map(int,open(0).read().split())
na = np.array(A)

for i in range(K):
    if all(na) == N:
        break
    B = [0] * N
    nb = np.array(B)
    for n in range(N):
        L = max(0, n-na[n])
        R = min(N-1 , n + na[n])
        nb[L] += 1
        if R+1 != N:
            nb[R+1] -= 1
      
    na = nb.cumsum()        
 
print(*na,sep=" ")

Buggy submission (verdict: Runtime Error):
N,K,*A = map(int,open(0).read().split())

for k in range(K):
    if len(set(A)) == 1:
        break
    B = [0] * N
    for n in range(N):
        L = max(0, n-A[n])
        R = min(N-1 , n + A[n])
        B[L] += 1
        if R+1 != N:
            B[R+1] -= 1
    
    ruiseki = [0] * N
    ruiseki[0] = B[0]
    for i in range(1,N):
        ruiseki[i] = ruiseki[i-1] + B[i]
        
    A = ruiseki[:]
print(*ruiseki,sep=" ")