Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = [""]
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    else:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    elif s[i] == "B" and len(q)!=0:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    else:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    elif s[i] == "B" and len(q)!=0:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k= map(int,input().split())
d = list(map(int,input().split()))
able = [True]*10
for i in range(k):
    able[d[i]] = False
use = []
for i in range(len(able)):
    if able[i] == True:
        use.append(i)
while True:
    ans = ""
    s = str(n)
    for i in range(len(s)):
        c = int(s[i])
        for j in range(len(use)):
            if c<=use[j]:
                ans += str(use[j])
                break
    if int(ans)>=n:
        break
    else:
        n += 1
print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k= map(int,input().split())
d = list(map(int,input().split()))
able = [True]*10
for i in range(k):
    able[d[i]] = False
use = []
for i in range(len(able)):
    if able[i] == True:
        use.append(i)
flag = False
while True:
    s = str(n)
    for i in range(len(s)):
        c = int(s[i])
        if c in use:
            flag = True
        else:
            flag = False
            break
    if flag:
        print(n)
        sys.exit()
    n += 1
Buggy python submission (verdict: Time Limit Exceeded):
def ri():
    return int(input())


def rii():
    return [int(v) for v in input().split()]


def solve():
    N = ri()
    ans = 0
    for a in range(1, N):
        for b in range(1, N):
            if a * b < N:
                ans += 1
    print(ans)


if __name__ == "__main__":
    solve()

Fixed submission:
def ri():
    return int(input())


def rii():
    return [int(v) for v in input().split()]


def solve():
    N = ri()
    ans = 0
    for a in range(1, N):
        b = 1
        while b * a < N:
            ans += 1
            b += 1
    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
if x == 1:
	print(0)
else:
	print(1)

Fixed submission:
if int(input()) == 0:
	print(1)
else:
	print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(v) for v in input().split()]
MOD = int(1e9 + 7)
s = 0
L = {}
for i in range(N):
    for j in range(i+1, N):
        if (A[i], A[j]) in L or (A[j], A[i]) in L:
            s = (s + L[(A[i], A[j])]) % MOD
        else:
            r = (A[i] * A[j])
            s = (s + r) % MOD
            L[(A[i], A[j])] = r
            L[(A[j], A[i])] = r

print(s)

Fixed submission:
N = int(input())
A = [int(v) for v in input().split()]
MOD = int(1e9 + 7)

S = sum(A)
SQ = S * S
IS = sum(a*a for a in A)

print(((SQ - IS) // 2) % MOD)
Buggy python submission (verdict: Runtime Error):
N, K = int(input()), int(input())
P = [int(v) for v in input().split()]

print(sum(sorted(P)[:K]))

Fixed submission:
N, K = [int(v) for v in input().split()]
P = [int(v) for v in input().split()]

print(sum(sorted(P)[:K]))
Buggy python submission (verdict: Runtime Error):
print(int(input()) * int(input()))

Fixed submission:
A, B = [int(v) for v in input().split()]
print(A * B)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import operator
_ = input()
M = reduce(operator.mul, [int(v) for v in input().split()])

print(M if M <= 10**18 else -1)

Fixed submission:

_ = input()
N = sorted([int(v) for v in input().split()])
s = 1
for n in N:
    s *= n
    if s == 0 or s > 10**18:
        break

print(s if s <= 10**18 else -1)
Buggy python submission (verdict: Runtime Error):
S = int(input())

check = S[2] == S[3] and S[4] == S[5]

print("Yes" if check else "No")

Fixed submission:
S = input()

check = S[2] == S[3] and S[4] == S[5]

print("Yes" if check else "No")

Buggy python submission (verdict: Runtime Error):
S = int(input())

check = S[2] == S[4] and S[3] == S[5]

print("Yes" if check else "No")

Fixed submission:
S = input()

check = S[2] == S[3] and S[4] == S[5]

print("Yes" if check else "No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
prnit(N//2 + N%2)

Fixed submission:
N = int(input())
print(N//2 + N%2)
Buggy python submission (verdict: Runtime Error):
ri = lambda S: [int(v) for v in S.split()]
def rii(): return ri(input())

H, A = rii()

print((H // A)

Fixed submission:
ri = lambda S: [int(v) for v in S.split()]
def rii(): return ri(input())

H, A = rii()

print((H + A - 1) // A)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
result = 0
count = 0
while True:
  if not a and not b:
    print(count)
  if result > k:
    print(count-1)
    break
  if not a:
    result += b.pop()
    count += 1
  elif not b:
    result += a.pop()
    count += 1
  elif a[0] < b[0]:
    result += a.pop(0)
    count += 1
  else:
    result += b.pop(0)
    count += 1

Fixed submission:
n,m,k=map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]

for i in range(n):
  a.append(a[i] + A[i])
for i in range(m):
  b.append(b[i] + B[i])
  
ans, j = 0, m

for i in range(n+1):
  if a[i] > k:
    break
  while b[j] > k - a[i]:
    j -= 1
  ans = max(ans, i + j)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alphabet=list('zabcdefghijklmnopqrstuvwxyz')
result = ''
while N > 0:
  result = alphabet[N%26]+result
  if N%26==0:
    N-=1
    N//=26
print(result)

Fixed submission:
N=int(input())
alphabet=list('zabcdefghijklmnopqrstuvwxyz')
result = ''
while N > 0:
  result = alphabet[N%26]+result
  if N%26==0:
    N-=1
  N//=26
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alphabet='zabcdefghijklmnopqrstuvwxyz'
result = ''
while N > 0:
  result = alphabet[N%26]+result
  if N%26==0:
    N-=1
    N//=26
print(result)

Fixed submission:
N=int(input())
alphabet=list('zabcdefghijklmnopqrstuvwxyz')
result = ''
while N > 0:
  result = alphabet[N%26]+result
  if N%26==0:
    N-=1
  N//=26
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
alphabet=list('abcdefghijklmnopqrstuvwxyz')
result = []
while N >= 0:
  num, N = N%26, N//26
  result.append(alphabet[num-1])
print(''.join(result)[::-1])

Fixed submission:
N=int(input())
alphabet=list('zabcdefghijklmnopqrstuvwxyz')
result = ''
while N > 0:
  result = alphabet[N%26]+result
  if N%26==0:
    N-=1
  N//=26
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
for i in range(Q):
  A = [BC[i][1] if j == BC[i][0] else j for j in A]
  print(int(sum(A)))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
total = sum(A)
dict = {}
for i in range(len(A)):
  if A[i] not in dict:
    dict[A[i]] = 1
  else:
    dict[A[i]] += 1
for i in range(Q):
  if BC[i][0] not in dict:
    dict[BC[i][0]] = 0
  if BC[i][1] not in dict:
    dict[BC[i][1]] = 0
  if dict[BC[i][0]] > 0:
    num = (BC[i][1] - BC[i][0]) * (dict[BC[i][0]])
    total += num
  print(total)
  dict[BC[i][1]] += dict[BC[i][0]]
  dict[BC[i][0]] = 0

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
for i in range(Q):
  A = [BC[i][1] if j == BC[i][0] else j for j in A]
  print(sum(A))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
total = sum(A)
dict = {}
for i in range(len(A)):
  if A[i] not in dict:
    dict[A[i]] = 1
  else:
    dict[A[i]] += 1
for i in range(Q):
  if BC[i][0] not in dict:
    dict[BC[i][0]] = 0
  if BC[i][1] not in dict:
    dict[BC[i][1]] = 0
  if dict[BC[i][0]] > 0:
    num = (BC[i][1] - BC[i][0]) * (dict[BC[i][0]])
    total += num
  print(total)
  dict[BC[i][1]] += dict[BC[i][0]]
  dict[BC[i][0]] = 0

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
for i in range(Q):
  A = [BC[i][1] if j == BC[i][0] else j for j in A]
  print(sum(A))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
total = sum(A)
dict = {}
for i in range(len(A)):
  if A[i] not in dict:
    dict[A[i]] = 1
  else:
    dict[A[i]] += 1
for i in range(Q):
  if BC[i][0] not in dict:
    dict[BC[i][0]] = 0
  if BC[i][1] not in dict:
    dict[BC[i][1]] = 0
  if dict[BC[i][0]] > 0:
    num = (BC[i][1] - BC[i][0]) * (dict[BC[i][0]])
    total += num
  print(total)
  dict[BC[i][1]] += dict[BC[i][0]]
  dict[BC[i][0]] = 0
Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
p=sorted(map(int,input().split()))
p = [i for i in range(min(p),max(p)+1) if i not in p]
if X in p:
  print(X)
else:
  p = list(set(p))
  p.append(X)
  p.sort()
  index_num = p.index(X)
  if 0 < index_num < len(p)-2:
    num1=index_num+1
    num2=index_num-1
    num1_abs=abs(p[index_num]-p[num1])
    num2_abs=abs(p[inedx_num]-p[num2])
    if num1_abs < num2_abs:
      print(p[num1])
    else:
      print(p[num2])
  elif index_num==0:
    num1=index_num+1
    print(p[num1])
  elif index_num == len(p)-1:
    num2=index_num-1
    print(p[num2])

Fixed submission:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

i = 0
while True:
    if X - i not in (p):
        print(X-i)
        exit()
    if X + i not in (p):
        print(X+i)
        exit()
    i += 1
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(map(int,input().split()))
data=[]
for i in range(n):
  judge=True
  for j in range(n):
    if i==j:
      continue
    if a[i]%a[j]==0:
      judge=False
  if judge:
    data.append(a[i])
print(len(data))

Fixed submission:
import collections as c
n,a1=int(input()),[*map(int,input().split())]
a2,a3,b=set(a1),c.Counter(a1),[0]*(10**6+1)
for i in a2:
  for j in range(i,10**6+1,i):
    b[j]+=1
print(sum(b[i]==1 and a3[i]==1 for i in a2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A=list(map(int,input().split()))
judge = True
count = 0
for i in range(len(A)):
  judge = True
  for j in range(len(A)):
    if i==j:
      continue
    if A[i]%A[j]==0:
      judge = False
      break
  if judge:
    count += 1
print(count)

Fixed submission:
import collections as c
n,a1=int(input()),[*map(int,input().split())]
a2,a3,b=set(a1),c.Counter(a1),[0]*(10**6+1)
for i in a2:
  for j in range(i,10**6+1,i):
    b[j]+=1
print(sum(b[i]==1 and a3[i]==1 for i in a2))
Buggy python submission (verdict: Time Limit Exceeded):
input();ans,limit=1,10**18
for i in map(int,input().split()):
  ans*=i
print([ans,-1][ans>limit])

Fixed submission:
def main():
  N = int(input())
  A = list(map(int, input().split()))

  if 0 in A:
    print(0)
    return
  
  num = 1
  max_num = 10**18
  for i in A:
    num *= i
    
    if num > max_num:
      print(-1)
      return
  
  print(num)
  
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
result = 1
for i in A:
  result *= i
if result > 10**18:
  print(-1)
else:
  print(result)

Fixed submission:
def main():
  N = int(input())
  A = list(map(int, input().split()))

  if 0 in A:
    print(0)
    return
  
  num = 1
  max_num = 10**18
  for i in A:
    num *= i
    
    if num > max_num:
      print(-1)
      return
  
  print(num)
  
main()
Buggy python submission (verdict: Runtime Error):
print(eval(input().replace('.','').replace(' ','*'))//100)

Fixed submission:
A, B = map(int, input().replace('.', '').split())
print(A*B//100)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())
point = 0
judge = False
if A == K:
  point = A
  judge = True
elif A == 0 and B == K:
  point = 0
  judge = True
elif A == 0 and B == 0 and C == K:
  point = -K
  judge = True
if not judge:
  if A > 0 and K > 0:
    while A > 0 and K > 0:
      K -= 1
      A -= 1
      point += 1
  if B > 0 and K > 0:
    while B > 0 and K > 0:
      K -= 1
      B -= 1
      point += 0
  if C > 0 and K > 0:
    while C > 0 and K > 0:
      K -= 1
      C -= 1
      point -= 1
print(point)

  

Fixed submission:
a,b,c,k=map(int,input().split());count=0
if k<=a: print(k)
elif k<=a+b: print(a)
else: print(a-(k-a-b))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
result = []
for i in range(1, N+1):
  result.append(A.count(i))
for i in range(len(result)):
  print(result[i])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
result = {}
for i in range(N):
  result[i+1] = 0
for i in range(N-1):
  if A[i] in result:
    result[A[i]] += 1
for i in result.values():
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
result = []
for i in range(1, N+1):
  print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
result = {}
for i in range(N):
  result[i+1] = 0
for i in range(N-1):
  if A[i] in result:
    result[A[i]] += 1
for i in result.values():
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
result=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      result+=(math.gcd(math.gcd(i,j),k))
print(result)

Fixed submission:
import math
n=int(input())
result=0
for i in range(1,n+1):
  for j in range(1,n+1):
    num=math.gcd(i,j)
    for k in range(1,n+1):
      result+=math.gcd(num,k)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());s=[*input()];count=0
for i in range(n):
  for j in range(i,n):
    for k in range(j,n):
      if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k] and j-i != k-j:
        count+=1
print(count)

Fixed submission:
n=int(input());s=[*input()];count=0
count=s.count('R')*s.count('G')*s.count('B')
for i in range(n+1):
  for j in range(i,n+1):
    k=2*j-i
    if k<n:
      if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
        count-=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
S = list(S)
count = 0
for i in range(N):
  for j in range(i+1, N):
    if S[i] == S[j]:
      continue
    for k in range(j+1, N):
      if S[i] == S[j] or S[j] == S[k] or S[i] == S[k]:
        continue
      if j-i == k-j:
          continue
      count += 1
print(count)

Fixed submission:
n=int(input());s=[*input()];count=0
count=s.count('R')*s.count('G')*s.count('B')
for i in range(n+1):
  for j in range(i,n+1):
    k=2*j-i
    if k<n:
      if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
        count-=1
print(count)

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

Fixed submission:
n=int(input());s=[*input()];count=0
count=s.count('R')*s.count('G')*s.count('B')
for i in range(n+1):
  for j in range(i,n+1):
    k=2*j-i
    if k<n:
      if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
        count-=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s,q=deque([*input()]),int(input())
for i in range(q):
  t=input().split()
  if len(t)==1:
    s.reverse()
  else:
    t,f,c=t
    if f=='1': s.appendleft(c)
    else: s.append(c)
print(*s,sep='')

Fixed submission:
from collections import deque
s,q=deque([*input()]),int(input())
judge=False
for i in range(q):
  t=input().split()
  if len(t)==1:
    judge = not judge
  else:
    t,f,c=t
    if not judge and f=='1': s.appendleft(c)
    elif not judge and f=='2': s.append(c)
    elif judge and f=='1': s.append(c)
    else: s.appendleft(c)
if judge: s.reverse()
print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s,q=deque([*input()]),int(input())
for i in range(q):
  t=input().split()
  if len(t)==1:
    s.reverse()
  else:
    if t[1]=='1': s.appendleft(t[2])
    else: s.append(t[2])
print(*s,sep='')

Fixed submission:
from collections import deque
s,q=deque([*input()]),int(input())
judge=False
for i in range(q):
  t=input().split()
  if len(t)==1:
    judge = not judge
  else:
    t,f,c=t
    if not judge and f=='1': s.appendleft(c)
    elif not judge and f=='2': s.append(c)
    elif judge and f=='1': s.append(c)
    else: s.appendleft(c)
if judge: s.reverse()
print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s,q=[*input()],int(input())
for i in range(q):
  t=input().split()
  if len(t)==1:
    s=s[::-1]
  else:
    if t[1]=='1':
      s.insert(0,t[2])
    else: s.append(t[2])
print(*s,sep='')

Fixed submission:
from collections import deque
s,q=deque([*input()]),int(input())
judge=False
for i in range(q):
  t=input().split()
  if len(t)==1:
    judge = not judge
  else:
    t,f,c=t
    if not judge and f=='1': s.appendleft(c)
    elif not judge and f=='2': s.append(c)
    elif judge and f=='1': s.append(c)
    else: s.appendleft(c)
if judge: s.reverse()
print(*s,sep='')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(0 if A - (B*2) < 0 else A - (B*2))A

Fixed submission:
A, B = map(int, input().split())
print(0 if A - (B*2) < 0 else A - (B*2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [n for n in input()]
temp = []
result = []
for i in range(N-1):
  if S[i] == S[i+1]:
    temp.append(i)
for i in range(N):
  if i not in temp:
    result.append(S[i])
print(len(result))


Fixed submission:
n=int(input());s=input();print(1+sum([s[i-1]!=s[i] for i in range(1,n)]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split());a={i+1:k for i in range(n)}
for _ in range(q):
  m=int(input())
  for i in range(1,n+1):
    if i==m: continue
    a[i]-=1
print(*['Yes' if a[i]>0 else 'No' for i in range(1,n+1)],sep='\n')

Fixed submission:
n,k,q=map(int,input().split());a=[k-q for i in range(n)]
for _ in range(q): a[int(input())-1]+=1
print(*['Yes' if i>0 else 'No' for i in a],sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
point = [K for _ in range(N)]
for i in range(Q):
  A = int(input())
  point = list(map(lambda x: x - 1, point))
  point[A-1] += 1
for i in point:
  if i > 0:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k,q=map(int,input().split());a=[k-q for i in range(n)]
for _ in range(q): a[int(input())-1]+=1
print(*['Yes' if i>0 else 'No' for i in a],sep='\n')
Buggy python submission (verdict: Runtime Error):
n=int(input())
N=[0]*(n+1)
result=0
for i in range(1,n+1):
  N[i]=i
for i in range(2,len(N)):
  result+=N[i-1]%N[i]
print(result)

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

Buggy python submission (verdict: Runtime Error):
n1=[*range(1,int(input())+1)]
n2=n1[1:]+[n1[0]]
count=0
for i in range(len(n1)):
  count+=n1[i]%n2[i]
print(count)

Fixed submission:
n=int(input());print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
s=[sorted(input()) for _ in range(int(input()))]
print(sum([sum(k) for k in [[s[i]==s[j] for j in range(i+1,len(s))] for i in range(len(s))]]))

Fixed submission:
dict={}
for _ in range(int(input())):
  s=''.join(sorted(input()))
  if s not in dict: dict[s]=1
  else: dict[s]+=1
print(sum([i*(i-1)//2 for i in dict.values()]))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [[' '.join(sorted(i)) for i in input().split()] for _ in range(N)]
count = 0
for i in range(len(s)):
  for j in range(i+1, len(s)):
    if s[i][0] == s[j][0]:
      count += 1
print(count)

Fixed submission:
dict={}
for _ in range(int(input())):
  s=''.join(sorted(input()))
  if s not in dict: dict[s]=1
  else: dict[s]+=1
print(sum([i*(i-1)//2 for i in dict.values()]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n=deque(int(input()) for _ in range(int(input())))
for _ in range(len(n)): m=n.popleft();print(max(n));n.append(m)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
max_num = sorted(a, reverse=True)[0]
max_num2 = sorted(a, reverse=True)[1]
[print(max_num) if i!=max_num else print(max_num2) for i in a]

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for _ in range(N)]
for i in range(len(a)):
  num = a[:]
  num.pop(i)
  print(max(num))

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
max_num = sorted(a, reverse=True)[0]
max_num2 = sorted(a, reverse=True)[1]
[print(max_num) if i!=max_num else print(max_num2) for i in a]
Buggy python submission (verdict: Runtime Error):
n=list(map(int,input().split()));print(min([i+j for i in n for j in n if i!=j]))

Fixed submission:
P, Q, R = map(int, input().split())
time = [P, Q, R]
result = []
for i in range(len(time)):
  for j in range(i+1, len(time)):
    result.append(time[i]+time[j])
print(min(result))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
result = []
for i in range(Q):
  l, r = map(int, input().split())
  result.append(S.count('AC',l-1,r))
[print(i) for i in result]

Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
  t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for _ in range(q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
result = []
for i in range(Q):
  l, r = map(int, input().split())
  result.append(S[l-1:r].count('AC'))
[print(i) for i in result]

Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
  t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for _ in range(q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])