Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [0] * (n + 1)
 
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self, i, x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

from itertools import accumulate
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [int(input())-k for i in range(n)]
acc = [0]+list(accumulate(a))
acc_i = []
for i,x in enumerate(acc):
  acc_i.append((x,i+1))
acc_i.sort()
bit = Bit(n+2)
ans = 0
for i in range(n+1):
  x = acc_i[i][1]
  ans += n+1-x+bit.sum(x)
  bit.add(1,-1)
  bit.add(x+1,1)
print(ans)

Fixed submission:
class Bit:
  def __init__(self, n):
    self.size = n
    self.tree = [0] * (n + 1)
 
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self, i, x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i

from itertools import accumulate
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [int(input())-k for i in range(n)]
acc = [0]+list(accumulate(a))
acc_i = []
for i,x in enumerate(acc):
  acc_i.append((x,i+1))
acc_i.sort()
bit = Bit(n+2)
ans = 0
for i in range(n+1):
  x = acc_i[i][1]
  ans += n+1-x+bit.sum(x)
  bit.add(1,-1)
  bit.add(x+1,1)
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a==b:
  print(1)
  exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
  while abin[0]==bbin[0]:
    abin=abin[1:]
    bbin=bbin[1:]
  while len(abin)>1 and abin[0]=="0":
    abin=abin[1:]
cbin=bbin[1:]
while cbin and cbin[0]=="0":
  cbin=cbin[1:]
c=2**(len(cbin))-1
a=int(abin,2)
b=int(bbin,2)
lb=len(bbin)
lbnd=2**(lb-1)+c
hbnd=2**(lb-1)+a
if lbnd>=hbnd:
  print(2**lb-a)
else:
  print(2**(lb-1)-a+lbnd-a+1)


Fixed submission:
n,a,b=map(int,input().split())
if a>b:
  print(0)
  exit()
if n == 1:
  if a == b:
    print(1)
  else:
    print(0)
  exit()
if n == 2:
  print(1)
  exit()
print((b-a)*(n-2)+1)
Buggy python submission (verdict: Runtime Error):
import scipy
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford

n,m = map(int,input().split())
evv = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
  evv[i][2] = -evv[i][2]
  evv[i][0] -= 1
  evv[i][1] -= 1
v1,v2,edge = zip(*evv)
csr = csr_matrix((edge,(v1,v2)),shape = (n,n))
try:
  print(-int(bellman_ford(csr, indices = 0)[n-1]))
except scipy.sparse.csgraph._shortest_path.NegativeCycleError:
  print("inf")

Fixed submission:
n,m = map(int,input().split())
vve = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,e in vve:
  graph[a].append((b,-e))
score = [10**15 for i in range(n+1)]
score[1] = 0
for j in range(n+1):
  flg = 0
  for i in range(m):
    v1,v2,e = vve[i]
    e = -e
    if score[v1] != 10**15 and score[v2] > score[v1]+e:
      score[v2] = score[v1]+e
      flg = 1
      if j == n-1:
        p = -score[n]
      if j == n:
        q = -score[n]
  if flg == 0:
    break
if flg == 0:
  print(-score[n])
else:
  if p == q:
    print(p)
  else:
    print("inf")
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter
n,m=map(int,input().split())
a=list(map(int,read().split()))
c=Counter(a)
ans="YES"
for i in c.values():
  if i%2:
    ans="NO"
print(ans)

Fixed submission:
import sys
from collections import Counter
read=sys.stdin.read
n,m=map(int,input().split())
a=list(map(int,read().split()))
c=Counter(a)
ans="YES"
for i in c.values():
  if i%2:
    ans="NO"
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))
def operate(ls,x):
    sm = 0
    ans = 0
    ans += abs(ls[0]-x)
    k = x
    for i in range(1,len(ls)):
        sm += k
        if sm > 0:
            if abs(ls[i]) <= sm or sm < ls[i]:
                ans += abs(ls[i]+sm+1)
                k = -sm-1
            else:
                k = ls[i]
        if sm < 0:
            if abs(ls[i]) <= abs(sm) or sm > ls[i]:
                ans += abs(-sm+1-ls[i])
                k = -sm+1
            else:
                k = ls[i]
    return ans

anstot = []
if a[0] > 0:
    inv = -1
if a[0] < 0:
    inv = 1
if a[0] != 0:
    anstot.append(operate(a,a[0]))
    anstot.append(operate(a,inv))
if a[0] == 0:
    for i in range(n):
        if a[i] == 0:
            a[i] = -1**(i%2)
        if a[i] != 0:
            r = i
            break
    anstot.append(operate(r+a,a[0]))
    for i in range(r):
        a[i] = -1**((1+i)%2)
    anstot.append(operate(r+a,a[0]))    
print(min(anstot))

Fixed submission:
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))
def operate(ls,x):
    sm = 0
    ans = 0
    ans += abs(ls[0]-x)
    k = x
    for i in range(1,len(ls)):
        sm += k
        if sm > 0:
            if abs(ls[i]) <= sm or sm < ls[i]:
                ans += abs(ls[i]+sm+1)
                k = -sm-1
            else:
                k = ls[i]
        if sm < 0:
            if abs(ls[i]) <= abs(sm) or sm > ls[i]:
                ans += abs(-sm+1-ls[i])
                k = -sm+1
            else:
                k = ls[i]
    return ans

anstot = []
if a[0] > 0:
    inv = -1
if a[0] < 0:
    inv = 1
if a[0] != 0:
    anstot.append(operate(a,a[0]))
    anstot.append(operate(a,inv))
if a[0] == 0:
    a[0] = 1
    anstot.append(1+operate(a,1))
    a[0] = -1
    anstot.append(1+operate(a,-1))    
print(min(anstot))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[list(input()) for in range(n)]
for i in s:
  i.sort()

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")
  c_tmp.clear()

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[list(input()).sort() for in range(n)]

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")
  c_tmp.clear()
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum[1:2*n+2:2])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[1:2*n:2]))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

mod = 10**9+7
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

import sys
input = sys.stdin.readline
n,X,Y = map(int,input().split())
cw = [list(map(int,input().split())) for i in range(n)]
cw.sort()
mnls = []
graph = [[] for i in range(n)]
notmn = set()
for i in range(n):
  if i == 0 or cw[i-1][0] != cw[i][0]:
    mnls.append((i,*cw[i]))
  else:
    if cw[i][1]+mnls[-1][2] <= X:
      graph[i].append(mnls[-1][0])
      graph[mnls[-1][0]].append(i)
    else:
      notmn.add(i)
mnls.sort(key = lambda x:x[2])
for i,x in enumerate(mnls):
  if i == 0:
    continue
  if x[2]+mnls[0][2] <= Y:
    graph[x[0]].append(mnls[0][0])
    graph[mnls[0][0]].append(x[0])
for i in notmn:
  if mnls[0][2]+cw[i][1] <= Y:
    graph[i].append(mnls[0][0])
    graph[mnls[0][0]].append(i)
vis = [0 for i in range(n)]
ans = 1
for i in range(n):
  if vis[i]:
    continue
  vis[i] = 1
  stack = [i]
  color = defaultdict(int)
  while stack:
    x = stack.pop()
    color[cw[x][0]] += 1
    for y in graph[x]:
      if vis[y] == 0:
        vis[y] = 1
        stack.append(y)
  sm = sum(color.values())
  for v in color.values():
    ans = ans*cmb(sm,v)%mod
    sm -= v
print(ans)

Fixed submission:
from collections import defaultdict

mod = 10**9+7
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

import sys
input = sys.stdin.readline
n,X,Y = map(int,input().split())
cw = [list(map(int,input().split())) for i in range(n)]
cw.sort()
mnls = []
graph = [[] for i in range(n)]
notmn = set()
for i in range(n):
  if i == 0 or cw[i-1][0] != cw[i][0]:
    mnls.append((i,cw[i][0],cw[i][1]))
  else:
    if cw[i][1]+mnls[-1][2] <= X:
      graph[i].append(mnls[-1][0])
      graph[mnls[-1][0]].append(i)
    else:
      notmn.add(i)
mnls.sort(key = lambda x:x[2])
for i,x in enumerate(mnls):
  if i == 0:
    continue
  if x[2]+mnls[0][2] <= Y:
    graph[x[0]].append(mnls[0][0])
    graph[mnls[0][0]].append(x[0])
for i in notmn:
  if mnls[0][1] != cw[i][0]:
    if mnls[0][2]+cw[i][1] <= Y:
      graph[i].append(mnls[0][0])
      graph[mnls[0][0]].append(i)
  else:
    if len(mnls) >= 2 and mnls[1][2]+cw[i][1] <= Y:
      graph[i].append(mnls[1][0])
      graph[mnls[1][0]].append(i)
vis = [0 for i in range(n)]
ans = 1
for i in range(n):
  if vis[i]:
    continue
  vis[i] = 1
  stack = [i]
  color = defaultdict(int)
  while stack:
    x = stack.pop()
    color[cw[x][0]] += 1
    for y in graph[x]:
      if vis[y] == 0:
        vis[y] = 1
        stack.append(y)
  sm = sum(color.values())
  for v in color.values():
    ans = ans*cmb(sm,v)%mod
    sm -= v
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
std = [list(map(int,input().split())) for i in range(n)]
chk = [list(map(int,input().split())) for i in range(m)]
for s in std:
  print(min(lambda i:abs(s[0]-chk[i][0])+abs(s[1]-chk[i][1])))

Fixed submission:
n,m=map(int,input().split())
std = [list(map(int,input().split())) for i in range(n)]
chk = [list(map(int,input().split())) for i in range(m)]
for s in std:
  ans=[]
  for i in range(m):
    ans.append([abs(s[0]-chk[i][0])+abs(s[1]-chk[i][1]),i+1])
    ans.sort()
  print(ans[0][1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans = []
for i in range(1,n**0.5+1):
  if n%i==0:
    j=n//i
    ans.append(len(str(i))+len(str(j)))
print(max(ans))

Fixed submission:
n=int(input())
ans = []
for i in range(1,int(n**0.5+1)):
  if n%i==0:
    j=n//i
    ans.append(max(len(str(i)),len(str(j))))
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(input()) for i in range(n)]
if max([a[i].count("#") for i in range(n)]) ==0:
  print(-1)
  exit()
minus=0
for i in range(n):
  if a[i].count(".")==0:
    minus=n
    break
  if a[i][i]=="#":
    minus=max(minus,a[i].count("#"))
b=zip(*a)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)

Fixed submission:
n=int(input())
a=[list(input()) for i in range(n)]
if max([a[i].count("#") for i in range(n)]) ==0:
  print(-1)
  exit()
minus=0
b=list(zip(*a))
for i in range(n):
  if b[i].count("#")>=1:
    minus=max(minus,a[i].count("#"))
  else:
    minus=max(minus,a[i].count("#")-1)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(input()) for i in range(n)]
if max(a[i].count("#") for i in range(n)) ==0:
  print(-1)
  exit()
minus=0
for i in range(n):
  if a[i].count(".")==0:
    minus=n
    break
  if a[i][i]=="#":
    minus=max(minus,a[i].count("#"))
b=zip(*a)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)

Fixed submission:
n=int(input())
a=[list(input()) for i in range(n)]
if max([a[i].count("#") for i in range(n)]) ==0:
  print(-1)
  exit()
minus=0
b=list(zip(*a))
for i in range(n):
  if b[i].count("#")>=1:
    minus=max(minus,a[i].count("#"))
  else:
    minus=max(minus,a[i].count("#")-1)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
if max(a[i].count(".") for i in range(n)) ==0:
  print(-1)
  exit()
minus=0
for i in range(n):
  if a[i].count(".")==0:
    minus=n
    break
  elif a[i][i]=="#":
    minus=max(minus,a[i].count("#"))
b=zip(*a)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)

Fixed submission:
n=int(input())
a=[list(input()) for i in range(n)]
if max([a[i].count("#") for i in range(n)]) ==0:
  print(-1)
  exit()
minus=0
b=list(zip(*a))
for i in range(n):
  if b[i].count("#")>=1:
    minus=max(minus,a[i].count("#"))
  else:
    minus=max(minus,a[i].count("#")-1)
for j in range(n):
  if b[j].count(".")==0:
    minus+=1
print(2*n-minus)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if (A+11)%13 > (B+11)%13:
  print("Alice")
elif (A+11)%13 < (B+11)%13:
  print("Bob")
else:
  print("Draw")

Fixed submission:
A,B=map(int,input().split())
if (A+11)%13 > (B+11)%13:
  print("Alice")
elif (A+11)%13 < (B+11)%13:
  print("Bob")
else:
  print("Draw")
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input())
A = [input() for _ in range(N)]
B = [input() for _ in range(N)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k][l]:
          break
        if A[k][l] == B[k][l] and k == i+M-1 and l == j+M-1:
          ans = 1
    else:
      continue
    break
if ans == 0:
  print("No")
else:
  print("Yes")

Fixed submission:
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k-i][l-j]:
          break
        if A[k][l] == B[k-i][l-j] and k == i+M-1 and l == j+M-1:
          ans = 1
      else:
        continue
      break

if ans == 0:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
n,m=map(int,input().split())
side=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  side[a].append(b)
  side[b].append(a)
route=[i for i in range(2,n+1)]
ans=0
for x in permutations(route):
  x=(1)+x
  for i in range(n-1):
    if x[i+1] not in side[x[i]]:
      break
  else:
    ans+=1
print(ans)

Fixed submission:
from itertools import permutations
n,m=map(int,input().split())
side=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  side[a].append(b)
  side[b].append(a)
route=[i for i in range(2,n+1)]
ans=0
for x in permutations(route):
  x=list(x)
  x.insert(0,1)
  for i in range(n-1):
    if x[i+1] not in side[x[i]]:
      break
  else:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import random
import sys
input = sys.stdin.readline
n = int(input())
stone = [0]+list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
dp = [[] for i in range(n+1)]
deg = [0]*(n+1)
stack = []
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
root = 0
for i in range(1,n+1):
  if deg[i] == 1:
    stack.append(i)
  elif root == 0:
    root = i
if root == 0:
  print(2/0)
  if stone[0] == stone[1]:
    print("YES")
  else:
    print("NO")
  exit()
deg[root] += 1
flg = 1
while stack:
  x = stack.pop()
  if x == root:
    if sum(dp[x]) != 2*stone[x] or max(dp[x]) > stone[x]:
      flg = 0
    break
  elif dp[x]:
    if max(max(dp[x])*2,sum(dp[x])) > stone[x]*2 or stone[x] > sum(dp[x]):
      flg = 0
      break
    stone[x] = 2*stone[x]-sum(dp[x])
  for y in graph[x]:
    if deg[y] > 1:
      dp[y].append(stone[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
if flg:
  print("YES")
else:
  print("NO")

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
stone = [0]+list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
dp = [[] for i in range(n+1)]
deg = [0]*(n+1)
stack = []
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
root = 0
for i in range(1,n+1):
  if deg[i] == 1:
    stack.append(i)
  elif root == 0:
    root = i
if root == 0:
  if stone[1] == stone[2]:
    print("YES")
  else:
    print("NO")
  exit()
deg[root] += 1
flg = 1
while stack:
  x = stack.pop()
  if x == root:
    if sum(dp[x]) != 2*stone[x] or max(dp[x]) > stone[x]:
      flg = 0
    break
  elif dp[x]:
    if max(max(dp[x])*2,sum(dp[x])) > stone[x]*2 or stone[x] > sum(dp[x]):
      flg = 0
      break
    stone[x] = 2*stone[x]-sum(dp[x])
  for y in graph[x]:
    if deg[y] > 1:
      dp[y].append(stone[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
if flg:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
a = list(map(int,input().split()))
def gcds(ls):
  ret = 0
  for i in ls:
    ret = gcd(ret,i)
  return ret
def flg(ls):
  if (sum(ls)-len(ls))%2:
    ret = 1
  else:
    ret = 2
  return ret
if n%2 == 0:
  if sum(a)%2:
    print("Second")
  else:
    print("First")
else:
  cnt = 0
  while flg(a)%2 == 0:
    odd = 0
    oddidx = -1
    even = 0
    for i,x in enumerate(a):
      if x%2:
        odd += 1
        oddidx = i
      else:
        even += 1
    if odd == 1 and a[oddidx] > 1:
      a[oddidx] -= 1
      g = gcds(a)
      for i in range(n):
        a[i] //= g
      cnt += 1
    else:
      break
  if (flg(a)+cnt)%2 == 1:
    print("First")
  else:
    print("Second")

Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
def gcds(ls):
  ret = 0
  for i in ls:
    ret = gcd(ret,i)
  return ret
def flg(ls):
  if (sum(ls)-len(ls))%2:
    ret = 1
  else:
    ret = 2
  return ret
if n%2 == 0:
  if sum(a)%2:
    print("First")
  else:
    print("Second")
else:
  cnt = 0
  while flg(a)%2 == 0:
    odd = 0
    oddidx = -1
    even = 0
    for i,x in enumerate(a):
      if x%2:
        odd += 1
        oddidx = i
      else:
        even += 1
    if odd == 1 and a[oddidx] > 1:
      a[oddidx] -= 1
      g = gcds(a)
      for i in range(n):
        a[i] //= g
      cnt += 1
    else:
      break
  if (flg(a)+cnt)%2 == 1:
    print("First")
  else:
    print("Second")
Buggy python submission (verdict: Runtime Error):
n=int(input())
ab=[list(map(int,input())) for i in range(n)]
ans = 0
for i in range(n-1,-1,-1):
  k = (ab[i][0]+ans)%ab[i][1]
  if k!=0:
    ans += ab[i][1]-k
print(ans)

Fixed submission:
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n-1,-1,-1):
  k = (ab[i][0]+ans)%ab[i][1]
  if k!=0:
    ans += ab[i][1]-k
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def prm(a):
  if a==1:
    return False
  for i in range(2,int(a**0.5+1)):
    if a%i==0:
      return False
  else:
    return True
x=int(input())
d=[1]*(x+1)
for i in range(1,x+1):
  if prm(i):
    d[i]+=1
  else:
    while not prm(i):
      for j in range(2,i):
        if i%j==0:
          d[j]+=1
          i=i//j
          break
ans=0
for i in range(x+1):
  ans = ans * d[i] % (10**9+7)
print(ans)

Fixed submission:
def prm(a):
  if a==1 or a == 4:
    return False
  for i in range(2,int(a**0.5+1)):
    if a%i==0:
      return False
  else:
    return True
x=int(input())
d=[1]*(x+1)
for i in range(1,x+1):
  if prm(i):
    d[i]+=1
  else:
    while not prm(i) and i != 1:
      for j in range(2,i):
        if i%j==0:
          d[j]+=1
          i=i//j
          break
    if i!= 1:
      d[i]+=1
ans=1

for i in range(x+1):
  ans = ans * d[i] % (10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans = 0
for i in range(k+1):
  if k <=s-i<=2*k:
    ans+= s-i+1
  elif 0<=s-i<=k:
    ans+= k*2-s+1
print(ans)

Fixed submission:
print(input().replace(","," "))

Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans = 0
for i in range(k+1):
  if k<=s-i<=2*k:
      ans+= s-i+1
  elif 0<=s-i<=k:
      ans+= k*2-s+1
print(ans)

Fixed submission:
print(input().replace(","," "))
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans = 0
for i in range(1,k+1):
  for j in range(1,k;1):
    if s-i-j<=k:
      ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans = 0
for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j<=k:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
abc = [list(map(int,input().split())) for i in range(m)]
abc = [[abc[i][0]-1,abc[i][1]-1,abc[i][2]] for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,c in abc:
  graph[a].append((b,c))
  graph[b].append((a,c))
v1,v2,edge = zip(*abc)
csr = csr_matrix((edge,(v1,v2)),shape = (n,n))
dist = floyd_warshall(csr, directed = False)
ans = 0
for i,j in combinations(range(n),2):
  fs1,fs2 = zip(*graph[i])
  if j in fs1:
    x = fs1.index(j)
    if fs2[x] > dist[i][j]:
      ans += 1
print(ans)

Fixed submission:
from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
n,m = map(int,input().split())
abc = [list(map(int,input().split())) for i in range(m)]
abc = [[abc[i][0]-1,abc[i][1]-1,abc[i][2]] for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,c in abc:
  graph[a].append((b,c))
  graph[b].append((a,c))
v1,v2,edge = zip(*abc)
csr = csr_matrix((edge,(v1,v2)),shape = (n,n))
dist = floyd_warshall(csr, directed = False)
ans = 0
for i,j in combinations(range(n),2):
  fs1,fs2 = zip(*graph[i])
  if j in fs1:
    x = fs1.index(j)
    if fs2[x] > dist[i][j]:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,op,b=map(input().split())
if op=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Fixed submission:
a,op,b=input().split()
if op=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Buggy python submission (verdict: Runtime Error):
a,op,b=map(int,input().split())
if op=="+":
  print(a+b)
else:
  print(a-b)

Fixed submission:
a,op,b=input().split()
if op=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
Buggy python submission (verdict: Runtime Error):
N,x=map(int, input().split(' '))
a = list(map(int, input().split(' ')))
wa = [a[0]]+[a[i]+a[i+1] for i in range(N-1)]+[a[-1]]
ans = 0

for i in range(N):
    print(i, a,wa,ans)
    if wa[i] <= x:
        continue
    if a[i] >= x:
        ans += wa[i]-x
        a[i] -= wa[i]-x
        wa[i] -= wa[i]-x
        wa[i+1] -= wa[i+1]-x
        continue
    if a[i] < x:
        ans += wa[i]-x
        a[i] = 0
        a[i] = x
        wa[i] = x

print(ans)

Fixed submission:
N,x=map(int, input().split(' '))
a = list(map(int, input().split(' ')))
wa = [a[0]]+[a[i]+a[i+1] for i in range(N-1)]+[a[-1]]
ans = 0

for i in range(N):
    if wa[i] <= x:
        continue
    if wa[i] > x:
        dif = wa[i]-x
        ans += dif
        a[i] -= dif
        wa[i] -= dif
        wa[i+1] -= dif
        continue

if wa[-1] > x:
    ans += wa[-1]-x
    a[-1] = wa[-1]-x
    wa[-1] -= wa[-1]-x

print(ans)