Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
B = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
C = [int(i) for i in input().split()]	# 1 2 3 4 5 ...

A.sort()
B.sort()
C.sort()

#print(A)
#print(B)
#print(C)
##exit(0)

ab=[0]*N
bc=[0]*N

b=N-1
c=N-1
count=0
while (0<=b):
	while (0<=c):
		if B[b]<C[c]:
			count += 1
			c -= 1
		else:
			break
	bc[b] = count
	if b<N-1:
		bc[b] += bc[b+1]
	b -= 1

a=N-1
b=N-1
count=0
while (0<=a):
	while (0<=b):
		if A[a]<B[b]:
			count += 1
			b -= 1
		else:
			break
	ab[a] = count
	a -= 1


#print(ab)
#print(bc)

ans=0

for i in ab:
#	print(i, bc[N-i:N])
#	ans += sum(bc[N-i:N])
	ans += bc[N-i]

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
B = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
C = [int(i) for i in input().split()]	# 1 2 3 4 5 ...

A.sort()
B.sort()
C.sort()

#print(A)
#print(B)
#print(C)
##exit(0)

ab=[0]*N
bc=[0]*N

b=N-1
c=N-1
count=0
while (0<=b):
	while (0<=c):
		if B[b]<C[c]:
			count += 1
			c -= 1
		else:
			break
	bc[b] = count
	if b<N-1:
		bc[b] += bc[b+1]
	b -= 1

a=N-1
b=N-1
count=0
while (0<=a):
	while (0<=b):
		if A[a]<B[b]:
			count += 1
			b -= 1
		else:
			break
	ab[a] = count
	a -= 1


#print(ab)
#print(bc)

ans=0

for i in ab:
#	print(i, bc[N-i:N])
#	ans += sum(bc[N-i:N])
	if i>0:
		ans += bc[N-i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
B = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
C = [int(i) for i in input().split()]	# 1 2 3 4 5 ...

A.sort()
B.sort()
C.sort()

#print(A)
#print(B)
#print(C)
##exit(0)

ab=[0]*N
bc=[0]*N

b=N-1
c=N-1
count=0
while (0<=b):
	while (0<=c):
		if B[b]<C[c]:
			count += 1
			c -= 1
		else:
			break
	bc[b] = count
	b -= 1

a=N-1
b=N-1
count=0
while (0<=a):
	while (0<=b):
		if A[a]<B[b]:
			count += 1
			b -= 1
		else:
			break
	ab[a] = count
	a -= 1


#print(ab)
#print(bc)

ans=0

for i in ab:
#	print(i, bc[N-i:N])
	ans += sum(bc[N-i:N])

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
B = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
C = [int(i) for i in input().split()]	# 1 2 3 4 5 ...

A.sort()
B.sort()
C.sort()

#print(A)
#print(B)
#print(C)
##exit(0)

ab=[0]*N
bc=[0]*N

b=N-1
c=N-1
count=0
while (0<=b):
	while (0<=c):
		if B[b]<C[c]:
			count += 1
			c -= 1
		else:
			break
	bc[b] = count
	if b<N-1:
		bc[b] += bc[b+1]
	b -= 1

a=N-1
b=N-1
count=0
while (0<=a):
	while (0<=b):
		if A[a]<B[b]:
			count += 1
			b -= 1
		else:
			break
	ab[a] = count
	a -= 1


#print(ab)
#print(bc)

ans=0

for i in ab:
#	print(i, bc[N-i:N])
#	ans += sum(bc[N-i:N])
	if i>0:
		ans += bc[N-i]

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())		# 5 7

h=[]
for i in range(N+1):
	h.append([])

a=[]
b=[]

for i in range(M):
	A, B = map(int, input().split())		# 5 7
	h[A].append(B)
	h[B].append(A)
	a.append(A)
	b.append(B)



def dfs(Graph, Start, Visited=None):
	if(Visited==None): Visited = []
	Visited.append(Start)
	#print(Start, Visited)
	for Next in Graph[Start]:
		if( Next in Visited ): 
			#print("   Visited", Next, Visited)
			continue
		dfs(Graph, Next, Visited)

z=[_ for _ in range(1, N+1)]
#print(z)
ans=0

import copy
for i in range(N):
	g = copy.deepcopy(h)
	
	A = a[i]
	B = b[i]
	n = i+1

	g[A].remove(B)
	g[B].remove(A)
	
	Visited = []
	dfs(g, n, Visited)
	
	#print(Visited)
	if len( list(set(z) - set(Visited)) ) > 0:
	    ans += 1

	
print(ans)


Fixed submission:
N, M = map(int, input().split())		# 5 7

h=[]
for i in range(N+1):
	h.append([])

a=[]
b=[]

for i in range(M):
	A, B = map(int, input().split())		# 5 7
	h[A].append(B)
	h[B].append(A)
	a.append(A)
	b.append(B)




def dfs(Graph, Start, Visited=None):
	if(Visited==None): Visited = []
	Visited.append(Start)
	#print(Start, Visited)
	for Next in Graph[Start]:
		if( Next in Visited ): 
			#print("   Visited", Next, Visited)
			continue
		dfs(Graph, Next, Visited)

z=[_ for _ in range(1, N+1)]
#print(z)
ans=0

import copy
for i in range(M):
	g = copy.deepcopy(h)
	
	A = a[i]
	B = b[i]

	g[A].remove(B)
	g[B].remove(A)
	
	Visited = []
	dfs(g, 1, Visited)
	
	#print(A, B, i, Visited)
	if len( list(set(z) - set(Visited)) ) > 0:
	    ans += 1

	
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())						# 5
#a = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
s = "0 " + input()
a = [int(i) for i in s.split()]	# 1 2 3 4 5 ...

N = len(a)
#print(a)

ans = 0
bSkip = False

for i in range(N):
	if i==0: continue;
	if bSkip:
		bSkip = False
		continue;
#	print(i, a[i])
	
	if i==a[i]:
		ans += 1
		if(i<N):
			if(i+1)==a[i+1]:
				bSkip = True

print(ans)


Fixed submission:
N = int(input())						# 5

s = "0 " + input()
a = [int(i) for i in s.split()]	# 1 2 3 4 5 ...


ans = 0
bSkip = False

for i in range(N+1):
	if i==0: continue;
	if bSkip:
		bSkip = False
		continue;
#	print(i, a[i])
	
	if i==a[i]:
		ans += 1
		if(i<N):
			if(i+1)==a[i+1]:
				bSkip = True

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())						# 5
#a = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
s = "0 " + input()
a = [int(i) for i in s.split()]	# 1 2 3 4 5 ...

N = len(a)
#print(a)

ans = 0
bSkip = False

for i in range(N):
	if i==0: continue;
	if bSkip:
		bSkip = False
		continue;
#	print(i, a[i])
	
	if i==a[i]:
		ans += 1
		if(i+1)==a[i+1]:
			bSkip = True

print(ans)


Fixed submission:
N = int(input())						# 5

s = "0 " + input()
a = [int(i) for i in s.split()]	# 1 2 3 4 5 ...


ans = 0
bSkip = False

for i in range(N+1):
	if i==0: continue;
	if bSkip:
		bSkip = False
		continue;
#	print(i, a[i])
	
	if i==a[i]:
		ans += 1
		if(i<N):
			if(i+1)==a[i+1]:
				bSkip = True

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        ans+=A[i]*A[j]%(10**9+7)
        ans%=(10**9+7)
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
    tmp+=A[i]
    
for i in range(N):
    tmp-=A[i]
    ans+=A[i]*tmp%(10**9+7)
    ans%=(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        ans+=A[i]*A[j]%(10**9+7)
print(ans%(10**9+7))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
    tmp+=A[i]
    
for i in range(N):
    tmp-=A[i]
    ans+=A[i]*tmp%(10**9+7)
    ans%=(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        ans+=A[i]*A[j]%(10**9+7)
print(ans%(10**9+7))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
    tmp+=A[i]
    
for i in range(N):
    tmp-=A[i]
    ans+=A[i]*tmp%(10**9+7)
    ans%=(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
par=[i for i in range(N+1)]
def find(x):
    if par[x] ==x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x]=y
for i in range(Q):
    a,b=map(int,input().split())
    unite(a,b)
ans=dict()
for i in par:
    tmp=find(i)
    if tmp in ans:
        ans[tmp]+=1
    else:
        ans[tmp]=1
print(max(ans.values()))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

N,Q=map(int,input().split())
par=[i for i in range(N+1)]
def find(x):
    if par[x] ==x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x]=y
for i in range(Q):
    a,b=map(int,input().split())
    unite(a,b)
ans=dict()
for i in par:
    tmp=find(i)
    if tmp in ans:
        ans[tmp]+=1
    else:
        ans[tmp]=1
print(max(ans.values()))
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M=map(int,input().split())
mine=[list(map(int,input().split()))for i in range(M)]
mine_h=[0]*H
mine_w=[0]*W
ans=0
val=-1
for i in range(M):
    mine_h[mine[i][0]-1]+=1
    mine_w[mine[i][1]-1]+=1
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[i+1 for i, x in enumerate(mine_w)if x == max_w]
for i in h_index:
    for j in w_index:
        if [i,j] in mine:
            continue
        else:
            val=0
            break
print(max_h+max_w+val)

Fixed submission:
H,W,M=map(int,input().split())
mine_h=[0]*H
mine_w=[0]*W
val=-1
mine=set()
for i in range(M):
    a,b=map(int,input().split())
    mine_h[a-1]+=1
    mine_w[b-1]+=1
    mine.add((a,b))
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[i+1 for i, x in enumerate(mine_w)if x == max_w]
for i in h_index:
    for j in w_index:
        if (i,j) in mine:
            continue
        else:
            val=0
            break
print(max_h+max_w+val)

Buggy python submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
mine=[list(map(int,input().split()))for i in range(M)]
mine_h=[0]*H
mine_w=[0]*W
ans=0
for i in range(M):
    mine_h[mine[i][0]-1]+=1
max_h=max(mine_h)
for i in mine_h:
    tmp=0
    if i ==max_h:
        mine_w=[0]*W
        for j in range(M):
            if mine[j][0]-1!=i:
                mine_w[mine[j][0]-1]+=1
        tmp=max_h+max(mine_w)
        if tmp>ans:
            ans=tmp
print(ans)


Fixed submission:
H,W,M=map(int,input().split())
mine_h=[0]*H
mine_w=[0]*W
val=-1
mine=set()
for i in range(M):
    a,b=map(int,input().split())
    mine_h[a-1]+=1
    mine_w[b-1]+=1
    mine.add((a,b))
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[i+1 for i, x in enumerate(mine_w)if x == max_w]
for i in h_index:
    for j in w_index:
        if (i,j) in mine:
            continue
        else:
            val=0
            break
print(max_h+max_w+val)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%2==0:
    print(-1)
    exit()
num=7
ans=-1
for i in range(1,10*8):
    if num%N==0:
        ans=i
        break
    num=str(num)
    num+='7'
    num=int(num)
if i ==79:
    print(N-1)
else
    print(ans)


Fixed submission:
N=int(input())
x=7%N
for i in range(1,N+1):
    if x==0:
        print(i)
        exit()
    x=(x*10+7)%N
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A_max=max(A)
for i in A:
    i=i/A_max
ans=list()
tmp=1
for i in range(K):
    tmp=tmp*A[i]
for i in range(K,N):
    tmp_old=tmp
    tmp=tmp_old*A[i]/A[i-K]
    if tmp_old<tmp:
        ans.append('Yes')
    else:
        ans.append('No')
for i in ans:
    print(i)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=list()
for i in range(K,N):
    if A[i-K]<A[i]:
        ans.append('Yes')
    else:
        ans.append('No')
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=list()
tmp=1
for i in range(K):
    tmp=tmp*A[i]
for i in range(K,N):
    tmp_old=tmp
    tmp=tmp_old*A[i]//A[i-K]
    if tmp_old<tmp:
        ans.append('Yes')
    else:
        ans.append('No')
for i in ans:
    print(i)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=list()
for i in range(K,N):
    if A[i-K]<A[i]:
        ans.append('Yes')
    else:
        ans.append('No')
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[list(map(int,input().split()))for i in range(Q)]
dic_A=dict()
sum_A=sum(A)
ans=list()
for i in A:
    if i in dic_A:
        dic_A[i]+=1
    else:
        dic_A[i]=1
for j in range(Q):
    if B[j][0] in dic_A:
        tmp=sum_A+ dic_A[B[j][0]]*(B[j][1]-B[j][0])
        ans.append(tmp)
        sum_A=tmp
        if B[j][1] not in dic_A:
            dic_A[B[j][1]]=dic_A[B[j][0]]
        else:
            dic_A[B[j][1]]+=dic_A[B[j][0]]
        dic_A[B[j][0]]=0
    else:
        ans.append(tmp)
for k in ans:
    print(k)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[list(map(int,input().split()))for i in range(Q)]
dic_A=dict()
sum_A=sum(A)
ans=list()
tmp=0
for i in A:
    if i in dic_A:
        dic_A[i]+=1
    else:
        dic_A[i]=1
for j in range(Q):
    if B[j][0] in dic_A:
        tmp=sum_A+ dic_A[B[j][0]]*(B[j][1]-B[j][0])
        ans.append(tmp)
        sum_A=tmp
        if B[j][1] not in dic_A:
            dic_A[B[j][1]]=dic_A[B[j][0]]
        else:
            dic_A[B[j][1]]+=dic_A[B[j][0]]
        dic_A[B[j][0]]=0
    else:
        if tmp==0:
            ans.append(sum_A)
        else:
            ans.append(tmp)
for k in ans:
    print(k)
Buggy python submission (verdict: Runtime Error):
import math
A,B,N=map(float,input().split())
if N = B:
    N = N-1
ans = math.floor((A*N/B)) - A*math.floor(N/B)
print(int(ans))

Fixed submission:
import math
A,B,N=map(float,input().split())
if N >= B:
    N = B-1
ans = math.floor(A*N/B) - A*math.floor(N/B)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
if B==1 or A==1:
    ans = 0
elif A==10**6 and B ==10**12
    ans = 10**6
else:
    while N%B==0:
        N = N-1
    ans = (A*N)//B - A*(N//B)
print(ans)

Fixed submission:
import math
A,B,N=map(float,input().split())
if N >= B:
    N = B-1
ans = math.floor(A*N/B) - A*math.floor(N/B)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input()for i in range(N)]
ans=[]
for i in range(N):
    if not S[i] in ans:
        ans.append(S[i])
print(len(ans))

Fixed submission:
N = int(input())
S = [input()for i in range(N)]
print(len(set(S)))
Buggy python submission (verdict: Runtime Error):
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(M):
    x,y,c=map(int,input().split())
    tmp = a[x-1]+b[x-1]-c
    if ans==0:
        ans=tmp
    if min(a)+min(b) < tmp:
        ans=min(a)+min(b)
    else:
        ans=tmp
print(ans)

Fixed submission:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split()))for i in range(M)]
ans=min(a)+min(b)
for i in range(M):
    tmp = a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2]
    if ans > tmp:
        ans=tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
t=dict()
ans=list()
for i in range(N):
    tmp=input()
    if tmp in t:
        t[tmp]+=1
    else:
        t[tmp]=1
ans=[kv[0] for kv in t.items() if kv[1] == max(t.values())]
ans.sort()
for i in ans:
    print(i)

Fixed submission:
N=int(input())
t=dict()
ans=list()
for i in range(N):
    tmp=input()
    if tmp in t:
        t[tmp]+=1
    else:
        t[tmp]=1
max_v=max(t.values())
ans=[kv[0] for kv in t.items() if kv[1] == max_v]
ans.sort()
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
t=dict()
ans=list()
for i in range(N):
    tmp=input()
    if tmp in t:
        t[tmp]+=1
    else:
        t[tmp]=1
ans=[kv[0] for kv in t.items() if kv[1] == max(t.values())]
ans.sort()
for i in ans:
    print(i)

Fixed submission:
N=int(input())
t=dict()
ans=list()
for i in range(N):
    tmp=input()
    if tmp in t:
        t[tmp]+=1
    else:
        t[tmp]=1
max_v=max(t.values())
ans=[kv[0] for kv in t.items() if kv[1] == max_v]
ans.sort()
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
H=int(input())
count=1
ans=0
while H//2!=1:
    count+=1
    H=H//2
for i in range(0,count+1):
    ans+=2**i
print(ans)

Fixed submission:
H=int(input())
count=1
ans=0
if H==1:
    print(1)
    exit()
while H//2!=1:
    count+=1
    H=H//2
for i in range(0,count+1):
    ans+=2**i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H=int(input())
count=1
ans=0
while H//2!=1:
    count+=1
    H=H//2
for i in range(0,count+1):
    ans+=2**i
print(ans)

Fixed submission:
H=int(input())
count=1
ans=0
if H==1:
    print(1)
    exit()
while H//2!=1:
    count+=1
    H=H//2
for i in range(0,count+1):
    ans+=2**i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=20202020200
for i in range(N):
    tmp=abs(sum(A[:i])-sum(A[i:N]))
    if tmp<ans:
        ans=tmp
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=20202020200
sum_A=0
sum_B=sum(A)
for i in range(N):
    sum_A+=A[i]
    sum_B-=A[i]
    tmp=abs(sum_A-sum_B)
    if tmp<ans:
        ans=tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=0
for i in range(1,N):
    ans+=i
print(ans)

Fixed submission:
N=int(input())

print((N-1)*N//2)
Buggy python submission (verdict: Runtime Error):
def last_num(a):
    while a//10!=0:
        a=a%10
    return a

def marume(a):
    b=a
    while a//10!=0:
        a=a%10
    if a!=0:
        b=b-a+10
    return b

A=[int(input())for _ in range(5)]
last_order=9
ans=0
for i in range(5):
    if 0 < last_num(A[i]) < last_order:
        last_order=last_num(A[i])
        order_num=i
for j in range(5):
    if j !=order_num:
        ans+=marume(A[j])
    else:
        ans+=A[j]
print(ans)


Fixed submission:
def last_num(a):
    while a//10!=0:
        a=a%10
    return a

def marume(a):
    b=a
    while a//10!=0:
        a=a%10
    if a!=0:
        b=b-a+10
    return b

A=[int(input())for _ in range(5)]
last_order=9
order_num=0
ans=0
for i in range(5):
    if 0 < last_num(A[i]) < last_order:
        last_order=last_num(A[i])
        order_num=i
for j in range(5):
    if j !=order_num:
        ans+=marume(A[j])
    else:
        ans+=A[j]
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=dict()
ans=0
for i in range(N):
    a,b=map(int,input().split())
    A[a]=b
A=list(A.items())
A.sort()
for i in range(N):
    if M>A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)


Fixed submission:
N,M=map(int,input().split())
A=dict()
ans=0
A=[list(map(int,input().split()))for i in range(N)]
A.sort()
for i in range(N):
    if M>A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=dict()
ans=0
for i in range(N):
    a,b=map(int,input().split())
    A[a]=b
A=list(A.items())
A.sort()
for i in range(N):
    if M>=A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)


Fixed submission:
N,M=map(int,input().split())
A=dict()
ans=0
A=[list(map(int,input().split()))for i in range(N)]
A.sort()
for i in range(N):
    if M>A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=dict()
ans=0
for i in range(N):
    a,b=map(int,input().split())
    A[a]=b
A=list(A.items())
A.sort()
for i in range(N):
    if M>=A[i][0]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)


Fixed submission:
N,M=map(int,input().split())
A=dict()
ans=0
A=[list(map(int,input().split()))for i in range(N)]
A.sort()
for i in range(N):
    if M>A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,min(i+1,K+1)))
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    memo=10**9
    for j in range(1,min(i+1,K+1)):
        tmp=(dp[i-j]+abs(h[i-j]-h[i]))
        if tmp < memo:
            memo=tmp
    dp[i]=memo
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
B=list()
B.append(input())
for i in range(N-1):
	tmp=input()
	if tmp in B:
		print('No')
		exit()
	if tmp[0]!=B[i-1][-1]:
		print('No')
		exit()
print('Yes')

Fixed submission:
N=int(input())
B=list()
B.append(input())
ans='Yes'
for i in range(N-1):
    tmp=input()
    if tmp in B:
        ans='No'
    if tmp[0]!=B[i][-1]:
        ans='No'
    B.append(tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
1 N, X = map(int, input().split())
2 m = []
3 for i in range(N):
4 m.append(int(input()))
5 print(N + (X - sum(m)) // min(m))

Fixed submission:
N,X = map(int,input().split())
m=[]
for i in range(N):
	m.append(int(input()))
print(N + (X-sum(m))//min(m))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
while len(d)>K:
    if i!=0:
        ans += d.pop(K)
    else:
        break
print(ans)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
if len(d)>K:
    ans =sum(d[K:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
while len(d)>K:
    if i!=0:
        ans += d[K]
        d.pop(K)
    else:
        break
print(ans)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
if len(d)>K:
    ans =sum(d[K:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
while len(d)>K:
    if i!=0:
        ans += d[K]
        d.pop(K)
    else:
        break
print(ans)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
if len(d)>K:
    ans =sum(d[K:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort()
while len(d)>K:
    ans += d[0]
    d.pop(0)
print(ans)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
if len(d)>K:
    ans =sum(d[K:])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
min=min(a)
max=max(a)
ans=0
for i in range(min-1,max+2):
	tmp=0
	for j in range(N):
		if a[j]-1<= i <=a[j]+1:
			tmp+=1
		if tmp>=ans:
			ans=tmp
print(ans)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
ad=dict()
ans=0
for i in range(len(a)):
	if a[i] in ad:
		ad[a[i]]+=1
	else:
		ad[a[i]]=1
for i in range(min(ad),max(ad)+1):
	tmp=0
	if i in ad:
		tmp+=ad[i]
	if i-1 in ad:
		tmp+=ad[i-1]
	if i+1 in ad:
		tmp+=ad[i+1]
	if tmp>ans:
		ans=tmp
print(ans)