Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
S = input()
n = len(S)
mod = 10**9+7

facs = [1] * (n+k)
invs = [1] * (n+k)
nfac = 1
for i in range(1, n+k):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

ans = 0
for i in range(k+1):
    left = facs[i+n-1] * invs[i] * invs[n-1] % mod
    left = left * pow(25, i, mod) % mod
    ans += left * pow(26, k-i, mod) % mod
    ans %= mod
print(ans)

Fixed submission:
k = int(input())
S = input()
n = len(S)
mod = 10**9+7

facs = [1] * (n+k)
# invs = [1] * (n+k)
nfac = 1
for i in range(1, n+k):
    nfac = nfac * i % mod
    facs[i] = nfac
    # invs[i] = pow(facs[i], mod-2, mod)
invn1 = pow(facs[n-1], mod-2, mod)

ans = 0
for i in range(k+1):
    left = facs[i+n-1] * pow(facs[i], mod-2, mod) * invn1 % mod
    left = left * pow(25, i, mod) % mod
    ans += left * pow(26, k-i, mod) % mod
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = []
B = []
for _ in range(n):
    a, b = tuple(map(int, input().split()))
    A.append(a)
    B.append(b)

A = sorted(A)
B = sorted(B)

if n%2==1:
    sa = AB_A[n//2]
    lb = AB_B[n//2]
    print(lb - sa + 1)
else:
    sal = AB_A[n//2-1]
    sar = AB_A[n//2]

    lbl = AB_B[n//2-1]
    lbr = AB_B[n//2]
    print((lbl + lbr) - (sal + sar) +1)


Fixed submission:
n = int(input())

AB = []
for _ in range(n):
    ab = tuple(map(int, input().split()))
    AB.append(ab)

AB_A = sorted(AB, key=lambda x: x[0])
AB_B = sorted(AB, key=lambda x: x[1])

if n%2==1:
    sa, sb = AB_A[n//2]
    la, lb = AB_B[n//2]
    print(lb - sa + 1)
else:
    sal, sbl = AB_A[n//2-1]
    sar, sbr = AB_A[n//2]

    lal, lbl = AB_B[n//2-1]
    lar, lbr = AB_B[n//2]
    print((lbl + lbr) - (sal + sar) +1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
mod = 998244353

facs = [1] * N
nfac = 1
for i in range(1, N):
    nfac = nfac * i % mod
    facs[i] = nfac

s = 0
for i in range(K+1):
    d = facs[N-1] * pow(facs[i], mod-2, mod) * pow(facs[N-1-i], mod-2, mod) \
        * M * pow(M-1, N-1-i, mod) % mod
    s = (s + d) % mod

print(s)

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

facs = [1] * N
invs = [1] * N
nfac = 1
for i in range(1, N):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

s = 0
for i in range(K+1):
    d = facs[N-1] * invs[i] * invs[N-1-i] \
        * M * pow(M-1, N-1-i, mod) % mod
    s = (s + d) % mod

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
mod = 998244353

facs = [1] * (N + 1)
nfac = 1
for i in range(1, N):
    nfac = nfac * i %mod
    facs[i] = nfac

s = 0
for i in range(0, K+1):
    patterns = facs[N-1] * pow(facs[i], mod-2, mod) * pow(facs[N-1-i], mod-2, mod) % mod
    d = patterns * M * pow(M-1, N-1-i, mod) % mod
    s = (s + d) % mod

print(s)

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

facs = [1] * N
invs = [1] * N
nfac = 1
for i in range(1, N):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

s = 0
for i in range(K+1):
    d = facs[N-1] * invs[i] * invs[N-1-i] \
        * M * pow(M-1, N-1-i, mod) % mod
    s = (s + d) % mod

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
mod = 998244353

facs = [1]        
nfac = 1
for i in range(1, N):
    nfac = nfac * i %mod
    facs.append(nfac)

s = 0
for i in range(0, K+1):
    patterns = facs[N-1] * pow(facs[i], mod-2, mod) * pow(facs[N-1-i], mod-2, mod) % mod
    d = patterns * M * pow(M-1, N-1-i, mod) % mod
    s = (s + d) % mod

print(s % mod)

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

facs = [1] * N
invs = [1] * N
nfac = 1
for i in range(1, N):
    nfac = nfac * i % mod
    facs[i] = nfac
    invs[i] = pow(facs[i], mod-2, mod)

s = 0
for i in range(K+1):
    d = facs[N-1] * invs[i] * invs[N-1-i] \
        * M * pow(M-1, N-1-i, mod) % mod
    s = (s + d) % mod

print(s)
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe'

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
for i in range(len(S) - 3):
    for j in range(i+5, len(S)+1):
        if int(S[i:j]) % 2019 == 0:
            count += 1
            break
print(count)

Fixed submission:
S = input()
mod = 2019

cs_mods = {0:1}
cumsum = 0
count = 0
for i, s in enumerate(S[::-1]):
    cumsum = (cumsum + int(s) * pow(10, i, mod)) % mod
    cs_mods.setdefault(cumsum, 0)
    # count += cs_mods[cumsum]
    cs_mods[cumsum] += 1

# count = 0
for k, v in cs_mods.items():
    count += v*(v-1)//2

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
for i in range(len(S) - 3):
    for j in range(i+5, len(S)+1):
        if int(S[i:j]) % 2019 == 0:
            count += 1
print(count)

Fixed submission:
S = input()
mod = 2019

cs_mods = {0:1}
cumsum = 0
count = 0
for i, s in enumerate(S[::-1]):
    cumsum = (cumsum + int(s) * pow(10, i, mod)) % mod
    cs_mods.setdefault(cumsum, 0)
    # count += cs_mods[cumsum]
    cs_mods[cumsum] += 1

# count = 0
for k, v in cs_mods.items():
    count += v*(v-1)//2

print(count)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
for i in range(i, len(S) - 4):
    for j in range(i+4, len(S)):
        if int(S[i:j]) // 2019 == 0:
            count += 1
print(count)

Fixed submission:
S = input()
mod = 2019

cs_mods = {0:1}
cumsum = 0
count = 0
for i, s in enumerate(S[::-1]):
    cumsum = (cumsum + int(s) * pow(10, i, mod)) % mod
    cs_mods.setdefault(cumsum, 0)
    # count += cs_mods[cumsum]
    cs_mods[cumsum] += 1

# count = 0
for k, v in cs_mods.items():
    count += v*(v-1)//2

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*nums):
    return reduce(math.gcd, nums)

K = int(input())
s = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            s += gcd(a, b, c)
print(s)

Fixed submission:
import math
from functools import reduce
def gcd(*nums):
    return reduce(math.gcd, nums)

K = int(input())
s = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(b, K+1):
            if b == c:
                s += gcd(a, b, c)
            else:
                s += 2*gcd(a, b, c)
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
R_indices = []
G_indices = []
B_indices = []
for i, s in enumerate(S):
    if s == 'R':
        R_indices.append(i)
    elif s == 'G':
        G_indices.append(i)
    elif s == 'B':
        B_indices.append(i)

count = len(R_indices) * len(G_indices) * len(B_indices)

for r in R_indices:
    for g in G_indices:
        for b in B_indices:
            i, j ,k = sorted([r, g, b])
            if j - i == k - j:
                count -=  1

print(count)

Fixed submission:
N = int(input())
S = input()
moji = {'R', 'G', 'B'}

count = 0
for j in range(1, N-1):
    sj = S[j]
    diff_m = moji - {sj}
    rem_moji = list(diff_m)
    for mi, mj in zip(rem_moji, rem_moji[::-1]):
        ci = S.count(mi, 0, j)
        ck = S.count(mj, j+1, N)
        count += ci * ck

    l = min([j+1, N - j])
    for d in range(1, l):
        si = S[j-d]
        sk = S[j+d]
        if si != sj and sj != sk and sk != si:
            count -= 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
moji = {'R', 'G', 'B'}

count = 0
for j in range(1, N-1):
    sj = S[j]
    for i in range(0, j):
        si = S[i] 
        if si == sj:
            continue
        
        diff_m = moji - {sj, si}
        m = list(diff_m)[0]
        c = S.count(m, j+1, N)

        if (j+j-i) < N:
            sk = S[j + j - i]
            if sk != sj and sk != si:
                c -= 1
        count += c

print(count)

Fixed submission:
N = int(input())
S = input()
moji = {'R', 'G', 'B'}

count = 0
for j in range(1, N-1):
    sj = S[j]
    diff_m = moji - {sj}
    rem_moji = list(diff_m)
    for mi, mj in zip(rem_moji, rem_moji[::-1]):
        ci = S.count(mi, 0, j)
        ck = S.count(mj, j+1, N)
        count += ci * ck

    l = min([j+1, N - j])
    for d in range(1, l):
        si = S[j-d]
        sk = S[j+d]
        if si != sj and sj != sk and sk != si:
            count -= 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

count = 0
for i in range(0, N-2):
    si = S[i]

    for j in range(i+1, N-1):
        sj = S[j]
        if si == sj:
            continue
        else:
            for k in range(j+1, N):
                if si == S[k] or sj == S[k]:
                    continue
                if j - i != k - j:
                    count += 1

print(count)

Fixed submission:
N = int(input())
S = input()
moji = {'R', 'G', 'B'}

count = 0
for j in range(1, N-1):
    sj = S[j]
    diff_m = moji - {sj}
    rem_moji = list(diff_m)
    for mi, mj in zip(rem_moji, rem_moji[::-1]):
        ci = S.count(mi, 0, j)
        ck = S.count(mj, j+1, N)
        count += ci * ck

    l = min([j+1, N - j])
    for d in range(1, l):
        si = S[j-d]
        sk = S[j+d]
        if si != sj and sj != sk and sk != si:
            count -= 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int, input().split()))

d = dict()
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

for k in range(0, N):
    c = 0
    ak = A[k]
    for key, v in d.items():
        if key == ak:
            c += (v-1)*(v-2)//2
        else:
            c += v*(v-1)//2
    print(c)

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

d = dict()
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

counts = 0
for k, v in d.items():
    counts += v*(v-1)//2

for k in range(0, N):
    ak = A[k]
    print(counts - d[ak] + 1)
Buggy python submission (verdict: Runtime Error):
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K])

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input()) - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
S = input()
Q = int(input())

state = 1 # 反転していたら-1
for i in range(Q):
    q = input()
    if q == '1':
        state *= -1
    else:
        Y, f, c = q.split()
        if (state == 1 and f == '1') or (state == -1 and f == '2'):
            S = c + S
        elif (state == 1 and f == '2') or (state == -1 and f == '1'):
            S = S + c

if state == -1:
    S = S[::-1]
print(S)


Fixed submission:
from collections import deque
S = input()
Q = int(input())

state = 1 # 反転していたら-1
Stock = deque([S])
for i in range(Q):
    q = input()
    if q == '1':
        state *= -1
    else:
        Y, f, c = q.split()
        if (state == 1 and f == '1') or (state == -1 and f == '2'):
            Stock.appendleft(c)
        elif (state == 1 and f == '2') or (state == -1 and f == '1'):
            Stock.append(c)
S = ''.join(Stock)
if state == -1:
    S = S[::-1]
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Y = [0] * Q
Task = [0] * Q

state = 1 # 反転していたら-1
for i in range(Q):
    q = input()
    if q == '1':
        state *= -1
    else:
        Y, f, c = q.split()
        if (state == 1 and f == '1') or (state == -1 and f == '2'):
            S = c + S
        elif (state == 1 and f == '2') or (state == -1 and f == '1'):
            S = S + c

if state == -1:
    S = S[::-1]
print(S)


Fixed submission:
from collections import deque
S = input()
Q = int(input())

state = 1 # 反転していたら-1
Stock = deque([S])
for i in range(Q):
    q = input()
    if q == '1':
        state *= -1
    else:
        Y, f, c = q.split()
        if (state == 1 and f == '1') or (state == -1 and f == '2'):
            Stock.appendleft(c)
        elif (state == 1 and f == '2') or (state == -1 and f == '1'):
            Stock.append(c)
S = ''.join(Stock)
if state == -1:
    S = S[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
N = int(input())
xlist = list(map(int, input().split()))
def power(p, xlist):
    s = 0
    for x in xlist:
        s += (x - p)**2
    return s

xmax = max(xlist)
xmin = min(xlist)
powers = []
for p in range(xmin, xmax):
    powers.append(power(p, xlist))
print(min(powers))

Fixed submission:
N = int(input())
xlist = list(map(int, input().split()))
p = round(sum(xlist) / N)
s = 0
for x in xlist:
    s += (x-p)**2
print(s)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
counts = [0]*(n+1)
counts[1] = n
mod = 10**9+7
for i in range(2, n+1):
    counts[i] = counts[i-1] * (n-i+1) // i % mod
counts[a] = 0
counts[b] = 0
print(sum(counts))

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9+7
ans = pow(2, n, mod) - 1

up = 1
bo = 1
for i in range(b):
    up = up*(n-i)%mod
    bo = bo*(i+1)%mod
    if i == a-1:
        acombs = up*pow(bo, mod-2, mod)%mod

bcombs = up*pow(bo, mod-2, mod)%mod

print((ans - acombs - bcombs)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(0, N):
    p_i = P[i]
    for j in range(0, i):
        if p_i > P[j]:
            break
    else:
        count += 1

print(count)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
count = 0
leftmin = P[0]
for i in range(0, N):
    if leftmin >= P[i]:
        count += 1

    if leftmin > P[i]:
        leftmin= P[i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
c = 1

for i in range(N-1):
    Q = P[0:i+2]
    if P[i+1] <= min(Q):
        c = c+1
    else:
        c = c
print(c)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))
count = 0
leftmin = P[0]
for i in range(0, N):
    if leftmin >= P[i]:
        count += 1

    if leftmin > P[i]:
        leftmin= P[i]

print(count)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs(maze, h, w, si, sj):
    q = deque([[si, sj]])
    score = [[0] * w for i in range(h)]

    pattern = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    while len(q) > 0:
        i, j = q.popleft()
        for move in pattern:
            ni, nj= i + move[0], j + move[1]
            if ni < 0 or h <= ni or nj < 0 or w <= nj:
                continue
            p = maze[ni][nj]
            if p == '#':
                continue
            if p == '.' and not score[ni][nj]:
                score[ni][nj] = score[i][j] + 1
                q.append([ni, nj])
    return max(sum(score, []))
  
h, w = map(int, input().split())
maze = [input() for i in range(h)]
scores = []
for si  in range(h):
    for sj in range(w):
        memo.append((si, sj))
        if maze[si][sj] == "#":
            continue
        scores.append(bfs(maze, h, w, si, sj))
print(max(scores))

Fixed submission:
print(chr(ord(input())+1))

Buggy python submission (verdict: Runtime Error):
print(chr(ord(input())+1)

Fixed submission:
print(chr(ord(input())+1))
Buggy python submission (verdict: Runtime Error):
# 大きさnの順列をすべて生成する
from itertools import permutations
def generate_permutations(n):
    perms = permutations(range(1, n+1), n)
    return [perm for perm in perms]

n = int(input())
ptuple = tuple(map(int, input().split()))
qtuple = tuple(map(int, input().split()))

perms = generate_permutations(n)
a = perms.index(ptuple)
b = perms.index(qtuple)
print(int(math.fabs(a - b)))

Fixed submission:
k, x = map(int, input().split())

if 500 * k  >= x:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# 大きさnの順列をすべて生成する
from itertools import permutations
def generate_permutations(n):
    perms = permutations(range(1, n+1), n)
    return [perm for perm in perms]

n = int(input())
ptuple = tuple(map(int, input().split()))
qtuple = tuple(map(int, input().split()))
 
perms = generate_permutations(n)
a = perms.index(ptuple)
b = perms.index(qtuple)
print(int(math.fabs(a - b)))

Fixed submission:
import math

def number(plist):
    a = 1
    memo = []
    while len(plist) > 0:
        p = plist.pop(0)
        memo.append(p)
        num = len(set(range(1, p)) - set(memo))
        a += math.factorial(len(plist)) * num
    return a

n = int(input())
plist = list(map(int, input().split()))
qlist = list(map(int, input().split()))

a = number(plist)
b = number(qlist)
print(int(math.fabs(a - b)))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

import math
l = A * B / math.gcd(A, B)
print(int(l))

Fixed submission:
A, B = map(int, input().split())
 
import fractions
l = A * B / fractions.gcd(A, B)
print(int(l))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

ans = 0
for k in range(61):
    num1 = 0
    for a in A:
        if (a >> k) & 1:
            num1 += 1
    ans += (num1 * (N-num1)) << k
    ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

def solve(N, A):
    ans = 0
    for k in range(61):
        num1 = 0
        for a in A:
            if (a >> k) & 1:
                num1 += 1
        ans += (num1 * (N-num1)) << k
        ans %= mod
    return ans
    
print(solve(N, A))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

ans = 0
for k in range(60):
    num1 = 0
    num0 = 0
    for a in A:
        if (a >> k) & 1:
            num1 += 1
        else:
            num0 += 1
    ans += num1 * num0 * pow(2, k) % mod
    ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

def solve(N, A):
    ans = 0
    for k in range(61):
        num1 = 0
        for a in A:
            if (a >> k) & 1:
                num1 += 1
        ans += (num1 * (N-num1)) << k
        ans %= mod
    return ans
    
print(solve(N, A))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

ans = 0
for k in range(0, 100):
    num1 = 0
    num0 = 0
    for a in A:
        if (a >> k) & 1:
            num1 += 1
        else:
            num0 += 1

    ans += num1 * num0 * pow(2, k) % mod
    ans %= mod

print(ans)


Fixed submission:
N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

def solve(N, A):
    ans = 0
    for k in range(61):
        num1 = 0
        for a in A:
            if (a >> k) & 1:
                num1 += 1
        ans += (num1 * (N-num1)) << k
        ans %= mod
    return ans
    
print(solve(N, A))
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
from collections import deque
q = deque([0])

prices = [100, 101, 102, 103, 104, 105]

while q:
    cost = q.pop()

    if cost > x:
        continue
    elif any([(x-cost)%p == 0 for p in prices]):
        print(1)
        break

    for p in prices:
        q.append(cost+p)
else:
    print(0)

Fixed submission:
x = int(input())
c = 1
while True:
    if c*100 <= x <= c*105:
        print(1)
        break

    if c*100 > x:
        print(0)
        break
    c += 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()

sapp = [[0] * n for _ in range(10)]

for idx, s in enumerate(S):
    si = int(s)
    sapp[si][idx] = 1

from itertools import accumulate
sacc = [list(accumulate(sa)) for sa in sapp]

pins = set()
for i in range(1, n-1):
    for lnum in range(10):
        lnumc = sacc[lnum][i-1]
        if lnumc == 0:
            continue
        for rnum in range(10):
            # i+1から最後までで出現するか
            rnumc = sacc[rnum][-1] - sacc[rnum][i]
            if rnumc > 0:
                pins.add(str(lnum) + S[i] + str(rnum))

print(len(pins))

Fixed submission:
n = int(input())
S = input()
ans = 0
nums = list(map(str, range(10)))
for i in nums:
    s1 = S.find(i)
    if s1 < 0:
        continue
    for j in nums:
        s2 = S.find(j, s1+1)
        if s2 < 0:
            continue
        for k in nums:
            s3 = S.find(k, s2+1)
            if s3 > 0:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()

nums = set()
from itertools import combinations
for c in combinations(list(range(n)), 3):
    ss = S[c[0]]  + S[c[1]]  + S[c[2]]
    nums.add(ss)

print(len(nums))


Fixed submission:
n = int(input())
S = input()
ans = 0
nums = list(map(str, range(10)))
for i in nums:
    s1 = S.find(i)
    if s1 < 0:
        continue
    for j in nums:
        s2 = S.find(j, s1+1)
        if s2 < 0:
            continue
        for k in nums:
            s3 = S.find(k, s2+1)
            if s3 > 0:
                ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int, input().split())
mod = 10**9 + 7

if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    def combs(n,n2x):
        invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n+1):
            nfac = nfac * i % mod
            invs[i] = pow(nfac, mod-2, mod)
        return nfac * invs[n2x] * invs[n-n2x] % mod

    print(combs(n, n2x))


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

if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    def combs(n,n2x):
        invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n+1):
            nfac = nfac * i % mod
            invs[i] = pow(nfac, mod-2, mod)
        return nfac * invs[n2x] * invs[n-n2x] % mod

    print(combs(n, n2x))

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

if (X + Y) % 3 != 0:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    def combs(n,n2x):
        facs = [1] * (n+1)
        invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n+1):
            nfac = nfac * i % mod
            facs[i] = nfac
            invs[i] = pow(facs[i], mod-2, mod)
        return facs[n] * invs[n2x] * invs[n-n2x] % mod

    print(combs(n, n2x))


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

if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    def combs(n,n2x):
        invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n+1):
            nfac = nfac * i % mod
            invs[i] = pow(nfac, mod-2, mod)
        return nfac * invs[n2x] * invs[n-n2x] % mod

    print(combs(n, n2x))

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

if (X + Y) % 3 != 0:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    facs = [1] * (n+1)
    invs = [1] * (n+1)
    nfac = 1
    for i in range(1, n+1):
        nfac = nfac * i % mod
        facs[i] = nfac
        invs[i] = pow(facs[i], mod-2, mod)
    
    combs = facs[n] * invs[n2x] * invs[n-n2x] % mod
    print(combs)

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

if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n2x = (2*X - Y) // 3
    n1x = (2*Y - X) // 3
    n = n2x + n1x

    # nCn2xを求める
    def combs(n,n2x):
        invs = [1] * (n+1)
        nfac = 1
        for i in range(1, n+1):
            nfac = nfac * i % mod
            invs[i] = pow(nfac, mod-2, mod)
        return nfac * invs[n2x] * invs[n-n2x] % mod

    print(combs(n, n2x))