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

Fixed submission:
a=list(input())
b=list(input())
from collections import Counter
def f(s):
    return sorted(Counter(s).values())
if f(a)==f(b):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
list(input())
t=list(input())
a=[0]*27
for i in range(len(s)):
  if a[ord(s[i])-96]==0:
    a[ord(s[i])-96]=ord(t[i])-96
  elif a[ord(s[i])-96]==ord(t[i])-96:
    continue
  else:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=[0]*26
for i in range(len(s)):
  if a[ord(s[i])]==0:
    a[ord(s[i])]=ord(t[i])
  elif a[ord(s[i])]==ord(t[i]):
    continue
  else:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=[0]*26
for i in range(len(s)):
  if a[ord(s[i])]==0:
    a[ord(s[i])]=ord(t[i])
  elif a[ord(s[i])]==ord(t[i]):
    continue
  else:
    print("No")
    exit()
Problem p03326 (python)

Fixed submission:
from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip(*t)):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip((*t))):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
s=[]
tt=[]
n,m=map(int,input().split())
for i in range(n):
    a,b,c=map(int,input().split())
    s.append([a,b,c])
import itertools
t=list(itertools.permutations(s,m))
for i in t:
    total=np.zeros((3))
    for j in range(m):
        total+=np.array(i[j])
        tt.append(abs(total[0])+abs(total[1])+abs(total[2])//1)
print(int(max(tt)))
Problem p03329 (python)

Fixed submission:
n=int(input())
s=[]
t=1000
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
        t=min(t,b+a)
    if t>=b+1:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(t)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[]
t=1000
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
    t=min(t,b+a)
    if t>=b+1:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(t)
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
if N%2==0:
    print(N/2)
else:
    print((N+1)/2)
Problem p02623 (python)

Fixed submission:
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
a,b = [0],[0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
 
ans,j = 0,m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy

N, M, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

A_time = []
B_time = []

if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)
else:
    #A_res = list(numpy.cumsum(A))
    #B_res = list(numpy.cumsum(B))

    books = []

    for i in range(len(A)):
        A_sum = sum(A[0:i+1])
        if A_sum > K:
            break
        res = K - A_sum

        for j in range(M+1, 0, -1):
            B_sum = sum(B[0:j])
            if B_sum in B:
                books.append(i + j + 1)
                break
    print(max(books))

Buggy submission (verdict: Runtime Error):
import numpy
 
N,M,K = [int(i) for i in input().split()]
A= [int(i) for i in input().split()]
B= [int(i) for i in input().split()]
 
A_time = []
B_time = []
 
if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)
else:
    A_res = list(numpy.cumsum(A))
    B_res = list(numpy.cumsum(B))
 
    books = []
 
    for i in range(len(A_res)):
        if A[i] > K:
            break
        res = K - A[i]

        for b_best in range(int(res), 0, -1):
            if b_best in B_res:
                books.append(i + B_res.index(b_best) + 1)
                break
    print(max(books))

Buggy submission (verdict: Runtime Error):
import numpy

N,M,K = [int(i) for i in input().split()]
A= [int(i) for i in input().split()]
B= [int(i) for i in input().split()]

A_time = []
B_time = []

if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)
else:
    A_res = numpy.cumsum(A)
    B_res = numpy.cumsum(B)

    books = []

    for i in range(len(A_res)):
        if A[i] > K:
            break
        res = K - A[i]
        tmp = 0
        for j in range(1,len(B_res)):
            if B[j] > res:
                books.append(i + tmp + 1)
                break
            tmp = j
    print(max(books))

Buggy submission (verdict: Runtime Error):
N,M,K = [int(i) for i in input().split()]
A= [int(i) for i in input().split()]
B= [int(i) for i in input().split()]

if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)

else:
    books = []
    for i in range(N):
        a_num = i+1
        a_time = sum(A[0:a_num+1])
        b_time = 0
        for j in range(M):
            if a_time + b_time + B[j] > K and a_time + b_time < K:
                books.append( i + j + 2)
                break
            b_time += B[j]

   
    print(max(books))
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b_new = int(b.replace('.',''))
ans = (a * b_new)// 100
print(ans)

Buggy submission (verdict: Runtime Error):
s = input().split()
s = [float(i) for i in s]

#delete numbers under 0.001 order
tmp = int((s[0] * int(s[1]*100) /100)
print(tmp)
Problem p02688 (python)

Fixed submission:
n,k=map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
  input()
  a=list(map(int,input().split()))
  for j in a:
    if j in ans:
      ans.remove(j)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
    input()
	a=list(map(int,input().split()))
	for j in a:
      if j in ans:
        ans.remove(j)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
	a=list(map(int,input().split()))
	for j in a:
      if j in ans:
        ans.remove(j)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
    input()
	a=list(map(int,input()))
	for j in a:
      if j in ans:
        ans.remove(j)
print(len(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans = [i for i in range(1,n+1)]
for i in range(k):
	a=list(map(int,input()))
	for j in a:
      if j in ans:
        ans.remove(j)
print(len(ans))
Problem p02689 (python)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1].append(b-1)
  x[b-1].append(a-1)
c=0
for i in range(n):
  f=1
  maxh=0
  for j in x[i]:
    maxh=max(maxh,h[j])
  if maxh>=h[i]:
    f=0
  c+=f
print(c)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
h=list(map,input().split())
x=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1].append(b-1)
  x[b-1].append(a-1)
c=0
for i in range(n):
  f=1
  maxh=0
  for j in x[i]:
    maxh=max(maxh,h[j])
  if maxh>=h[i]:
    f=0
  c+=f
print(c)
Problem p02693 (python)

Fixed submission:
a=int(input())
b,c=map(int,input().split())
if c-b>=c%a:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input())
if c-b>=c%a:
  print("Yes")
else:
  print("No")
Problem p02711 (python)

Fixed submission:
print(["No","Yes"][int("7" in input())])

Buggy submission (verdict: Runtime Error):
print(["No","Yes"][int("7" in input())]
Problem p02712 (python)

Fixed submission:
n=int(input())
a=0
k=n//15
a+=60*k**2
while not 0==n%15:
  if not n%3==0 and not n%5==0:
    a+=n
  n-=1
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
k=n//15
a+=60*k**2
While 0==n%15:
  if not n%3==0 and not n%5==0:
    a+=n
  n-=0
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
k=n//15
a+=60*k**2
While 0=n%15:
  if not n%3=0 and not n%5=0:
    a+=n
  n-=0
print(a)
Problem p02987 (python)

Fixed submission:
s=sorted(input())
if s[0]==s[1] and s[2] == s[3] and s[1]!=s[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=sorted(input())
if s[0]==s[1] and s[2]: == s[3] and s[1]!=s[2]:
  print("Yes")
else:
  print("No")
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
s=s[:k-1]+s[k-1].lower()+s[k:]
print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s[k]=s[k-1].lower()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s[k]=lower(s[k])
Problem p03042 (python)

Fixed submission:
i=input()
l,m=map(int,[i[:2],i[2:]])
my=int(1<=l and l<=12)
ym=int(1<=m and m<=12)<<1
print(["NA","MMYY","YYMM","AMBIGUOUS"][my+ym])

Buggy submission (verdict: Runtime Error):
i=input()
l,m=map(int,[i[:2],i[2:]])
my=int(1<=l and l<=12)
ym=int(1<=m and m<=12)<<1
print(["NA","MMYY","YYMM","AMBIGUOUS"][my+ym]
Problem p03072 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
count=0
for i in range(k):
  j=int(input())
  a.append(j)
  if max(a)<=j:count+=1
print(count)
Problem p03075 (python)

Fixed submission:
a=input()
for i in range(3):
  input()
e=input()
k=input()
if int(e)-int(a)<=int(k):
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a=input()
for i in range(3):
  input()
e=input()
k=input()
if e-a<=k:
  print("Yay!")
else:
  print(":(")
Problem p02659 (python)

Fixed submission:
a,b = input().split()
a = int(a)
b = round(float(b)*100)
print((a*b)//100)

Buggy submission (verdict: Runtime Error):
a,b = input().split()
a = int(a)
b = float(b*100)
print((a*b)//100)
Problem p02793 (python)

Fixed submission:
# coding:utf-8
from fractions import gcd

def calc_lcm(a, b):
    return (a * b) // gcd(a, b)

N = int(input())
A = [int(n) for n in input().split(' ')]
div_n = 10 ** 9 + 7
min_a = min(A)
lcm = A[0]

for a in A:
    lcm = calc_lcm(lcm, a)

if min_a == lcm:
    print((1*N) % div_n)
else:
    stack = 0
    for a in A:
        stack += lcm // a
    print(stack % div_n)

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

N = int(input())
A = [int(n) for n in input().split(' ')]
div_n = 10 ** 9 + 7
min_a = min(A)
lcm = A[0]

for a in A:
    lcm = np.lcm(lcm, a)

if min_a == lcm:
    print((1*N) % div_n)
else:
    stack = 0
    for a in A:
        stack += lcm // a
    print(stack % div_n)
Problem p03053 (python)

Fixed submission:
h,w= map(int, input().split())
s_list = []
b_list = []
for i in range(h):
    li = input()
    aa = []
    for j in range(w):
        aa.append(li[j])
        if aa[j] == '#':
            b_list.append((i, j))
    s_list.append(aa)
ans = 0
while True:
    bb_list = []
    for p in b_list:
        pp = [(p[0]-1, p[1]), (p[0]+1, p[1]), (p[0], p[1]-1), (p[0], p[1]+1)]
        for ppp in pp:
            if (0 <= ppp[0] < h) and (0 <= ppp[1] < w):
                if s_list[ppp[0]][ppp[1]] == '.':
                    s_list[ppp[0]][ppp[1]] = '#'
                    bb_list.append((ppp[0], ppp[1]))
    # ここで複数回同じbをやらなくて済むようにしている
    b_list = bb_list
    if len(b_list) == 0:
        break
    ans += 1
    # print(x)
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
c_list = list()
for i in range(H):
  b_list = list(map(lambda x: x, input()))
  for w in range(W):
    if b_list[w] == '#':
      c_list.append([i, w])

ans_ll = []

for h in range(H):
  for w in range(W):
    if not [h, w] in c_list:
      ans_list = list()
      for c in c_list:
        ans_list.append(abs(h-c[0]) + abs(w-c[1]))
      ans_ll.append(min(ans_list))
print(max(ans_ll))
Problem p03250 (python)

Fixed submission:
nums = list(map(int, input().split()))
nums.sort()
nums.reverse()
num = nums[0]*10 + nums[1] + nums[2]
print(num)

Buggy submission (verdict: Runtime Error):
n, m, X, Y = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))
xlist.sort()
ylist.sort()

if xlist[-1] <= ylist[0]:
   for i in range(xlist[-1]+1, ylist[0]+1):
      if X < i and i <= Y:
          print("No War")
          break
else:
   print("War")
Problem p02762 (python)

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

n,m,k = map(int,input().split())
parent_of = [-1 for _ in range(n)]
#print(parent_of)
def root_of(x):
	if parent_of[x] < 0:
		return x
	else:
		parent_of[x] = root_of(parent_of[x])
		return parent_of[x]

def unite(x,y):
	top_root_x = root_of(x)
	top_root_y = root_of(y)
	if top_root_x == top_root_y:
		return False
	if parent_of[top_root_x] > parent_of[top_root_y]:
		top_root_x,top_root_y = top_root_y,top_root_x
	#print(parent_of[top_root_y])
	parent_of[top_root_x] += parent_of[top_root_y]
	parent_of[top_root_y] = top_root_x
	return True

def size_of(x):
		return -parent_of[root_of(x)]

def is_same(x,y):
	return root_of(x) == root_of(y)

friend_list = [-1] * n
for _ in range(m):
	a,b = map(int,input().split())
	a -= 1
	b -= 1
	friend_list[a] -=1
	friend_list[b] -=1
	unite(a,b)

for _ in range(k):
	c,d = map(int,input().split())
	c -= 1
	d -= 1
	if root_of(c) == root_of(d):
		friend_list[c] -= 1
		friend_list[d] -= 1
for i in range(n):
	friend_list[i] += size_of(i)
	#print(size_of(i))
print(*friend_list)

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

n,m,k = map(int,input().split())
parent_of = [-1 for _ in range(n)]
#print(parent_of)
def root_of(x):
	if parent_of[x] < 0:
		return x
	else:
		parent_of[x] = root_of(parent_of[x])
		return parent_of[x]

def unite(x,y):
	top_root_x = root_of(x)
	top_root_y = root_of(y)
	if top_root_x == top_root_y:
		return False
	if parent_of[top_root_x] > parent_of[top_root_y]:
		top_root_x,top_root_y = top_root_y,top_root_x
	#print(parent_of[top_root_y])
	parent_of[top_root_x] += parent_of[top_root_y]
	parent_of[top_root_y] = top_root_x
	return True

def size_of(x):
		return -parent_of[root_of(x)]

def is_same(x,y):
	return root_of(x) == root_of(y)

friend_list = [-1] * n
for _ in range(m):
	a,b = map(int,input().split())
	a -= 1
	b -= 1
	friend_list[a] -=1
	friend_list[b] -=1
	unite(a,b)

for _ in range(k):
	c,d = map(int,input().split())
	c -= 1
	d -= 1
	if root_of(c) == root_of(d):
		block_list[c] -= 1
		block_list[d] -= 1
for i in range(n):
	friend_list[i] += size_of(i)
	#print(size_of(i))
print(*friend_list)
Problem p02862 (python)

Fixed submission:
x,y = map(int,input().split())
m = 10**9+7
if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3):
    print(0);exit()

def comb(n,k):
    #if 2 * k > n:
        #k = n - k
    a = 1
    for i in range(1,k+1):
        a *= (n - ( i - 1)) * pow(i,m-2,m)
        a = a%m
    return a

n = (x+y)//3
k = x-n
print(comb(n,k))

Buggy submission (verdict: Runtime Error):
from collections import deque
p = 10**9+7
x,y = map(int,input().split())
x += 1 ; y += 1
map_a=[[0]*y for _ in range(x)]
d = [(2,1),(1,2)]
que = deque()
que.append((0,0))

map_a[0][0] = 1

while que:
    a,b = que.popleft()
    for u,v in d:
        m = a + u ; n = b + v
        if 0<=m<x and 0<=n<y:
            map_a[m][n] += map_a[a][b]%p
            que.append((m,n))

print(map_a[-1][-1])

Buggy submission (verdict: Runtime Error):
from collections import deque
p = 10**9+7
x,y = map(int,input().split())
x += 1 ; y += 1
map_a=[[0]*y for _ in range(x)]
d = [(2,1),(1,2)]
que = deque()
que.append((0,0))

map_a[0][0] = 1

print(map_a)
while que:
    a,b = que.popleft()
    for u,v in d:
        m = a + u ; n = b + v
        if 0<=m<x and 0<=n<y:
            map_a[m][n] += map_a[a][b]%p
            que.append((m,n))

print(map_a[-1][-1])
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())

n,m = inpm()
dp = [0] * (n+2)
for _ in range(m):
    a = int(input())
    dp[a] = -1

# init
dp[0] = 1
# start
for i in range(n):
    if dp[i] == -1:continue
    dp[i] %= mod
    if dp[i+1] != -1:
        dp[i+1] += dp[i]
    if dp[i+2] != -1:
        dp[i+2] += dp[i]
print(dp[n]%mod)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())

n,m = inpm()
dp = [0] * (n+2)
for _ in range(m):
    a = int(input())
    dp[a] = -1

# init
dp[0] = 1
# start
print(a)
for i in range(n):
    if dp[i] == -1:continue
    dp[i] %= mod
    if dp[i+1] != -1:
        dp[i+1] += dp[i]
    if dp[i+2] != -1:
        dp[i+2] += dp[i]

print(dp[n]%mod)
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b = map(int, input().split())
for i in range(a,b+1):
    if i%k == 0:
        print('OK')
        exit()
print('NG')

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
from collections import deque
import copy
def lis(A: list):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            # Lの末尾よりaが大きければ増加部分列を延長できる
            L.append(a)
        else:
            # そうでなければ、「aより小さい最大要素の次」をaにする
            # 該当位置は、二分探索で特定できる
            L[bisect_left(L, a)] = a
    return len(L)
n = int(input())
a = tuple(map(int, input().split()))
G = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v = map(int, input().split())
    G[u].append(v)
    G[v].append(u)

letu = [[] for _ in range(n+1)]
letu[1].append(1)
que = deque([1])

while que:
    q = que.popleft()

    for nq in G[q]:
        let = copy.deepcopy(letu[q])
        if letu[nq] != []: #seen配列としても使う。seenないと閉路でWA
            continue
        let = let + [nq]
        letu[nq] = let
        que.append(nq)
for j in range(1,n+1):
    tmp = [a[aa-1] for aa in letu[j]]
    print(lis(tmp))
Problem p02835 (python)

Fixed submission:
a = list(map(int, input().split()))
if sum(a) > 21:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
N  = int(input())
testimony = [[]for i in range(N)]
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1,state])#3次元配列の作り方
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if(i>>j)&1 == 1:
            for x,y in testimony[j]:#3次元リストからx,yを取り出す書きかた　覚える
                if (i>>x)&1 != y: #正直といっているがそうではない　と　嘘つきといっているがそうではない　の二つ同時
                    flag =1
                    break
    if flag == 0:
        honest = max(honest, bin(i)[2:].count('1'))# bin()で二進数に変換　最初の二文字は0bで取り除く count('1')で数える
print(honest)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
print(s if a>=3200 else 'red')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(300000) #上限上げないと引っかかる
n,q = map(int, sys.stdin.readline().rstrip().split())
sco = [0]*(n+1)
G =[[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int, sys.stdin.readline().rstrip().split())
    G[a].append(b)
    G[b].append(a)

for j in range(q):
    p,x = map(int, sys.stdin.readline().rstrip().split())
    sco[p]+=x


#本体
seen = [False for _ in range(n+1)]
def dfs(G,V,score):
    global sco
    sco[V] +=score

    seen[V] = True
    for next_V in G[V]:
        if (seen[next_V]):
            continue
        dfs(G, next_V,sco[V])

#入力受け取り
#例
dfs(G,1,0)
print(*sco[1:])
#単にdfs(G,0)だと、木構造でないとき(頂点1つでない時)不正解

Buggy submission (verdict: Runtime Error):
a,s = map(int, open(0).read().split())
print(s if a>=3200 else 'red')
Problem p02873 (python)

Fixed submission:
def calc(n):
    return n * (n+1) / 2

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        prev = S[i]
        series = 1

l.append((prev, series))

prev_max = l[0][1]
prev = calc(prev_max)
res = prev

for s, n in l[1::]:
    if s == '<':
        prev = calc(n)
        prev_max = n
        res += prev
    else:
        if n >= prev_max:
            res -= prev_max
            prev = calc(n)
            res += prev
        else:
            prev = calc(n-1)
            res += prev

print(int(res))

Buggy submission (verdict: Runtime Error):
import math

S = list(input())

prev = S[0]
series = 1
l = []

for i in range(1, len(S)):
    if prev == S[i]:
        series += 1
    else:
        l.append((prev, series))
        series = 1


prev_max = l[0][1]-1
prev = math.factorial(l[0][1]-1)
res = prev

for s, n in range(len(l)):
    if s == '<':
        prev = math.factorial(n-1)
        prev_max = n-1
        res += prev
    else:
        if n-1 > prev_max:
            prev = math.factorial(n-2)
            res += prev
        else:
            res -= prev_max
            prev = math.factorial(n-1)
            res += prev

print(res)
Problem p03805 (python)

Fixed submission:
def bfs(u):
  if used.count(True) == N:
    res[0] += 1
    return
  for v in adj[u]:
    if used[v]:
      continue
    used[v] = True
    bfs(v)
    used[v] = False

N, M = map(int, input().split())
adj = [[] for i in range(N)]
for i in range(M):
  u, v = map(lambda x: int(x)-1, input().split())
  adj[u].append(v)
  adj[v].append(u)

used = [False for i in range(N)]
used[0] = True
res = [0]
bfs(0)

print(res[0])

Buggy submission (verdict: Runtime Error):
def bfs(u):
  if used.count(True) == N:
    res[0] += 1
    return
  for v in adj[u]:
    if used[v]:
      continue
    used[v] = True
    bfs(v)
    used[v] = False

N, M = map(int, input().split())
adj = [[] for i in range(N)]
for i in range(N):
  u, v = map(lambda x: int(x)-1, input().split())
  adj[u].append(v)
  adj[v].append(u)

used = [False for i in range(N)]
used[0] = True
res = [0]
bfs(0)

print(res[0])
Problem p02711 (python)

Fixed submission:
inp=input()
ok=0
for i in range(len(inp)):
  if(inp[i]=='7'):
    print("Yes")
    ok=1
    break
if(ok==0):
  print("No")

Buggy submission (verdict: Runtime Error):
in=input()
ok=0
for i in range(len(in)):
  if(in[i]=='7'):
    print("Yes")
    ok=1
    break
if(ok==0):
  print("No")
Problem p02771 (python)

Fixed submission:
a, b, c = list(map(int, input().split()))
if a==b and b!=c:
    print('Yes')
elif a==c and a!=b:
    print('Yes')
elif c==b and b!=a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]

import collections
c0 = collections.Counter(s)
c1 = c0.most_common()
max = c1[0][1]
l = []
for x, i in c0.items():
    if i == max:
        l.append(x)
ans = sorted(l)
for i in ans:
    print(i)