Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import re
N = int(input())
S = input()
ans = 0
tmp = [[m.start() for m in re.finditer(str(i), S)] for i in range(10)]
for i in range(10):
  if len(tmp[i]) == 0:
    continue
  for j in range(10):
    if len(tmp[j]) == 0:
      continue
    for k in range(10):
      if len(tmp[k]) == 0:
        continue
      l = tmp[i][0]
      r = tmp[k][-1]
      for m in range(l+1, r):
        if m in tmp[j]:
          ans += 1
          break
print(ans)

Fixed submission:
import re
N = int(input())
S = input()
ans = 0
tmp = [[m.start() for m in re.finditer(str(i), S)] for i in range(10)]
for i in range(10):
  if len(tmp[i]) == 0:
    continue
  for j in range(10):
    if len(tmp[j]) == 0:
      continue
    for k in range(10):
      if len(tmp[k]) == 0:
        continue
      l = tmp[i][0]
      flag = True
      for m in tmp[j]:
        if m > l:
          flag = False
          break
      if flag:
        continue
      for n in tmp[k]:
        if n > m:
          ans += 1
          break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
point = [K for _ in range(N)]
for i in range(Q):
  point = [point[j]-1 for j in range(A[i]-1)] + [point[A[i]-1]] + [point[j]-1 for j in range(A[i], N)]
for i in range(N):
  if point[i]>0:
    print('Yes')
  else:
    print('No')

Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
point = [K for _ in range(N)]
for i in range(Q):
  point[A[i]-1] += 1
point = [i-Q for i in point]
for i in range(N):
  if point[i]>0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'
if N == 1:
  print(ans)
else:
  for i in range(N):
    if i == 0:
      if H[0]-1 > H[1]:
        ans = 'NO'
        break
      elif H[0] > H[1]:
        H[0] -= 1
    else:
      if H[i] <= H[i+1]:
        continue
      elif H[i]-1 > H[i+1]:
        ans = 'No'
        break
      elif H[i] > H[i+1]:
        if H[i-1] == H[i]:
          ans = 'No'
          break
        else:
          H[i] -= 1
  print(ans)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'
if N == 1:
  print(ans)
else:
  for i in range(N-1):
    if i == 0:
      if H[0]-1 > H[1]:
        ans = 'No'
        break
      elif H[0]-1 == H[1]:
        H[0] -= 1
        continue
    else:
      if H[i] <= H[i+1]:
        if H[i-1]<=H[i]-1:
          H[i] -=1
        continue
      elif H[i]-1 > H[i+1]:
        ans = 'No'
        break
      elif H[i]-1 == H[i+1]:
        if H[i-1] == H[i]:
          ans = 'No'
          break
        else:
          H[i] -= 1
  print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
NG = []
a = 10**9+7
for i in range(M):
  NG.append(int(input()))
ans = [0 for _ in range(N + 2)]
ans[0] = 1
for i in range(N):
  if not i + 1 in NG:
    ans[i + 1] = (ans[i + 1] + ans[i])%a
  if not i + 2 in NG:
    ans[i + 2] = (ans[i + 2] + ans[i])%a
print(ans[N])

Fixed submission:
P, Q, R = map(int, input().split())
print(P+Q+R-max(P,Q,R))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
NG = []
a = 10**9+7
for i in range(M):
  NG.append(int(input()))
ans = [0 for _ in range(N + 2)]
ans[0] = 1
for i in range(N):
  if not i + 1 in NG:
    ans[i + 1] = (ans[i + 1] + ans[i])%a
  if not i + 2 in NG:
    ans[i + 2] = (ans[i + 2] + ans[i])%a
print(ans[N])

Fixed submission:
N, M = map(int, input().split())
NG = []
a = 10**9+7
NG = [True for _ in range(N + 2)]
for i in range(M):
  NG[int(input())] = False
ans = [0 for _ in range(N + 2)]
ans[0] = 1
for i in range(N):
  if NG[i + 1]:
    ans[i + 1] = (ans[i + 1] + ans[i])%a
  if NG[i + 2]:
    ans[i + 2] = (ans[i + 2] + ans[i])%a
print(ans[N])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
NG = []
for i in range(M):
  NG.append(int(input()))
ans = [0 for _ in range(N + 2)]
ans[0] = 1
for i in range(N):
  if not i + 1 in NG:
    ans[i + 1] += ans[i]
  if not i + 2 in NG:
    ans[i + 2] += ans[i]
print(ans[N]%(10**9+7))

Fixed submission:
N, M = map(int, input().split())
NG = []
a = 10**9+7
NG = [True for _ in range(N + 2)]
for i in range(M):
  NG[int(input())] = False
ans = [0 for _ in range(N + 2)]
ans[0] = 1
for i in range(N):
  if NG[i + 1]:
    ans[i + 1] = (ans[i + 1] + ans[i])%a
  if NG[i + 2]:
    ans[i + 2] = (ans[i + 2] + ans[i])%a
print(ans[N])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
cnt = 0
ans = 0
while cnt < M:
  ind = np.argmin(A)
  m = min(M - cnt, B.pop(ind))
  ans += A.pop(ind) * m
  cnt += m
print(ans)  

Fixed submission:
import numpy as np
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
cnt = 0
ans = 0
ind = np.argsort(A)
for i in range(N):
  m = min(M - cnt, B[ind[i]])
  ans += A[ind[i]] * m
  cnt += m
  if cnt >= M:
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int, input().split())
ans = []
for i in range(A, A+K):
  ans.append(i)
for i in range(B-K+1, B+1):
  ans.append(i)
ans = list(set(ans)).sort(reverse=True)
for i in ans:
  if i>=A and i<=B:
    print(i)

Fixed submission:
A,B,K = map(int, input().split())
ans = []
for i in range(A, A+K):
  ans.append(i)
for i in range(B-K+1, B+1):
  ans.append(i)
ans = list(set(ans))
ans.sort(reverse=False)
for i in ans:
  if i>=A and i<=B:
    print(i)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a%2 == 1 and b% == 1:
  print('Odd')
else:
  print('Even')

Fixed submission:
a, b = map(int, input().split())
if a%2 == 1 and b%2 == 1:
  print('Odd')
else:
  print('Even')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(input().split())
ans = []
for i in A:
  cnt = 0
  while i%2 == 0:
    cnt += 1
    i /= 2
  ans.append(cnt)
print(min(ans))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = []
for i in A:
  cnt = 0
  while i%2 == 0:
    cnt += 1
    i /= 2
  ans.append(cnt)
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def func(array, value):
  ng = -1
  ok = len(array)
  #if value
  while ok - ng > 1:
    mid = (ok + ng)//2
    if array[mid] < value:
      ng = mid
    elif array[mid] >= value:
      ok = mid
  return ok
for a in A:
  b_idx = func(B, a + 1)
  if b_idx == len(B):
    break
  #print('a', a)
  #print('B[b_idx:]',B[b_idx:])
  for b in B[b_idx:]:
    c_idx = func(C, b + 1)
    #print('b',b)
    #print('C[c_idx:]',C[c_idx:])
    if c_idx == len(C):
      break
    #print(a, b_idx, c_idx)
    ans += len(C) - c_idx
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def low_func(array, value):
  ng = -1
  ok = len(array)
  #if value
  while ok - ng > 1:
    mid = (ok + ng)//2
    if array[mid] < value:
      ng = mid
    elif array[mid] >= value:
      ok = mid
  return ok

def up_func(array, value):
  ok = -1
  ng = len(array)
  #if value
  while abs(ok - ng) > 1:
    mid = (ok + ng)//2
    if array[mid] <= value:
      ok = mid
    elif array[mid] > value:
      ng = mid
  return ok

for b in B:
  a_idx = up_func(A, b - 1)
  if a_idx == -1:
    continue
  c_idx = low_func(C, b + 1)
  if c_idx == len(C):
    break
  ans += (a_idx + 1)*(len(C) - c_idx)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def func(array, value):
  ng = -1
  ok = len(array)
  #if value
  while ok - ng > 1:
    mid = (ok + ng)//2
    if array[mid] < value:
      ng = mid
    elif array[mid] >= value:
      ok = mid
  return ok
for a in A:
  b_idx = func(B, a + 1)
  if b_idx == len(B):
    continue
  #print('a', a)
  #print('B[b_idx:]',B[b_idx:])
  for b in B[b_idx:]:
    c_idx = func(C, b + 1)
    #print('b',b)
    #print('C[c_idx:]',C[c_idx:])
    if c_idx == len(C):
      continue
    #print(a, b_idx, c_idx)
    ans += len(C) - c_idx
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def low_func(array, value):
  ng = -1
  ok = len(array)
  #if value
  while ok - ng > 1:
    mid = (ok + ng)//2
    if array[mid] < value:
      ng = mid
    elif array[mid] >= value:
      ok = mid
  return ok

def up_func(array, value):
  ok = -1
  ng = len(array)
  #if value
  while abs(ok - ng) > 1:
    mid = (ok + ng)//2
    if array[mid] <= value:
      ok = mid
    elif array[mid] > value:
      ng = mid
  return ok

for b in B:
  a_idx = up_func(A, b - 1)
  if a_idx == -1:
    continue
  c_idx = low_func(C, b + 1)
  if c_idx == len(C):
    break
  ans += (a_idx + 1)*(len(C) - c_idx)
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A == B:
  print('Draw')
else:
  if A == 1:
    print('Alice')
  elif B == 1:
    print('Bob')
  elif A < B:
    print('Bob')
  else B < A:
    print('Alice')

Fixed submission:
A, B = map(int, input().split())
if A == B:
  print('Draw')
else:
  if A == 1:
    print('Alice')
  elif B == 1:
    print('Bob')
  elif A < B:
    print('Bob')
  elif B < A:
    print('Alice')
Buggy python submission (verdict: Runtime Error):
a = input()
if a >= 1200:
  print('ARC')
else:
  print('ABC')

Fixed submission:
a = int(input())
if a >= 1200:
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
ans =0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i+j+k == S:
        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 S-i-j<=K and S-i-j>=0:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
half = math.floor(N/2)
ans = 2**(half)
if N%2 == 1 and A[-1] !=0:
  ans = 0
for i in range(half):
  if A[2*i] == N-2*i-1 and A[2*i+1] == N-2*i-1:
    continue
  else:
    ans = 0
    break
print(ans/(10**9+7))

Fixed submission:
import math
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
half = math.floor(N/2)
ans = 2**(half)
if N%2 == 1 and A[-1] !=0:
  ans = 0
for i in range(half):
  if A[2*i] == N-2*i-1 and A[2*i+1] == N-2*i-1:
    continue
  else:
    ans = 0
    break
print(ans%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
def func(T_pre, A_pre, T, A):
  for i in range(1, 10**10):
    if T_pre <= T and A_pre <= A:
      return T, A
    else:
      T = T*(i+1)/i
      A = A*(i+1)/i
for i in range(N):
  T, A = map(int, input().split())
  if i == 0:
    T_pre = T
    A_pre = A
  else:
    T_pre, A_pre = func(T_pre, A_pre, T, A)
print(int(T_pre+A_pre))

Fixed submission:
N = int(input())
def func(T_pre, A_pre, T, A):
  if T_pre <= T and A_pre <= A:
    return T, A
  else:
    t = -(-T_pre//T)
    a = -(-A_pre//A)
    x = max(t, a)
    return T*x, A*x
for i in range(N):
  T, A = map(int, input().split())
  if i == 0:
    T_pre = T
    A_pre = A
  else:
    T_pre, A_pre = func(T_pre, A_pre, T, A)
print(int(T_pre+A_pre))
Buggy python submission (verdict: Runtime Error):
N = int(imput())
print(N*(N+1)/2)

Fixed submission:
N = int(input())
print(int(N*(N+1)/2))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

c=Counter(a)
ck=list(Counter(a).keys())
for i in range(1,n+1):
    if i in ck:
        print(c[i])
    else:
        print(0)

Fixed submission:
from collections import Counter


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



c=Counter(a)
ck=set(Counter(a).keys())
for i in range(1,n+1):
    if i in ck:
        print(c[i])
    else:
        print(0)

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


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

c=Counter(a)
ck=list(Counter(a).keys())
for i in range(1,n+1):
    if i in ck:
        print(c[i])
    else:
        print(0)

Fixed submission:
from collections import Counter


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



c=Counter(a)
ck=set(Counter(a).keys())
for i in range(1,n+1):
    if i in ck:
        print(c[i])
    else:
        print(0)

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

for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
from collections import Counter


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



c=Counter(a)
ck=set(Counter(a).keys())
for i in range(1,n+1):
    if i in ck:
        print(c[i])
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
n=int(input())
    
res=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            res+=gcd(a,b,c)
print(res)

Fixed submission:
import math
from functools import reduce


n=int(input())
    
res=0
nlist=[]
for a in range(1,n+1):
    for b in range(1,n+1):
        nlist.append(math.gcd(a,b))
        
import collections

c = collections.Counter(nlist)
ck=list(c.keys())
cv=list(c.values())

cn=len(ck)

for i in range(cn):
    for c in range(1,n+1):
        res+=math.gcd(c,ck[i])*cv[i]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
while(abs(n-k)<n):
    n=abs(n-k)
print(n)

Fixed submission:
def zettai(n,k):
    return abs(n-k)
n,k=map(int,input().split())
n=n%k
while(zettai(n,k)<n):
    n=zettai(n,k)
print(n)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
for i in range(k):
    h.pop()
print(sum(h))

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
for i in range(k):
    if len(h)>0:
        h.pop()
print(sum(h))
Buggy python submission (verdict: Runtime Error):
n=int(input())
result=1000000000000
for i in range(n):
  nn=n/(i+1)
  if (nn.is_integer() and result>nn+i-1):
    result=nn+i-1
print(result)

Fixed submission:
a,b=map(int,input().split())
if a>9 or b>9:
  print(-1)
else:
  print(a*b)

Buggy python submission (verdict: Runtime Error):
n=int(input())
result=1000000000000
for i in range(n):
  nn=n/(i+1)
  if (nn.is_integer() and result>nn+i-1):
    result=nn+i-1
    print(nn)
    print(i+1)
print(result)

Fixed submission:
a,b=map(int,input().split())
if a>9 or b>9:
  print(-1)
else:
  print(a*b)

Buggy python submission (verdict: Runtime Error):
n=int(input())
result=100000000000000000000000000
for i in range(n):
  nn=n/(i+1)
  if (nn.is_integer() and result>nn+i-1):
    result=nn+i-1
    print(nn)
    print(i+1)
print(result)

Fixed submission:
a,b=map(int,input().split())
if a>9 or b>9:
  print(-1)
else:
  print(a*b)

Buggy python submission (verdict: Runtime Error):
n=int(input())
result=100000000000000000000000000
for i in range(n):
  nn=n/(i+1)
  if (nn.is_integer() and result>nn+i-1):
	result=nn+i-1
print(result)
    
    


Fixed submission:
a,b=map(int,input().split())
if a>9 or b>9:
  print(-1)
else:
  print(a*b)
Buggy python submission (verdict: Runtime Error):
n=int(input())
flag=0
for i in range(9):
  nn=n/(i+1)
  if(nn<10 and type(nn)==int):
    flag=1
    break:
if(flag):
  print("Yes")
else:
  print("No")

Fixed submission:
n=int(input())
flag=0
for i in range(9):
  nn=n/(i+1)
  if(nn<10 and (nn.is_integer())):
    flag=1
    break
if(flag):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
result=1000000000000
for i in range(n):
  nn=n/(i+1)
  if (nn.is_integer() and result>nn+i-1):
    result=nn+i-1
print(int(result))


Fixed submission:
n = int(input())
list=[]
for i in range(1,int(n**0.5+1)):
  if n%i == 0:
    list.append(int(i+n/i))
print(min(list)-2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
result=100000000000000000000000000
for i in range(n):
  nn=n/i
  if (nn.is_integer() and result>nn+i-2):
	result=nn+i-2
print(result)
    
    

Fixed submission:
n = int(input())
list=[]
for i in range(1,int(n**0.5+1)):
  if n%i == 0:
    list.append(int(i+n/i))
print(min(list)-2)
Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
if s[1]==1:
	print(0)
else:
  	num=1
	cost=s[0]
	while cost < s[1]:
    	num+=1
    	cost+=(s[0]-1)
print(num)

Fixed submission:
s=input()
t=input()
result=0
if s[:1]==t[:1]:
    result=result+1

if s[1:2]==t[1:2]:
    result=result+1

if s[2:3]==t[2:3]:
    result=result+1
print(result)

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
num=1
cost=s[0]
while cost < s[1]:
    num+=1
    cost=num*s[0]-1
print(num)

Fixed submission:
s=input()
t=input()
result=0
if s[:1]==t[:1]:
    result=result+1

if s[1:2]==t[1:2]:
    result=result+1

if s[2:3]==t[2:3]:
    result=result+1
print(result)

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
num=1
cost=s[0]
while cost < s[1]:
  num=num+1
  cost=num*s[0]-1
print(num)
  

Fixed submission:
s=input()
t=input()
result=0
if s[:1]==t[:1]:
    result=result+1

if s[1:2]==t[1:2]:
    result=result+1

if s[2:3]==t[2:3]:
    result=result+1
print(result)

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
num=1
cost=s[0]
while cost < s[1]:
  num+=1
  cost=num*s[0]-1
print(num)

Fixed submission:
s=input()
t=input()
result=0
if s[:1]==t[:1]:
    result=result+1

if s[1:2]==t[1:2]:
    result=result+1

if s[2:3]==t[2:3]:
    result=result+1
print(result)

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
num=1
cost=s[0]
while cost < s[1]:
    num+=1
    cost=num*s[0]-1
print(num)

Fixed submission:
s=input()
t=input()
result=0
if s[:1]==t[:1]:
    result=result+1

if s[1:2]==t[1:2]:
    result=result+1

if s[2:3]==t[2:3]:
    result=result+1
print(result)

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
num=1
cost=s[0]
while cost < s[1]:
    num+=1
    cost=num*s[0]-1
print(num)

Fixed submission:
s=input()
t=input()
result=0
if s[:1]==t[:1]:
    result=result+1

if s[1:2]==t[1:2]:
    result=result+1

if s[2:3]==t[2:3]:
    result=result+1
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)
flag=0
n=int(input())
list1=[]

for i in range(n):
    list1.append(input())
for i in range(n):
    for j in range(n):
        if i<j:
            if verify_anagrams(list1[i], list1[j]):
                flag=flag+1
print(flag)

Fixed submission:
from collections import defaultdict
N = int(input())
d = defaultdict(int)
 
for i in range(N):
    s = str(sorted(input()))
    d[s] += 1
ans = 0
 
for key in d.keys():
    ans += d[key]*(d[key]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)
flag=0
n=int(input())
list1=[]

for i in range(n):
    list1.append(input())
for i in range(n):
    for j in range(n):
        if i>j:
            if verify_anagrams(list1[i], list1[j]):
                flag=flag+1
print(flag)

Fixed submission:
from collections import defaultdict
N = int(input())
d = defaultdict(int)
 
for i in range(N):
    s = str(sorted(input()))
    d[s] += 1
ans = 0
 
for key in d.keys():
    ans += d[key]*(d[key]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)
flag=0
n=int(input())
list1=[]
check_list=[]
for i in range(n):
    list1.append(input())
for i in range(n):
    for j in range(n):
        if (i!=j)and(list1[j] not in check_list):
            if verify_anagrams(list1[i], list1[j]):
                check_list.append(list1[i])
                flag=flag+1
print(flag)

Fixed submission:
from collections import defaultdict
N = int(input())
d = defaultdict(int)
 
for i in range(N):
    s = str(sorted(input()))
    d[s] += 1
ans = 0
 
for key in d.keys():
    ans += d[key]*(d[key]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)
flag=0
n=int(input())
list1=[]
check_list=[]
for i in range(n):
    list1.append(input())
for i in range(n):
    for j in range(n):
        if verify_anagrams(list1[i], list1[j]):
            if (i!=j)and(list1[j] not in check_list):
                check_list.append(list1[i])
                flag=flag+1
print(flag)

Fixed submission:
from collections import defaultdict
N = int(input())
d = defaultdict(int)
 
for i in range(N):
    s = str(sorted(input()))
    d[s] += 1
ans = 0
 
for key in d.keys():
    ans += d[key]*(d[key]-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
count=0

def battle(a,ai,b):
  if a+ai <= b:
    ai=0
    count=a+ai
  elif a<=b:
    ai=ai-(b-a)
    count=b
  else:
    ai=ai
    count=b
  result ai,count
  
for i in range(n):
  c=0
  a[i+1],c=battle(a[i],a[i+1],b[i])
  count += c

print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
count=0
def battle(a,ai,b):
  if a+ai <= b:
    count=a+ai
    ai=0
  elif a<=b:
    ai=ai-(b-a)
    count=b
  else:
    ai=ai
    count=b
  return ai,count
  
for i in range(n):
  c=0
  a[i+1],c=battle(a[i],a[i+1],b[i])
  count += c
 
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [None]*N
for i in range(N):
  s, P = input().split()
  list[i]=(i,s,int(p)*-1)
for i in sorted(list, key = lambda x: (x[1],x[2])):
  print(i[0]+1)

Fixed submission:
N = int(input())
list = [None]*N
for i in range(N):
  s, p = input().split()
  list[i]=(i,s,int(p)*-1)
for i in sorted(list, key = lambda x: (x[1],x[2])):
  print(i[0]+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [None]*N
for i in range(N):
  s, P = input().split()
  list[i]=(i,s,int(p)*-1)
for i in sorted(list, key = lamda x: (x[1],x[2])):
  print(i[0]+1)

Fixed submission:
N = int(input())
list = [None]*N
for i in range(N):
  s, p = input().split()
  list[i]=(i,s,int(p)*-1)
for i in sorted(list, key = lambda x: (x[1],x[2])):
  print(i[0]+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [None]*N
for i in range(N):
  s, P = input().split()
  list[i]=(i,s,int(p)*-1)
for i in sorted(list, key = lamda x: (x[1],x[2])):
  print(i[0]+1)

Fixed submission:
N = int(input())
list = [None]*N
for i in range(N):
  s, p = input().split()
  list[i]=(i,s,int(p)*-1)
for i in sorted(list, key = lambda x: (x[1],x[2])):
  print(i[0]+1)