Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def boolean(a,b):
    if(abs(a[0] - b[0]) == abs(a[1] - b[1]) + abs(a[2] - b[2])):
        return 0
    else:
        return 1

N = int(input())
lists=[0 for i in range(n+1)]
lists[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    lists[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

Fixed submission:
def boolean(a,b):
    D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2])
    if(D >= 0 and D %2 == 0):
        return 0
    else:
        return 1

N = int(input())
txy=[0 for i in range(N+1)]
txy[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    txy[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
def boolean(a,b):
    if(abs(a[0] - b[0]) == abs(a[1] - b[1]) + abs(a[2] - b[2])):
        return 0
    else:
        return 1

N = int(input())
txy[0] = [0,0,0]
txy = [input() for i in range(1,N + 1)]
txy = [list(map(int, txy[i].split())) for i in range(N+ 1)]
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

Fixed submission:
def boolean(a,b):
    D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2])
    if(D >= 0 and D %2 == 0):
        return 0
    else:
        return 1

N = int(input())
txy=[0 for i in range(N+1)]
txy[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    txy[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(N):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cntNode[a] += 1
    cntNode[b] += 1

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('YES')
else:
    print('NO')

Fixed submission:
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cntNode[a] += 1
    cntNode[b] += 1

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(N):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cntNode[a] += 1
    cntNode[b] += 1

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('Yes')
else:
    print('No')

Fixed submission:
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    cntNode[a] += 1
    cntNode[b] += 1

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
ans = 0

if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0) ans = 0
print(ans)


Fixed submission:
x,y = map(int,input().split())
ans = 0
if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0):
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
vec = []

k = 0
sum = 0
while(k**2 + k < 2*N):
  k += 1
  sum += k
  vec.append(k)

vec.remove(sum - N)

for i in range(len(vec)):
  print(vec[i])

Fixed submission:
N = int(input())
vec = []

k = 0
sum = 0
while(k**2 + k < 2*N):
  k += 1
  sum += k
  vec.append(k)
if(sum - N):
  vec.remove(sum - N)


for i in range(len(vec)):
  print(vec[i])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import connected_components
from collections import Counter
n,m = map(int,input().split())

l = np.array([[0]*n for _ in range(n)])

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

x,labels= connected_components(l)
c = Counter(list(labels))
print(c.most_common()[0][1])

Fixed submission:
from collections import defaultdict,deque
n,m = map(int,input().split())

d = defaultdict(list)

if m==0:
    print(1)
    exit()

visited = [-1] + [False]*n
for i in range(m):
    a,b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)
maxi = 1
for i in range(1,n+1):
    if visited[i]:
        continue
    cnt = 0
    que = deque([i])
    while que:
        v = que.pop()
        if not visited[v]:
            visited[v] = True
            cnt += 1
        for j in d[v]:
            if not visited[j]:
                que.append(j)
    maxi = max(maxi,cnt)
print(maxi)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import connected_components
from collections import Counter
n,m = map(int,input().split())

l = np.array([[0]*n for _ in range(n)])

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

x,labels= connected_components(l)
c = Counter(list(labels))
print(c.most_common()[0][1])

Fixed submission:
from collections import defaultdict,deque
n,m = map(int,input().split())

d = defaultdict(list)

if m==0:
    print(1)
    exit()

visited = [-1] + [False]*n
for i in range(m):
    a,b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)
maxi = 1
for i in range(1,n+1):
    if visited[i]:
        continue
    cnt = 0
    que = deque([i])
    while que:
        v = que.pop()
        if not visited[v]:
            visited[v] = True
            cnt += 1
        for j in d[v]:
            if not visited[j]:
                que.append(j)
    maxi = max(maxi,cnt)
print(maxi)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,k = map(int,input().split())
l = list(map(int,input().split()))
product = 1
for i in range(k):
    product *= l[i]

que = deque(l[:k])
for i in range(n-k):
    previous = product
    product //= que.popleft()
    product *= l[k+i]
    if product <= previous:
        print('No')
    else:
        print('Yes')
    que.append(l[k+i])

Fixed submission:
from collections import deque
n,k = map(int,input().split())
l = list(map(int,input().split()))

que = deque(l[:k])
for i in range(n-k):
    p = que.popleft()
    que.append(l[k+i])
    if p < l[k+i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
from math import sqrt
l = [-1]+[0]*10**4
n = int(input())
for i in range(1,int(sqrt(n))+1):
    for j in range(1,int(sqrt(n))+1):
        for k in range(1,int(sqrt(n))+1):
            l[i**2+j**2+k**2+i*j+j*k+k*i] += 1
for i in range(1,n+1):
    print(l[i])

Fixed submission:
from math import sqrt
l = [-1]+[0]*10**4
n = int(input())
for i in range(1,int(sqrt(n))+2):
    for j in range(1,int(sqrt(n))+2):
        for k in range(1,int(sqrt(n))+2):
            ans = i**2+j**2+k**2+i*j+j*k+k*i
            if ans <= 10**4:
                l[ans] += 1
for i in range(1,n+1):
    print(l[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A.sort()

l = [0]*(2*10**5+1)

for i in A:
    for j in range(0,10**5,i):
        l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
A.sort()

l = [0]*(10**6+1)

for i in A:
    if l[i] <= 1:
        for j in range(0,10**6+1,i):
            l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
l= list(map(int,input().split()))
pro = l[0]
for i in range(1,n):
    pro *= l[i]
if pro > 10**18:
        print('-1')
else:
    print(pro)

Fixed submission:
n= int(input())
l= list(map(int,input().split()))
if 0 in l:
    print(0)
    exit()
pro = l[0]
for i in range(1,n):
    pro *= l[i]
    if pro > 10**18:
        print('-1')
        exit()
print(pro)
Buggy python submission (verdict: Runtime Error):
l = list(input())
a = int(l[0])
b = float(l[1])
print(int(a*b))

Fixed submission:
from decimal import Decimal
l = list(input().split())
a = int(l[0])
b = Decimal(l[1])
print(int(a*b))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)
n,k = map(int,input().split())
l = list(map(int,input().split()))
def trans(n):
    if n == 1:
        return l[0]
    else:
        return l[trans(n-1)-1]
print(trans(k)) 

Fixed submission:
n,k = map(int,input().split())
l = [-1]+list(map(int,input().split()))

visited = [-1]+[False]*n

i = 1
while True:
    if visited[i]:
        fragrant = i
        break
    else:
        visited[i] = True
        i = l[i]

i = fragrant
cnt = 1
while l[i] != fragrant:
    cnt += 1
    i = l[i]
# print(cnt)

i = 1
while k > 0:
    i = l[i]
    k -= 1
    if i == fragrant:
        k %= cnt
print(i)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)


Fixed submission:
import collections
n = int(input())
l = list(map(int,input().split()))
k = []
for i in range(n):
    k.append(i+1+l[i])
c = collections.Counter(k)
cnt = 0
for i in range(n):
    cnt += c[i+1-l[i]]
print(cnt)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = []
for i in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  if h[a]<h[b]:
    l.append(a)
  elif h[a] == h[b]:
    l += [a,b]
  else:
    l.append(b)
s = set(l)
print(n-len(s))


Fixed submission:
import collections
n = int(input())
l = list(map(int,input().split()))
k = []
for i in range(n):
    k.append(i+1+l[i])
c = collections.Counter(k)
cnt = 0
for i in range(n):
    cnt += c[i+1-l[i]]
print(cnt)
Buggy python submission (verdict: Runtime Error):
import itertools
n,m,q = map(int,input().split())
l = []
for i in range(q):
  l.append(list(map(int,input().split())))
j = [i for i in range(1,m+1)]
k = itertools.permutations(j, n)
for i in range(q):
  if k[l[i][1]]-k[l[i][0]] == l[i][2]:
    count += l[i][3]

Fixed submission:
import itertools
n,m,q = map(int,input().split())
l = []
for i in range(q):
  l.append(list(map(int,input().split())))
j = [i for i in range(1,m+1)]
kk = list(itertools.combinations_with_replacement(j,n))
ans = []
for k in kk:
  count = 0
  for i in range(q):
    if k[l[i][1]-1]-k[l[i][0]-1] == l[i][2]:
      count += l[i][3]
  ans.append(count)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
s = list(input())

c  = list(Counter(s).values())  

num = c[0]*c[1]*c[2]

for j in range(n):
    for d in range(1,min(j,n-j-1)+1):
        i = j-d
        k = j+d
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -= 1
print(num)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
s = list(input())

c  = Counter(s)  

num = c['R']*c['G']*c['B']

for j in range(n):
    for d in range(1,min(j,n-j-1)+1):
        i = j-d
        k = j+d
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -= 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(input())
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    if l[i] != l[j]:
      for k in range(j+1,n):
        if l[j] != l[k] and l[i] != l[k] and j-i != k-j:
          count += 1
print(count)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
s = list(input())

c  = Counter(s)  

num = c['R']*c['G']*c['B']

for j in range(n):
    for d in range(1,min(j,n-j-1)+1):
        i = j-d
        k = j+d
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -= 1
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(input())
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    flag = True
    if l[i] == l[j]:
      flag = False
    for k in range(j+1,n):
      if l[j] != l[k] and l[i] != l[k] and j-i != k-j and flag:
        count += 1
print(count)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
s = list(input())

c  = Counter(s)  

num = c['R']*c['G']*c['B']

for j in range(n):
    for d in range(1,min(j,n-j-1)+1):
        i = j-d
        k = j+d
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -= 1
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = tuple(map(int, input().split()))
for k in range(N):
  c = 0
  A = list(a)
  del A[k]
  while len(A) > 0:
    y = A.count(A[0])
    c += y*(y-1)//2
    x = A[0]
    while x in A:
        A.remove(x)
  print(c)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
from collections import Counter
c = Counter(l)
v = list(c.values())
s = 0
for i in v:
  s += i*(i-1)//2
for i in l:
  print(s-(c[i]-1))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a = list(input().split())
b = list(input().split())
l = []
n = []
for i in range(M):
  x, y, c = map(int, input().split())
  l.append(int(a[x-1])+int(b[y-1])-c)
for k in range(A):
  for m in range(B):
    n.append(int(a[k])+int(b[m]))
print(min(min(l), min(n)))

Fixed submission:
A, B, M = map(int, input().split())
a = list(input().split())
b = list(input().split())
l = []
for i in range(M):
  x, y, c = map(int, input().split())
  l.append(int(a[x-1])+int(b[y-1])-c)
l.sort()
n = int(min(a)) + int(min(b))
print(min(l[0], n))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a = list(input().split())
b = list(input().split())
l = []
n = []
for i in range(M):
  x, y, c = map(int, input().split())
  l.append(int(a[x-1])+int(b[y-1])-c)
l.sort()
for k in range(A):
  for m in range(B):
    n.append(int(a[k])+int(b[m]))
n.sort()
print(min(l[0],n[0]))

Fixed submission:
A, B, M = map(int, input().split())
a = list(input().split())
b = list(input().split())
l = []
for i in range(M):
  x, y, c = map(int, input().split())
  l.append(int(a[x-1])+int(b[y-1])-c)
l.sort()
n = int(min(a)) + int(min(b))
print(min(l[0], n))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a = list(input().split())
b = list(input().split())
l = []
for i in range(M):
  x, y, c = map(int, input().split())
  l.append(int(a[x-1])+int(b[y-1])-c)
for k in range(A):
  for m in range(B):
    l.append(int(a[k])+int(b[m]))
l.sort()
print(l[0])

Fixed submission:
A, B, M = map(int, input().split())
a = list(input().split())
b = list(input().split())
l = []
for i in range(M):
  x, y, c = map(int, input().split())
  l.append(int(a[x-1])+int(b[y-1])-c)
l.sort()
n = int(min(a)) + int(min(b))
print(min(l[0], n))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
print(100*l[0]+10*l[1]+l[2])

Fixed submission:
n,m = map(int,input().split())
if m == 0 and n != 1:
    print(10**(n-1))
    exit()
if m== 0 and n==1:
    print(0)
    exit()
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0 and n==1:
    print(0)
    exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
ans = 0
for i in range(n):
    ans += l[n-i-1]*10**i
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(min(l), max(l)):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(101):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(min(l), max(l)):
  ans=0
  for i in range(len(l)):
    x = (l[i] - j)**2
    ans += x
  k.append(ans)
print(min(k))

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(101):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
  l.append(input())
s = set(l)
ss = list(s)
ss.sort()
w = []
for i in range(len(ss)):
  w.append(l.count(ss[i]))
for i in range(len(w)):
  if max(w) == w[i]:
    print(ss[i])

Fixed submission:
from collections import Counter
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = Counter(l)
t = c.most_common()
x = 0
ans = []
for k,v in t:
  if x <= v:
    ans.append(k)
    x = v
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
  l.append(input())
s = []
w = []
for i in range(N):
    s.append(l.count(l[i]))
    w.append(l[i])
MAX = max(s)
g = []
for i in range(len(s)):
  if s[i] == MAX:
    g.append(w[i])
h = set(g)
j = list(h)
j.sort()
for i in range(len(j)):
  print(j[i])

Fixed submission:
from collections import Counter
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = Counter(l)
t = c.most_common()
x = 0
ans = []
for k,v in t:
  if x <= v:
    ans.append(k)
    x = v
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
  l.append(input())
s = []
w = []
for i in range(N):
    s.append(l.count(l[i]))
    w.append(l[i])
MAX = max(s)
g = []
for i in range(len(s)):
  if s[i] == MAX:
    g.append(w[i])
h = set(g)
j = list(h)
j.sort()
for i in range(len(j)):
  print(j[i])

Fixed submission:
from collections import Counter
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = Counter(l)
t = c.most_common()
x = 0
ans = []
for k,v in t:
  if x <= v:
    ans.append(k)
    x = v
ans.sort()
for i in range(len(ans)):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
l = list(input())
roop = n//k
last = n%k
count = 0
x = ''
for i in range(last):
  for j in range(roop+1):
    if l[i+k*j] == 'r' and x != 'P':
      count += p
      x = 'P'
    elif l[i+k*j] == 's' and x != 'R':
      count += r
      x = 'R'
    elif l[i+k*j] == 'p' and x != 'S':
      count += s
      x = 'S'
    else:
      x = ''
if last == 0:
  roop -=1
for i in range(last,k):
  for j in range(roop+1):
    if l[i+k*j] == 'r' and x != 'P':
      count += p
      x = 'P'
    elif l[i+k*j] == 's' and x != 'R':
      count += r
      x = 'R'
    elif l[i+k*j] == 'p' and x != 'S':
      count += s
      x = 'S'
    else:
      x = ''
print(count)


Fixed submission:
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

d = {'r': p, 's': r, 'p': s} #勝ちスコア

point = 0
for i in range(k): #kまでは普通に勝ってもよい
    point += d[t[i]]

for i in range(k, n): #kからnまでは、k個前と同じなら、後の方を無得点化する
    if t[i] == t[i - k]:
        t[i] = 'x'
        continue
    point += d[t[i]]

print(point)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
mod = 10**9+7
dp = [[0]*(x+1) for _ in range(y+1)]

dp[0][0] = 1
for i in range(y+1):
    for j in range(x+1):
        if i-2 >= 0 and j-1 >= 0:
            dp[i][j] += dp[i-2][j-1]
        if i-1 >= 0 and j-2 >= 0:
            dp[i][j] += dp[i-1][j-2]
    dp[i][j] %= mod
print(dp[y][x])

Fixed submission:
x,y = map(int,input().split())
mod = 10**9+7
def comb(N,x):
    numerator = 1
    for i in range(N-x+1,N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator * j % mod
    d = pow(denominator,mod-2,mod)
    return numerator * d % mod

if (x+y) % 3 == 0:
    a = (2*y-x) //3
    b = (2*x-y) //3

    if a >= 0 and b >= 0:
        print(comb(a+b,a))
        exit()
print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**8)
x,y = map(int,input().split())
mod = 10**9+7

def dfs(i,j):
    if i == 0 and j==0:
        return 1
    a = b = 0
    if i-2 >= 0 and j-1 >= 0:
        a = dfs(i-2,j-1)
    if i-1 >= 0 and j-2 >= 0:
        b = dfs(i-1,j-2)
    return (a+b)%mod

print(dfs(y,x))

Fixed submission:
x,y = map(int,input().split())
mod = 10**9+7
def comb(N,x):
    numerator = 1
    for i in range(N-x+1,N+1):
        numerator = numerator * i % mod
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator * j % mod
    d = pow(denominator,mod-2,mod)
    return numerator * d % mod

if (x+y) % 3 == 0:
    a = (2*y-x) //3
    b = (2*x-y) //3

    if a >= 0 and b >= 0:
        print(comb(a+b,a))
        exit()
print(0)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
d = {}
for i in range(1,int(math.sqrt(n))):
  if (n/i).is_integer():
    d.setdefault(i,n//i)
ans = []
for k,v in d.items():
  ans.append((k-1)+(v-1))
print(min(ans))

Fixed submission:
import math
n = int(input())
d = {}
for i in range(1,(int(math.sqrt(n)))+1):
  if (n/i).is_integer():
    d.setdefault(i,n//i)
ans = []
for k,v in d.items():
  ans.append((k-1)+(v-1))
print(min(ans))
Buggy python submission (verdict: Runtime Error):
from math import gcd,sqrt

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(sqrt(n))+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

a,b = map(int,input().split())

x = gcd(a,b)

print(len(factorization(x))+ (1 if len(factorization(x)) != 1 else 0))

Fixed submission:
from fractions import gcd

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

a,b = map(int,input().split())

x = gcd(a,b)

ans = len(factorization(x))+1
if factorization(x) == [[1,1]]:
  ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n-1):
  ans += i+1 % (i+2)
print(ans)

Fixed submission:
n = int(input())
print(n*(n-1)//2)