Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
lim=math.ceil(math.sqrt(n))
cnt=0
rec=0

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()
  if n%(i+1-lim)==0 and cnt==0:
    rec=n/(i+1-lim)
    cnt+=1
  if i>=rec:
    print(len(str(rec)))
    exit()

Fixed submission:
n=int(input())
l=int((n**0.5))+1
ans=n
for i in range(1, l+1):
  if n%i==0:
    ans=min(ans, len(str(n//i)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
lim=math.ceil(math.sqrt(n))

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()
  elif (n+1)/2<i:
    print(len(str(n)))
    exit()
    


Fixed submission:
n=int(input())
l=int((n**0.5))+1
ans=n
for i in range(1, l+1):
  if n%i==0:
    ans=min(ans, len(str(n//i)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
lim=math.ceil(math.sqrt(n))

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()

Fixed submission:
n=int(input())
l=int((n**0.5))+1
ans=n
for i in range(1, l+1):
  if n%i==0:
    ans=min(ans, len(str(n//i)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
lim=math.ceil(math.sqrt(n))

for i in range(lim, n+1):
  if n%i==0:
    print(len(str(i)))
    exit()

Fixed submission:
n=int(input())
l=int((n**0.5))+1
ans=n
for i in range(1, l+1):
  if n%i==0:
    ans=min(ans, len(str(n//i)))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s=map(int, input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x>s or y>s or z>s or x+y>s or x+z>s or y+z>s:
        continue
      elif x+y+z==s:
        count+=1
print(count)

Fixed submission:
k, s=map(int, input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
      
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s=map(int, input().split())
count=0
for x in range(k+1):
  if x>s:
    continue
  for y in range(k+1):
    if y>s:
      continue
    for z in range(k+1):
      if z>s:
        continue
      if x+y+z==s:
        count+=1
print(count)

Fixed submission:
k, s=map(int, input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
      
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s=map(int, input().split())
count=0
for x in range(k+1):
  if x>s:
    continue
  for y in range(k+1):
    if y>s:
      continue
    for z in range(k+1):
      if z>s:
        continue
      if x+y+z==s:
        count+=1
print(count)

Fixed submission:
k, s=map(int, input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
      
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s=map(int, input().split())
count=0

for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z==s:
        count+=1
print(count)

Fixed submission:
k, s=map(int, input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
      
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

red = 0
blue = 0
for s in S:
    if s == 'R':
        red++
    else:
        blue++

if red > blue:
    print('Yes')
else
    print('No')

Fixed submission:
N = int(input())
S = input()

red = 0
blue = 0
for s in S:
    if s == 'R':
        red = red+1
    else:
        blue = blue+1

if red > blue:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
colors = [0]*9
for i in a:
    colors[i//400] += 1
ans = 0
for i in colors[0:8]:
    if i != 0:
        ans += 1
print(ans, ans+colors[8])

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
colors = [0]*9
for i in a:
    idx = i//400
    if(idx > 8):
        idx = 8
    colors[idx] += 1
ans = 0
for i in colors[0:8]:
    if i != 0:
        ans += 1
if ans == 0:
    print(1, colors[8])
else:
    print(ans, ans+colors[8])
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if (x+y+z) == S:
                ans += 1;
print(ans)

Fixed submission:
K,S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-(x+y)
        if(0<=z<=K):
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if (x+y+z) == S:
                ans += 1;
print(ans)

Fixed submission:
K,S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-(x+y)
        if(0<=z<=K):
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n

for i in range(n):
    keisu[i] += sum(a[:i])


for i in range(n):
    ans += (a[i] * keisu[i])%(1000000000+7)

        
        

print(ans%(1000000000+7))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n
t = 0

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n

for i in range(n):
    keisu[i] += sum(a[:i])


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n
t = 0

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n

for i in range(n):
    for j in range(i+1,n):
        keisu[j] += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n
t = 0

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))

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]
        

print(ans%(1000000000+7))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
keisu = [0]*n
t = 0

for i in range(n):
    
    keisu[i] += t
    t += a[i]


for i in range(n):
    ans += a[i] * keisu[i]

        
        

print(ans%(1000000000+7))
Buggy python submission (verdict: Runtime Error):
x, k , d = map(int, input().split())
l = []

ans = 0

if x > 0:
    for i in range(x,-x,-d):
        l.append(i)
        if i < 0:
            break

else:
    for i in range(x,-x,d):
        l.append(i)
        if i > 0:
            break
    

if len(l)-1 > k:
    ans = l[k]
else:
    if len(l)%2 ==0:
        odd = l[len(l)-1]
        even = l[len(l)-2]
    else :
        odd = l[len(l)-2]
        even = l[len(l)-1]
    if k%2 == 0:
        ans = even
    else:
        ans = odd

print(abs(ans))

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

c = x//d

a = x - x//d * d
b = d - abs(a)

if x//d%2 == 0:
    odd = a
    even = b
else:
    odd = b
    even = a

if abs(x//d) > k:
    ans = abs(abs(x) - abs(d*k))
else:
    if k%2 ==0:
        ans = odd
    else:
        ans = even

# print(odd,even)
print(abs(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import math as m
n = int(input())


for i in range(1,n+1):
    c = 0
    for x in range(1,m.ceil(m.sqrt(i))):
        for y in range(1,m.ceil(m.sqrt(i-x**2))):
            for z in range(1,m.ceil(m.sqrt(i-x**2-y**2))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    c +=1 
    print(c)



Fixed submission:
import math as m


n = int(input())

l = [0] * 10000

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if  ans <= 10000:
                l[ans-1] += 1

for i in range(n):
    print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
import math as m
n = int(input())


for i in range(1,n+1):
    c = 0
    for x in range(1,m.ceil(m.sqrt(i))):
        for y in range(1,m.ceil(m.sqrt(i-x**2))):
            for z in range(1,m.ceil(m.sqrt(i-x-y**2))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    c +=1 
    print(c)



Fixed submission:
import math as m


n = int(input())

l = [0] * 10000

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if  ans <= 10000:
                l[ans-1] += 1

for i in range(n):
    print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
import math as m
n = int(input())


for i in range(1,n+1):
    c = 0
    for x in range(1,m.ceil(m.sqrt(i))):
        for y in range(1,m.ceil(m.sqrt(i-x))):
            for z in range(1,m.ceil(m.sqrt(i-x-y))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    c +=1 
    print(c)



Fixed submission:
import math as m


n = int(input())

l = [0] * 10000

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if  ans <= 10000:
                l[ans-1] += 1

for i in range(n):
    print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
sa  = sorted(a)

q = int(input())
b = []
for _ in range(q):
    b.append([int(i) for i in input().split()])


for i in range(q):
    idx = -1
    seta = set(sa)
    if b[i][0] in seta:
         idx = sa.index(b[i][0])
    # print(idx)

    if idx != -1:
        while (True):
            if idx < n and sa[idx] == b[i][0]:
                sa[idx] = b[i][1]
                idx += 1
            else:
                break
    # print(sa)
    print(sum(sa))



Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]


q = int(input())
b = []
for _ in range(q):
    b.append([int(i) for i in input().split()])

al = {}
suma = sum(a)

for i in a:
    if i not in al:
        al[i] = 1
    else:
        al[i] += 1

for i in range(q):
    if b[i][0] in al:
        suma += (b[i][1] - b[i][0]) * al[b[i][0]]
        
        if b[i][1] in al:
            
            al[b[i][1]] += al[b[i][0]]
            al[b[i][0]] = 0
        else:
            al[b[i][1]] = al[b[i][0]]
            al[b[i][0]] = 0
    print(suma)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
b = []
for _ in range(q):
    b.append([int(i) for i in input().split()])


for i in range(q):
    for j in range(n):
        if a[j] == b[i][0]:
            a[j] = b[i][1]
    print(sum(a))



Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]


q = int(input())
b = []
for _ in range(q):
    b.append([int(i) for i in input().split()])

al = {}
suma = sum(a)

for i in a:
    if i not in al:
        al[i] = 1
    else:
        al[i] += 1

for i in range(q):
    if b[i][0] in al:
        suma += (b[i][1] - b[i][0]) * al[b[i][0]]
        
        if b[i][1] in al:
            
            al[b[i][1]] += al[b[i][0]]
            al[b[i][0]] = 0
        else:
            al[b[i][1]] = al[b[i][0]]
            al[b[i][0]] = 0
    print(suma)
Buggy python submission (verdict: Time Limit Exceeded):
m = 1000000000000000000

n = input()
a = [int(i) for i in input().split()]

o = 1

for i in a:
    o = o * i
if o > m:
    o = -1

print(o)

Fixed submission:
m = 1000000000000000000

n = input()
a = [int(i) for i in input().split()]

# s = a.set()
if 0 in a:
    print(0)
else:


    o = 1

    for i in a:
        if o <= m:
            o = o * i
        else:
            o = -1
            break
        
    if o > m:
        o = -1

    print(o)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
pl = []
sb = []
for i in range(len(a)):
	pl.append(i+int(a[i])+1)
	if i - int(a[i]) > 1:
		sb.append(i-int(a[i])+1)


if len(sb) == 0:
	print('0')
else:

# spl = sorted(pl)
	isb = [int(i) for i in sb]
	ipl = [int(i) for i in pl]
	ssb = sorted(isb)
	t = min(ssb)
	tl = [0] * max(ipl)
	for i in ssb:
		if int(i)-1 < len(tl):
			tl[int(i)-1] += 1
	# print(pl)
	# print(sb)
	# print(tl)
	cnt = 0
	for i in pl:
		if int(i)-1 < len(tl):
			cnt += tl[int(i)-1]

	print(cnt)
	



Fixed submission:
x = int(input())

ans1, ans2 = 0,0
for i in range(-200,200):
    for j in range(-200,200):
        if i**5 - j**5 == x:
            # print(i,j)
            ans1, ans2 = i,j

print(ans1,ans2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []

for i in range(n):
	ts = input()
	ad = True

	for j in s:
		if ts == j:
			ad = False
			break

	if ad :
		s.append(ts)


print(len(s))





Fixed submission:
n = int(input())
s = []

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

ss = sorted(s)
c = len(s)

for i in range(1,n):
	if ss[i-1] == ss[i]:
		c -= 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []

for i in range(n):
	ts = input()
	ad = True

	for j in s:
		if ts == j:
			ad = False

	if ad :
		s.append(ts)


print(len(s))





Fixed submission:
n = int(input())
s = []

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

ss = sorted(s)
c = len(s)

for i in range(1,n):
	if ss[i-1] == ss[i]:
		c -= 1

print(c)
Buggy python submission (verdict: Runtime Error):
import math
import itertools as it


i = input().split()



n = i[0]
m = i[1]
nc = it.combinations(range(n),2)
mc = it.combinations(range(m),2)

print(len(list(nc) + list(mc)))

Fixed submission:
import math
import itertools as it


i = input().split()



n = int(i[0])
m = int(i[1])
nc = it.combinations(range(n),2)
mc = it.combinations(range(m),2)

print(len(list(nc) + list(mc)))
Buggy python submission (verdict: Runtime Error):
nm = input().split()

n = nm[0]
m = nm[1]

if n < m :
	print(No)
else:
	print(Yes)



Fixed submission:
nm = input().split(' ')

n = int(nm[0])
m = int(nm[1])

if n > m :
	print('No')
else:
	print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
p = input().split()
cnt = 0
cn = 0

for i in range(len(p)):
	cn = int(p[i])
	for j in range(i + 1):
		if cn > int(p[j]):
			break
		if i == j:
			cnt += 1

print(cnt)

Fixed submission:
n = input()
p = input().split()
cnt = 0
tmin = 9999999999999999999999999999

for i in range(len(p)):
	tmin = min(tmin,int(p[i]))
	if tmin >= int(p[i]):
		cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
p = input().split()
cnt = 0
cn = 0

for i in range(len(p)):
	cn = int(p[i])
	cp = [int(p[j]) for j in range(i+1)]
	if cn > min(cp):
		continue
	else :
		cnt += 1

print(cnt)

Fixed submission:
n = input()
p = input().split()
cnt = 0
tmin = 9999999999999999999999999999

for i in range(len(p)):
	tmin = min(tmin,int(p[i]))
	if tmin >= int(p[i]):
		cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
p = input().split()
cnt = 0
cn = 0

for i in range(len(p)):
	cn = int(p[i])
	for j in range(i + 1):
		if cn > int(p[j]):
			break
		if i == j:
			cnt += 1

print(cnt)

Fixed submission:
n = input()
p = input().split()
cnt = 0
tmin = 9999999999999999999999999999

for i in range(len(p)):
	tmin = min(tmin,int(p[i]))
	if tmin >= int(p[i]):
		cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

i = -1
c = 0

while True:
	i = s.find('ABC', i + 1)
	if i == -1:
		break
	c++
print(c)

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

i = -1
c = 0

while True:
	i = s.find('ABC', i + 1)
	if i == -1:
		break
	c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
ny = input().split()
n = int(ny[0])
yen = int(ny[1])

ichiman = -1
gosen = -1
sen = -1
flg = False

for x in range(n + 1):
	if flg : break
	for y in range(n-x+1):
		if flg : break
		for z in range(n-x-y+1):
			if x + y + z == n and 10000*x + 5000*y + 1000*z == yen:
				ichiman = x
				gosen = y
				sen = z
				flg = True

print(ichiman,gosen,sen)

Fixed submission:
ny = input().split()
n = int(ny[0])
yen = int(ny[1])

ichiman = -1
gosen = -1
sen = -1
flg = False

for x in range(n + 1):
	if flg : break
	for y in range(n-x+1):
		if 10000*x + 5000*y + 1000*(n-x-y) == yen:
			flg = True
			ichiman = x
			gosen = y
			sen = n-x-y
			break

print(ichiman,gosen,sen)

Buggy python submission (verdict: Time Limit Exceeded):
ny = input().split()
n = int(ny[0])
y = int(ny[1])

ichiman = 0
gosen = 0
sen = 0
flg = False

for i in range(n+1):
	y1 = y
	if flg:
		break
	if y1 >= 10000 * i:
		y1 -= 10000 * i
	if y1 == 0 and i == n:
		ichiman = i
		flg = True
		break
	if y1 <= 0:
		break

	for j in range(n+1-i):
		y2 = y1
		if flg:
			break
		if y2 >= 5000*j:
			y2 -= 5000*j
		if y2 == 0 and i + j == n:
			ichiman = i
			gosen = j
			flg = True
			break
		if y2 <= 0:
			break

		for k in range(1, n+1-i-j):
			y3 = y2
			if y3 >= 1000*k:
				y3 -= 1000*k
			if y3 == 0 and i+j+k == n:
				ichiman = i
				gosen = j
				sen = k
				flg = True
				break
			if y3 <= 0:
				break


if not flg:
	ichiman = -1
	gosen = -1
	sen = -1

print(ichiman,gosen,sen)



Fixed submission:
ny = input().split()
n = int(ny[0])
yen = int(ny[1])

ichiman = -1
gosen = -1
sen = -1
flg = False

for x in range(n + 1):
	if flg : break
	for y in range(n-x+1):
		if 10000*x + 5000*y + 1000*(n-x-y) == yen:
			flg = True
			ichiman = x
			gosen = y
			sen = n-x-y
			break

print(ichiman,gosen,sen)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

def func(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

t_max = 10000
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        tmp = func(s[i:i+len(t)], t)
        if tmp < t_max:
            t_max = tmp
print(t_max)


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

def func(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

t_max = 10000
for i in range(len(s) - len(t) + 1):
    tmp = func(s[i:i+len(t)], t)
    if tmp < t_max:
        t_max = tmp
print(t_max)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

def func(a, b):
    t = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            t += 1
    return t

t_max = 10000
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        tmp = func(s[i:i+len(t)], t)
        if tmp < t_max:
            t_max = tmp
print(t_max)


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

def func(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

t_max = 10000
for i in range(len(s) - len(t) + 1):
    tmp = func(s[i:i+len(t)], t)
    if tmp < t_max:
        t_max = tmp
print(t_max)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
item = [int(i) for i in input().split()]
ans = 0
for a, b in list(itertools.combinations(item, 2)):
    ans += a * b
print(ans % (10**9 + 7))


Fixed submission:

n = int(input())
item = [int(i) for i in input().split()]
mod = 10**9+7
t = (sum(item)**2 - sum([i**2 for i in item]))

print(int(t * pow(2, -1, mod)) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))

count = 0
if 1 in x:
    try:
        for i in range(n):
            while x[i]!=(i+1):
                del x[i]
                count += 1            
        print(count)
    except:
        print(count)
else:
    print(-1)

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

count = 0
if 1 in x:
    try:
        j = 0
        for i in range(n):
            while x[j]!=(i+1):
                j = j+1
                count += 1    
            j +=1        
        print(count)
    except:
        print(count)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import numpy
import heapq
import math

N,M = list(map(int, input().split()))
data = [[]for _ in range(M)]
for _ in range(N):
    A,B = list(map(int, input().split()))
    if (A - 1) <= M:
        data[A-1].append(-B)

rew = 0
heap=[]
for i in range(M):
    for rewo in data[i]:
        heapq.heappush(heap,rewo)
    if len(heap) > 0:
        r = heapq.heappop(heap)
        rew += -r

print(rew)
    
        


Fixed submission:
import numpy
import heapq
import math

N,M = list(map(int, input().split()))
data = [[]for _ in range(M)]
for _ in range(N):
    A,B = list(map(int, input().split()))
    if (A - 1) < M:
        data[A-1].append(-B)

rew = 0
heap=[]
for i in range(M):
    for rewo in data[i]:
        heapq.heappush(heap,rewo)
    if len(heap) > 0:
        r = heapq.heappop(heap)
        rew += -r

print(rew)
Buggy python submission (verdict: Runtime Error):
n.k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
ans=0
for i in ar:
  if(k==0):
    break
  ans+=i
  k-=1
print(ans)

Fixed submission:
n,k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
ans=0
for i in ar:
  if(k==0):
    break
  ans+=i
  k-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
ar=[int(x) for x in input().split()]
for i in range(n):
  if(ar[i]==0):
    print((i+1))
    break

Fixed submission:
ar=[int(x) for x in input().split()]
for i in range(len(ar)):
    if(ar[i]==0):
        print(i+1)
        break
Buggy python submission (verdict: Runtime Error):
n = int(input())
int_list = list(map(int, input().split()))

ans = 1
if 0 in int_list:
  ans = 0
else:
  for i in range(n):
    ans *= int_list[i]
    if ans > 10 ** 18:
      ans = -1
      break

print(ans)

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

Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
print(int(a*b))

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

mod_n = 10**9+7

cum_A = [0]
for i in range(n-1):
  cum_A.append(cum_A[i]+A[::-1][i])
  
ans = 0
for i in range(n-1):
  ans += A[i]*cum_A[::-1][i]%mod_n
  
print(ans%mod_n)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
B = A[::-1]

mod_n = 10**9+7

cum_A = [0]
for i in range(n-1):
  cum_A.append(cum_A[i]+B[i])
  
ans = 0
cum_B = cum_A[::-1]
for i in range(n-1):
  ans += A[i]*cum_B[i]%mod_n
  
print(ans%mod_n)