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

Fixed submission:
import sys

X, Y = map(int, input().split())

n = (2*Y-X) / 3
m = (2*X-Y) / 3

if (X + Y) % 3 != 0 or n < 0 or m < 0:
    print(0)
    sys.exit(0)

N = int(n + m)
r = int(min([n, m]))
p = 10**9 + 7
fact = [1, 1]
inv = [0, 1]
factinv = [1, 1]

for i in range(2, N+1):
    fact.append(fact[-1]*i % p)
    inv.append(-inv[p%i] * (p//i) % p)
    factinv.append(factinv[-1] * inv[-1] % p)

print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy submission (verdict: Runtime Error):
import sys

X, Y = map(int, input().split())

if ((X + Y) % 3) != 0:
    print(0)
    sys.exit(0)

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

N = c + c_r
r = min([c, c_r])
fact = [1, 1]
inv = [0, 1] 
factinv = [1, 1]
p = 10 ** 9 + 7
for i in range(2, N+1):
    fact.append(fact[-1] * i % p)
    inv.append(-inv[p%i] * (p // i) % p)
    factinv.append(factinv[-1] * inv[-1] % p)
print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

if ((X + Y) % 3) != 0:
    print(0)
else:
    N = c + c_r
    r = min([c, c_r])
    fact = [1, 1]
    inv = [0, 1] 
    factinv = [1, 1]
    p = 10 ** 9 + 7
    for i in range(2, N+1):
        fact.append(fact[-1] * i % p)
        inv.append(-inv[p%i] * (p // i) % p)
        factinv.append(factinv[-1] * inv[-1] % p)
    print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

if check == 0:
    print(0)
else:
    N = c + c_r
    r = min([c, c_r])
    fact = [1, 1]
    inv = [0, 1] 
    factinv = [1, 1]
    p = 10 ** 9 + 7
    for i in range(2, N+1):
        fact.append(fact[-1] * i % p)
        inv.append(-inv[p%i] * (p // i) % p)
        factinv.append(factinv[-1] * inv[-1] % p)
    print(fact[N] * factinv[r] * factinv[N-r] % p)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

c = 0
check = 0
X_k, Y_k = X, Y
while c < max([X, Y]):
    if (X_k / 2) == Y_k:
        check = 1
        c_r = Y_k
        break
    else:
        X_k -= 1
        Y_k -= 2
        c += 1

if check == 0:
    print(0)
else:
    N = c + c_r
    r = min([c, c_r])
    fact = [1, 1]
    inv = [0, 1] 
    factinv = [1, 1]
    p = 10 ** 9 + 7
    for i in range(2, N+1):
        fact.append(fact[-1] * i % p)
        inv.append(-inv[p%i] * (p // i) % p)
        factinv.append(factinv[-1] * inv[-1] % p)

print(fact[N] * factinv[r] * factinv[N-r] % p)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a < 3200:
    print('red')
else:
    print(s)

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

if a >= 3200:
  print('red')
else:
  print(s)
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().strip().split()))

f = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] == h[b-1]:
        f[a-1] = 1
        f[b-1] = 1
    elif h[a-1] > h[b-1]:
        f[b-1] = 1
    elif h[a-1] < h[b-1]:
        f[a-1] = 1

#print(h0)
#print(h)


ans = 0
for i in range(n):
    if f[i] <= 0:
        #print(i)
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, m = map(int, input().split())
h = list(map(int, input().strip().split()))

g = np.zeros((n+1,n+1),dtype='uint64')
for i in range(1,n+1):
    g[i][i] = i


for i in range(m):
    a, b = map(int, input().split())
    g[a][b] = h[b-1]
    g[b][a] = h[a-1]

#for i in range(1,n+1):
#    print(g[i,:])


ans = 0
for i in range(1,n+1):
    if np.argmax(g[i,:]) == i:
        #print(i)
        ans += 1

print(ans)
Problem p02779 (python)

Fixed submission:
#C
n = int(input())
a = list(map(int, input().strip().split()))
a_l = set(a)

if len(a_l) == n:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
#C
import numpy as np
n = int(input())
a = list(map(int, input().strip().split()))
b = np.zeros((10**9+9))
for i in range(n):
    if b[a[i]] == 0:
        b[a[i]] += 1
    else:
        print('NO')
        exit()
print('YES')
Problem p02880 (python)

Fixed submission:
#B

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



n = int(input())

g = factorization(n)

#print(g)
f = []
for x in g:
    for y in range(1,x[1]+1):
        f.append(x[0])

#print(f)
f.sort()
#print(f)

ans = False


l = len(f)
dex = 0
a = f[0]
while l > 2 and dex < len(f)-1:
    if a * f[dex+1] < 10:
        dex += 1
        a *= f[dex]
        l -= 1
    else:
        break

b_dex = dex+1
b = 1
while b_dex < len(f):
    b *= f[b_dex]
    b_dex += 1

#print(a,b)
if a < 10 and b < 10:
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#B

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct


n = int(input())

f = factorize(n)
#print(f)
f.sort()
#print(f)

ans = False


l = len(f)
dex = 0
a = f[0]
while l > 2 and dex < len(f)-1:
    if a * f[dex+1] < 10:
        dex += 1
        a *= f[dex]
        l -= 1
    else:
        break

b_dex = dex+1
b = 1
while b_dex < len(f):
    b *= f[b_dex]
    b_dex += 1

#print(a,b)
if a < 10 and b < 10:
        ans = True

if ans:
    print('Yes')
else:
    print('No')
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red)
Problem p02984 (python)

Fixed submission:
import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

for i in range(1,n):
    x[i] = 2 * b[i-1] - x[i-1]

x = (x.astype(int)).tolist()

s = str(x)
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
s = s.replace('  ',' ')

print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = np.array(list(map(int, input().strip().split())))
s = sum(b)
x = []

for i in range(n):
    y = s
    k = i + 1
    for j in range(int((n-1)/2)):
        y -= 2*b[k%n]
        k += 2

    x.append(y)

s = str(x)
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)

Buggy submission (verdict: Runtime Error):
import scipy.linalg as linalg

import numpy as np
n = int(input())
b = np.array(list(map(int, input().strip().split())))
b *= 2
A = np.zeros((n,n))
for i in range(n):
    if i == n - 1:
        A[i,0] = 1
        A[i,n-1] = 1
    else:
        A[i,i] = 1
        A[i,i+1] = 1

#Ainv = np.linalg.inv(A)
#x = np.dot(Ainv, b)

#x = np.linalg.solve(A, b)

LU = linalg.lu_factor(A)
x = linalg.lu_solve(LU, b)

s = str(x.astype(int))
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
b = np.array(list(map(int, input().strip().split())))
b *= 2
A = np.zeros((n,n))
for i in range(n):
    if i == n - 1:
        A[i,0] = 1
        A[i,n-1] = 1
    else:
        A[i,i] = 1
        A[i,i+1] = 1

#Ainv = np.linalg.inv(A)
#x = np.dot(Ainv, b)

x = np.linalg.solve(A, b)

s = str(x.astype(int))
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
b = np.array(list(map(int, input().strip().split())))
b *= 2
A = np.zeros((n,n))
for i in range(n):
    if i == n - 1:
        A[i,0] = 1
        A[i,n-1] = 1
    else:
        A[i,i] = 1
        A[i,i+1] = 1

Ainv = np.linalg.inv(A)         # A の逆行列を計算
x = np.dot(Ainv, b)             # A の逆行列と b の内積
s = str(x.astype(int))
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)
Problem p02990 (python)

Fixed submission:
def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n, k = map(int, input().split())



for i in range(1,k+1):
    if (n-k+1) >= i:
        print((comb(n-k+1, i) * comb(k-1, i-1))%(1000000007))
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

n, k = map(int, input().split())

for i in range(1,k+1):
    print((comb(n-k+1, i, exact=True) * comb(k-1, i-1, exact=True))%(1000000007))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

n, k = map(int, input().split())

for i in range(1,k+1):
    print((comb(n-k+1, i, exact=True) * comb(k-1, i-1, exact=True))%(1000000000+7))
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())

s = [0] * (N+1)

for i in range(M):
    ai = int(input())
    s[ai] = -1

s[0] = 1

if N == 1:
    print(1)
else:
    if s[1] == 0:
        s[1] = 1

    for i in range(2,N+1):
        if s[i] >= 0:
            s[i] += (max(0,s[i-1]) + max(0,s[i-2]))

    print(s[N] % 1000000007)

Buggy submission (verdict: Runtime Error):

N, M = map(int, input().split())

s = [0] * (N+1)

for i in range(M):
    ai = int(input())
    s[ai] = -1

print(s)

s[0] = 1

if N == 1:
    print(1)
else:
    if s[1] == 0:
        s[1] = 1

    for i in range(2,N+1):
        if s[i] >= 0:
            s[i] += (max(0,s[i-1]) + max(0,s[i-2]))
        print(s)

    print(s[N] % 1000000007)
Problem p02661 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    N = int(input())
    Bs = []
    As = []
    for i in range(N):
        a, b = map(int, input().split())
        As.append(a)
        Bs.append(b)
    min_med = np.median(As)
    max_med = np.median(Bs)
    if N % 2 == 0:
        print(int(2 * (max_med - min_med) + 1))
    else:
        print(int((max_med - min_med) + 1))
    


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    N = int(input())
    Bs = []
    As = []
    for i in range(N):
        a, b = map(int, input().split())
        As.append(a)
        Bs.append(b)
    min_med = np.median(As)
    max_med = np.median(Bs)
    if N % 2 == 0:
        print(int(2 * (max_med - min_med) + 1))
    else:
        print(int((max_med - min_med) + 1))
    


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

Fixed submission:
from decimal import *
A, B = input().split()
print(int(int(A) * Decimal(B)))

Buggy submission (verdict: Runtime Error):
A, B = input().split(' ')

A = int(A)
B100 = int(B.replace('.', ''))

ans = A * B * 0.01

print(ans)
Problem p02659 (python)

Fixed submission:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

L = input().split()
A = int(L[0])
B = int(L[1].replace(".", ""))


print(int(A*B)//100)

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B = MAP()


print(int(A*B))
Problem p02754 (python)

Fixed submission:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, A, B = MAP()



sets = N // (A+B) 
remain = N % (A+B)

blues = sets * A + min(remain, A)
print(blues)

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, A, B = MAP()

# blues = 0
# while N > 0:
#     if N - A < 0:
#         A = N
#     N -= A
#     blues += A

#     N -= B

# print(blues)

S = []

while len(S) <= N:
    S += "b" * A
    S += "r" * B

print(S[:N].count("b"))
Problem p03137 (python)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))

# print(n, m, x)

# #%%
# n, m =2, 5
# x = [10, 12, 1, 2, 14]


#%%
x.sort()

#%%




#%%

diff_list = []
for i in range(m-1):
    diff = x[i+1] - x[i]
    diff_list.append(diff)


#%%
diff_list.sort()


#%%
if n-1>0:
    print(sum(diff_list[:-(n-1)]))
else:
    print(sum(diff_list))    

#%%


#%%

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))

# print(n, m, x)

# #%%
# n, m =2, 5
# x = [10, 12, 1, 2, 14]


#%%
x.sort()

#%%




#%%

diff_list = []
for i in range(m-1):
    diff = x[i+1] - x[i]
    diff_list.append(diff)


#%%
diff_list.sort()


#%%
if n-1>0:
    print(sum(diff_list[:-(n-1))])
else:
    print(0)    

#%%


#%%

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))

# print(n, m, x)

# #%%
# n, m =2, 5
# x = [10, 12, 1, 2, 14]


#%%
x.sort()

#%%




#%%

diff_list = []
for i in range(m-1):
    diff = x[i+1] - x[i]
    diff_list.append(diff)


#%%
diff_list.sort()


#%%
print(x[-1] - x[0] - sum(diff_list[-(n-1):])

#%%


#%%

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))

# print(n, m, x)

# #%%
# n, m =2, 5
# x = [10, 12, 1, 2, 14]


#%%
x.sort()

#%%




#%%

diff_list = []
for i in range(m-1):
    diff = x[i+1] - x[i]
    diff_list.append(diff)


#%%
diff_list.sort()


#%%
print(x[-1] - x[0] - sum(diff_list[-(n-1):])

#%%


#%%
Problem p02623 (python)

Fixed submission:
import itertools
N,M,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
B = [0]+list(map(int,input().split()))
SA = list(itertools.accumulate(A))
SB = list(itertools.accumulate(B))

ans = 0
pt = len(B)-1
for i,sa in enumerate(SA):
    while(pt>=0):
        if sa + SB[pt] <= K:
            ans = max(ans,i+pt)
            break
        pt-=1
print (ans)

Buggy submission (verdict: Runtime Error):
import itertools
N,M,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
B = [0]+list(map(int,input().split()))
SA = list(itertools.accumulate(A))
SB = list(itertools.accumulate(B))
ans = 0
j = len(B)-1
for i in range(len(SA)):
    while(pt>=0):
        if SA[i] + SB[j] <= K:
            ans = max(ans,i+j)
            break
        j-=1
print (ans)
Problem p02624 (python)

Fixed submission:
N = int(input())
ans = 0
for X in range(1, N+1):
  Y = N // X
  ans += Y * (Y + 1) // 2 * X
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for X in range(1, n+1):
  Y = n // X
  ans += Y * (Y + 1) // 2 * X
print(ans)
Problem p02679 (python)

Fixed submission:
import math
MOD = 1000000007
N = int(input())
d_p = dict()
d_m = dict()
zz = 0
for n in range(N):
    a,b = map(int,input().split())

    if a==0 and b==0:
        zz += 1
        continue
    if a==0:
        n_sign = 1
        a=0
        b=0
    elif b==0:
        n_sign = 0
        a=0
        b=0  


    else:    
        n_sign = ((a<0) + (b<0))%2
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a,b)
        a//=gcd
        b//=gcd
        #print(n_sign,a,b)

    

    if n_sign==1:
        s =str(b)+'/'+str(a)
        d_m[s] = d_m.get(s,0) + 1
    elif n_sign==0:
        s =str(a)+'/'+str(b)
        d_p[s] = d_p.get(s,0) + 1      
    
#print (d_m,d_p)

ans = 1
for k,v in d_m.items():
    if k in d_p:
        ans *= (2**v + 2**d_p[k] - 1)
        
        d_p.pop(k)
    else:
        ans *= 2**v
    ans %= MOD

for k,v in d_p.items():
    ans *= 2**v
    ans %= MOD
ans -= 1
ans += zz
ans %= MOD
print (ans)

Buggy submission (verdict: Runtime Error):
import math
MOD = 1e+9+7
N = int(input())

d_p = dict()
d_m = dict()
ans = 1
zz = 0

for n in range(N):
    a,b = map(int,input().split())

    if a==0 and b==0:
        zz += 1
        continue
    if a==0:
        n_sign = 0
        b = 0
    elif b==0:
        n_sign = 1
        a = 0

    else:    
        n_sign = ((a<0) + (b<0))%2
        a = abs(a)
        b = abs(b)
        gcd = math.gcd(a,b)
        a//=gcd
        b//=gcd

    if n_sign==1:
        s =str(b)+'/'+str(a)
        d_m[s] = d_m.get(s,0) + 1
    elif n_sign==0:
        s =str(a)+'/'+str(b)
        d_p[s] = d_p.get(s,0) + 1      

for k,v in d_m.items():
    if k in d_p:
        ans *= (2**v + 2**d_p[k] - 1)
        d_p.pop(k)
    else:
        ans *= 2**v
    ans %= MOD

for k,v in d_p.items():
    ans *= 2**v
    ans %= MOD
    
ans -= 1
ans += zz
ans %= MOD
print (ans)
Problem p02685 (python)

Fixed submission:
N,M,K = map(int,input().split())
MOD = 998244353
ans = 0


fact = [1] * (N+1) # 階乗を格納するリスト
factinv = [1] * (N+1) # 階乗を格納するリスト



for i in range(N):
    fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
    factinv[i+1] = pow(fact[i+1], MOD-2, MOD)# MODを法とした逆元

def nCk(n,k): # 組み合わせ(MOD)を返却する
    return fact[n] * factinv[n-k] * factinv[k] % MOD

def solve(k):
    r = M * pow(M-1,N-1-k,MOD) * nCk(N-1,k)
    return r

for k in range(K+1):
    ans += solve(k)
    ans %= MOD
print (ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
# dp = [[0]*(K+2) for _ in range(2)]

# print (1)
# dp[0][0] = M
# MOD = 998244353
# for n in range(N-1):
#     n = n % 2
#     a = (n+1) % 2
#     dp[a] = [0]*(K+2) 
#     for k in range(K+1):
        
        
        
#         dp[a][k] += dp[n][k] * (M-1)
#         dp[a][k+1] += dp[n][k]
#         dp[a][k] %= MOD
#         dp[a][k+1] %= MOD
# #print (dp)
# print(sum(dp[(N+1)%2][:-1]))
import numpy as np
old = np.zeros(K+1).astype(np.int)
MOD = 998244353
old[0] = M
for n in range(N-1):
    new = old*(M-1)
    new[1:] += old[:K]
    new %= MOD
    old = new
print (sum(new)%MOD)
Problem p02831 (python)

Fixed submission:
#coding:utf-8
import fractions
a,b = map(int,input().split())
print( a * b // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import fractions
a = int(input())
b = int(input())
print( a * b // fractions.gcd(a, b))
Problem p02862 (python)

Fixed submission:
MOD = 10**9+7
X, Y = sorted(list(map(int, input().split())))

if (X+Y)%3 != 0:
    print (0)
    exit()

if (2*X < Y):
    print (0)
    exit()

W = X - ((X+Y)//3)
H = Y - ((X+Y)//3)

mx = 10**6
fact = [1] * (mx+1) # 階乗を格納するリスト
def inv(n): # MODを法とした逆元
    return pow(n, MOD-2, MOD)
for i in range(mx):
    fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
ans = (fact[W+H] * inv(fact[W]) * inv(fact[H])) % MOD # comb(W+H,W) = (W+H)!/(W!H!)
print (ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
X, Y = map(int, input().split()))
if (X > Y):
    X, Y = Y, X

if (X+Y)%3 != 0:
    print (0)
    exit()

if (2*X < Y):
    print (0)
    exit()

W = X - ((X+Y)//3)
H = Y - ((X+Y)//3)

mx = 10**6
fact = [1] * (mx+1) # 階乗を格納するリスト
def inv(n): # MODを法とした逆元
    return pow(n, MOD-2, MOD)
for i in range(mx):
    fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
ans = (fact[W+H] * inv(fact[W]) * inv(fact[H])) % MOD # comb(W+H,W) = (W+H)!/(W!H!)
print (ans)
Problem p02891 (python)

Fixed submission:
#coding: utf-8
s = input()
k = int(input())

if len(set(s))==1:
  print((len(s)*k)//2)
  exit()

dup = [1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:
    dup[-1]+=1
  else:
    dup.append(1)
    
ans = 0
for i in dup:
  ans += (i//2)*k

if s[0]==s[-1]:
  ans += ((dup[0]+dup[-1])//2 - (dup[0]//2+dup[-1]//2))*(k-1)

print(ans)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
s = input()
k = int(input())


if len(set(s))==1:
    print ((len(s)*k)//2)
    exit()

old = ""
ans = 0
for i in range(len(s)):
    if(s[i]==old):
        ans+=1
        old = ""
    else:
        old = s[i]



head = 0
for i in range(len(s)):
    if head==0 or s[i]==s[i-1]:
        head+=1
    else:
        break

tail = 0
t = s[::-1]
for i in range(len(t)):
    if tail==0 or t[i]==t[i-1]:
        tail+=1
    else:
        break

print (ans*k-(k-1)*(head//2)+tail//2)-((head+tail)//2)))
Problem p02948 (python)

Fixed submission:
import heapq
N,M = map(int,input().split())
ls = []
h = []
ans = 0
for n in range(N):
    ls.append(list(map(int,input().split())))
ls = sorted(ls,key=lambda ls:ls[0],reverse=False)
n = 0
for m in range(1,M+1):
    #print (m)
    while(n<N and ls[n][0]<=m ):
        heapq.heappush(h, -ls[n][1])
        n+=1
    if len(h)>0:
        ans -= heapq.heappop(h)
        # print (m,ans)
print (ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
N,M = map(int,input().split())
ls = []
for n in range(N):
  ls.append(list(map(int,input().split())))
ls = np.array(ls)
idx = np.argsort(ls[:,1])[::-1]
#print (ls[idx])
days = list(range(1,M+1))
days = {k: 0 for k in days}
#print (days)
sum = 0
for work in ls[idx]:
  d = work[0]
  while(d<=M):
    if d in days:
      sum+=work[1]
      days.pop(d)
      d=M+1
    else:
      d+=1
print (sum)
Problem p02984 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
sm = sum(A)
x = sm-2*sum(A[1::2])
X = []
X.append(str(x))
for i in range(N-1):
   x = 2*A[i]-x
   X.append(str(x))
print (" ".join(X))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
argmn = np.argmin(A)
mn = A[argmn]
for m in range(mn+1):
  B = np.zeros(len(A))
  B[argmn] = m * 2
  for i in range(len(A)):
    idx = (i + argmn)%len(A)
    B[(idx+1)%len(A)]  += A[idx] * 2  - B[idx]
  B[argmn] -= m * 2
  if (B[argmn]+B[(argmn+1)%len(A)]==(A[argmn]*2)):
    print (" ".join(B.astype(np.int).astype(np.str)))
    exit()
Problem p02987 (python)

Fixed submission:
#coding:utf-8
from collections import Counter

S = input()
cnt = Counter(list(S))
ls = list(cnt.values())
if (ls[0]==2 and ls[1]==2):
    print ("Yes")
else:
    print ("No")

Buggy submission (verdict: Runtime Error):
#coding:utf-8
N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
idx = len(D) // 2
print(D[idx] - D[idx-1])