Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa)

Fixed submission:
import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa))
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

count = 0
n = 0
ans = []
flag = 0
while n <len(s)-len(t)+1:
    count = 0
    for m in range(len(t)):
        if s[n+m] == "?" or s[n+m]==t[m]:
            count += 1
    if count == len(t):
        flag = 1
        ans = s[0:n+m+1]
        break
    n += 1
#print(n,m)
if flag == 1:
    for i in range(n):
        if ans[i] == "?":
            ans[i] = "a"
    for i in range(m+1):
        ans[n+i] =t[i]
    for _ in ans:
        #print(*_,end="")
else:
    print("UNRESTORABLE")

Fixed submission:
s = list(input())
t = list(input())

count = 0
n = 0
ans = []
flag = 0
n=len(s)-len(t)
while n >=0:
    count = 0
    for m in range(len(t)):
        if s[n+m] == "?" or s[n+m]==t[m]:
            count += 1
        else:
            break
    if count == len(t):
        flag = 1
        break
    else:
        n -= 1

if flag == 1:
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
    for i in range(m+1):
        s[n+i] =t[i]
    
    for _ in s:
        print(*_,end="")

else:
    print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0

if 2*N<=M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
elif M<2*N:
    count += M//2
print(count)

Fixed submission:
N=int(input())

x=N*800
y=200*(N//15)
print(x-y)

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
else:
    count += M//2
print(count)

Fixed submission:
N=int(input())

x=N*800
y=200*(N//15)
print(x-y)

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count += N
    N1=0
    M1=M-2*N
else:
    count += M//2
    N1 =N-M//2
    M1 =M-(M//2)*2
    
for i in range(N1):
    if N1 ==0 or M1<=1:
        break
    N1=N1-1
    M1=M1-2
    count += 1
if N1==0:
    for i in range(M1):
        if M1>=4:
            M1 -= 4
            count += 1
        if M1<4:
            break
print(count)
        

Fixed submission:
N=int(input())

x=N*800
y=200*(N//15)
print(x-y)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power=1

for i in range(1,N+1):
    power=power*i
print(power%(pow(10,9)+7))


Fixed submission:
N = int(input())
x=1
for i in range(1,N+1):
    x=i*x%(pow(10,9)+7)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
count = 0
for i in range(N):
    if N ==0 or M<=1:
        break
    N=N-1
    M=M-2
    count += 1
if N==0:
    for i in range(M):
        if M>=4:
            M -= 4
            count += 1
print(count)

Fixed submission:
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0

if 2*N<=M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
elif M<2*N:
    count += M//2
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=input().split()
K=int(k)
S=int(s)
count =0
for p in range(K+1):
    for q in range(K+1):
        for r in range(K+1):
            if p+q+r==S:
                count += 1
print(count)                
                



Fixed submission:
k,s=input().split()
K=int(k)
S=int(s)
count =0
for p in range(K+1):
    for q in range(K+1):
        r=S-p-q
        if 0<=r and r<=K:
            count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
C = [0]*N
a=0
def line(A,N):
    for i in range(N):
        C[A[i]] += 1
    if C[0] == 1:
        if N % 2==1:
            return pow(2,(N-1)//2)
        else:
            return 0
    for i in range(N):
        if C[i] != 2 and C[i]>=1:
            return 0
        elif C[i]==0:
            continue
    return pow(2,(N-1)//2)
a=line(A,N)
print(a%(pow(10,9)+7))


Fixed submission:
L = list(input().split())
A=int(L[0])
B=int(L[2])
if L[1]=="+":
    print(A+B)
elif L[1]=="-":
    print(A-B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []
for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)

for i in range(M):
    dsum = 0
    dsum = fsum - T[i] + grid[i][1]
    print(dsum)
    





Fixed submission:
L = list(input().split())
A=int(L[0])
B=int(L[2])
if L[1]=="+":
    print(A+B)
elif L[1]=="-":
    print(A-B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []
for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)

for i in range(M):
    dsum = 0
    dsum = fsum - T[i] + grid[i][1]
    print(dsum)
    





Fixed submission:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []

for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)
for i in range(M):
##    print("gridi0="+str(grid[i][0]))
##    print("grioi1="+str(grid[i][1]))
##    print("T="+str(T[grid[i][0]-1]))
    dsum = fsum - T[grid[i][0]-1] + grid[i][1]
    print(dsum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]

if len(parent) == (2**N):
	pritn("Yes")
else:
	print('No')



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

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]

if len(parent) == (2**N):
	print("Yes")
else:
	print('No')

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				next_parent.append(x)
				break
			else:
				next_rest.append(x)
	parent += next_parent
	parent.sort()
	rest = rest + next_rest[::-1]

if len(parent) == (2**N):
	pritn("Yes")
else:
	print('No')



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

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]

if len(parent) == (2**N):
	print("Yes")
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
a, s = input().split()
if int(a) >= 3200:print(s)
else:print("red")

Fixed submission:
a= int(input())
s = str(input())
if int(a) >= 3200:print(s)
else:print("red")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

m = a+b
if m<a*b:
  m = a*b:
if m<a-b:
  m=a-b
print(m)

Fixed submission:
a, b = map(int, input().split())
 
m = a+b
if m<a*b:
    m = a*b
if m<a-b:
    m=a-b
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
cnt = 0
for i in range(n):
    tmp = "".join(sorted(input()))
    cnt += S.count(tmp)
    S.append(tmp)

print(cnt)

Fixed submission:
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
#print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
for i in range(n):
    tmp = "".join(sorted(input()))
    S.append(tmp)
#print(S)
cnt = 0
for s in S:
    #print(S.count(s))
    cnt += (S.count(s)-1)
    S = S[1:]
print(cnt)

Fixed submission:
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
#print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
for i in range(n):
    tmp = "".join(sorted(input()))
    S.append(tmp)
#print(S)
cnt = 0
for s in S:
    #print(S.count(s))
    cnt += (S.count(s)-1)
print(cnt//2)

Fixed submission:
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
#print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
for i in range(n):
    tmp = "".join(sorted(input()))
    S.append(tmp)
count = 0
for j in range(len(S)):
    for k in range(j+1,len(S)):
        if S[j] == S[k]:
            count+=1
print(count)

Fixed submission:
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
#print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    S.append(tmp)
count = 0
for j in range(len(S)):
    for k in range(j+1,len(S)):
        if S[j] == S[k]:
            count+=1
print(count)

Fixed submission:
import collections
n = int(input())
s = collections.Counter(["".join(sorted(input())) for _ in range(n)]).most_common()
#print(s)
cnt = 0
for i in s:
    for j in range(1, i[1]):
        cnt += j
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, i = map(int, input().split())
print(N-i+1))

Fixed submission:
N, i = map(int, input().split())
print(N-i+1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input.split())

print(a*b-a-b+1)

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

print(a*b-a-b+1)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

if n%k!=0:
	print(1)
else:
	pritn(0)

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

if n%k!=0:
	print(1)
else:
	print(0)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

if n%k!=0:
	print(0)
else:
	pritn(1)

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

if n%k!=0:
	print(1)
else:
	print(0)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

if n%k==0:
	print(0)
else:
	pritn(1)

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

if n%k!=0:
	print(1)
else:
	print(0)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

if n%0==0:
	print(0)
else:
	print(1)

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

if n%k!=0:
	print(1)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
// B103.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	cin >> a[2] >> a[1] >> a[0];
	sort(a, a + 3);
	cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;

	return 0;
}


Fixed submission:
import math
A = list(map(int, input().split()))

A.sort()
print(abs(A[1]-A[0])+ abs(A[2]-A[1]))
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())

for i in range(len(S)):
	tmp = S[i:] + [:i]
	if T == tmp:
		print('Yes')
		break
print('No') 

Fixed submission:
S = list(input())
T = list(input())

for i in range(len(S)):
	tmp = S[i:] + S[:i]
	if T == tmp:
		print('Yes')
		exit()
print('No')

Buggy python submission (verdict: Runtime Error):
import collections

S = list(input())
T = list(input())

for i in range(len(S)):
	tmp = S[i:] + [:i]
	if T == tmp:
		print('Yes')
		break
print('No') 

Fixed submission:
S = list(input())
T = list(input())

for i in range(len(S)):
	tmp = S[i:] + S[:i]
	if T == tmp:
		print('Yes')
		exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

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

for i in range(n):
    for j in range(i+1,n):
        if abs(i-j)==(a[i]+a[j]):
            ans+=1

print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
li=[]
ans=0

for i,var in enumerate(a,1):
    li.append(i+var)

li=collections.Counter(li)

for j,var in enumerate(a,1):
    ans+=li[j-var]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    
n=int(input())
ans=0

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(i,j,k)

print(ans)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    
n=int(input())
ans=0

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(i,j,k)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

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

c=c.most_common()

for i in a:
    ans=0
    for j in c:
        t1=j[0]
        t2=j[1]
        
        if t1==i:
            t2-=1
        
        ans+=(t2*(t2-1))//2
    else:
        print(ans)

Fixed submission:
import collections
 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
all_ans=0

for i,j in c.items():
    all_ans+=(j*(j-1))//2

for k in a:
    print(all_ans-((c[k]*(c[k]-1))//2)+(((c[k]-1)*(c[k]-2))//2))
Buggy python submission (verdict: Runtime Error):
k=int(input())

print(li[k-1])

Fixed submission:
li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(li[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
an=0

while 1:
    if n>a:
        n-=a
        an+=a
    else:
        print(an+n)
        exit()
    
    if n>b:
        n-=b
    else:
        print(an)
        exit()

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

if a==0:
    print("0")
    exit()
elif b==0:
    print(n)
    exit()

t1=(n//(a+b))
t2=(n%(a+b))

if t2>a:
    print((t1*a)+a)
else:
    print((t1*a)+t2)
Buggy python submission (verdict: Time Limit Exceeded):
an=list(input())
q=int(input())

for _ in range(q):
    li=input().split()

    if li[0]=="1":
        an.reverse()
    else:
        if li[1]=="1":
            an[0:0]=li[2]
        else:
            an.append(li[2])

print(*an,sep="")

Fixed submission:
from collections import deque
s=input()
q=int(input())

flug=0
ans=deque(list(s))

for i in range(q):
    t=list(input().split())

    if t[0]=="1":
        flug+=1
    else:
        if (flug%2==0 and t[1]=="2") or (flug%2==1 and t[1]=="1"):
            ans.append(t[2])
        else:
            ans.appendleft(t[2])

ans="".join(map(str,ans))

if flug%2==1:
    ans=ans[::-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n=int(input())

li=[]
ma=0
an=[]

for i in range(n):
    li.append(input())

c=collections.Counter(li)
ma=c.most_common()[0][1]


for j in range(n):
    if c.most_common()[j][1]==ma:
        an.append(c.most_common()[j][0])
        
        if len(c)==j+1:
            break
    else:
        break

an.sort()

for k in range(len(an)):
    print(an[k])

Fixed submission:
n=int(input())

li={}
an=[]
ma=0

for i in range(n):
    t=input()
    if t in li:
        li[t]+=1
    else:
        li[t]=1

li2=sorted(li.items(), key=lambda x:x[1],reverse=True)

ma=li2[0][1]

for j in range(n):
    if li2[j][1]==ma:
        an.append(li2[j][0])
        
        if len(li2)==j+1:
            break
    else:
        break

an.sort()
 
for k in range(len(an)):
    print(an[k])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))

m=0
li=0
an=0

for i in range(n-k+1):
    if m<sum(p[i:i+k]):
        m=sum(p[i:i+k])
        li=i

for j in range(k):
    an+=(p[li+j]*0.5)+0.5

print(an)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
 
an=0
an2=0
t=0
 
for i in range(n):
    if i<k:
        an+=((p[i]+1)/2)
        an2=an
    else:
        t=((p[i-k]+1)/2)
        if an+((p[i]+1)/2)-t>an2:
            an2=an+((p[i]+1)/2)-t
        an=an+((p[i]+1)/2)-t
            
print(an2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li=list(map(int,input().split()))
ans=0

for i in range(1,n):
    if li[i]>min(li[0:i+1]):
        ans+=1

print(n-ans)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))
ans=0
tmp=li[0]

for i in range(n):
    if li[i]>tmp:
        ans+=1
    else:
        tmp=li[i]

print(n-ans)

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

for i in range(n):
    for j in range(i+1):
        if li[i]>li[j]:
            ans+=1
            break

print(n-ans)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))
ans=0
tmp=li[0]

for i in range(n):
    if li[i]>tmp:
        ans+=1
    else:
        tmp=li[i]

print(n-ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n=int(input())
s=list(input())

a=itertools.combinations(s,3)
print(len(set(a)))

Fixed submission:
n=int(input())
s=input()
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1

print(ans)

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

n=int(input())
s=list(input())

print(len(set(list(itertools.combinations(s,3)))))

Fixed submission:
n=int(input())
s=input()
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1

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

for i in range(1,n+1):
    print(li.index(i)+1,end=" ")

Fixed submission:
n=int(input())
li=list(map(int,input().split()))
an=[0]*n

for i in range(n):
    an[li[i]-1]=i+1

print(*an)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li = list(map(int,input().split()))
an=[]

for i in range(1,n+1):
    an.append(li.index(i)+1)

print(*an)

Fixed submission:
n=int(input())
li=list(map(int,input().split()))
an=[0]*n

for i in range(n):
    an[li[i]-1]=i+1

print(*an)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
t=0

for i in range(m):
    a[0]=a[0]//2
    t=a[0]
    
    if n>1:
        for j in range(m):
            if a[j]<a[j+1]:
                a[j]=a[j+1]
                a[j+1]=t
            else:
                break
    
print(sum(a))

Fixed submission:
import heapq
 
N,M = map(int, input().split())
A = list(-int(i) for i in input().split()) 

heapq.heapify(A)

for i in range(M):
    x=heapq.heappop(A)//(-2)
    heapq.heappush(A, -x)
 
print(-sum(A))

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

for i in range(m):
    a[0]=a[0]//2
    a.sort(reverse=True)

print(sum(a))

Fixed submission:
import heapq
 
N,M = map(int, input().split())
A = list(-int(i) for i in input().split()) 

heapq.heapify(A)

for i in range(M):
    x=heapq.heappop(A)//(-2)
    heapq.heappush(A, -x)
 
print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
x=[x for x in set(c) if c.count(x) > 1]
an=0

for i in x:
    t=c.count(i)
    for j in range(t):
        an+=j

print(an)

Fixed submission:
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
an=0
d={}

for i in c:
    if i in d:
        an += d[i]
        d[i]+=1
    else:
        d[i]=1

print(an)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
x=[x for x in set(c) if c.count(x) > 1]
an=0

for i in x:
    t=c.count(i)
    for j in range(t):
        an+=j

print(an)

Fixed submission:
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
an=0
d={}

for i in c:
    if i in d:
        an += d[i]
        d[i]+=1
    else:
        d[i]=1

print(an)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
an=0

for i in set(c):
    t=c.count(i)
    for j in range(t):
        an+=j

print(an)

Fixed submission:
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
an=0
d={}

for i in c:
    if i in d:
        an += d[i]
        d[i]+=1
    else:
        d[i]=1

print(an)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
an=0

for i in set(c):
    t=c.count(i)
    for j in range(t):
        an+=j

print(an)

Fixed submission:
n=int(input())
c=[''.join(sorted(input())) for _ in range(n)]
an=0
d={}

for i in c:
    if i in d:
        an += d[i]
        d[i]+=1
    else:
        d[i]=1

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

a = [int(input()) for i in range(n)]
ma = max(a)

for i in range(n):
    if a[i] == ma:
        a[i] = 1
        print(max(a))
        a[i] = ma
    else:
        print(ma)

Fixed submission:
n = int(input())

a = [int(input()) for i in range(n)]
ma1 = max(a)
ma2 = a.count(ma1)

for i in range(n):
    if a[i] == ma1:
        if ma2 == 1:
            a[i] = 1
            print(max(a))
            a[i] = ma1
        else:
            print(ma1)
    else:
        print(ma1)