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

Fixed submission:
s = list(input())
t = list(input())
 
def f(s, t):
  s.sort()
  t.sort(reverse=True)
  s_sum = 0
  t_sum = 0
  for i in range(len(s)):
    s[i] = ord(s[i])
  
  for i in range(len(t)):
    t[i] = ord(t[i])
  
  for i in range(len(s)):
    if not i + 1 >= len(t):
      s_sum += s[i]
      t_sum += t[i]

      if s_sum < t_sum:
        return 'Yes'
      elif s_sum > t_sum:
        return 'No'
    else:
      break

  if len(s) < len(t):
    return 'Yes'
  else:
    return 'No'

print(f(s, t))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
 
def f(s, t):
  s.sort()
  t.sort(reverse=True)
  s_sum = 0
  t_sum = 0
  for i in range(len(s)):
    s[i] = ord(s[i])
  
  for i in range(len(t)):
    t[i] = ord(t[i])
  
  for i in range(len(s)):
    s_sum += s[i]
    t_sum += t[i]

    if s_sum < t_sum:
      return 'Yes'
    elif s_sum > t_sum:
      return 'No'

  if len(s) < len(t):
    return 'Yes'
  else:
    return 'No'
  
print(f(s, t))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
 
def f(s, t):
  s.sort()
  t.sort(reverse=True)
  s_sum = 0
  t_sum = 0
  for i in range(len(s)):
    s[i] = ord(s[i])
  
  for i in range(len(t)):
    t[i] = ord(t[i])
  
  for i in range(len(s)):
    s_sum += s[i]
    t_sum += t[i]

    if s_sum < t_sum:
      return 'Yes'
    elif s_sum > t_sum:
      return 'No'
    elif s_sum == t_sum and i + 1 >= len(s) and not i + 1 >= len(t):
      return 'Yes'
  return 'No'
print(f(s, t))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())

def f(s, t):
  s.sort()
  t.sort(reverse=True)

  for i in range(len(s)):
    if s[i] < t[i]:
      return 'Yes'
    elif s[i] > t[i]:
      return 'No'
    elif i + 1 >= len(s) and not i + 1 >= len(t):
      return 'No'
  return 'No'

print(f(s, t))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())

def f(s, t):
  s.sort()
  t.sort(reverse=True)

  for i in range(len(s)):
    if s[i] < t[i]:
      return 'Yes'
    elif s[i] > t[i]:
      return 'No'
    elif i + 1 >= len(s) and not i + 1 >= len(t):
      return 'Yes'
  return 'No'

print(f(s, t))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())

def f(s, t):
  s.sort()
  t.sort(reverse=True)

  for i in range(len(s)):
    if s[i] < t[i]:
      return 'Yes'
    elif s[i] > t[i]:
      return 'No'
    elif i + 1 >= len(s) and not i + 1 >= len(t):
      return 'Yes'

  return 'No'

print(f(s, t))
Problem p03544 (python)

Fixed submission:
N = int(input())
memo = [0] * 87
def luca(n):

  if n == 0:
    return 2
  elif n == 1:
    return 1

  if not memo[n]:
    memo[n] = luca(n - 2) + luca(n - 1)
  return memo[n]

print(luca(N))

Buggy submission (verdict: Runtime Error):
N = int(input())
pre = 1
luca = 3
if N == 2:
  print(4)
  break
elif N == 1:
  print(1)
  break
elif N == 0:
  print(2)
  break
else:
  for i in range(N - 2):
    temp = luca
    luca = pre + luca
    pre = temp
    
  print(luca)
Problem p03597 (python)

Fixed submission:
N = int(input())
A = int(input())
 
print(pow(N, 2) - A)

Buggy submission (verdict: Runtime Error):
NUM = int(input())
K = int(input())
POS = list(map(int, input().split()))
sum = 0
for i in POS:
    a = pow(i, 2)
    b = pow(abs((i - K)), 2)
    sum += min(a, b)
print(sum)
Problem p03609 (python)

Fixed submission:
l = list(map(int, input().split()))
if l[0] - l[1] <= 0:
  print('0')
else:
  print(l[0] - l[1])

Buggy submission (verdict: Runtime Error):
S = input().split()
if S[0] - S[1] <= 0:
  print('0')
else:
  print(S[0] - S[1])

Buggy submission (verdict: Runtime Error):
S = input().split()
d = S[0] - S[1]
if d <= 0:
  print('0')
else:
  print(d)

Buggy submission (verdict: Runtime Error):
S = map(int, input().split())
d = S[0] - S[1]
if d <= 0:
  print("0")
else:
  print(d)

Buggy submission (verdict: Runtime Error):
S = map(int, input().split())
d = S[0] - S[1]
if d <= 0:
  print(0)
else:
  print(d)
Problem p03611 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
ans = 0
count = {}
for i in range(0, 10**5+1):
  count[i] = 0

for i in l:
  count[i] = count[i] + 1

for i in range(0, 10**5+1):
  if i == 0:
    temp = count[i] + count[i+1]
  elif i == 10**5:
    temp = count[i] + count[i-1]
  else:
    temp = count[i] + count[i+1] + count[i-1]

  if temp > ans:
    ans = temp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
target = A[1]
for i in range(N - 1):
    if target == A[i] or target - 1 == A[i] or target + 1 == A[i]:
        count += 1

print(count)
Problem p03624 (python)

Fixed submission:
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"
found = [i for i in alphabet if i not in S]
found.sort()
if len(found) == 0:
  print('None')
else:
  print(found[0])

Buggy submission (verdict: Runtime Error):
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"
for i in alphabet:
  if i not in S:
    print(i)
    return
  else:
    print('None')

Buggy submission (verdict: Runtime Error):
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"
found = [i for i in alphabet if i not in S]
found.sort()
print(found[0])
Problem p03625 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
l = []

for i in range(0, N - 1):
    if len(l) == 2:
        break
    if A[i] == A[i + 1] and not A[i] == 0:
        l.append(A[i])
        A[i + 1] = 0
        
if len(l) == 2:
    print(l[0] * l[1])
else:
    print('0')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
width = 0
height = 0
found = False
for i in A:
    if A.count(i) >= 4:
        width = i
        height = i
        count += 1
        break
    elif A.count(i) >= 2:
        if width == 0:
            width = i
        elif not i == width:
            height = i
            found = True
            break

if found:
    print(width * height)
else:
    print('0')
Problem p03632 (python)

Fixed submission:
s = input().split()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])
 
a_c = max(A, C)
b_d = min(B, D)
 
if b_d - a_c > 0:
  print(b_d - a_c)
else:
  print("0")

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

A, B, C, D = [for i in s]

if D <= A or C >= B:
  print("0")
elif C <= A and D >= B:
  print(B - A)
elif C >= A and D >= B:
  print(B - C)
elif D <= B and C <= A:
  print(D - A)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

n = int(input())
nums = [int(input()) for i in range(n)]


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

def lcm(nums):
  return reduce(lcm_base, nums, 1)

print(lcm(nums))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

n = int(input())
nums = [int(input()) for i in range(n)]


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

def lcm(nums):
  return reduce(lcm_base, nums, 1)

print(lcm(nums))
Problem p03739 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
even = 0
e_sum = 0
odd = 0
o_sum = 0
for i in range(n):
  e_sum += l[i]
  if i % 2 == 0 and e_sum <= 0:
    even += abs(e_sum)+1
    e_sum = 1
  elif not i % 2 == 0 and e_sum >= 0:
    even += abs(e_sum)+1
    e_sum = -1

for i in range(n):
  o_sum += l[i]
  if i % 2 == 0 and o_sum >= 0:
    odd += abs(o_sum)+1
    o_sum = -1
  elif not i % 2 == 0 and o_sum <= 0:
    odd += abs(o_sum)+1
    o_sum = 1

print(min(even, odd))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  if l[i] + l[i-1] > x:
    ans += (l[i] + l[i-1]) - x
    l[i] -= (l[i] + l[i-1]) - x
print(ans)
Problem p03779 (python)

Fixed submission:
n = int(input())
l = []

def f(n, l):
  sum = 0
  for i in range(1, n+1):
    sum += i
    if sum >= n:
      return i

print(f(n, l))

Buggy submission (verdict: Runtime Error):
def f(n, l):
  sum = 0
  for i in range(1, n+1):
    sum += i
    if sum >= n:
      return i

print(f(n, l))
Problem p03854 (python)

Fixed submission:
s = input()[::-1]
l = ["dream", "dreamer", "erase", "eraser"]
start = 0

for i in range(len(l)):
  l[i] = l[i][::-1]
  
def f():
  i = 0
  j = 0
  while j <= len(s):
    can = False
    for d in l:
      if s[i:i+len(d)] == d:
        i += len(d)
        can = True

    if i == len(s) and can == True:
      return 'YES'

    if can == False:
      return 'NO'
    j += 1

  return 'YES'

print(f())

Buggy submission (verdict: Runtime Error):
s = input()
ans = False
def dfs(now, length):
  global ans
  if len(now) >= length:
    if now == s:
      ans = True
    return
  
  dfs(now + 'dream', length)
  dfs(now + 'dreamer', length)
  dfs(now + 'erase', length)
  dfs(now + 'eraser', length)

dfs('', len(s))

if ans:
  print('YES')
else:
  print('NO')
Problem p02615 (python)

Fixed submission:
import math
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
s = A[0]

for i in range(1,N-1):
    s += A[math.ceil(i/2)]

print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
ring = [A[0]]
score = [A[0]]
s = 0

for i in A[1:N]:
    s += max(score)
    j = score.index(max(score))
    ring.insert(j,A[i])
    score.insert(j,A[i])
    score[j-1] = A[i]

print(s)
Problem p02732 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
S = 0

for i in range(N):
    B[A[i]] += 1

for i in range(1, N+1):
    S += B[i]*(B[i]-1)//2

for k in range(N):
    print(S-B[A[k]]+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = []
S = 0

for i in range(1, N+1):
    B[i] = A.count(i)
    S += B[i]*(B[i]-1)/2

for i in range(N):
    if B[A[i]] < 2:
        print(S)
    else:
        print(S-B[A[i]]+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = []
S = 0

for i in range(1, N+1):
	B[i] = A.count(i)
	S += B[i]*(B[i]-1)/2

for i in range(N):
	if B[A[i]] < 2:
		print(S)
	else:
		print(S-B[A[i]]+1)
Problem p02756 (python)

Fixed submission:
s = str(input())
Q = int(input())
forward = 1
front = ""
back = ""

for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        forward *= -1
    else:
        if q[1] == "1":
            if forward == 1:
                front = q[2] + front
            else:
                back = back + q[2]        
        else:
            if forward == 1:
                back = back + q[2]
            else:
                front = q[2] + front

s = front + s + back
if forward == -1:
    s = s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s = str(input())
Q = int(input())
front = 1
for i in range(Q):
    q = list(map(str, input().split()))
    if q[0] == "1":
        front *= -1
    else:
        if q[1] == "1":
            if front == 1
                s = q[2] + s
            else:
                s = s + q[2]             
        else:
            if front == 1
                s = s + q[2]
            else:
                s = q[2] + s

if front == -1:
    s = s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
Q = int(input())
for i in range(Q):
    q = list(map(str, input().split())
    if q[0] == "1":
        if len(s) > 1:
            s = s[-1] + s[1:-1] + s[0]
    else:
        if q[1] == "1":
            s = q[2] + s 
        else:
            s = s + q[2]
print(s)
Problem p03078 (python)

Fixed submission:
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
e = []
s = []

for i in A:
    for j in B:
        e.append(i+j)
e = sorted(e, reverse=True)

if K<len(e):
    e = e[0:K]

for i in e:
    for j in C:
        s.append(i+j)

s = sorted(s, reverse=True)

for i in range(K):
    print(s[i])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
s = []

for i in A:
    for j in B:
        for k in C:
            s.append(i+j+k)

s = sorted(s, reverse=True)

for i in range(K):
    print s[i]

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
s = []

for i in A:
	for j in B:
		for k in C:
			s.append(i+j+k)

s = sorted(s, reverse=True)

for i in range(K):
	print s[i]
Problem p03082 (python)

Fixed submission:
from collections import defaultdict as dd
MOD = 10**9 + 7

def main():
    N, X = list(map(int, input().split()))
    S = list(map(int, input().split()))
    S = sorted(S, reverse=True)

    dp = dd(int)
    dp[X] = 1
    for i in range(N):
        new = dd(int)
        for x in dp:
            xx = x % S[i]
            new[x] += dp[x] * (N-i-1)
            new[x] %= MOD
            new[xx] += dp[x]
            new[xx] %= MOD
        dp = new

    total = 0
    for x in dp:
        total += dp[x] * x
        total %= MOD
    print(total)

main()

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7

def gen_candidate(N):
    for i in range(1 << (N-1)):
        bit = bin(i)[2:]
        bit = '0'*(N-1 - len(bit)) + bit
        yield bit+'1'

def main():
    N, X = list(map(int, input().split()))
    S = list(map(int, input().split()))
    S = sorted(S, reverse=True)
    total = 0
    for bit in gen_candidate(N):
        x = X
        for j, char in enumerate(bit):
            if int(char):
                x = x % S[j]
        num = 1
        num_one = 0
        num_zero = 0
        for b in reversed(bit):
            if int(b):
                num_one += 1
            else:
                num *= num_one + num_zero
                num_zero += 1
        total = (total + x * num) % MOD
    print(total)

main()
Problem p03095 (python)

Fixed submission:
from collections import defaultdict
import itertools
from functools import reduce


def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  counts = tuple(s_count.values())
  return counts

N = int(input())
string = input()

def search(N, string):
    memo = {}
    def count(counts, num_set):
        if (counts, num_set) in memo:
            return memo[(counts, num_set)]

        if num_set == 1:
            ans = sum(counts)
        elif num_set == 2:
            num_sum = sum(counts)
            ans = 0
            for i in range(len(counts)):
                num_sum -= counts[i]
                ans += counts[i] * num_sum
        else:
            ans = 0
            for i in range(len(counts) - 1):
                ans += counts[i] * count(counts[i + 1:], num_set - 1)

        memo[(counts, num_set)] = ans
        return ans

    counts = analyze(string)
    ans = 0
    for i in range(1, len(counts) + 1):
        ans += count(counts, i)
    print(ans % (10**9 + 7))

search(N, string)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import itertools


def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  return s_count

def count_up(s_count):
  strings = list(s_count.keys())
  ans = 0
  for num in range(1, len(strings) + 1):
    for s_list in itertools.combinations(strings, num):
      num_list = [s_count[s] for s in s_list]
      ans += reduce((lambda x, y: x * y), num_list)
  print(ans % (10**9 + 7))

N = int(input())
string = input()

s_count = analyze(string)
count_up(s_count)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import itertools
 

def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  return s_count
 
def count_up(s_count):
  strings = list(s_count.keys())
  ans = 0
  for num in range(1, len(strings) + 1):
    for s_list in itertools.product(strings, num):
      a = 1
      for s in s_list:
        a *= s_count[s]
      ans += a
  print(ans)
  
N, string = input().split('\n')
N = int(N)
 
s_count = analyze(string)
count_up(s_count)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import itertools


def analyze(string):
  s_count = defaultdict(int)
  for s in string:
    s_count[s] += 1
  return s_count

def count_up(s_count):
  strings = list(s_count.keys())
  ans = 0
  for num in range(1, len(strings) + 1):
    for s_list in itertools.product(strings, num):
      a = 1
      for s in s_list:
        a *= s_count[s]
      ans += a
  print(ans)
  
N, string = input().split('\n')
N = int(N)

s_count = analyze(string)
count_up(s_count)
Problem p02796 (python)

Fixed submission:
import sys
readline = sys.stdin.buffer.readline

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    return data.sort(key=lambda x:x[col],reverse=True)

n = int(input())
xl = [ list(myinput()) for _ in range(n) ]
# print(xl)

ls = []
for i in range(n):
    x = xl[i][0]
    l = xl[i][1]
    s = x - l
    e = x + l
    d = [s,e]
    ls.append(d)
# print(ls)
ls.sort(key=lambda x:x[1],reverse=False)
# print(ls)

count = 0
e = -1*float("inf")
for i in range(n):
    ns,ne = ls[i]
    if ns>=e:
        count += 1
        e = copy(ne)
    else:
        pass

print(count)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,readline().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    return data.sort(key=lambda x:x[col],reverse=True)

n = int(input())
xl = [ list(myinput()) for _ in range(n) ]

ls = []
for i in range(n):
    x = xl[i][0]
    l = xl[i][1]
    s = x - l
    e = x + l
    d= [s,e]
    ls.append(d)
# print(ls)
ls.sort(key=lambda x:x[1],reverse=False)
# print(ls)

count = 0
e = -1*float("inf")
for i in range(n):
    ns,ne = ls[i]
    if ns>=e:
        count += 1
        e = copy(ne)
    else:
        pass

print(count)
Problem p02807 (python)

Fixed submission:
import math

n = int(input())
x = list(map(int,input().split()))

mod = 10**9 + 7

f = math.factorial(n-1)
f %= mod

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

count = 0
k = f
plus = 0
for i in range(1,n):
    # print(k)
    k = f + plus
    count += l[i-1] * k
    plus += f * modinv(i+1,mod)

print(int(count)%mod)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
x = list(map(int,input().split()))

mod = 10**9 + 7

f = math.factorial(n-1)

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

count = 0
k = f
plus = 0
for i in range(1,n):
    # print(k)
    k = f + plus
    count += l[i-1] * k
    plus += f / (i+1)

print(int(count)%mod)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
x = list(map(int,input().split()))

mod = 10**9 + 7

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

f = math.factorial(n-1)

count = 0
k = f
plus = 0
for i in range(1,n):
    # print(k)
    k = f + plus
    count += l[i-1] * k
    plus += f / (i+1)

print(int(count)%mod)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
x = list(map(int,input().split()))

mod = 10**9 + 7

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

f = math.factorial(n-1)

count = 0
k = f
plus = 0
for i in range(1,n):
    print(k)
    k = f + plus
    count += l[i-1] * k
    plus += f / (i+1)

print(int(count)%mod)

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

mod = 10**9 + 7

l = []
for i in range(n-1):
    d = x[i+1] - x[i]
    l.append(d)

# print(l)

import math
f = math.factorial(n-1)

count = 0

for i in range(1,n):
    k = f * 1/i * (n-i) 
    plus = l[i-1] * k
    count += plus

print(int(count)%mod)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()
count = 0
for i in range(n-2):
    if s[i]!="A":
        pass
    else:
        if s[i+1]!="B":
            pass
        else:
            if s[i+2]!="C":
                pass
            else:
                count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
count = 0
for i in range(n):
    if s[i]!="A":
        pass
    else:
        if s[i+1]!="B":
            pass
        else:
            if s[i+2]!="C":
                pass
            else:
                count += 1
print(count)
Problem p02861 (python)

Fixed submission:
n = int(input())

xy = [list(map(int,input().split())) for _ in range(n)]

# print(xy)

import itertools
import numpy as np

def calc_distance(z1,z2):
    v1 = np.array(z1)
    v2 = np.array(z2)
    d = np.linalg.norm(v1-v2,2)
    return d


table = np.zeros((n,n))
for i in range(n):
    for j in range(n):
        if i==j:
            pass
        else:
            z1 = xy[i]
            z2 = xy[j]
            table[i,j] = calc_distance(z1,z2)
        
    
# print(table)

wa = 0
count = 0
for i in itertools.permutations(range(1,n+1)):
    # print(i)
    count += 1
    for j in range(len(i)-1):
        d = table[i[j]-1,i[j+1]-1]
        # print(d)
        wa += d

ans = wa/count
# print(wa)
# print(count)
print(ans)

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

mod = 10**9 + 7

# import math
# def comb(n,r):
#     return (math.factorial(n)//(math.factorial(n-r)*math.factorial(r)))

def comb(n,r,mod):
	'''
	return nCr
	O(min{n-r, r})
	'''
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

if (x+y)%3!=0:
    print(0)
    exit()
else:
    n = (2/3)*x - (1/3)*y
    m = (2/3)*y - (1/3)*x
    if n>=0 and m>=0:
        print(comb(int(n+m),int(m),mod))
        exit()
    else:
        print(0)
        exit()
Problem p02888 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        count += bisect.bisect_left(l,l[i]+l[j]) - j - 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        count += bisect.bisect_left(l[j+1:],l[a]+l[b])
        # print(l,a,b,s)
print(count)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l[j+1:],l[a]+l[b])
        count += s
        # print(l,a,b,s)
print(count)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.radline
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l[j+1:],l[a]+l[b])
        count += s
        # print(l,a,b,s)
print(count)