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

Fixed submission:
import sys

s=str(input())

for i in range(len(s)):
    if i%2==0 and s[i]=="L":
        print("No")
        sys.exit(0)
    elif i%2==1 and s[i]=="R":
        print("No")
        sys.exit(0)

print("Yes")

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

for i in range(s):
    if i%2==0 and s[i]=="R":
        print("No")
    elif i%2==1 and s[i]=="L":
        print("No")
    else:
        print("Yes")

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

for i in range(S):
    if i%2==0 and s[i]=="R":
        print("No")
    elif i%2==1 and s[i]=="L":
        print("No")
    else:
        print("Yes")

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

if s[0] == "L" or s[2] == "L" or s[1] == "R" or s[3] =="R":
    print("No")
else:
    print("Yes")
Problem p02922 (python)

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

result=1
count=0
while result < b:
    result += a-1
    count += 1

print(count)

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

result=a
count=1
while result =< b:
    result += a-1
    count += 1

print(count)
Problem p02982 (python)

Fixed submission:
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt=0

for i in range(n):
    for j in range(i+1,n):
        distance=0
        for k in range(d):
            distance += (x[i][k]-x[j][k])**2
        if (distance**0.5).is_integer():
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            sum=0
            sum += (x[i][k]-x[j][k])**2
        route = sum**0.5
        if route.is_integer:
        cnt += 1
        
print(cnt)
Problem p02993 (python)

Fixed submission:
s=input()

cnt=0

for i in range(1,len(s)):
    if s[i]==s[i-1]:
        cnt += 1

if cnt >= 1:
    print("Bad")
else:
    print("Good")

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

cnt=0

for i in range(1,len(s):
    if s[i]==s[i-1]:
        cnt += 1

if cnt > 1:
    print("Bad")
else:
    print("Good")
Problem p03030 (python)

Fixed submission:
n=int(input())
d=[]

for i in range(n):
    s,p=input().split()
    d.append((s,100-int(p),i+1))

d.sort()
for i in range(n):
    print(d[i][2])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=0

for i in range(n):
    s,p=input().split()
    d.append(s,int(100-p),i)

d.sort()
for i in range(n):
    print(d[i][2])
Problem p03125 (python)

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

if b%a==0:
    print(a+b)
else:
    print(b-a)

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

if B%A==0:
    print(a+b)
else:
    print(b-a)
Problem p03323 (python)

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

if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")

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

if a > 8 or b > 8:
    print(":(")
else:
    priunt("Yay!")
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())

if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())

if abs(a,c)<=d or (abs(a-b)<=d and abs(b-c) <=d):
    print("Yes")
else:
    print("No")
Problem p03385 (python)

Fixed submission:
s=list(input())
s.sort()
s="".join(s)

if s=="abc":
    print("Yes")
else:
    print("No")

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

if s=="abc":
    print("Yes")
else:
    print("No")
Problem p03399 (python)

Fixed submission:
l=[int(input()) for _ in range(4)]
print(min(l[0],l[1])+min(l[2],l[3]))

Buggy submission (verdict: Runtime Error):
l=[int(input)for _ in range(n)]
print(min(l[0],l[1])+min(l[2],l[3]))
Problem p03455 (python)

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

if c % 2:
    print("Odd")

else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a, b = map(input().split())
c = a*b

if c%2 = 0:
    print("Even")

    else:
        print("Odd")
Problem p03485 (python)

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

if (a+b)%2==0:
    print((a+b)//2)    
else:
    print((a+b)//2+1)

Buggy submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())
c=math.floor((a+b)//2)
print(c)

import math

a,b=map(int,input().split())
c=math.floor((a+b)//2)
print(c)
Problem p03555 (python)

Fixed submission:
s1=input()
s2=input()

cnt=0
for i in range(len(s1)):
    if s1[i]==s2[-i-1]:
        cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s1=input()
s2=input()
s3=s2[::-1]

if s1=s3:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s1=input()
s2=input()

cnt=0
for i in range(len(l1)):
    print(l1[i])
    print(l2[-i-1])
    if l1[i]==l2[-i-1]:
        cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
l1=list(map(str,input().split()))
l2=list(map(str,input().split()))

cnt=0
for i in range(len(l1)):
    if l[i]==l[-i-1]:
        cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")

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

cnt=0
for i in range(len(l1)):
    if l[i]==l[-i-1]:
    cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")

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

cnt=0
for i in range(len(l1)):
    l[i]==l[-i-1]:
    cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
ad=abs(x-a)
bd=abs(x-b)

if ad > bd:
    print("B")
elif ad < bd:
    print("A")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
ad=abs(x-a)
bd=abs(x-b)

if ad > bd:
    print("A")
elif ad < bd
    print("B")
Problem p03693 (python)

Fixed submission:
r,g,b = map(int, input().split())

t=r*100+g*10+b

if t % 4 ==0:
    print("YES")
else:
     print("NO")

Buggy submission (verdict: Runtime Error):
r,g,b = map(int, input().split())

t=r*100+g*10+b

if t % 4 ==0:
    print("YES")
    else:
        print("NO")
Problem p02690 (python)

Fixed submission:
X = int(input())
# X = 1
stopFlag = 0
for i in range (-201, 201):
    a = i
    for j in range(-201, 201):
        if a**5 - j**5 == X:
            print (a, j)
            stopFlag = 1            
        if stopFlag:
            break
    if stopFlag:
        break

Buggy submission (verdict: Runtime Error):
X = int(input())
# X = 1

B = 0
while(True):
    B5 = B**5
    C5 = (-B)**5
    A5 = (X + B5)**0.2
    A5r = (X + C5)**0.2
    if A5 == round(A5,0):
        print (int(A5), int(B5))
        break
    if A5r ==  round(A5r,0):
        print (int(A5r), int(C5))
        break
    B += 1
Problem p02708 (python)

Fixed submission:
N, K = map(int, input().split())
sumR = 0
for i in range(K, N+2):
    front = i*(2*N + 2 - i + 1)/2
    rear = i*(i+1)/2
    number = front - rear + 1
#    print (i)
#    print (number)
    sumR += number
print (int(sumR%(1000000007)))

Buggy submission (verdict: Runtime Error):
N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, i+8):
#        print (i, j)
        number = int(str(N[i:j]))
        if number%2019 == 0:
            count +=1
            break


print (count)

Buggy submission (verdict: Runtime Error):
N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, i+8):
#        print (i, j)
        number = int(str(N[i:j]))
#        if number%2019 == 0:
#            count +=1
#            break
#            print (i, j)
#T = int(N)//2019
#
#for t in range (T):
#    den = 2019*t
#    length = len(str(den))
#    sum_length = len(N)
#    for i in range(sum_length-length):
#        if den == int(N[i:i+length]):
#            count +=1

print (count
Problem p02709 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a, i) in enumerate(ABI):
    curr = [0]*(k+2)
    for l in range(k+1):
        curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))
        curr[l+1] = prev[l]+a*abs(i-l-1)
    prev = curr
print (max(prev))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = np.array(list(map(int,input().split())))
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a, i) in enumerate(ABI)
    curr = [0]*(k+2)
    for l in range(k+1):
        curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))
        curr[l+1] = prev[l]+a*abs(i-l-1)
    prev = curr
print (max(prev))

Buggy submission (verdict: Runtime Error):
N = int(input())
stuff = list(map(int,input().split()))
#stuff = [5, 5, 6, 1, 1, 1]
junban = list(range(N))

max_happness = 0
for subset in permutations(junban):
    happness = 0
    newjunban = (list(subset))
    for i in range(len(junban)):
        happness +=stuff[i]*abs(newjunban[i]-i)
    if happness>max_happness:
        max_happness = happness
print (max_happness)
Problem p02691 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
self_front = [0]*(2*(10**5)+3)
for i in range(N):
    if(i-A[i] >= 0):
        self_front[i-A[i]] += 1
cnt = 0
for i in range(N):
    if(i+A[i] < 2*(10**5)+3):
        cnt += self_front[i+A[i]]
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
self_front = [0]*(2*(10**5)+3)
for i in range(N):
    if(i-A[i] >= 0):
        self_front[i-A[i]] += 1
cnt = 0
for i in range(N):
    cnt += self_front[i+A[i]]
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
self_front = [0]*(2*(10**5))
self_back = [0]*(2*(10**5))
for i in range(N):
    if(i-A[i] >= 0):
        self_front[i-A[i]] += 1
cnt = 0
for i in range(N):
    cnt += self_front[i+A[i]]
print(cnt)
Problem p02730 (python)

Fixed submission:
S = input()
N = len(S)
def kaibun(s,n):
    for i in range(n//2):
        if(s[i]!=s[n-i-1]):
            return False
    return True

if(kaibun(S,N) & kaibun(S[0:(N+1)//2-1],N//2) & kaibun(S[N:(N+3)//2-2:-1],N//2)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
def kaibun(s,n):
    for i in range(n//2):
        if(s[i]!=s[n-i-1]):
            return false
    return true

if(kaibun(S,N) & kaibun(S[0:(N+1)//2-1],N//2) & kaibun(S[N:(N+3)//2-2:-1],N//2)):
    print("Yes")
else:
    print("No")
Problem p03047 (python)

Fixed submission:
n,k=map(int, input().split())
print (n-(k-1))

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
print (n-(k-1))
Problem p03262 (python)

Fixed submission:
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
D = abs(x[0]-X)
for i in range(1,N):
    D = fractions.gcd(D, abs(X-x[i]))
print(D)

Buggy submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))
D = abs(x[0]-X)
for i in range(1,N):
    D = math.gcd(D, abs(X-x[i]))
print(D)
Problem p03352 (python)

Fixed submission:
X = int(input())
ans=0
for p in range(2,10):
    for b in range(1,32):
        if(b**p <= X and ans < b**p):
            ans = b**p
print(ans)

Buggy submission (verdict: Runtime Error):
X = int(input())
while(1):
    for i in range(2,11):
        f = pow(X,1.0/float(i))
        if(1-f%1<=10**-8):
            print(X)
            exit()
    X-=1
Problem p03160 (python)

Fixed submission:
N=int(input())
his=list(map(int,input().split()))
DP=[]
DP.append(0)
DP.append(abs(his[0]-his[1]))
for i in range(2,N):
  DP.append(min(DP[i-1]+abs(his[i-1]-his[i]),DP[i-2]+abs(his[i-2]-his[i])))
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
his=[int(input()) for i in range(N)]
DP=[]
DP.append(0)
DP.append(abs(his[0]-his[1]))
for i in range(2,N):
  DP.append(min(DP[i-1]+abs(his[i-1]-his[i]),DP[i-2]+abs(his[i-2]-his[i])))
print(DP)

Buggy submission (verdict: Runtime Error):
N=int(input())
his=list(int,input().split())
DP=[]
DP.append(0)
DP.append(his[0]-his[1])
for i in range(2,len(his)):
  DP.append(max(DP[i-1]-his[i],DP[i-2])
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
his=input().split()
DP=[]
DP.append(0)
DP.append(his[0]-his[1])
for i in range(2,len(his)):
  DP.append(max(DP[i-1]-his[i],DP[i-2])
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
his=input().split()
DP=[]
DP.append(0)
DP.append(his[0]-his[1])
for i in range(2,len(his)):
  DP.append(max(DP[i-1]-his[i],DP[i-2])
print(DP[-1]
Problem p02705 (python)

Fixed submission:
N = float(input())
 
print(2*N*3.1416)

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

print(2*N*3.1416)
Problem p02708 (python)

Fixed submission:
NK = list(map(int, input().split()))
N = NK[0]; K = NK[1]
 
result = 0
for i in range(K,N+2):
    result += i*(N-i+1) +1
    result = result%1000000007
 
print(result)

Buggy submission (verdict: Runtime Error):
N = list(map(int, input().split()))
N = NK[0]; K = NK[1]

result = 0
for i in range(K,N+2):
    result += i*(N-i+1) +1

print(result)
Problem p02761 (python)

Fixed submission:
import sys
 
nmlist = list(map(int, input().split()))
N = nmlist[0]
M = nmlist[1]
order_list = [list(map(int, input().split())) for _ in range(M)]
 
Number = [0,0,0]
cnt = 0

for k in range(M):
    if N==1 and order_list[k] == [1,0]:
        cnt += 1
 
if cnt == M and cnt>0:
    print(0)
    sys.exit()
for j in range(M):
    if order_list[j][0] > N:
        print(-1)
        sys.exit()
    if order_list[j][0] == 1 and order_list[j][1] == 0:
        print(-1)
        sys.exit()
 
for i in range(M):
    if Number[order_list[i][0]-N+2] != 0 and Number[order_list[i][0]-N+2] != order_list[i][1]:
        print(-1)
        sys.exit()
    Number[order_list[i][0]-N+2] = order_list[i][1]
 
if N == 1 and Number[0]+Number[1]+Number[2] == 0:
    print(0)
    sys.exit()
 
if Number[3-N] == 0:
    Number[3-N] = 1
 
print(100*Number[0]+10*Number[1]+Number[2])

Buggy submission (verdict: Runtime Error):
import sys

nmlist = list(map(int, input().split()))
N = nmlist[0]
M = nmlist[1]
order_list = [list(map(int, input().split())) for _ in range(M)]

cnt = 0

for k in range(M):
    if order_list[k] == [1,0]:
        cnt += 1

if cnt == M:
    print(0)
    sys.exit()

for j in range(M):
    if order_list[j][0] > N:
        print(-1)
        sys.exit()
    if order_list[j][0] == 1 and order_list[j][1] == 0:
        print(-1)
        sys.exit()

for i in range(M):
    if Number[order_list[i][0]-N+2] != 0 and Number[order_list[i][0]-N+2] != order_list[i][1]:
        print(-1)
        sys.exit()
    Number[order_list[i][0]-N+2] = order_list[i][1]

if Number[3-N] == 0:
    Number[3-N] = 1

print(100*Number[0]+10*Number[1]+Number[2])
Problem p02767 (python)

Fixed submission:
N = int(input())
coordinate = list(map(int, input().split()))
result = 0
resultl = 0
 
for j in range(N):
    result += (1-coordinate[j])**2
    
for i in range(1,101):
    for k in range(N):
        resultl += (i-coordinate[k])**2
 
    if resultl < result:
        result = resultl
    resultl = 0
    
print(result)

Buggy submission (verdict: Runtime Error):
N = input()
coordinate = list(map(int, input().split()))
result = 0
resultl = 0

for j in range(N):
    result += (1-coordinate[j])**2

for i in range(1,101):
    for k in range(N):
        resultl += (i-coordinate[k])**2

    if resultl < result:
        result = resultl
    resultl = 0

print(result)
Problem p02778 (python)

Fixed submission:
S = str(input())
result = []
 
for i in range(len(S)):
  result.append('x')
 
result = ''.join(result)
print(result)

Buggy submission (verdict: Runtime Error):
S = str(input())
result = []

for i in range(len(S)):
  result.append(x)

result = ''.join(result)
print(result)
Problem p02786 (python)

Fixed submission:
N = int(input())
cnt = 0

while N>1:
    N = int(N/2)
    cnt +=1

print(2**(cnt+1)-1)

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

while N>1:
    N = int(N/2)
    cnt +=1

print(2**(cnt+1)-1)
Problem p02791 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
 
result = 0
mini = [P[0]]
 
for i in range(N-1):
    if mini[i]>P[i+1]:
        mini.append(P[i+1])
    else:
        mini.append(mini[i])
 
for i in range(N):
    if P[i]==mini[i]:
        result += 1
 
print(result)

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

result = 0
mini = [P[0]]

for i in range(N-1):
    if mini[i]>P[i+1]:
        mini.append(P[i+1])
    else:
        mini.append(mini[i])

for i in range(N):
    if P[i]==mini[i]:
        result += 1

print(result)
Problem p02817 (python)

Fixed submission:
ST = list(map(str, input().split()))
 
print(ST[1]+ST[0])

Buggy submission (verdict: Runtime Error):
ST = list(map(str, inpuy().split()))

print(ST[1]+ST[0])
Problem p02747 (python)

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if len(S) % 2 == 1:
        print(NO)
        exit()
    n = 0
    while n != len(S):
        if S[n] == "h" and S[n+1] == "i":
            n += 2
        else:
            break
    if n == len(S):
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    n = 0
    while n != len(S):
        if n % 2 == 1:
            break
        if S[n] == "h" and S[n+1] == "i":
            n += 2
        else:
            break
    if n == len(S):
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    n = 0
    while n != len(S):
        if S[n] == "h" and S[n+1] == "i":
            n += 2
        else:
            break
    if n == len(S):
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
Problem p02861 (python)

Fixed submission:
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
print(ans*2/n)

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

ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += ((xy[i][0] - xy[i][1])**2 + (xy[j][0] - xy[j][1])**2)**0.5
print(ans*2/n)

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

ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += pow(pow(xy[i][0] - xy[i][1],2) + pow(xy[j][0] - xy[j][1],2),0.5)
print(ans*2/n)
Problem p02936 (python)

Fixed submission:
n, q = list(map(int, input().split()))
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b= list(map(int, input().split()))
    tree[a-1].append(b-1)
s = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    s[p-1] += x

queue = [0]

while(len(queue) != 0):
    n = queue.pop()
    for i in range(len(tree[n])):
        s[tree[n][i]] += s[n]
        queue.append(tree[n][i])
# def f(n):
#     global s
#     for i in range(len(tree[n])):
#         s[tree[n][i]] += s[n]
#         f(tree[n][i])
#
# f(0)

print(" ".join(list(map(str, s))))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n, q = list(map(int, input().split()))
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b= list(map(int, input().split()))
    tree[a-1].append(b-1)
s = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    s[p-1] += x


def f(n):
    global s
    for i in range(len(tree[n])):
        s[tree[n][i]] += s[n]
        f(tree[n][i])



f(0)

print(" ".join(list(map(str, s))))
Problem p03006 (python)

Fixed submission:
N = int(input())
if N == 1:
    print(1)
    exit()

x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

l = {}

for i in range(N):
    for j in range(i + 1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        if p < 0:
            p = -p
            q = -q
        if p == 0:
            q = abs(q)
        if str([p, q]) in l:
            l[str([p, q])] += 1
        else:
            l[str([p, q])] = 1

print(N - max(l.values()))

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

l = {}

for i in range(N):
    for j in range(i + 1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        if p < 0:
            p = -p
            q = -q
        if str([p, q]) in l:
            l[str([p, q])] += 1
        else:
            l[str([p, q])] = 1

print(N - max(l.values()))
Problem p03061 (python)

Fixed submission:

import fractions
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
y = [0] * N
tmp = A[0]
for i in range(1, N):
    t = fractions.gcd(tmp, A[i])
    x[i] = int(tmp / t)
    tmp = t
tmp = A[N - 1]
for i in range(N - 2, -1, -1):
    t = fractions.gcd(tmp, A[i])
    y[i] =  int(tmp / t)
    tmp = t
m = 0
for i in range(1, N - 1):
    a = fractions.gcd(x[i], y[i])
    if m < a:
        m = a
print(tmp * max(m, y[0], x[N - 1]))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
y = [0] * N
tmp = A[0]
for i in range(1, N):
    t = math.gcd(tmp, A[i])
    x[i] = int(tmp / t)
    tmp = t
tmp = A[N - 1]
for i in range(N - 2, -1, -1):
    t = math.gcd(tmp, A[i])
    y[i] =  int(tmp / t)
    tmp = t
m = 0
for i in range(1, N - 1):
    a = math.gcd(x[i], y[i])
    if m < a:
        m = a
print(tmp * max(m, y[0], x[N - 1]))
Problem p03085 (python)

Fixed submission:
b = input()
tmp = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
print(tmp[b])

Buggy submission (verdict: Runtime Error):
N, Q = list(map(int, input().split()))
S = input()
l = [0] * Q
r = [0] * Q
for x in range(Q):
    l[x], r[x] = list(map(int, input().split()))

isAC = [0] * len(S)
for x in range(len(S) - 1):
    if S[x] == "A" and S[x + 1] == "C":
        isAC[x] = 1

for x in range(Q):
    ans = 0
    cut_isAC = isAC[l[x] - 1:r[x] - 1]
    for y in range(len(cut_isAC)):
        ans += cut_isAC[y]
    print(ans)