Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import heapq
n = int(input())
a = list(map(int, input().split()))

l = a[:n]
heapq.heapify(l)
memo_l = [0 for _ in range(n+1)]
memo_l[0] = sum(a[:n])

for i in range(1, n+1):
    memo_l[i] = memo_l[i-1]
    if l[0] < a[n+i-1]:
        x = heapq.heappop(l)
        heapq.heappush(l, a[n+i-1])
        memo_l[i] += a[n+i-1] - x


r = [-a[-i] for i in range(1, n+1)]
heapq.heapify(r)
memo_r = [0 for _ in range(n+1)]
memo_r[0] = sum(a[-n:])

for i in range(1, n+1):
    memo_r[i] = memo_r[i-1]
    if abs(x) > a[-n-i]:
        x = heapq.heappop(r)
        heapq.heappush(r, -a[-n-i])
        memo_r[i] += x + a[-n-i]


ans = - 10 ** 20
for i in range(n+1):
    ans = max(ans, memo_l[i] - memo_r[n-i])

print(ans)

Fixed submission:
import heapq
n = int(input())
a = list(map(int, input().split()))

l = a[:n]
heapq.heapify(l)
memo_l = [0 for _ in range(n+1)]
memo_l[0] = sum(a[:n])

for i in range(1, n+1):
    memo_l[i] = memo_l[i-1]
    if l[0] < a[n+i-1]:
        x = heapq.heappop(l)
        heapq.heappush(l, a[n+i-1])
        memo_l[i] += a[n+i-1] - x


r = [-a[-i] for i in range(1, n+1)]
heapq.heapify(r)
memo_r = [0 for _ in range(n+1)]
memo_r[0] = sum(a[-n:])

for i in range(1, n+1):
    memo_r[i] = memo_r[i-1]
    if abs(r[0]) > a[-n-i]:
        x = heapq.heappop(r)
        heapq.heappush(r, -a[-n-i])
        memo_r[i] += x + a[-n-i]


ans = - 10 ** 20
for i in range(n+1):
    ans = max(ans, memo_l[i] - memo_r[n-i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#060_D
n, w_ = map(int, input().split())
w, v = [], []

for _ in range(n):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
    
dp = [[0 for _ in range(w_+1)] for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(1, w_+1):
        if j < w[i-1]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])

print(dp[n][w_])

Fixed submission:
#060_D
n, W = map(int, input().split())
w1, w2, w3, w4 = [], [], [], []
w, v = map(int, input().split())
w1.append(v)
for _ in range(n-1):
    a, b = map(int, input().split())
    if a == w: w1.append(b)
    if a == w+1: w2.append(b)
    if a == w+2: w3.append(b)
    if a == w+3: w4.append(b)
    
for w_ in [w1, w2, w3, w4]:
    w_.sort(reverse= True)
    
ans = 0
for i in range(0, len(w1)+1):
    for j in range(0, len(w2)+1):
        for k in range(0, len(w3)+1):
            res = W - (i * w + j * (w+1) + k * (w+2))
            if res < 0:
                continue
            tmp = sum(w1[:i])+sum(w2[:j])+sum(w3[:k])+sum(w4[:res//(w+3)])
            ans = max(tmp, ans)
            
print(ans)
Buggy python submission (verdict: Runtime Error):
#054_C
from itertools import permutations
n,m=map(int,input().split())
edges=[[False for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edges[a][b]=edges[b][sa]=True

ans=0
for l in permutations(range(1,n),n-1):
    l=[0]+list(l)
    if all(edges[l[i]][l[i+1]] for i in range(n-1)):
        ans+=1
print(ans)

Fixed submission:
#054_C
from itertools import permutations
n,m=map(int,input().split())
edges=[[False for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edges[a][b]=edges[b][a]=True

ans=0
for l in permutations(range(1,n),n-1):
    l=[0]+list(l)
    if all(edges[l[i]][l[i+1]] for i in range(n-1)):
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#051_B
k,s=map(int,input().split())
print(sum([x+y+z==s for x in range(k+1) for y in range(k+1) for z in range(k+1)]))

Fixed submission:
#051_B
k,s=map(int,input().split())
print(sum([0<=s-x-y<=k for x in range(k+1) for y in range(k+1)]))
Buggy python submission (verdict: Runtime Error):
#051_D
from heapq import heappop, heappush
inf = 10 ** 10
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
n, m = map(int, input().split())
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    edges.append((a-1, b-1))

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
                
warshall_floyd(d)

ans = 0
for u, v in edges:
    for i in range(n):
        if i == u or i == v:
            continue
        if d[u][i] + d[i][v] == d[u][v]:
            ans += 1
            break

print(ans)

Fixed submission:
#051_D
inf = 10 ** 10
n, m = map(int, input().split())
d = [[inf for _ in range(n)] for _ in range(n)]
for i in range(n):
    d[i][i] = 0
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    edges.append((a-1, b-1, c))

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
                
warshall_floyd(d)

ans = m
for u, v, c in edges:
    flg = False
    for i in range(n):
        if d[i][v] + c == d[i][u]:
            flg = True
    
    if flg:
        ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#049_C
import sys
sys.setrecursionlimit(100000)

s = input()

def dfs(x):
    if x == s:
        return True
    if len(x) > len(s):
        return False

    if any (dfs(x + k) for k in ['dream', 'dreamer', 'erase', 'eraser']):
        return True
    
    return False

print('YES' if dfs('') else 'NO')

Fixed submission:
#049_C
s = input()[::-1]
k = ['maerd', 'remaerd', 'esare', 'resare']

tmp = 0
flg = True
while tmp < len(s):
    check = False
    for x in k:
        if s[tmp: tmp + len(x)] == x:
            check = True
            tmp += len(x)
    if check == False:
        flg = False
        break
        
print('YES' if flg else 'NO')

Buggy python submission (verdict: Runtime Error):
#049_C
s = input()

def dfs(x):
    if x == s:
        return True
    if len(x) > len(s):
        return False

    if any (dfs(x + k) for k in ['dream', 'dreamer', 'erase', 'eraser']):
        return True
    
    return False

print('YES' if dfs('') else 'NO')

Fixed submission:
#049_C
s = input()[::-1]
k = ['maerd', 'remaerd', 'esare', 'resare']

tmp = 0
flg = True
while tmp < len(s):
    check = False
    for x in k:
        if s[tmp: tmp + len(x)] == x:
            check = True
            tmp += len(x)
    if check == False:
        flg = False
        break
        
print('YES' if flg else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
x = list(map(int, input().split()))

dp = [[[0] * 2501 for _ in range(51)] for _ in range(51)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(2501):
            if k + x[i] <= 2500:
                dp[i+1][j+1][k+x[i]] += dp[i][j][k]
            dp[i+1][j][k] += dp[i][j][k]


ans = 0
for j in range(1, n+1):
    ans += dp[n][j][j * a]

print(ans)

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

dp = [[[0] * 2501 for _ in range(51)] for _ in range(51)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(2501):
            if k + x[i] <= 2500:
                dp[i+1][j+1][k+x[i]] += dp[i][j][k]
            dp[i+1][j][k] += dp[i][j][k]


ans = 0
for j in range(1, n+1):
    ans += dp[n][j][j * a]

print(ans)
Buggy python submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7
n = h + w

f = [1 for _ in range(n)]
for i in range(1, n):
    f[i] = f[i-1] * i

def f_inv(x):
    return pow(f[x], mod-2, mod)

def comb(n, k):
    return (f[n] * f_inv[k] % mod) * f_inv[n-k] % mod

ans = comb(h+w-2, h-1)
for i in range(b):
    print(h-a+i, i)
    print(a+w-i-2, a-1)
    ans -= comb(h-a+i-1, i) * comb(a+w-i-2, a-1) % mod
    ans %= mod

print(ans)

Fixed submission:
h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7
n = h + w

f = [1 for _ in range(n)]
f_inv = [1 for _ in range(n)]
for i in range(1, n):
    f[i] = f[i-1] * i % mod
    f_inv[i] = pow(f[i], mod-2, mod)


def comb(n, k):
    return (f[n] * f_inv[k] % mod) * f_inv[n-k] % mod

ans = comb(h+w-2, h-1)
for i in range(b):
    ans -= comb(h-a+i-1, i) * comb(a+w-i-2, a-1) % mod
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
if 30<= x:
  print"Yes"
else:
  print"No"

Fixed submission:
X = int(input())

if 30<= X:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
x = max(map(len,input().split(S)))
print(x)

Fixed submission:
x = max(map(len,input().split("S")))
print(x)
Buggy python submission (verdict: Runtime Error):
N = map(int,input())
x = 0
while x < N :
  x = x + 1000
print(x-N)

Fixed submission:
N = int(input())
x = 0
while x < N :
  x = x + 1000
print(x-N)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

for a in range(0,A+1):
  y = X-500*a
  if y<500:
    break

for b in range(0,B+1):
  z = y-100*b
  if z<100:
    break

for c in range(0,C+1):
  w = z-50*a
  if w<50:
    break
if w != 0:
  print(0)
else:
  d = (X-y)/500
  e = (y-z)/100
  f = (z-w)/50
  i = -1
  for n in range(0,d+1):
    if B-e-5*n >= 0:
      i=i+1
  for m in range(0,e+5*i):
    if C-f-2*m >= 0:
      i=i+1
  print(i)
    
  
 
    
    



Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
i=0
for a in range(0,A+1):
  for b in range(0,B+1):
    for c in range(0,C+1):
      if 500*a + 100*b + 50*c == X:
        i = i+1
print(i)
Buggy python submission (verdict: Runtime Error):
x = input().split()
y = int(x[0])*int(x[1])
if y%2 = 1:
  print("Odd")
else:
  print("Even")

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

Buggy python submission (verdict: Runtime Error):
x = imput().split()
y = int(x[0])*int(x[1])
if y % 2:
  print("Odd")
else:
  print("Even")

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

Buggy python submission (verdict: Runtime Error):
x = imput().split()
y = int(x[0])*int(x[1])
if y%2 = 1:
  print("Odd")
else:
  print("Even")

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

Buggy python submission (verdict: Runtime Error):
x = split().input()
y = int(x[0])*int(x[1])
if y%2 = 0:
  print(Even)
else:
  print(Odd)


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

Buggy python submission (verdict: Runtime Error):
if a*b % =0:
	print(even)
else:
    print(odd)

Fixed submission:
a, b = map(int, input().split())
if (a*b) % 2:
  print("Odd")
else:
  print("Even")
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
for M in range(1,N+1,1)
  n =　str(M)
  a=0
  b=0
  c=0
  d=0
  e=0
  y=0
  if N=10000:
    e=n[0]
  if 1000<=N<10000:
    d=n[0]
    c=n[1]
    b=n[2]
    a=n[3]
  if 100<=N<1000:
    c=n[0]
    b=n[1]
    a=n[2]
  if 10<=N<100:
    b=n[0]
    a=n[1]
  if N<10:
    a=n[0]
  x = int(d) + int(c) + int(b) + int(a) + int(e)
  if A <= x <= B:
    y = y + int(n)
  print(y)





Fixed submission:
N,A,B = map(int,input().split())
a=0
b=0
c=0
d=0
e=0
y=0
for i in range(1,N+1,1):
  n = str(i)
 
  if int(n)==10000:
    e=n[0]
    d=n[1]
    c=n[2]
    b=n[3]
    a=n[4]
  if 1000<=int(n)<10000:
    d=n[0]
    c=n[1]
    b=n[2]
    a=n[3]
  if 100<=int(n)<1000:
    c=n[0]
    b=n[1]
    a=n[2]
  if 10<=int(n)<100:
    b=n[0]
    a=n[1]
  if int(n)<10:
    a=n[0]
  x = int(d) + int(c) + int(b) + int(a) + int(e)
  if A <= x <= B:
    y = y + int(n)
print(y)
Buggy python submission (verdict: Runtime Error):
print(count("1"))

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
import math 
N = input()
a =list(map(int,input().split()))
for i in a:
  B = min(len(bin(i)) -  bin(i).rfind("1") - 1)
print(B)

Fixed submission:
import math 
N = int(input())
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))

Buggy python submission (verdict: Runtime Error):
import math 
N = input().int()
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))


Fixed submission:
import math 
N = int(input())
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))

Buggy python submission (verdict: Runtime Error):
N = input().int()
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))


Fixed submission:
import math 
N = int(input())
A = map(int,input().split())
B = map(bin,A)
def Y(x):
  y = len(x)-x.rfind("1")-1
  return y
C = map(Y,B)
print(min(C))
Buggy python submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
def jouken(a,waru):
    return a**2%waru
ni = 0
num =0
for i in range(n-1):
    ni = x
    if i ==0:
        num+=x
    x = jouken(ni,m)
    num+=x
print(num)


Fixed submission:
sentence = input()
if sentence[-1] == 's':
  print(sentence+'es')
else:
  print(sentence+'s')
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
S,T = len(s),len(t)

ans = T

for i in range(S-T+1):
    tmp = [c1!=c2 for c1,c2 in zip(s[i:i+T],t)].count(True)
    ans = min(ans,tmp)

print(ans)


Fixed submission:
D,T,S = map(int,input().split())
if D/T <= S:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import bisect
N, K = map(int, input().split())

LR = [list(map(int, input().split())) for i in range(K)]
S = set()
for i in LR:
    for j in range(i[0], i[1]+1):
        S.add(j)
L = sorted(list(S))

dp = [0 for i in range(N)]
dp[0] = 1
for i in range(1, N):
    x = bisect.bisect(L, i)
    t = L[:x]
    for j in t:
        dp[i] += dp[i-j]
    dp[i] = dp[i] % 998244353

print(dp[-1] % 998244353)


Fixed submission:
S = input()

if S[-1] == 's':
    print(S + 'es')
else:
    print(S + 's')
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = [map(int, input().split()) for i in range(N)]

seq = 0
for i in range(len(D)):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                print('Yes')
                exit()

print('No')


Fixed submission:
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]

seq = 0
for i in range(len(D)-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                print('Yes')
                exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

cnt = 0
for A in range(1,N):
    for B in range(1,N):
        if A * B <= N-1:
            cnt += 1
        else:
            break
print(cnt)


Fixed submission:
N = int(input())
cnt = 0
for A in range(1,N):
    cnt += (N-1) // A
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)

#N = 12
#A = [12,9,9,6,6,5,5,4,3,2,1,1]

ret = 0
array = []
array.append(A.pop())
while len(A) > 0:
    #print('array', array)
    comfort = [0 for i in range(len(array))]
    for i in range(len(comfort)):
        comfort[i] = min(array[i-1], array[i])
    #print('comfort', comfort)
    val = max(comfort)
    ret += val
    #print('ret', ret)
    array.insert(comfort.index(val), A.pop())

print(ret)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)

ret = 0
c_pointer = 0
comfort = []
tmp = A.pop()
comfort.append(tmp)

while len(A) > 0:
    tmp = A.pop()
    c_pointer += 1
    comfort.append(tmp)
    comfort.append(tmp)

print(sum(comfort[:c_pointer]))
Buggy python submission (verdict: Runtime Error):
import bisect

N, M, K = input().split()

desk1 = list(map(int, input().split()))
desk2 = list(map(int, input().split()))

max_time = int(K)
item1 = [0]
item2 = [0]
for i in desk1:
    item1.append(item1[-1] + i)
for i in desk2:
    item2.append(item2[-1] + i)

ret = 0
for i, t in enumerate(item1):
    remain_time = max_time - t
    if remain_time > 0:
        j = bisect.bisect(item2, remain_time) - 1
        if j < 0:
            j = 0
        ret = max(ret, i + j)
    else:
        ret = max(ret, i)
print(ret)import bisect

N, M, K = input().split()

desk1 = list(map(int, input().split()))
desk2 = list(map(int, input().split()))

max_time = int(K)
item1 = [0]
item2 = [0]
for i in desk1:
    item1.append(item1[-1] + i)
for i in desk2:
    item2.append(item2[-1] + i)

ret = 0
for i, t in enumerate(item1):
    remain_time = max_time - t
    if remain_time > 0:
        j = bisect.bisect(item2, remain_time) - 1
        if j < 0:
            j = 0
        ret = max(ret, i + j)
    else:
        ret = max(ret, i)
print(ret)

Fixed submission:
import bisect

N, M, K = input().split()

desk1 = list(map(int, input().split()))
desk2 = list(map(int, input().split()))

max_time = int(K)
item1 = [0]
item2 = [0]
for i in desk1:
    item1.append(item1[-1] + i)
for i in desk2:
    item2.append(item2[-1] + i)

ret = 0
for i, t in enumerate(item1):
    remain_time = max_time - t
    if remain_time >= 0:
        j = bisect.bisect(item2, remain_time) - 1
        ret = max(ret, i + j)

print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
def lcm(a,b):
    return (a * b // gcd(a, b))
h = reduce(lcm, A)
B = [(h // A[i] % MOD) for i in range(N)]
print(sum(B) % MOD)


Fixed submission:
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

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

def modpow(a, n, mod): # a^n mod
    result = 1
    while n > 0:
        if n & 1: result = result * a % mod
        a = a * a % mod
        n >>= 1
    return result

h = reduce(lcm, A)
B = [h * modpow(A[i], MOD-2, MOD) for i in range(N)]
print(sum(B) % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
B = [i for i in range(N)]
MOD = 10 ** 9 + 7
def lcm(a,b):
    return a * b // gcd(a, b)
h = reduce(lcm, A)

for i in range(N):
    B[i] = (h // A[i] % MOD)

print(sum(B) % MOD)


Fixed submission:
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

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

def modpow(a, n, mod): # a^n mod
    result = 1
    while n > 0:
        if n & 1: result = result * a % mod
        a = a * a % mod
        n >>= 1
    return result

h = reduce(lcm, A)
B = [h * modpow(A[i], MOD-2, MOD) for i in range(N)]
print(sum(B) % MOD)

Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
B = [i for i in range(N)]
MOD = 10 ** 9 + 7
def lcm(a,b):
    return a * b // gcd(a, b)
h = reduce(lcm, A)

for i in range(N):
    B[i] = (h // A[i] % MOD)

print(sum(B) % MOD)


Fixed submission:
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

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

def modpow(a, n, mod): # a^n mod
    result = 1
    while n > 0:
        if n & 1: result = result * a % mod
        a = a * a % mod
        n >>= 1
    return result

h = reduce(lcm, A)
B = [h * modpow(A[i], MOD-2, MOD) for i in range(N)]
print(sum(B) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
#from operator import mul
from math import factorial
#from functools import reduce
X, Y = map(int, input().split())
MOD = (10 ** 9) + 7
if ((2 * X) - Y) % 3 != 0:
    print(0)
    exit()
q = ((2 * X) - Y) // 3
p = X - (2 * q)
if q < 0 or p < 0:
    print(0)
    exit()
r = max(p, q)
s = min(p, q)

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p))%p

print(comb(r+s, r, MOD) % MOD)


Fixed submission:
from operator import mul
from math import factorial
from functools import reduce

def modpow(a, n, mod): # a^n mod
    result = 1
    while n > 0:
        if n & 1: result = result * a % mod
        a = a * a % mod
        n >>= 1
    return result

X, Y = map(int, input().split())
MOD = (10 ** 9) + 7
if ((2 * X) - Y) % 3 != 0:
    print(0)
    exit()
q = ((2 * X) - Y) // 3
p = X - (2 * q)
if q < 0 or p < 0:
    print(0)
    exit()
r = max(p, q)
s = min(p, q)

over = 1
for i in range(2,r+s+1):
    over = (over * i) % MOD
under = 0
e = 1
f = 1
for i in range(2,s+1):
    e = (e * i) % MOD
for i in range(2,r+1):
    f = (f * i) % MOD
under = e * f

result = (over * modpow(under, MOD-2, MOD) % MOD)
print(result)
Buggy python submission (verdict: Runtime Error):
import sys

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

dif = math.inf

for i in range(1,N):
    tmp = abs(sum(W[:i]) - sum(W[i:]))
    if dif > tmp:
        dif = tmp
print(dif)


Fixed submission:
import sys

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

dif = 9999999999

for i in range(1,N):
    tmp = abs(sum(W[:i]) - sum(W[i:]))
    if dif > tmp:
        dif = tmp
print(dif)

Buggy python submission (verdict: Runtime Error):
import sys
import math
N = int(input())
W = list(map(int,input().split()))

dif = math.inf

for i in range(1,N):
    tmp = abs(sum(W[:i]) - sum(W[i:]))
    print(i,tmp)
    if dif > tmp:
        dif = tmp
print(dif)


Fixed submission:
import sys

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

dif = 9999999999

for i in range(1,N):
    tmp = abs(sum(W[:i]) - sum(W[i:]))
    if dif > tmp:
        dif = tmp
print(dif)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
cnt = 0
if N == 2:
    cnt = 1
elif N == 3:
    cnt = 3
elif N > 3:
    cnt = 3
    for i in range(1,N-1):
        A = N-i
        rA = math.sqrt(A)
        intA = math.floor(rA)
        if rA == intA:
            cnt -= 1
        if intA == 1:
            cnt += 1
        else:
            for j in range(1,intA+1):
                if A%j == 0:
                    cnt += 2

print(cnt)

Fixed submission:
S = input()
l = len(S)
if S[l-1]=='s':
    S = S + 'es'
else:
    S = S + 's'
print(S)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

if N == 2:
    cnt = 1
elif N == 3:
    cnt = 3
elif N > 3:
    cnt = 3
    for i in range(1,N-1):
        A = N-i
        rA = math.sqrt(A)
        intA = math.floor(rA)
        if rA == intA:
            cnt -= 1
        if intA == 1:
            cnt += 1
        else:
            for j in range(1,intA+1):
                if A%j == 0:
                    cnt += 2

print(cnt)

Fixed submission:
S = input()
l = len(S)
if S[l-1]=='s':
    S = S + 'es'
else:
    S = S + 's'
print(S)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

if N == 2:
    cnt = 1
elif N == 3:
    cnt = 3
    
elif N > 3:
    for i in range(1,N-1):
        A = N-i
        rA = math.sqrt(A)
        intA = math.floor(rA)
        if rA == intA:
            cnt -= 1
        if intA == 1:
            cnt += 1
        else:
            for j in range(1,intA+1):
                if A%j == 0:
                    cnt += 2

print(cnt)

Fixed submission:
S = input()
l = len(S)
if S[l-1]=='s':
    S = S + 'es'
else:
    S = S + 's'
print(S)
Buggy python submission (verdict: Runtime Error):
    pass1 = str(input())
    pass2 = str(input())
    
    pass2_org = pass2[0:-1]
    
    if pass1 == pass2_org:
        print(f'Yes')
    else:
        print(f'No')

Fixed submission:
pass1 = str(input())
pass2 = str(input())
  
pass2_org = pass2[0:-1]
  
if pass1 == pass2_org:
    print(f'Yes')
else:
    print(f'No')