Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import product
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

hmax_index = []
for i in range(H):
    if hsum[i] == hmax:
        hmax_index.append(i)
wmax_index = []
for i in range(H):
    if wsum[i] == wmax:
        wmax_index.append(i)

for x in hmax_index:
    for y in wmax_index:
        if (x, y) not in s:
            print(hmax+wmax)
            sys.exit()
print(hmax+wmax-1)

Fixed submission:
import sys
from itertools import product
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

hmax_index = []
for i in range(H):
    if hsum[i] == hmax:
        hmax_index.append(i)
wmax_index = []
for i in range(W):
    if wsum[i] == wmax:
        wmax_index.append(i)

for x in hmax_index:
    for y in wmax_index:
        if (x, y) not in s:
            print(hmax+wmax)
            sys.exit()
print(hmax+wmax-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

for i in range(H):
    for j in range(W):
        if hsum[i] == hmax and wsum[j] == wmax and (i, j) not in s:
            print(hmax + wmax)
            sys.exit()
print(hmax+wmax-1)

Fixed submission:
import sys
from itertools import product
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

hmax_index = []
for i in range(H):
    if hsum[i] == hmax:
        hmax_index.append(i)
wmax_index = []
for i in range(W):
    if wsum[i] == wmax:
        wmax_index.append(i)

for x in hmax_index:
    for y in wmax_index:
        if (x, y) not in s:
            print(hmax+wmax)
            sys.exit()
print(hmax+wmax-1)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
if s == 'SSS':
    print(3)
elif s == 'SSR' or s == 'RSS':
    print(2)
elif s == 'SRR' or s == 'RSR' s == 'RRS' or s == 'SRS':
    print(1)
else:
    print(0)

Fixed submission:
s = input()
ans = 0
if s == 'SSS':
    print(0)
elif s == 'SSR' or s == 'RSS' or s == 'SRS' or s == 'RSR':
    print(1)
elif s == 'SRR' or s == 'RRS':
    print(2)
else:
    print(3)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
N, M, K = map(int, input().split())
A = deque([int(i) for i in input().split()])
B = deque([int(i) for i in input().split()])
if sum(A) + sum(B) <= K:
    print(N+M)
    sys.exit()
cur = 0
ans = 0
while cur < K and ans < N+M:
    if len(A) != 0 and len(B) != 0:
        a = A.popleft()
        b = B.popleft()
        if a <= b:
            cur += a
            if cur > K:
                break
            B.appendleft(b)
            ans += 1
        else:
            cur += b
            if cur > K:
                break
            A.appendleft(a)
            ans += 1
    elif len(A) == 0:
        b = B.popleft()
        cur += b
        if cur > K:
            break
        ans += 1
    elif len(B) == 0:
        a = A.popleft()
        cur += a
        if cur > K:
            break
        ans += 1
print(ans)

from collections import deque
N, M, K = map(int, input().split())
A = deque([int(i) for i in input().split()])
B = deque([int(i) for i in input().split()])

num = 0
cur1, cur2 = 0, 0
while cur1 < N and cur2 < M and num < K:
    if A[cur1] <= B[cur2]:
        num += A[cur1]
        cur1 += 1
    else:
        num += B[cur2]
        cur2 += 1
amari = N-cur1-cur2


Fixed submission:
from itertools import accumulate
from bisect import bisect_right

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

ans = 0
m = [0] + list(accumulate(A))
l = list(accumulate(B))
for i, x in enumerate(m):
    if x > K:
        break        
    else:
        ans = max(ans, i + bisect_right(l, K-x))
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
num_list = 0
for i in range(N):
  a = int(input())
  num_list.append(a)
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)

Fixed submission:
import sys
N = int(input())
num_list = [int(i) for i in input().split()]
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)
Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i%K  0:
    print('Yes')
    sys.exit()
print('No')

Fixed submission:
import sys
K = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i%K == 0:
    print('OK')
    sys.exit()
print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
for i in range(1, len(s)+1):
    a[int(s[:i][::-1])%2019] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    if x >= 2:
        ans += comb(x)
print(ans)

Fixed submission:
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
cur = 0
for i, x in enumerate(s):
    cur += (int(x)*pow(10, i, 2019))%2019
    cur %= 2019
    a[cur] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    if x >= 2:
        ans += comb(x)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
for i in range(1, len(s)+1):
    a[int(s[:i][::-1])%2019] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    ans += comb(x)
print(ans)

Fixed submission:
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
cur = 0
for i, x in enumerate(s):
    cur += (int(x)*pow(10, i, 2019))%2019
    cur %= 2019
    a[cur] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    if x >= 2:
        ans += comb(x)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, defaultdict

s = input()
ls = []
for i in range(1, len(s)+1):
    ls.append(int(s[len(s)-i:]))

a = defaultdict(int)
a[0] += 1
for i in range(len(s)):
    a[ls[i]%2019] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    ans += comb(x)
print(ans)

Fixed submission:
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
cur = 0
for i, x in enumerate(s):
    cur += (int(x)*pow(10, i, 2019))%2019
    cur %= 2019
    a[cur] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    if x >= 2:
        ans += comb(x)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s = input()
ls = []
for i in range(1, len(s)+1):
    ls.append(int(s[len(s)-i:]))

arr = [0 for i in range(len(s)+1)]
for i in range(len(s)):
    arr[i+1] = ls[i]%2019

def comb(a):
    return a*(a-1)//2

m = Counter(arr)
ans = 0
for x, y in m.items():
    ans += comb(y)
print(ans)

Fixed submission:
from collections import Counter, defaultdict
a = defaultdict(int)
a[0] += 1
s = input()[::-1]
cur = 0
for i, x in enumerate(s):
    cur += (int(x)*pow(10, i, 2019))%2019
    cur %= 2019
    a[cur] += 1

def comb(a):
    return a*(a-1)//2

ans = 0
for x in a.values():
    if x >= 2:
        ans += comb(x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
N = int(input())
if N <= 3:
    print(0)
    sys.exit()
s = input()
ls = [defaultdict(int) for i in range(N)]
a = ['R', 'G', 'B']
for i, x in enumerate(s):
    for y in a:
        if x == y:
            ls[i][y] = ls[max(0, i-1)][y] + 1
        else:
            ls[i][y] = ls[max(0, i-1)][y]
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if s[i] != s[j]:
            for k in a:
                if k != s[i] and k != s[j]:
                    ans += ls[-1][k] - ls[j][k]
            if 2*j-i <N and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
                ans -= 1
print(ans)

Fixed submission:
import sys
from collections import defaultdict
N = int(input())
if N <= 3:
    print(0)
    sys.exit()
s = input()
ls = [defaultdict(int) for i in range(N)]
a = ['R', 'G', 'B']
for i, x in enumerate(s):
    for y in a:
        if x == y:
            ls[i][y] = ls[max(0, i-1)][y] + 1
        else:
            ls[i][y] = ls[max(0, i-1)][y]
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if s[i] != s[j]:
            for k in a:
                if k != s[i] and k != s[j]:
                    ans += ls[-1][k] - ls[j][k]
            if 2*j-i <N and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
                ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

f_list = [0 for i in range(N+1)]
f_list[0] = 1
for i in range(1, N+1):
    f_list[i] = f_list[i-1]*i

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

def c(n):
    return n *(n-1) // 2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

f_list = [0 for i in range(N+1)]
f_list[0] = 1
for i in range(1, N+1):
    f_list[i] = f_list[i-1]*i

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
s = 0
for x, y in m.items():
    else:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

def c(n):
    return n *(n-1) // 2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Buggy python submission (verdict: Runtime Error):
from collections import Counter, defaultdict
N = int(input())
A = [int(i) for i in input().split()]

f_list = [0 for i in range(N+1)]
f_list[0] = 1
for i in range(1, N+1):
    f_list[i] = f_list[-1]*i

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
ans = defaultdict(int)
s = 0
for x, y in m.items():
    if y == 1:
        ans[x] = 0
    else:
        ans[x] = c(y)
        s += ans[x]
for a in A:
    print(s - (m[a] - 1))

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

def c(n):
    return n *(n-1) // 2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, defaultdict
N = int(input())
A = [int(i) for i in input().split()]

f_list = [1]
for i in range(1, N+1):
    f_list.append(f_list[-1]*i)

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
ans = defaultdict(int)
s = 0
for x, y in m.items():
    if y == 1:
        ans[x] = 0
    else:
        ans[x] = c(y)
        s += ans[x]
for a in A:
    print(s - (m[a] - 1))

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

def c(n):
    return n *(n-1) // 2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', 1))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, c+2):
            q.append((i, b + chr(96+i), max(map(int, list(b + chr(96+i)))))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)



Fixed submission:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, max(map(int, list(c)))+2):
            q.append((i, b + chr(96+i), c + str(i)))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, '1', 1))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, c+2):
            q.append((i, b + str(i), max(i, a)))
        j += 1
    cur += 1

d = dict()
for i in range(1, n+1):
    d[str(i)] = chr((i-1) + 97)

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b.translate(str.maketrans(d)))


Fixed submission:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, max(map(int, list(c)))+2):
            q.append((i, b + chr(96+i), c + str(i)))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b = q.popleft()
        for i in range(1, a+2):
            q.append((i, b + str(i)))
        j += 1
    cur += 1

d = dict()
for i in range(1, n+1):
    d[str(i)] = chr((i-1) + 97)

for i in range(len(q)):
    a, b = q.popleft()
    print(b.translate(str.maketrans(d)))


Fixed submission:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, max(map(int, list(c)))+2):
            q.append((i, b + chr(96+i), c + str(i)))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    ls = list(map(str, input().split()))
    
    if len(ls) == 1:
        s = s[::-1]
    else:
        if ls[1] == '1':
            s = ls[2] + s
        else:
            s = s + ls[2]
print(s)

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())
cur = 0
for i in range(q):
    ls = list(map(str, input().split()))
    if len(ls) == 1:
        cur += 1
    else:
        if ls[1] == '1':
            if cur%2 == 0:
                s.appendleft(ls[2])
            else:
                s.append(ls[2])
        else:
            if cur%2 == 0:
                s.append(ls[2])
            else:
                s.appendleft(ls[2])
if cur%2 == 0:
    print(*s, sep='')
else:
    print(*list(s)[::-1], sep='')
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n%2=0:
  print(n//2)
else:
  print(n//2+1)

Fixed submission:
n=int(input())
if n%2==0:
  print(n//2)
else:
  print(n//2+1)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(N, N-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod
  
ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)

Fixed submission:
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)
ans = 0
for a in A:
    ans += num//a%mod
ans %= mod
print(ans)


Fixed submission:
from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)
ans = 0
for a in A:
    ans += (num * pow(a, mod-2, mod))%mod
ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)
ans = 0
for a in A:
    ans += num//a%mod
ans %= mod
print(ans)


Fixed submission:
from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)
ans = 0
for a in A:
    ans += (num * pow(a, mod-2, mod))%mod
ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
print(char(ord(a)+1))

Fixed submission:
a = input()
print(chr(ord(a)+1))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
print(a+b)

Fixed submission:
ls = list(map(str, input().split()))
print(ls[1]+ls[0])

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

Fixed submission:
ls = list(map(str, input().split()))
print(ls[1]+ls[0])
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
for i in range(1, 4):
  if a != i and b!= i:
    print(i)

Fixed submission:
a, b = int(input()), int(input())
for i in range(1, 4):
  if a != i and b!= i:
    print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%2 == 1:
    print(0)
else:
    cur_two, cur_ten = 2, 10
    num_two, num_ten = 0, 0
    while cur_two <= n:
        num_two += n//cur_two
        cur_two *= 2
    while cur_ten <= n:
        num_ten += n//cur_ten
        cur_ten *= 5
print(min(num_two, num_ten))

Fixed submission:
import sys
n = int(input())
if n%2 == 1:
    print(0)
    sys.exit()
else:
    cur_two, cur_ten = 2, 10
    num_two, num_ten = 0, 0
    while cur_two <= n:
        num_two += n//cur_two
        cur_two *= 2
    while cur_ten <= n:
        num_ten += n//cur_ten
        cur_ten *= 5
    print(min(num_two, num_ten))
Buggy python submission (verdict: Runtime Error):
import sys
from functools import reduce
X, Y = map(int, input().split())
mod = 10**9 + 7

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

if 2 * min(X, Y) < max(X, Y):
    print(0)
    sys.exit()

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, d)%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//6
    d = ((X+Y) - 3*abs(X-Y))//6
    ans = f(r+d, d)%mod

print(ans)

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

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

if 2 * min(X, Y) < max(X, Y):
    print(0)
    sys.exit()

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, d)%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//6
    d = ((X+Y) - 3*abs(X-Y))//6
    if d == 0:
        print(1)
        sys.exit()
    ans = f(r+d, d)%mod

print(ans)

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

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

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, min(r, d))%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//3
    d = ((X+Y) - 3*abs(X-Y))//3
    ans = f(r+d, d)%mod

print(ans)

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

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

if 2 * min(X, Y) < max(X, Y):
    print(0)
    sys.exit()

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, d)%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//6
    d = ((X+Y) - 3*abs(X-Y))//6
    if d == 0:
        print(1)
        sys.exit()
    ans = f(r+d, d)%mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

for i in range(M):
    ind = A.index(max(A))
    A[ind] = max(A)//2
print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    max_ = heapq.heappop(A)
    max_ = -max_//2
    heapq.heappush(A, -max_)
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
for i in range(M):
    A[-1] = A[-1]//2
    A.sort()
print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    max_ = heapq.heappop(A)
    max_ = -max_//2
    heapq.heappush(A, -max_)
print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
if N == 1:
    print(0)
else:
    num = 0
    for i in range(1, N):
        num += i
    print(num)

Fixed submission:
N = int(input())
if N == 1:
    print(0)
else:
    print((N-1)*N//2)