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

Fixed submission:
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(n-k+1):
  ans += (a[n-1-i]-a[i])*cmb(n-1-i,k-1,mod)
  ans %=  mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(n-k+1):
  ans += (a[n-1-i]-a[i])*cmb(n-1-i,k-1,mod)
  ans %=  mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(N-K+1):
  ans += (a[n-1-i]-a[i])*cmb(n-1-i,k-1,mod)
  ans %=  mod
print(ans)
Problem p02600 (python)

Fixed submission:
print(10-int(input())//200)

Buggy submission (verdict: Runtime Error):
print(10-int(input)//200)
Problem p02601 (python)

Fixed submission:
a=list(map(int,input().split()))
k=int(input())
while a[0]>=a[1]:
  k-=1
  a[1]*=2
while a[1]>=a[2]:
  k-=1
  a[2]*=2
if k>=0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=list(map,input().split())
k=int(input())
while a[0]>=a[1]:
  k-=1
  a[1]*=2
while a[1]>=a[2]:
  k-=1
  a[2]*=2
if k>=0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=list(map,input().split())
k=int(input())
while a[0]>=a[1]:
  k--
  a[1]*=2
while a[1]>=a[2]:
  k--
  a[2]*=2
if k>=0:
  print("Yes")
else:
  print("No")
Problem p02814 (python)

Fixed submission:
import fractions


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
# print(v[0])
while (v[0] % 2 == 0):
    v[0] //= 2
    num += 1
# print(v[0])
ans = v[0]
for i in range(n - 1):
    if (v[i + 1] % (2 ** num) != 0 or v[i + 1] % (2 ** (num + 1)) == 0):
        ans = 2
        break
    # print(v[i+1])
    v[i+1] //= 2**num
    # print(v[i+1])
    ans = lcm(ans, v[i + 1])
# print(ans)
if (ans % 2 == 0):
    print(0)
    exit(0)
ans *= 2**(num-1)
print(((m//ans)+1)//2)

Buggy submission (verdict: Runtime Error):
import fractions


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


n, m = map(int, input().split())
v = list(map(int, input().split()))
num = 0
# print(v[0])
while (v[0] % 2 == 0):
    v[0] //= 2
    num += 1
# print(v[0])
ans = v[0]
for i in range(n - 1):
    v[i+1] //= 2**num
    ans = lcm(ans, v[i + 1])
# print(ans)
if (ans % 2 == 0):
    print(0)
    exit(0)
ans *= 2**num
print(m//ans)
Problem p03227 (python)

Fixed submission:
s=input()
if (len(s)==3):
	s=s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s=input()
if (len(s)==3):
	s=reverse(s)
print(s)
Problem p03347 (python)

Fixed submission:
n=int(input())
l=[int(input()) for _ in range(n)]
ans=0
if l[0]!=0:
  print(-1)
  exit()
for i in range(n-1):
  if l[i+1]-l[i]>1:
    print(-1)
    exit()
  elif (l[i]+1==l[i+1]):
    ans+=1
  else:
    ans+=l[i+1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for _ in range(n)]
ans=0
if l[0]!=0:
  print(-1)
  exit()
for i in range(n-1):
  if l[i+1]-l[i]>1:
    print(-1)
    exit()
  elif (l[i]+1==l[i+1]):
    ans+=1
  else:
	ans+=l[i+1]
print(ans)
Problem p03627 (python)

Fixed submission:
#coding utf-8
import collections
_=input()
bars=[i for i in map(int,input().split())]
data=sorted(collections.Counter(bars).items(),key= lambda x: -x[0] )
stock=0
ret=0
for bar ,count in data:
    if count>=4:
        if stock:
            ret=stock*bar
            break
        else:
            ret=bar*bar
            break
    elif count>=2:
        if stock:
            ret=stock*bar
            break
        else:
            stock=bar
print(ret)

Buggy submission (verdict: Runtime Error):
#coding utf-8
_=input()
bars=[i for i in map(int,input().split())]
bars.sort(reverse=True)
stock=[]
ret=0
_old=-1
for bar in bars:
    if bar=_old:
        continue
    _old=bar
    count=bars.count(bar)
    if count>=4:
        if len(stock)!=0 and  bar not in stock:
            #print("ret bar bar")
            ret=bar*stock[0]
        else:
            #print("ret bar bar")
            ret=bar*bar
        break
    elif count>=2:
        if bar in stock:
            continue
        stock.append(bar)
        if len(stock)==2 :
            #print("ret stock stock")
            ret=stock[0]*stock[1]
            break
print(ret)
Problem p03632 (python)

Fixed submission:
l=list(map(int,input().split()))
ans=min(l[1],l[3])-max(l[0],l[2])
print(ans if ans>0 else 0)

Buggy submission (verdict: Runtime Error):
i=input()
l=map(int,input().split())
ans=min(l[1],l[3])-max(l[0],l[2])
print(ans if ans>0 else 0)
Problem p03646 (python)

Fixed submission:
import math

def f(l):
    mx=max(l)
    flg=True
    for i in range(len(l)):
        if (mx==l[i] and flg==True):
            flg=False
            l[i]-=50
            l[i]=max(0,l[i])
        else:
            l[i]+=1
    return l


def solve(k):
    #k=int(input())
    N=50
    a=k//N+1
    if (k%N==0) :
        a-=1
    l=[a+i for i in range(50)]
    mod=(N-(k%N))%N
    for i in range(mod):
        l=f(l)
    l=sorted(l,reverse=True)
    print(50)
    for i in range(50):
        print(str(l[i])+" ",end="")
    print("")
    ret=0
solve(int(input()))

Buggy submission (verdict: Runtime Error):
k=int(input())
m=k//2
if (k%2==0):
    print(2)
    print"{} {}".format(m,m+1)
else:
    print(2)
    print"{} {}".format(m,m+2)
Problem p03970 (python)

Fixed submission:
s="CODEFESTIVAL2016"
t=input()
ans=0
for c1,c2 in zip(s,t):
  if c1!=c2 : ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s="CODEFESTIVAL2016"
t=input()
ans=0
for c1,c2 in zip(s,t):
  if c1!=c2 : ns+=1
print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse = True)[: X]
q = sorted(list(map(int, input().split())), reverse = True)[: Y]
r = list(map(int, input().split()))

all_apple = sorted(p + q + r, reverse = True)
print(sum(all_apple[: X + Y]))

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
r_list = list(map(int, input().split()))

eat = []
for i in range(X):
  p_max = max(p_list)
  r_max = max(r_list)
  if p_max >= r_max or len(r_list) == 0:
    eat.append(p_max)
    p_list.remove(p_max)
  else:
    eat.append(r_max)
    r_list.remove(r_max)
for i in range(Y):
  q_max = max(q_list)
  r_max = max(r_list)
  if q_max >= r_max or len(r_list) == 0:
    eat.append(q_max)
    q_list.remove(q_max)
  else:
    eat.append(r_max)
    r_list.remove(r_max)
print(sum(eat))
Problem p02574 (python)

Fixed submission:
class prime_factorize_by_osa_k():
    def __init__(self, max_val):
        '''
        割ることが出来る最小の値を格納したリストを返す
        :param max_val:
        :return:
        '''
        self.minFactor = [-1] * (max_val + 1)
        for i in range(2, max_val + 1):
            if self.minFactor[i] == -1:
                self.minFactor[i] = i
                # エラトステネスの篩と同様の処理を行う
                for j in range(i * i, max_val + 1, i):
                    if self.minFactor[j] == -1:
                        self.minFactor[j] = i

    def osa_k(self, n):
        '''
        preprocessをしたあと、O(logN)で素因数分解を行う。nの最大値をn_maxとする。
        :param n:
        :return:
        '''
        from collections import defaultdict
        d = defaultdict(int)
        now = n
        while now > 1:
            d[self.minFactor[now]] += 1
            now //= self.minFactor[now]
        return d
def gcd(a, b):
    while b: a, b = b, a % b
    return a

N = int(input())
A = list(map(int, input().split()))
# N = 10 ** 6
# A = [10 ** 6] * N
ob = prime_factorize_by_osa_k(10 ** 6)
pairwise = False
prime_key = set(ob.osa_k(A[-1]).keys())
break_flag = False
prime_flags = [False] * (10 ** 6 + 1)
for i in range(N):
    for key in ob.osa_k(A[i]).keys():
        if prime_flags[key]:
            break_flag = True
            break
        else:
            prime_flags[key] = True
    if break_flag:
        break
else:
    pairwise = True
if pairwise:
    print('pairwise coprime')
    exit()
work = gcd(A[0], A[1])
for i in range(2, N):
    work = gcd(work, A[i])
if work != 1:
    print('not coprime')
else:
    print('setwise coprime')

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def prime_factorize(n):
    '''
    素因数分解のリストを返す。n == 1のとき[]になるので注意。
    :param n:int
    素因数分解する自然数
    :return: list
    素因数分解した結果。

    例
    n : 10
    primes : [[2, 1], [5, 1]]
    '''
    primes = []
    for i in range(2, int(n ** (1 / 2)) + 1):
        if n % i != 0:
            continue
        num = 0
        while n % i == 0:
            num += 1
            n //= i
        primes.append([i, num])
    if n != 1:
        primes.append([n, 1])
    return primes

N = int(input())
A = list(map(int, input().split()))
# N = 10 ** 6
# A = [10 ** 6] * N
pairwise = False
prime_key = set(prime_factorize(A[-1]).keys())
break_flag = False
prime_flags = [False] * (10 ** 6 + 1)
for i in range(N):
    for key in prime_factorize(A[i]).keys():
        if prime_flags[key]:
            break_flag = True
            break
        else:
            prime_flags[key] = True
    if break_flag:
        break
else:
    pairwise = True
if pairwise:
    print('pairwise coprime')
    exit()
work = gcd(A[0], A[1])
for i in range(2, N):
    work = gcd(work, A[i])
if work != 1:
    print('not coprime')
else:
    print('setwise coprime')
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())
pirnt(a * b)
Problem p02675 (python)

Fixed submission:
x = input()
pon = ['0', '1', '6', '8']
if x[-1] in pon:
  print('pon')
elif x[-1] == '3':
  print('bon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
x = input()
pon = ['0', '1', '6', '8']
if x[-1] if pon:
  print('pon')
elif x[-1] == '3':
  print('bon')
else:
  print('hon')
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
sc = list(list(map(int, input().split())) for _ in range(M))

for i in range(1000):
    str_num = str(i)
    num_len = len(str_num)
    if num_len != N:
        continue
    for s, c in sc:
        if num_len < s:
            break
        if int(str_num[s - 1]) != c:
            break
    else:
        print(i)
        exit()

print("-1")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = list(list(map(int, input().split())) for _ in range(M))
sc.sort()
for i in range(M - 1):
    if sc[i][0] == sc[i + 1][0] and sc[i][1] != sc[i + 1][1]:
        print('-1')
        exit()


max_len = sc[-1][0]
min_idx = sc[0][0]
is_ans = False
for i in range(10 ** (3 - min_idx),1000):
    str_num = str(i)
    num_len = len(str_num)
    for s, c in sc:
        # if num_len max_len:
        #     break
        if int(str_num[s - 1]) != c:
            break
    else:
        is_ans = True
        ans = i
        break
if is_ans:
    print(ans)
else:
    print("-1")
Problem p02765 (python)

Fixed submission:
N , R = map(int,input().split())
if N < 10:
    print(100 * (10 - N) + R)
else:
    print(R)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
X_max = max(X)
ans = float('inf')
for i in range(X_max + 1):
    tmp_ans = 0
    for x in X:
        tmp_ans += (x - i) ** 2
    if tmp_ans < ans:
        ans = tmp_ans
print(ans)
Problem p02768 (python)

Fixed submission:
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
while ans < 0:
    ans += MOD
print(ans)

Buggy submission (verdict: Runtime Error):
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
print(ans　% MOD)
Problem p02837 (python)

Fixed submission:
N = int(input())
info = [[] for _ in range(N)]
people = [-1] * N
for i in range(N):
    A = int(input())
    if A == 0:
        info[i].append([0])
    for j in range(A):
        x , y = map(int,input().split())
        info[i].append([A , x - 1 , y])
#print(info[0][0][0])
ans = 0
# ビット全探索を行う
for i in range(2 ** N):
    cnt = 0
    Flag = True
    # ビットが１の時、正直者としてpeopleに格納
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            people[j] = 1
        else:
            people[j] = 0
    for j in range(N):
        # 正直者の発言と実際に正直者であるかを判定
        if i >> j & 1:
            info_num = info[j][0][0]
            for k in range(info_num):
                judge = info[j][k][2]
                origin = people[info[j][k][1]]
                if judge != origin:
                    Flag = False
                    break
        if not Flag:
            break
    if Flag:
        if ans < cnt:
            ans = cnt
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
info = [[] for _ in range(N)]
people = [-1] * N
for i in range(N):
    A = int(input())
    for j in range(A):
        x , y = map(int,input().split())
        info[i].append([A , x - 1 , y])
#print(info[0][0][0])
ans = 0
for i in range(2 ** N):
    cnt = 0
    Flag = True
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            people[j] = 1
        else:
            people[j] = 0
    for j in range(N):
        if i >> j & 1:
            info_num = info[j][0][0]
            for k in range(info_num):
                judge = info[j][k][2]
                origin = people[info[j][k][1]]
                if judge != origin:
                    Flag = False
                    break
        if not Flag:
            break
    if Flag:
        if ans < cnt:
            ans = cnt
print(ans)
Problem p02850 (python)

Fixed submission:
from collections import deque
# 入力、初期化
N = int(input())
tree = [[] for _ in range(N)]
input_list = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    input_list.append([a, b])
    tree[a].append(b)
    tree[b].append(a)


# visitedにノードの色を格納する
# visited_edge = [[0] * N for _ in range(N)]
dict = {}
'''
# bfsによる色付けを行う
def bfs(now_node, max_val=0):
    queue = deque([[tree[now_node], -1, now_node]])
    while queue:
        next_nodes, before_color, now_node = queue.pop()
        now_color = 1
        for next_node in next_nodes:
            if visited_edge[now_node][next_node] != 0:
                continue
            if now_color == before_color:
                now_color += 1
            if max_val < now_color:
                max_val = now_color
            visited_edge[next_node][now_node] = now_color
            visited_edge[now_node][next_node] = now_color
            queue.appendleft([tree[next_node], now_color, next_node])
            now_color += 1
    return max_val
'''
def bfs(now_node, max_val=0):
    queue = deque([[tree[now_node], -1, now_node]])
    while queue:
        next_nodes, before_color, now_node = queue.pop()
        now_color = 1
        for next_node in next_nodes:
            key = tuple(sorted([now_node, next_node]))
            if not dict.get(key) is None:
                continue
            if now_color == before_color:
                now_color += 1
            if max_val < now_color:
                max_val = now_color
            dict[key] = now_color
            # visited_edge[now_node][next_node] = now_color
            queue.appendleft([tree[next_node], now_color, next_node])
            now_color += 1
    return max_val

ans = bfs(0)
print(ans)
for a, b in input_list:
    # print(visited_edge[a][b])
    print(dict[tuple(sorted([a,b]))])

Buggy submission (verdict: Runtime Error):
from collections import deque
import heapq
# 入力、初期化
N = int(input())
tree = [[] for _ in range(N)]
input_list = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    input_list.append([a, b])
    tree[a].append(b)
    tree[b].append(a)


# visitedにノードの色を格納する
visited_edge = [[0] * N for _ in range(N)]


# bfsによる色付けを行う
def bfs(now_node):
    queue = deque([[tree[now_node], 0, now_node]])
    while queue:
        next_nodes, before_color, now_node = queue.pop()
        now_color = 1
        for next_node in next_nodes:
            if visited_edge[now_node][next_node] != 0:
                continue
            if now_color == before_color:
                now_color += 1
            visited_edge[next_node][now_node] = now_color
            visited_edge[now_node][next_node] = now_color
            queue.appendleft([tree[next_node], now_color, next_node])
            now_color += 1


bfs(0)
ans = []
for a, b in input_list:
    ans.append(visited_edge[a][b])
max_val = 0
for row in visited_edge:
    row = row.sort()
    tmp_max = row[-1]
    if tmp_max > max_val:
        max_val = tmp_max
print(max_val)
print(*ans, sep="\n")
Problem p02888 (python)

Fixed submission:
import bisect
N = int(input())
l = list(map(int,input().split()))
l.sort()
#print(l)


ans = 0
for i in range(N - 1 , 1, -1):
    for j in range(i - 1 , 0 , -1):
        #work = l[:j]
        x = l[i] - l[j]
        #idx = bisect.bisect_right(work, x)
        idx = bisect.bisect_right(l, x)
        ans += max(j - idx , 0)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
l.sort()
for i in range(N - 2):
    for j in range(i + 1,N - 1):
        for k in range(j + 1, N ):
            if l[i] < l[j] + l[k]:
                ans += 1
print(ans)
Problem p02903 (python)

Fixed submission:
H , W , A , B = map(int , input().split())
mat = [[1] * W for _ in range(H)]
for row in range(H):
    for col in range(W):
        if col < A and row < B or col >= A and row >= B:
            mat[row][col] = 0
for row in mat:
    print(*row,sep = "")
print()

Buggy submission (verdict: Runtime Error):
H , W ,A , B = map(int ,input().split())
matrix = [[0] * W for _ in range(H)]
idx = 0
k = 0
for i in range(H):
    for j in range(A):
        if k >= W:
            k -= W
        matrix[i][k] = 1
        k += 1
    k -= B - 1
flag = True
for i in matrix:
    if i.count(1) != A and i.count(0) != A:
        flag = False
for i in zip(*matrix):
    if i.count(1) != B and i.count(0) != B:
        flag = False
if flag:
    for row in matrix:
        print(*row)
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H , W ,A , B = map(int ,input().split())
matrix = [[0] * W for _ in range(H)]
idx = 0
k = 0
for i in range(H):
    for j in range(A):
        matrix[i][k] = 1
        k += 1
    k -= B - 1

for row in matrix:
    print(*row)
Problem p02936 (python)

Fixed submission:
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, Q = list(map(int, input().split()))

M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x

Q = [0]

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)

    Q += M[current]

print(' '.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    if now < N:

        for next in graph[now]:
            # 次のノードが前に参照した値の時はcontinue
            if next == prev:
                continue

            # 現在の値を次のポイントに加算することで累積和をとる
            point[next] += point[now]

            # 次のノードと現在のノードを引数にdfsを継続する
            dfs(next , now)

dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
N , Q = map(int,input().split())
stack = []
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

def dfs(now , prev = -1):
    for next in graph[now]:
        if next == prev:
            continue
        #print(now , next)
        #print(point)
        point[next] += point[now]
        dfs(next , now)

#print(point)
dfs(0)
print(*point)
Problem p02945 (python)

Fixed submission:
a , b  = map(int,input().split())
add = a + b
sub = a - b
mul = a * b
if add >= sub and add >= mul:
	max = add
elif sub >= add and sub >= mul:
  	max = sub
else:
    max = mul
print(max)

Buggy submission (verdict: Runtime Error):
a , b  = int(input.split())
add = a + b
sub = a - b
mul = a * b
if add >= sub and add >= mul:
	max = add
elif sub >= add and sub >= mul:
  	max = sub
else:
    max = mul
print(max)
Problem p02947 (python)

Fixed submission:
#from Collections import Counter

N = int(input())
count = 0
word = {}
def str_sort(str):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(str)
for _ in range(N):
    sorted_str = str_sort(input())
    if sorted_str not in word:
        word[sorted_str] = [0]
        word[sorted_str].append(1)
    else:
        if word[sorted_str] == 0:
            word[sorted_str][0] = 1
        else:
            word[sorted_str][0] += word[sorted_str][1]
            word[sorted_str][1] += 1
            #word[sorted_str] = word[sorted_str][0] + word[sorted_str][1]
total = sum(
    v[0] for v in word.values()
)
#print(word)
print(total)

Buggy submission (verdict: Runtime Error):
from collections import Counter
#from math import factorial
from scipy.special import comb
def com(n , r):
    return factorial(n) // (factorial(n - r) * factorial(r))
N = int(input())
S = []
for _ in range(N):
    s = input()
    S.append("".join(sorted(s)))
CS = Counter(S)
ans = 0
for val in CS.values():
    ans += comb(val , 2 , exact = True)
print(ans)

Buggy submission (verdict: Runtime Error):
a