Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
for a in input().upper().split():
print(a[0] end="")

Fixed submission:
s = list(input().upper().split())
print(s[0][0]+s[1][0]+s[2][0])
Buggy python submission (verdict: Time Limit Exceeded):
p=1
n=10**9+7
for i in range(1, int(input())+1):
    p=p*i
print(p%n)

Fixed submission:
p=1
n=10**9+7
for i in range(1, int(input())+1):
    p=p*i
    p=p%n
print(p)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,inpyt().split())
print(max(a*b,c*d))

Fixed submission:
a,b,c,d=map(int,input().split())
print(max(a*b,c*d))
Buggy python submission (verdict: Runtime Error):
s = input()
ans=[]
for i in range(len(s)):
    if(s[i] == '0' or s[i] == '1'):
        ans.append(s[i])

    else:
        del ans[-1]

for i in range(len(ans)):
    print(ans[i], end ="")

Fixed submission:
s = input()
ans=[]
for i in range(len(s)):
    if(s[i] == '0' or s[i] == '1'):
        ans.append(s[i])

    else:
        if(len(ans) != 0):
            del ans[-1]

for i in range(len(ans)):
    print(ans[i], end ="")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import math
import numpy as np
# N, K = map(int, input().split(' '))
N = int(input())
run = [list(map(str, range(1, 10)))]
l = 0
count = 9
stop = 10**5
while(1):
    if count > stop:
        break
    nextrun = []
    for i in run[l]:
        if i[-1] == '0':
            nextrun.append(i+'0')
            nextrun.append(i+'1')
        elif i[-1] == '9':
            nextrun.append(i+str(int(i[-1])-1))
            nextrun.append(i+str(int(i[-1])))
        else:
            nextrun.append(i+str(int(i[-1])-1))
            nextrun.append(i+str(int(i[-1])))
            nextrun.append(i+str(int(i[-1])+1))
    run.append(nextrun)
    count += len(nextrun)
    l += 1

newrun = []
for i in run:
    newrun.extend(i)
print(newrun[N-1])


Fixed submission:
from collections import defaultdict
import math
# N, K = map(int, input().split(' '))
N = int(input())
run = [list(map(str, range(1, 10)))]
l = 0
count = 9
stop = 10**5
while(1):
    if count > stop:
        break
    nextrun = []
    for i in run[l]:
        if i[-1] == '0':
            nextrun.append(i+'0')
            nextrun.append(i+'1')
        elif i[-1] == '9':
            nextrun.append(i+str(int(i[-1])-1))
            nextrun.append(i+str(int(i[-1])))
        else:
            nextrun.append(i+str(int(i[-1])-1))
            nextrun.append(i+str(int(i[-1])))
            nextrun.append(i+str(int(i[-1])+1))
    run.append(nextrun)
    count += len(nextrun)
    l += 1

newrun = []
for i in run:
    newrun.extend(i)
print(newrun[N-1])
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import math
import numpy as np
N, X, Y = map(int, input().split(' '))
d = defaultdict(int)
for i in range(1, N):
    for k in range(i+1, N+1):
        if(k < X):
            ans = k-i
            d[ans] += 1
        else:
            ans = min(k-i, abs(Y-k)+1+abs(i-X))
            d[ans] += 1

for i in range(1, N):
    print(d[i])


Fixed submission:
from collections import defaultdict
import math
import numpy as np
N, X, Y = map(int, input().split(' '))
d = defaultdict(int)
for i in range(1, N):
    for k in range(i+1, N+1):
        if(k < X):
            ans = k-i
            d[ans] += 1
        else:
            ans = min(k-i, abs(Y-k)+1+abs(i-X))
            d[ans] += 1

for i in range(1, N):
    print(d[i])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        S = S[::-1]
    else:
        if query[1] == '1':
            S = query[2]+S
        else:
            S = S+query[2]

print(S)

Fixed submission:
#import time
S = input()
Q = int(input())
f = True
head = []
tail = []
for i in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        f = not f
    else:
        if (query[1] == '1' and f) or (query[1] == '2' and not f):
            head.append(query[2])
        else:
            tail.append(query[2])

S = ''.join(head)[::-1]+S+''.join(tail)
if not f:
    S = S[::-1]
print(S)

# start = time.time()
# elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

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

for i in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        S = S[::-1]
    else:
        if query[1] == '1':
            S = query[2]+S
        else:
            S = S+query[2]

print(S)


Fixed submission:
#import time
S = input()
Q = int(input())
f = True
head = []
tail = []
for i in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        f = not f
    else:
        if (query[1] == '1' and f) or (query[1] == '2' and not f):
            head.append(query[2])
        else:
            tail.append(query[2])

S = ''.join(head)[::-1]+S+''.join(tail)
if not f:
    S = S[::-1]
print(S)

# start = time.time()
# elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")
Buggy python submission (verdict: Runtime Error):
a, b, c = list(input())

if a == b == c:
    print('No')
else:
    print('Yes')

Fixed submission:
a,b = map(int,input().split(" "))
c= a*b%2

if c==0:
    print('Even')
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
N = int(input())
num = list(map(int, input().split(" ")))
oparation = 10 ^ 8

for i in range(N):
    temp = 0
    while(1):
        if(num[i] % 2 or num[i] == 0):
            break
        else:
            num[i] /= 2
            temp += 1
    if(oparation > temp):
        oparation = temp

print(oparation)


Fixed submission:
a=input().split('1')
b=len(a)-1
print(b)

Buggy python submission (verdict: Runtime Error):
N=int(input())
num=map(int,input().split(" "))
oparation=10^8

for i in range(N):
    temp=0
    while(1):
        if(num[i]%2 or num[i]=0):
            break:
        else:
            num[i]/=2
            temp+=1
    if(oparation>temp):
        oparation=temp

print(oparation)
        

Fixed submission:
a=input().split('1')
b=len(a)-1
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

thre = 10**18

a.sort()
#print(a)

tmp = a[0]
if(tmp==0):
  print(0)
else:
  for i in range(1,n):
    tmp*= a[i]
  if(tmp > thre):
    print(-1)
  else:
    print(tmp)

Fixed submission:
#import numpy as np
n = int(input())
a = list(map(int,input().split()))

thre = 10**18

a.sort(reverse=True)
#print(a)

flag = 0
tm = a[n-1]
if(tm==0):
  print(0)
else:
  tmp=a[0]
  for i in range(1,n):
    tmp*= a[i]
    if(tmp > thre):
      flag = 1
      break
  if(flag == 1):
    print(-1)
  else:
    print(tmp)

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

thre = 10**18

a.sort()
#print(a)

tmp = a[0]
for i in range(1,n):
  tmp*= a[i]
  if(tmp == 0):
    break

if(tmp > thre):
  print(-1)
else:
  print(tmp)

Fixed submission:
#import numpy as np
n = int(input())
a = list(map(int,input().split()))

thre = 10**18

a.sort(reverse=True)
#print(a)

flag = 0
tm = a[n-1]
if(tm==0):
  print(0)
else:
  tmp=a[0]
  for i in range(1,n):
    tmp*= a[i]
    if(tmp > thre):
      flag = 1
      break
  if(flag == 1):
    print(-1)
  else:
    print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K = map(int,input().split())

i = 0
maxSum = 0
while(i<K):
  if(i<A):
    maxSum += 1
  elif(i<A+B):
    maxSum += 0
  elif(i<A+B+C):
    maxSum -= 1
  i+=1
print(maxSum)

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

tmp = K
maxSum = 0
i = 0
if(tmp>A):
  maxSum+=A
  tmp-=A
else:
  maxSum+=K
  tmp = 0
#print(str(tmp) + ' sum = ' + str(maxSum))

if(tmp>B):
  tmp-=B
else:
  tmp = 0
#print(str(tmp) + ' sum = ' + str(maxSum))

if(tmp>C):
  maxSum-=C
  tmp-=C
else:
  maxSum-=tmp
  tmp = 0
#print(str(tmp) + ' sum = ' + str(maxSum))

print(maxSum)
Buggy python submission (verdict: Runtime Error):
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(1000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)


Fixed submission:
N = int(input())
mi,ma = map(int,input().split())

flag = 0
for i in range(mi,ma+1):
  if(i % N == 0):
    flag = 1
    break
if(flag == 1):
  print('OK')
else:
  print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
import math
import random
import decimal

A,B,N = map(int,input().split())

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

decimal.getcontext().prec = 6
max = quick(decimal.Decimal(N))
for i in range(800000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(decimal.Decimal(ran))
  if(max < tem):
    max = tem

print(max)


Fixed submission:
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(80000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Fixed submission:
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(1000000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Fixed submission:
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)
Buggy python submission (verdict: Runtime Error):
a=int(input())

def sum30:
  return (1+2+4+7+8+11+13+14+16+17+19+22+23+26+28+29)

def sumx(x):
  ret = 0
  for j in range(1,x):
    if(j%3 != 0 and j%5 != 0):
      ret+=j
  return ret

sum=0
i=1
while(a > 30):
  sum+=i*sum30
  i+=1
  a-=30
sum+=sumx(a)
    
print(sum)


Fixed submission:
a=int(input())

def sum30():
  return (1+2+4+7+8+11+13+14+16+17+19+22+23+26+28+29)

def sumx(x):
  ret = 0
  if(x ==0):
    return ret
  
  for j in range(1,x+1):
    if(j%3 != 0 and j%5 != 0):
      ret+=j
  return ret

def numx(x):
  ret = 0
  if(x ==0):
    return ret
  
  for j in range(1,x+1):
    if(j%3 != 0 and j%5 != 0):
      ret+=1
  return ret
sum=0

i=1
#if()
#sum+=temp*sum30()+sumx(a%30)
while(a > 0):
  if(a >= 30):
    temp=(i-1)*30*16+sum30()
    #print(temp)
    sum+=temp
  else:
    sum+=(i-1)*30*numx(a)+sumx(a)
  i+=1
  a-=30
#while(temp > 0):
#  sum+= temp*sum30()
#  temp-=1

    
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
Pi = list(map(int,input().split()))

Sim = [sum(Pi[0:i]) for i in range(N+1)]
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)




Fixed submission:
N,K = map(int,input().split())
Pi = list(map(int,input().split()))

Sim = [0]
for i in range(0,N):
  Sim.append(Sim[i]+Pi[i])
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)

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

print((1/2)*(max([sum(Pi[i:i+K]) for i in range(N-K+1)]) + K))

Fixed submission:
N,K = map(int,input().split())
Pi = list(map(int,input().split()))

Sim = [0]
for i in range(0,N):
  Sim.append(Sim[i]+Pi[i])
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)

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

#check max

MX = [sum(Pi[i:i+K]) for i in range(N-K+1)]

m= max(MX)
ans= (1/2)*(m + K)
print(ans)


Fixed submission:
N,K = map(int,input().split())
Pi = list(map(int,input().split()))

Sim = [0]
for i in range(0,N):
  Sim.append(Sim[i]+Pi[i])
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)

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

#check max

max=0
imax=0
for i in range(N-K+1):
  temp = sum(Pi[i:i+K])
  if max < temp:
    max = temp
    imax = i

ans=0
for i in range(imax,imax+K):
  ans +=(1/2)*(Pi[i]+1)
  
print(ans)
#n/2(n+1) / n = 1/2 (n+1)


Fixed submission:
N,K = map(int,input().split())
Pi = list(map(int,input().split()))

Sim = [0]
for i in range(0,N):
  Sim.append(Sim[i]+Pi[i])
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)
Buggy python submission (verdict: Runtime Error):

####
N = int(input())
A =  list(map(int,input().split()))

ans2 = 0
###
for y in range(N):
  for x in range(y+1,N):
    ans2 += (A[y] ^ A[x]) % 1000000007  
print(ans2%1000000007)
###


Fixed submission:
A1, A2, A3 = map(int, input().split())

if (A1+A2+A3) <= 21:
  print('win') 
elif(A1+A2+A3) > 21:
  print('bust')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ai = list(map(int,input().split()))
    
def create_list():
  MAXI = N
  
  sn = [0 for _ in range(MAXI+1)]
  judge = 0
  for i in range(1,MAXI+1):
    sn[i] = sn[i-1] + Ai[i-1]
     
  return sn

def iCj(i, j):
  mot = 1
  chi = 1
  for x in range(j):
    chi *= i-x
    mot *= x+1
  comb = int(chi/mot)
  return comb


base = create_list()
count = 0
base.sort()
i = 0
while(i<N+1):
  this = base.count(base[i])
  if(this >= 2):
    count += iCj(this,2)
  i += this
print(count)

Fixed submission:
N = int(input())
Ai = list(map(int,input().split()))
    
#print(Ai)
def create_list():
  MAXI = N
  
  sn = [0 for _ in range(MAXI+1)]
  judge = 0
  for i in range(1,MAXI+1):
    #print(str(i)+'+1 when '+S[i-1])
    sn[i] = sn[i-1] + Ai[i-1]
     
  return sn

def iCj(i, j):
  mot = 1
  chi = 1
  for x in range(j):
    chi *= i-x
    mot *= x+1
  comb = int(chi/mot)
  return comb


base = create_list()
#print(base)
count = 0
base.sort()
#print(base)
#for i in range(N):
#  for j in range(i+1,N+1):
#    if(base[j]-base[i] == 0):
#      count += 1
    #  print(str(j)+' - '+str(i))
    #else:
    #  print(str(j)+' = '+str(i))
#  print( base[r[i]] - base[l[i]] )#sum(rnum)-sum(lnum) )
i = 0
while(i<N+1):
  this = 1
  j = i+1
  while(j < N+1 and base[j] == base[i]):
    this += 1
    j += 1
  if(this >= 2):
    count += iCj(this,2)
  i += this
print(count)

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

N = int(input())
Ai = list(map(int,input().split()))
    
#print(Ai)
def create_list():
  MAXI = N
  
  sn = [0 for _ in range(MAXI+1)]
  judge = 0
  for i in range(1,MAXI+1):
    sn[i] = sn[i-1] + Ai[i-1]
     
  return sn

base = create_list()
#print(base)
count = 0
for i in range(N):
  for j in range(i+1,N+1):
    if(base[j]-base[i] == 0):
      count += 1
print(count)

Fixed submission:
N = int(input())
Ai = list(map(int,input().split()))
    
#print(Ai)
def create_list():
  MAXI = N
  
  sn = [0 for _ in range(MAXI+1)]
  judge = 0
  for i in range(1,MAXI+1):
    #print(str(i)+'+1 when '+S[i-1])
    sn[i] = sn[i-1] + Ai[i-1]
     
  return sn

def iCj(i, j):
  mot = 1
  chi = 1
  for x in range(j):
    chi *= i-x
    mot *= x+1
  comb = int(chi/mot)
  return comb


base = create_list()
#print(base)
count = 0
base.sort()
#print(base)
#for i in range(N):
#  for j in range(i+1,N+1):
#    if(base[j]-base[i] == 0):
#      count += 1
    #  print(str(j)+' - '+str(i))
    #else:
    #  print(str(j)+' = '+str(i))
#  print( base[r[i]] - base[l[i]] )#sum(rnum)-sum(lnum) )
i = 0
while(i<N+1):
  this = 1
  j = i+1
  while(j < N+1 and base[j] == base[i]):
    this += 1
    j += 1
  if(this >= 2):
    count += iCj(this,2)
  i += this
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

P = [(x + 2) for x in range(N-1)] + [1]
M = [i % P[i-1] for i in range(N)]
print(sum(M))

Fixed submission:
N = int(input())

#P = [(x + 2) for x in range(N-1)] + [1]
#M = [i % P[i-1] for i in range(N)]
print((N)*(N-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

#print(N, Q, ab, px)
class Tree:
    def __init__(self):
        # n番目のノードの値
        self.value = [0 for _ in range(N+1)]
        # n番目の, 親から含めたノードの値
        self.total_value = [0 for _ in range(N+1)]
        # n番目のノードの一つ下の辺リスト
        self.edge = [[] for _ in range(N+1)]

    def build(self, a, b):
        #print("Tree build ", a, " ", b)
        self.edge[a].append(b)
        self.edge[b].append(a)


    def add(self, p, x):
        # 木の値を更新していく
        self.value[p] += x

    # 値を親から子に向かって更新する
    def reflesh(self):
        stack = deque()
        stack.append((1, 0))
        while stack:
            st = stack.pop()
            node, parent = st[0], st[1]
            children = self.edge[node]
            for child in children:
                if child == parent:
                    continue
                #print("c n", child, node)
                self.value[child] += self.value[node]
                stack.append((child, node))


tree = Tree()
for ab_ in ab:
    tree.build(*ab_)

for px_ in px:
    tree.add(*px_)

tree.reflesh()
#print(" ".join([str(tree.value[x]) for x in range(1,N+1)]))
print(" ".join([str(tree.value[x]) for x in range(1,N+1)]))
#for i in range(1,N+1):
    #print(tree.edge[i], end=",")
#    print(tree.value[i], end=" ")

Fixed submission:
from collections import deque

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

#print(N, Q, ab, px)
class Tree:
    def __init__(self):
        # n番目のノードの値
        self.value = [0 for _ in range(N+1)]
        # n番目の, 親から含めたノードの値
        self.total_value = [0 for _ in range(N+1)]
        # n番目のノードの一つ下の辺リスト
        self.edge = [[] for _ in range(N+1)]

    def build(self, a, b):
        #print("Tree build ", a, " ", b)
        self.edge[a].append(b)
        self.edge[b].append(a)


    def add(self, p, x):
        # 木の値を更新していく
        self.value[p] += x

    # 値を親から子に向かって更新する
    def reflesh(self):
        stack = deque()
        stack.append((1, 0))
        while stack:
            st = stack.pop()
            node, parent = st[0], st[1]
            children = self.edge[node]
            for child in children:
                if child == parent:
                    continue
                #print("c n", child, node)
                self.value[child] += self.value[node]
                stack.append((child, node))


tree = Tree()
for ab_ in ab:
    tree.build(*ab_)

for px_ in px:
    tree.add(*px_)

tree.reflesh()
#print(" ".join([str(tree.value[x]) for x in range(1,N+1)]))
print(" ".join([str(tree.value[x]) for x in range(1,N+1)]))
#for i in range(1,N+1):
    #print(tree.edge[i], end=",")
#    print(tree.value[i], end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for _ in range(N)]
os = [ "" for _ in range(N) ]

for i in range(N):
    os[i] = "".join(sorted(s[i]))
#print(os)
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        #print(dicts[i], dicts[j])
        if os[i] == os[j]:
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
dic = defaultdict(int)

for i in range(N):
    os = "".join(sorted(s[i]))
    dic[os] += 1
#print(os)
cnt = 0
for s, c in dic.items():
    #print(s, c)
    cnt += c * (c-1) // 2
    #print(c* (c - 1) // 2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input() for _ in range(N)]
os = [ "" for _ in range(N) ]

for i in range(N):
    os[i] = sorted(s[i])
#print(os)
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        #print(dicts[i], dicts[j])
        if os[i] == os[j]:
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
dic = defaultdict(int)

for i in range(N):
    os = "".join(sorted(s[i]))
    dic[os] += 1
#print(os)
cnt = 0
for s, c in dic.items():
    #print(s, c)
    cnt += c * (c-1) // 2
    #print(c* (c - 1) // 2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]

dicts = [defaultdict(int) for _ in range(N)]

for i in range(N):
    for j in range(10):
        dicts[i][s[i][j]] += 1
#print(dicts)
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        #print(dicts[i], dicts[j])
        if dicts[i] == dicts[j]:
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
dic = defaultdict(int)

for i in range(N):
    os = "".join(sorted(s[i]))
    dic[os] += 1
#print(os)
cnt = 0
for s, c in dic.items():
    #print(s, c)
    cnt += c * (c-1) // 2
    #print(c* (c - 1) // 2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]

dicts = [defaultdict(int) for _ in range(N)]

for i in range(N):
    for j in range(10):
        dicts[i][s[i][j]] += 1
#print(dicts)
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        #print(dicts[i], dicts[j])
        if dicts[i] == dicts[j]:
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
dic = defaultdict(int)

for i in range(N):
    os = "".join(sorted(s[i]))
    dic[os] += 1
#print(os)
cnt = 0
for s, c in dic.items():
    #print(s, c)
    cnt += c * (c-1) // 2
    #print(c* (c - 1) // 2)
print(cnt)
Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
i = 1
while D <= X and i <= N+1:
    #print("D, X", D, X)
    D += L[i-1]
    i += 1

print(i-1)

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
i = 1
while i - 1 < N:
    #print("D, X", D, X)
    D += L[i-1]
    if X < D:
        break
    i += 1

print(i)

Buggy python submission (verdict: Runtime Error):
N,X = map(int, input().split())
L = list(map(int, input().split()))
i = 0
D = 0
while D <= X and i <= N+1:
    D += L[i]
    i += 1
print(i)

Fixed submission:
N,X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
i = 1
while i - 1 < N:
    #print("D, X", D, X)
    D += L[i-1]
    if X < D:
        break
    i += 1

print(i)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
r =0
if A > B:
  r+=A  A-=1
else:
  r += B
  B-=1

r+=max(A,B)
print(r)

Fixed submission:
A, B = map(int, input().split())
r =0
if A > B:
  r+=A
  A-=1
else:
  r += B
  B-=1
 
r+=max(A,B)
print(r)