Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])
PY.sort(key = lambda x:x[0])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1

for i in range(n):
  j = 0
  while j < l[i]:
    list(filter(lambda x:x[0]==i+1,PY))[j].append(j+1)
    j += 1
  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))

Fixed submission:
n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1
  PY[i].append(l[PY[i][0]-1])

  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])
PY.sort(key = lambda x:x[0])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1

for i in range(n):
  j = 0
  while j < l[i]:
    list(filter(lambda x:x[0]==i+1,PY))[j].append(j+1)
    j += 1
  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))

Fixed submission:
n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1
  PY[i].append(l[PY[i][0]-1])

  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(i,map(int, input().split()))

PY.sort(key = lambda x:x[2])
PY.sort(key = lambda x:x[1])

l = [0]*(n)
for i in range(m):
  l[PY[i][1]-1]+=1

for i in range(n):
  j = 0
  while j < l[i]:
    list(filter(lambda x:x[1]==i+1,PY))[j].append(j+1)
    j += 1
  
PY.sort(key = lambda x:x[0])
for i in range(m):
  print('{:0=6}'.format(PY[i][1])+'{:0=6}'.format(PY[i][3]))
  

Fixed submission:
n,m = map(int, input().split())
PY = [[] for i in range(m)]
for i in range(m):
  PY[i] = list(map(int, input().split()))
  PY[i].append(i)
  
PY.sort(key = lambda x:x[1])

l = [0]*(n)
for i in range(m):
  l[PY[i][0]-1]+=1
  PY[i].append(l[PY[i][0]-1])

  
PY.sort(key = lambda x:x[2])
for i in range(m):
  print('{:0=6}'.format(PY[i][0])+'{:0=6}'.format(PY[i][3]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
XYH = list(map(int, input().split()) for _ in range(n))
  
XYH.sort(lambda x:x[2],reverse=True)
sx = XYH[0][0]
sy = XYH[0][1]
sh = XYH[0][2]
  
for i in range(0,101):
  for j in range(0,101):
    anss = sh + abs(sx-i) + abs(sy-j)
    for k in range(n):
      if H[k] == 0:
        continue
      if anss == XYH[k][2] + abs(XYH[k][0]-i) + abs(XYH[k][1]-j):
        continue
      else:
        break
    else:
      an = [sx, sy, sh]
      print(*an)
      exit()



Fixed submission:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
  
XYH.sort(key=lambda x:x[2],reverse=True)
sx = XYH[0][0]
sy = XYH[0][1]
sh = XYH[0][2]
  
for i in range(0,101):
  for j in range(0,101):
    anss = sh + abs(sx-i) + abs(sy-j)
    for k in range(n):
      if XYH[k][2] == max(anss - abs(XYH[k][0]-i) - abs(XYH[k][1]-j),0):
        pass
      else:
        break
    else:
      an = [i, j, anss]
      print(*an)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())

an = m //n
while an*n != m:
  an = m//n
  n = 1 + (m-1)*an
  
print(an)


Fixed submission:
n, m = map(int,input().split())

an = m //n
while an*n != m:
  an = m//n
  n = 1 + (m-1)//an
  
print(an)
Buggy python submission (verdict: Runtime Error):
n = int(input())
V = list(map(int,input().split()))

from collections import Counter

v1 = []
v2 = []
for i in range(0,n,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1)
c2 = Counter(v2)

if list(c1.keys())[0] == list(c2.keys())[0]:
  a1 = sum(list(c1.values())[1:])+list(c2.values())[0]+sum(list(c2.values()[2:]))
  a2 = sum(list(c2.values())[1:])+list(c1.values())[0]+sum(list(c1.values()[2:]))
           
  ans = min(a1,a2)
  
else:
  ans = sum(list(c1.values())[1:])+sum(list(c2.values())[1:])

print(ans)

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

from collections import Counter

v1 = []
v2 = []
for i in range(0,n-1,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1).most_common() + [(0,0)]
c2 = Counter(v2).most_common() + [(0,0)]

if c1[0][0] == c2[0][0]:
  a1 = n -c1[1][1]-c2[0][1]
  a2 = n -c1[0][1]-c2[1][1]
  ans = min(a1,a2)
  
else:
  ans = n-c1[0][1]-c2[0][1]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
V = list(map(int,input().split()))

v1 = []
v2 = []
for i in range(0,n,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
v1s = set(v1)
v2s = set(v2)

v1c = []
v2c = []
v1cc = []
v2cc = []
for i in list(v1s):
  v1c.append([i,v1.count(i)])
  v1cc.append(v1.count(i))
for i in list(v2s):
  v2c.append([i,v2.count(i)])
  v2cc.append(v2.count(i))
  
v1c.sort(key = lambda x:x[1],reverse=True)
v2c.sort(key = lambda x:x[1],reverse=True)
v1cc.sort(reverse=True)
v2cc.sort(reverse=True)

if v1c[0][0] == v2c[0][0]:
  print(min(sum(v1cc[1:])+sum([v2cc[0],sum(v2cc[2:])]),
            sum([v1cc[0],sum(v1cc[2:])])+sum(v2cc[1:])))
else:
  print(sum(v1cc[1:])+sum(v2cc[1:]))

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

from collections import Counter

v1 = []
v2 = []
for i in range(0,n-1,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1).most_common() + [(0,0)]
c2 = Counter(v2).most_common() + [(0,0)]

if c1[0][0] == c2[0][0]:
  a1 = n -c1[1][1]-c2[0][1]
  a2 = n -c1[0][1]-c2[1][1]
  ans = min(a1,a2)
  
else:
  ans = n-c1[0][1]-c2[0][1]

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
mod = 10**9+7

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

mf = factorize(m)
from collections import Counter

c = Counter(mf)
ans = 1
from scipy.misc import comb
for i in list(c.values()):
  ans*= comb((i+(n-1)),i)

print(round(ans)%mod)

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

mf = factorize(m)
from collections import Counter

c = Counter(mf)
ans = 1
from scipy.misc import comb
for i in list(c.values()):
  ans*= comb((i+(n-1)),i,exact=True)

print(int(round(ans))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()

countlist = []

for i in range(n):
  count1 = S[:i].count("W")
  count2 = S[i+1:].count("E")
  count_tem = count1+count2
  countlist.append(count_tem)
  
an = min(countlist)
print(an)


Fixed submission:
n = int(input())
S = input()

l = [0]*n
wl = [0]*n
el = [0]*n

for i in range(n-1):
  if i == 0:
    wl[i+1] = S[i].count("W")
  else:
    wl[i+1] = S[i].count("W")+wl[i]

for i in reversed(range(1,n)):
  if i == n:
    el[i-1] = S[i].count("E")
  else:
    el[i-1] = S[i].count("E")+el[i]
    
for i in range(n):
  l[i] = wl[i] + el[i]
  
print(min(l))

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

countlist = []

for i in range(n):
  count1 = S[:i].count("W")
  count2 = S[i+1:].count("E")
  count_tem = count1+count2
  countlist.append(count_tem)
  
an = min(countlist)
print(an)

Fixed submission:
n = int(input())
S = input()

l = [0]*n
wl = [0]*n
el = [0]*n

for i in range(n-1):
  if i == 0:
    wl[i+1] = S[i].count("W")
  else:
    wl[i+1] = S[i].count("W")+wl[i]

for i in reversed(range(1,n)):
  if i == n:
    el[i-1] = S[i].count("E")
  else:
    el[i-1] = S[i].count("E")+el[i]
    
for i in range(n):
  l[i] = wl[i] + el[i]
  
print(min(l))
Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())
S = [input() for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      b = sum([t[j].count("#") for t in S[max(0,i-1):min(H,i+1)]])
      b += S[i][max(0,j-1):min(W,j+1)].count("#")-1
      if b == 1:
        print("No")
        c = 1
        break
  else:
    continue
  break

if c !=1:
  print("Yes")

Fixed submission:
H, W = map(int, input().split())
S = [input() for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      bk = sum([t[j].count("#") for t in S[max(0,i-1):min(H,i+2)]])
      bk += S[i][max(0,j-1):min(W,j+2)].count("#")-1
      if bk == 1:
        print("No")
        exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

C = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      C += 1

S[0][0] = 0
for i in range(H):
  for j in range(W):
    if S[i][j] != "#":     
      for k in [[0,1],[1,0],[-1,0],[0,-1]]:
        if not(0 <= i + k[0] < H):
          continue
        elif not(0 <= j + k[1] < W):
          continue
        elif S[i+k[0]][j+k[1]] != ".":
          continue
        else:
          S[i+k[0]][j+k[1]] = S[i][j]+1
        
if S[H-1][W-1] == ".":
  print(-1)
  exit()
  
ans = C - S[H-1][W-1] -1
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

C = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      C += 1
    
S[0][0] = 0
for l in range(C-1):
  for i in range(H):
    for j in range(W):
      if S[i][j] == l:     
        for k in [[0,1],[1,0],[-1,0],[0,-1]]:
          if not(0 <= i + k[0] < H):
            continue
          elif not(0 <= j + k[1] < W):
            continue
          elif S[i+k[0]][j+k[1]] != ".":
            continue
          else:
            S[i+k[0]][j+k[1]] = S[i][j]+1
        
if S[H-1][W-1] == ".":
  print(-1)
  exit()
  
ans = C - S[H-1][W-1] -1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lista = []
for i in range(n):
  lista.append(int(input()))

count = 1
fp = lista[0]
for i in range(n):
  fp = lista[fp]
  count += 1
  if fp == 2:
    print(count)
    exit()
print(-1)
       

Fixed submission:
n = int(input())
lista = []
for i in range(n):
  lista.append(int(input()))

count = 1
fp = lista[0]
if fp == 2:
  print(count)
  exit()

for i in range(n):
  fp = lista[fp-1]
  count += 1
  if fp == 2:
    print(count)
    exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    flag = True
    exit()
  else:
    continue

if flag != True:
  print("NO")


Fixed submission:
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    exit()
  else:
    continue
print("NO")

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    flag = True
    exit()
  else:
    continue

if flag != True:
  print("No")
  


Fixed submission:
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    exit()
  else:
    continue
print("NO")

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

n = 100 * B

for i in range(1, n, B):
  if A * i % B == C:
    print("YES")
    flag = True
    break
  else:
    continue

if flag != True:
  print("No")
  


Fixed submission:
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    exit()
  else:
    continue
print("NO")

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

n = 100 * B

for i in range(1, n, B):
  if A * i % B == C:
    print("YES")
    flag = True:
    break
  else:
    continue

if flag != True:
  print("No")
  


Fixed submission:
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    exit()
  else:
    continue
print("NO")

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int,input().split())

n = 100 * B

for i in range(1, n, B):
  if A * i % B = C:
    print("YES")
    flag == True:
    break
  else:
    continue

if flag != True:
  print("No")
  

Fixed submission:
A, B, C = map(int,input().split())

for i in range(B):
  if A * i % B == C:
    print("YES")
    exit()
  else:
    continue
print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 1
for i in range(1,n+1):
  p = p*i
ap = p%1000000007
print(ap)


Fixed submission:
n = int(input())
import math
p = math.factorial(n)
ap = p%1000000007
print(ap)

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = 1
for i in range(1,n+1):
  p = p*i
ap = p/1000000007
print(ap)


Fixed submission:
n = int(input())
import math
p = math.factorial(n)
ap = p%1000000007
print(ap)

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = 1
for i in range(n):
  p = p*2^i
ap = p/(1000000007)
print(ap)

Fixed submission:
n = int(input())
import math
p = math.factorial(n)
ap = p%1000000007
print(ap)
Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    if S - i - j <= K :
        count += 1
      else:
        pass
      
print(count)


Fixed submission:
K, S = map(int, input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    if 0<= S - i - j <= K:
        count += 1
      
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + j + k == S:
        count += 1
      else:
        pass
      
print(count)

Fixed submission:
K, S = map(int, input().split())

count = 0
for i in range(K+1):
  for j in range(K+1):
    if 0<= S - i - j <= K:
        count += 1
      
print(count)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
n = 0
for i in range(a, b+1):
  if i%x == 0:
    p = i
    n += 1
    break

while p < b:
  p += x
  n += 1

n -= 1
print(n)
  
  

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

print(b//x-(a-1)//x)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, imput().split())
p = K*((K-1)**(N-1))
print(p)


Fixed submission:
N, K = map(int, input().split())
p = K*((K-1)**(N-1))
print(p)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, imput().split())
p = K*(K-1)^(N-1)
print(p)

Fixed submission:
N, K = map(int, input().split())
p = K*((K-1)**(N-1))
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
L = [int(x) for x in input().split(' ')]

count = 0
paris = list(itertools.combinations(L[1:], 2))
for i, a in enumerate(L[:-2]):
    count += sum([(a < b + c) * (b < c + a) * (c < a + b) for b, c in paris])
    del paris[:(N-i-2)]
print(count)



Fixed submission:
N = int(input())
L = sorted([int(x) for x in input().split(' ')], reverse=True)

count = 0
while len(L) > 2:
    a = L.pop(0)
    ic = len(L) - 1
    for ib, b in enumerate(L):
        diff = a - b
        while L[ic] <= diff and ib < ic:
            ic -= 1
        count += ic - ib
        if ib >= ic:
            break

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
L = [int(x) for x in input().split(' ')]

count = 0
for i, a in enumerate(L[:-2]):
    count += sum([(a < b + c) * (b < c + a) * (c < a + b) for b, c in itertools.combinations(L[(i+1):], 2)])

print(count)



Fixed submission:
N = int(input())
L = sorted([int(x) for x in input().split(' ')], reverse=True)

count = 0
while len(L) > 2:
    a = L.pop(0)
    ic = len(L) - 1
    for ib, b in enumerate(L):
        diff = a - b
        while L[ic] <= diff and ib < ic:
            ic -= 1
        count += ic - ib
        if ib >= ic:
            break

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = tuple([int(x) for x in input().split(' ')])
A = [int(x) for x in input().split(' ')]

for i in range(M):
    B, C = tuple([int(x) for x in input().split(' ')])
    A.extend([C]*B)

A.sort(reverse=True)
print(sum(A[:N]))

Fixed submission:
N, M = tuple([int(x) for x in input().split(' ')])
A = [int(x) for x in input().split(' ')]
minA = min(A)

BC = []
for i in range(M):
    BC.append(tuple([int(x) for x in input().split(' ')]))

BC.sort(key=lambda x:x[1], reverse=True)

sumB = 0
for B, C in BC:
    if C <= minA:
        break
    sumB += B
    A.extend([C]*B)
    if sumB >= N:
        break

A.sort(reverse=True)
print(sum(A[:N]))
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

ld=cf(a,b)
ld.append(1)

#ld2 = divisor(gcd(a,b))
cnt=0
#print(ld)
ansl=[]
for i in ld:
    flg=0
    for j in ansl:
        #if i==j or i==1:
        #    break
        if gcd(i,j) !=1:
            flg = 1
            #print('flg',i,j)
            #if j in ld:
            #    print('in',i,j,gcd(i,j))
            #    ld.remove(j)
            break
        #print(i,j,gcd(i,j))
    if flg == 0:
        ansl.append(i)


print(len(ansl))

#print(ld)

Fixed submission:
a,b = map(int,input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

ld=divisor(gcd(a,b))
ld.sort()
#ld.append(1)

#ld2 = divisor(gcd(a,b))
cnt=0
#print(ld)
ansl=[]
for i in ld:
    flg=0
    for j in ansl:
        #if i==j or i==1:
        #    break
        if gcd(i,j) !=1:
            flg = 1
            #print('flg',i,j)
            #if j in ld:
            #    print('in',i,j,gcd(i,j))
            #    ld.remove(j)
            break
        #print(i,j,gcd(i,j))
    if flg == 0:
        ansl.append(i)
    #print(ansl)


print(len(ansl))

#print(ld)
Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
        a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(l+1,r):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))



Fixed submission:
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
    a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(i+1,r+1):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))

Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
s=[]
rr=r-1
for i in range(l,rr):
    for j in range(l+1,r):
        #print(i,j)
        a=(i*j)%2019
        #print(a)
        s.append(a)
print(min(s))



Fixed submission:
l,r=map(int,input().split())
s=[]
if ((r//2019)!=(l//2019)):
    a=0
    s.append(a)
elif((r-l!=1)):
    for i in range(l,r-1):
        for j in range(i+1,r+1):
            #print(i,j)
            a=(i*j)%2019
            #print(a)
            s.append(a)
            if (a==0):
                break
else:
    a=(l*r)%2019
    s.append(a)
print(min(s))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int,input().split())
cnt=0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            total = i+j+k
            if total==s:
                cnt +=1
print(cnt)

Fixed submission:
k,s = map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if (z>=0)&(z<=k):
            cnt=cnt+1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if (x+y+z==s):
                cnt=cnt+1
print(cnt)

Fixed submission:
k,s = map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if (z>=0)&(z<=k):
            cnt=cnt+1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
res = list(np.argsort(l)+1)
print(" ".join(map(str, res)))


Fixed submission:
import numpy as np
n = int(input())
l = list(map(int, input().split()))
res = list(np.argsort(l)+1)
print(" ".join(map(str, res)))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array(range(1,n+1))
b = np.array([a[(i+1)%n] for i in range(n)])
print(sum(a%b))

Fixed submission:
import numpy as np
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(range(1,n+1))
b = np.array([a[(i+1)%n] for i in range(n)])
sum(a%b)import numpy as np
n = int(input())
a = np.array(range(1,n+1))
b = np.array([a[(i+1)%n] for i in range(n)])
print(sum(a%b))

Fixed submission:
import numpy as np
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ss = []
for i in range(n):
    ss.append(input())

def encode(s):
#     print(s)
    res = 0
    for ss in s:
        key = ord(ss)-ord('a')
        res += 10**key
    return res

lst = []
count = 0
for s in ss:
    en = encode(s)
#     print(en)
    for ls in lst:
        if ls == en:
            count += 1
#         print(s)
    lst.append(en)

print(count)
    


Fixed submission:
# n = 5
# ss = ["abaaaaaaaa",
# "oneplustwo",
# "aaaaaaaaba",
# "twoplusone",
# "aaaabaaaaa"]

n = int(input())
ss = []
for i in range(n):
    ss.append(input())

newss = []
for s in ss:
    newss.append("".join(sorted(list(s))))
newss = sorted(newss)
newss.append("XXXXXXXXXX")

last = newss[0]
count = 1
res = 0
for i in range(1,n+1):
    if last == newss[i]:
        count +=1
#         print(newss[i])
    else:
        res += (count*(count-1))//2
#         print(newss[i], (count*(count-1))//2)
        count = 1
    last = newss[i]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

result = 0

for i in range(n):
    result += np.min([a[i]+a[i+1], b[i]])
    a[i+1] = np.min([np.max([0, a[i]+a[i+1] - b[i]]), a[i+1]])
print(result)

Fixed submission:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(0)


result = 0

for i in range(n):
    if a[i] <= b[i]:
        result += a[i]
        if a[i]+a[i+1] < b[i]:
            result += a[i+1]
            a[i+1] = 0
        else:
            diff = a[i]+a[i+1] - b[i]
            result += (a[i+1] - diff)
            a[i+1] = diff
    else:
        result += b[i]
        
print(result)