Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03209 (python)

Fixed submission:
import numpy as np
def niku(level, num):
	maisu = 2**(level+2)-3
	if(num <= level):
		return 0
	elif(level == 0):
		return 1
	elif(num < (maisu+1)/2):
		return niku(level-1, num-1)
	elif(num == (maisu+1)/2):
		return 2**(level+1-1)-1+1
	else:
		return 2**(level+1-1)-1+1+niku(level-1, num-((maisu+1)/2))

def main():
	
	buf = input().split()
	n = int(buf[0])
	x = int(buf[1])
	print(niku(n, x))
		
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
def niku(level, num):
	maisu = 2**(level+2)-3
	if(num <= level):
		return 0
	elif(num < (maisu+1)/2):
		return niku(level-1, num-1)
	elif(num == (maisu+1)/2):
		return 2**(level+1-1)-1+1
	else:
		return 2**(level+1-1)-1+1+niku(level-1, num-((maisu+1)/2))

def main():
	
	buf = input().split()
	n = int(buf[0])
	x = int(buf[1])
	print(niku(n, x))
		
main()
Problem p03291 (python)

Fixed submission:
S = input()
m = 10**9+7
d = "ABC".index

dp = [0]*4
dp[0] = 1

for c in S:
	if(c == '?'):
		dp = [(3*dp[0])%m, (3*dp[1]+dp[0])%m, (3*dp[2]+dp[1])%m, (3*dp[3]+dp[2])%m]
	else:
		i = d(c)
		dp[i+1] += dp[i]%m 
print(dp[3]%m)

Buggy submission (verdict: Runtime Error):
import numpy as np
S = input()
n = len(S)
A, C, L, R = np.zeros(n), np.zeros(n), np.zeros(n), np.zeros(n)
a, c, l, r = 0, 0, 0, 0
for i in range(n):
	A[i] = a
	L[i] = l
	C[n-1-i] = c
	R[n-1-i] = r
	if(S[i] == 'A'):
		a += 1
	elif(S[i] == '?'):
		l += 1
	if(S[n-1-i] == 'C'):
		c += 1
	elif(S[n-1-i] == '?'):
		r += 1
ans = 0
for i in range(n):
	if(S[i] == 'B' or S[i] == '?'):
		left  = A[i] if L[i] == 0 else A[i]*(3**L[i])+3**(L[i]-1)
		right = C[i] if R[i] == 0 else C[i]*(3**R[i])+3**(R[i]-1)
		ans += left*right
		ans %= 10**9+7

print(int(ans))
#print(A, C, L, R)
#print(n)
Problem p03326 (python)

Fixed submission:
import numpy as np

b = input().split()
l = np.zeros((int(b[0]), 3))
for i in range(int(b[0])):
	buf = input().split()
	for j in range(3):
		l[i][j] = int(buf[j])
r = 0

for p in range(8):
	rbuf = 0
	box = ((-1)**p)*l.T[0]+((-1)**(p//2))*l.T[1]+((-1)**(p//4))*l.T[2]
	box = np.sort(box)[::-1]
	for i in range(int(b[1])):
		rbuf += box[i]
	if(rbuf > r):
		r = rbuf
		
print(int(r))

Buggy submission (verdict: Runtime Error):
b = input().split()
l = np.zeros((int(b[0]), 3))
for i in range(int(b[0])):
	buf = input().split()
	for j in range(3):
		l[i][j] = int(buf[j])
r = 0

for p in range(8):
	rbuf = 0
	box = ((-1)**p)*l.T[0]+((-1)**(p//2))*l.T[1]+((-1)**(p//4))*l.T[2]
	#print((-1)**p, (-1)**(p//2), (-1)**(p//4))
	for i in range(int(b[1])):
		rbuf += np.max(box)
		box[np.argmax(box)] = 0
	if(rbuf > r):
		r = rbuf
		
print(int(r))# your code goes here
Problem p02659 (python)

Fixed submission:
from decimal import *
a,b = map(Decimal,input().split())
print(int(a*b))

Buggy submission (verdict: Runtime Error):
a, b = map(float, input().split())
n = a*b
print(floor(n))
Problem p02623 (python)

Fixed submission:
N,M,K = map(int,input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
sum_AB = 0
cnt = 0
idx_A = -1
idx_B = -1
for i,a in enumerate(A):
    if sum_AB + a > K:
        break
    else:
        sum_AB += a
        cnt += 1
        idx_A = i
for i,b in enumerate(B):
    if sum_AB + b > K:
        break
    else:
        sum_AB += b
        cnt += 1
        idx_B = i
ans = cnt
A = A[0:idx_A+1][::-1]
from collections import deque
B = deque(B[idx_B+1:])
for a in A:
    sum_AB -= a
    cnt -= 1
    while B:
        if sum_AB + B[0] > K:
            break
        else:
            b = B.popleft()
            sum_AB += b
            cnt += 1
    ans = max(cnt,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

sum_AB = 0
cnt = 0
idx_A = -1
idx_B = -1
for i,a in enumerate(A):
  if sum_AB + a > K:
    break
  else:
    sum_AB += a
    cnt += 1
    idx_A = i
for i,b in enumerate(B):
  if sub_AB + b > K:
    break
  else:
    sum_AB += b
    cnt += 1
    idx_B = i
ans = cnt
A = [0:idx_A+1][::-1]
B = [idx_B:]
for a in A:
  sum_AB -= a
  cnt -= 1
  for b in B:
    if sum_AB + b > K:
      break
    else:
      sum_AB += b
      cnt += 1
  ans = max(cnt,ans)
print(ans)
Problem p02627 (python)

Fixed submission:
S = input()
if S.islower():
  print("a")
else:
  print("A")

Buggy submission (verdict: Runtime Error):
S = input()
if S.str.islower():
  print("a")
else:
  print("A")
Problem p02707 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
from collections import defaultdict as ddict

B = ddict(int)
for a in A:
  B[a-1] += 1
for n in range(N):
  print(B[n])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
from collections import defaultdict as ddict
for n in range(N-1):
  A.append(int(input()))

B = ddict(int)
for a in A:
  B[a-1] += 1
for n in range(N):
  print(B[n])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
from collections import defaultdict as ddict
for n in range(N-1):
  A.append(int(input()))

B = ddict(int)
for a in A:
  B[a-1] += 1
for n in range(N):
  print(B[n])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
from collections import defaultdict as ddict
for n in range(N):
  A.append(int(input()))

B = ddict(int)
for a in A:
  B[a] += 1
for n in range(N):
  print(B[n])
Problem p02829 (python)

Fixed submission:
A=int(input())
B=int(input())
C=list(range(1,4))
C.remove(A)
C.remove(B)
print(C[0])

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=list(range(1,4))
C.pop(A)
C.pop(B)
print(C[0])
Problem p02831 (python)

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
def lcd(x,y):
  return (x * y) // gcd(x, y)
print(lcd(A,B))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
A,B=map(int,input().split())
def lcd(x,y)
  return (x * y) // gcd(x, y)
print(lcd(A,B))
Problem p02835 (python)

Fixed submission:
A = [int(i) for i  in input().split()]
print("bust") if sum(A) >= 22 else print("win")

Buggy submission (verdict: Runtime Error):
print("bust") if sum(A) >= 22 else print("win")
Problem p02881 (python)

Fixed submission:
from math import ceil, sqrt
N = int(input())
for i in range(ceil(sqrt(N)),0,-1):
    if N%i == 0:
        print(i + N//i -2)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
from functools import reduce
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
A = factorize(N)
for i in range(1,len(A)):
    x = 1
    y = 1
    for a in A[0:i]:
        x *= a
    for a in A[i:]:
        y *= a
ans = x+y-2

ans = N-1 if len(A) == 1else ans
print(ans)
Problem p02948 (python)

Fixed submission:
from collections import defaultdict
import heapq

n, m = map(int, input().split())
dct = defaultdict(list)

for i in range(n):
    a, b = map(int, input().split())
    dct[a].append(-b)

h = []
res = 0

for i in range(1, m + 1):
    if dct[i]:
        for item in dct[i]:
            heapq.heappush(h, item)
    if h:
        res += heapq.heappop(h)

print(-res)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = [[0,0]]*N
for n in range(N):
    temp = list(map(int,input().split()))
    if temp[0] <= M:
        AB[n] = list(map(int,input().split()))
work_schedule = [0]*M
sorted_AB = sorted(AB,key=lambda x:(-x[1],x[0]))
for work in sorted_AB:
    cnt = 0
    while True:
        if work[0]-1+cnt >= M:
            break
        elif work_schedule[work[0]-1+cnt] == 0:
            work_schedule[work[0]-1+cnt]  = work[1]
            break
        elif  work_schedule[work[0]-1+cnt] != 0:
            cnt+=1
print(sum(work_schedule))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = [[0,0]]*N
for n in range(N):
    AB[n] = list(map(int,input().split()))
work_schedule = [0]*M
sorted_AB = sorted(AB,key=lambda x:(-x[1],x[0]))
for work in sorted_AB:
    cnt = 0
    while True:
        if work[0]-1+cnt >= M:
            break
        elif work_schedule[work[0]-1+cnt] == 0:
            work_schedule[work[0]-1+cnt]  = work[1]
            break
        elif  work_schedule[work[0]-1+cnt] != 0:
            cnt+=1
sum(work_scuedule)

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
AB = []
for n in range(N):
    temp = [int(i) for i in input().split()]
    if temp[0] <= M:
        AB.append(temp)
from collections import deque
#works = sorted(AB,key=lambda x:(-x[1],x[0],))
works = deque(works)
work_schedule = [0]*M
for w in range(len(works)):
    work = works.popleft()
    if work[0] > M:
        pass
    else:
        cnt = 0
        while True:
            if (work[0]-1+cnt) >= M:
                break
            elif work_schedule[work[0]-1+cnt]  == 0:
                work_schedule[work[0]-1+cnt] = work[1]
                break
            else:
                cnt+=1
print(sum(work_schedule))
Problem p02990 (python)

Fixed submission:
import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(0,B):
    ans = (nCr((R+1),i+1) * nCr((B-1),i))%mod
    print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
def nCr(n,r):
    return factorial(n) // factorial(r) // factorial(n - r)
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)

Buggy submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)
Problem p02577 (python)

Fixed submission:
n,t=input(),0

for i in range(len(n)):
  t+=int(n[i])

print('No' if t%9 else 'Yes')

Buggy submission (verdict: Runtime Error):
n,t=input(),0

for i in range(len(n)):
  t+=int(n[i])

 print('No' if t%9 else 'Yes')
Problem p02623 (python)

Fixed submission:
from bisect import bisect_right
from itertools import accumulate

N,M,K=map(int,input().split())
A=list(accumulate([0]+[int(x) for x in input().split()]))
B=list(accumulate([0]+[int(x) for x in input().split()]))

m=0
for i in range(0,N+1):
  if K<A[i]:
    break
  m=max(m,i+bisect_right(B,K-A[i])-1)

print(m)

Buggy submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=[int(x) for x in input().split()]+[10**9]
B=[int(x) for x in input().split()]+[10**9]

c,i,j=0,0,0
while K>0 and (i<N or j<M):
  if K<min(A[i],B[i]):
    break
  c+=1
  if A[i]<B[j]:
    K-=A[i]
    i+=1
  elif B[j]<A[i]:
    K-=B[j]
    j+=1
  else:
    if A[i+1]<=B[j+1]:
      K-=A[i]
      i+=1
    else:
      K-=B[j]
      j+=1

print(c)

Buggy submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=[int(x) for x in input().split()]+[10**9]
B=[int(x) for x in input().split()]+[10**9]

c,i,j=0,0,0
while K>0 and (i<N or j<M):
  if K==min(K,A[i],B[i]):
    break
  c+=1
  if A[i]<B[j]:
    K-=A[i]
    i+=1
  elif B[j]<A[i]:
    K-=B[j]
    j+=1
  else:
    if A[i+1]<=B[j+1]:
      K-=A[i]
      i+=1
    else:
      K-=B[j]
      j+=1

print(c)
Problem p02753 (python)

Fixed submission:
c=input().count('A')
print('No' if c==3 or c==0 else 'Yes')

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
S=set(range(25*A//2,25*(A+1)//2))&set(range(10*B,10*(B+1)))
print(S.pop() if len(S)>0 else -1)
Problem p02763 (python)

Fixed submission:
import bisect

N=int(input())
S=list(str(input()))

def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x)

d=[[] for _ in range(26)]
for i,s in enumerate(S):
  d[ci(s)].append(i)

for i in range(int(input())):
  t,x,y=input().split()
  if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[*str(input())]

n=1
while N>n:
	n*=2

d=[[0]*(2*n) for _ in range(26)]

def ci(c):
	return "abcdefghijklmnopqrstuvwxyz".find(c)

def update(d,k,a):
	k+=n-1
	d[k]=a
	while k>0:
		k=~-k//2
		d[k]=d[k*2+1]+d[k*2+2]

def query(d,a,b,k,l,r):
	if r<=a or b<=l:
		return 0
	if a<=l and r<=b:
		return d[k]
	else:
		return query(d,a,b,k*2+1,l,(l+r)//2)+query(d,a,b,k*2+2,(l+r)//2,r)

for i,c in enumerate(S):
	update(d[ci(c)],i,1)

for i in range(int(input())):
	t,x,y=input().split()
	if t=='1':
		update(d[ci(S[int(x)-1])],int(x)-1,0)
		update(d[ci(y)],int(x)-1,1)
	else:
		a=0
		for j in range(26):
			if query(d[j],int(x)-1,int(y),0,0,n)>0:
				a+=1
		print(a)
Problem p02925 (python)

Fixed submission:
from collections import deque

def main():
  N=int(input())
  A=[deque(int(a)-1 for a in input().split()) for _ in range(N)]

  P,W=[0]*N,[-1]*N
  c=deque(range(N))

  while c:
    i=c.popleft()
    j=A[i].popleft()
    W[i]=j

    if W[j]==i:
      P[i]=P[j]=max(P[i],P[j])+1
      if A[i]:
        c.append(i)
      if A[j]:
        c.append(j)

  print(-1 if any(len(a) for a in A) else max(P))

main()

Buggy submission (verdict: Runtime Error):
N=int(input())

def dfs(g,d,O):
  if d<N:
    m=-1
    if len(O[g])==0:
      return d+1
    for i in O[g]:
      m=max(m,dfs(i,d+1,O))
      if m>N:
        break
    return m
  else:
    return N+1

def main():
  I=[[] for i in range(N*~-N//2)]
  O=[[] for i in range(N*~-N//2)]

  for i in range(N):
    pv=-1
    for j in [int(x)-1 for x in input().split()]:
      v=j*~-j//2+i if i<j else i*~-i//2+j
      if pv!=-1:
        I[v].append(pv)
        O[pv].append(v)
      pv=v

  m=-1
  for s in range(N*~-N//2):
    if len(I[s])!=0:
      continue
    m=max(m,dfs(s,0,O))
    if m>N:
      print(-1)
      exit(0)
  print(m)

main()
Problem p03013 (python)

Fixed submission:
N,M = map(int,input().split())
a = [int(input()) for i in range(M)] 
t = d = [0]*(N+1)

for i in range(M):
  d[a[i]] = 1

t[0]=t[1]=1
if M>0:
  t[1] = 0 if (a[0]==1) else 1

for i in range(2,N+1):
  t[i] = 0 if d[i] else t[i-1]+t[i-2]
print (t[N] % 1000000007)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for i in range(M)] 
t = d = [0]*(N+1)

for i in range(M):
  d[a[i]] = 1

t[0]=1
t[1]=0 if a[0]==1 else 1
for i in range(2,N+1):
  t[i] = 0 if d[i] else t[i-1]+t[i-2]
print (t[N] % 1000000007)
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
l=[[int(x),1] for x in input().split()]
for i in range(m):
  b,c=map(int,input().split())
  l.append([c,b])

s = sorted(l, key=lambda x:x[0], reverse=True)

c=n
t=0
i=0
while c>0:
  n = s[i][1] if c>=s[i][1] else c
  t += s[i][0] * n
  c -= n
  i += 1

print(t)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(i) for i in input().split()]

a.sort()
for i in range(m):
 b,c=map(int,input().split())
 for i in range(b):
  if a[i] < c:
   a[i] = c
  else:
   break
 for j in range(i+1):
  if a[j] > a[j+i+1]:
   a[j],a[j+i+1]=a[j+i+1],a[j]
  else:
   break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(i) for i in input().split()]

for i in range(m):
 a.sort()
 print(a)
 b,c=map(int, input().split())
 for i in range(b):
  if a[i] < c:
   a[i] = c
  else:
   break
print(sum(a))
Problem p03108 (python)

Fixed submission:
n, m = map(int, input().split())
e = [[int(x) for x in input().split()] for _ in range(m)]

u = [-1]*(n+1)

def find(x):
  return x if u[x] < 0 else find(u[x])

t = n*(n-1)// 2
s = [t]

for i in range(m-1,0,-1):
  a = find(e[i][0])
  b = find(e[i][1])
  if a > b:
    a, b = b, a
  if a != b:
    t -= u[a]*u[b]
    u[a] += u[b]
    u[b] = a
  s.append(t)

for i in reversed(s):
  print(i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
b=[[int(x) for x in input().split()] for y in range(m)]
u=n*(n-1)//2

s=set()
a=[u]

for i in range(m-1,0,-1):
  x=y=-1
  for j in range(len(s)):
    if b[i][0] in s[j]:
      x = j
    if b[i][1] in s[j]:
      y = j
    if x!=-1 and y!=-1:
      break

  if x==-1 and y==-1:
    s.append(set((b[i][0],b[i][1])))
  elif y==-1:
    s[x].add(b[i][1])
  elif x==-1:
    s[y].add(b[i][0])
  elif x!=y:
    for k in range(len(s[y])):
      s[x].add(s[y].pop())
    s.pop(y)

  t=0
  for j in range(len(s)):
    t += (len(s[j])*(len(s[j])-1))//2
  a.append(u-t)
 
a.reverse()
for i in range(len(a)):
  print(a[i])
Problem p02546 (python)

Fixed submission:
s = input()
if s[-1] == 's':
  print(s + 'es')
else:
  print(s + 's')

Buggy submission (verdict: Runtime Error):
s = input()
if s[-1] == 's':
  print(s + 'es')
else:
  print(s + 's')
Problem p02723 (python)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if s[3] == s[4] and s[5] == s[6]:
  print('Yes')
else:
  print('No')
Problem p02577 (python)

Fixed submission:
n = int(input())
if n % 9 == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 9 == 0:
    print("Yes")
else:
    pritn("No")
Problem p02835 (python)

Fixed submission:

l = list(map(int,input().split()))
if sum(l) <= 21:
    print('win')
else:
    print('bust')

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int a,b,c;
	cin >> a >> b >> c;
	string ans = "win";
	if (a+b+c>21) ans = "bust";
  cout << ans << endl;
}
Problem p02873 (python)

Fixed submission:
s = input()
n = len(s)
dp = [0]*(n+1)
t = 0
for e,i in enumerate(s,1):
    if i=='<' :
        dp[e]=dp[e-1]+1
# print(dp)
t = 0
for e in range(n-1,-1,-1):
    i = s[e]
    # print(t)
    if i=='>' :
        dp[e]=max(dp[e],dp[e+1]+1)
# print(dp)
print(sum(dp))

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)+1
A = [0] * N
B = [0] * (N+1)

for i in range(N-1):
	if S[i] == '<':
		A[i+1] = A[i]+1
for i in range(N-2, -1, -1):
    if S[i] == '>':
        B[i+i] = B[i]+1

print(sum(A)+sum(B))
Problem p02948 (python)

Fixed submission:
n,m = map(int,input().split())
import heapq
from collections import defaultdict
dic = defaultdict(list)
l = []
heapq.heapify(l)
for i in range(n):
    a,b=map(int,input().split())
    b = -b
    dic[a].append(b)
s = 0
t = [0]
for i in range(m):
    for i in dic[i+1]:
        heapq.heappush(l,i)
    if len(l) ==0 : M = 0
    else:
        # print(l)
        M = heapq.heappop(l)
        s += -M
print(s)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
from collections import defaultdict
dic = defaultdict(list)
l = []
for i in range(n):
    a,b=map(int,input().split())
    dic[a].append(b)
s = 0
t = [0,0,0,0,0,0,0,0,0,0,0]
for i in range(m):
    t += dic[i+1]
    M = max(t)
    s +=M
    t.remove(M)
print(s)
Problem p03017 (python)

Fixed submission:

N,A,B,C,D = map(int,input().split())
a= input()
f = 0
s = 0
d = 1
t = []
k = []

f1 = 0
s1 = 0
d1 = 1
t1 = []
k1 = []


for i in a[A-1:C]:
    if i == "." and f ==1:
        k.append(d)
        s = 1
        f = 0
    elif i == ".":s+=1
    
    elif i == "#" and f==0:
        t.append(s)
        d = 1
        f = 1
    elif i == "#":d+=1
else:
    if f==1:
        k.append(d)
    else:
        t.append(s)
for i in a[B-2:D]:
    if i == "." and f1 ==1:
        k1.append(d1)
        s1 = 1
        f1 = 0
    elif i == ".":s1+=1
    
    elif i == "#" and f1==0:
        t1.append(s1)
        d1 = 1
        f1 = 1
    elif i == "#":d1+=1
else:
    if f1==1:
        k1.append(d1)
    else:
        t1.append(s1)
# print(t,k)
# print(t1,k1)
if C < D :
    if len(k) == sum(k) and  len(k1) == sum(k1):
        print("Yes")
    else:
        print("No")
else:
    if len(k) == sum(k) and any([i > 2 for i in t1]) :
        print("Yes")
    elif len(k) == sum(k) and t1[-1] >1:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
ｎ
Problem p03038 (python)

Fixed submission:
from heapq import heappush, heappop
from operator import itemgetter
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = []
for i in range(K):
    ta, tb = map(int, input().split())
    t.append([ta,tb]) 
a = sorted(t, key=itemgetter(1))
x.sort()
x = x[::-1]
s = 0
l = []
while x or a:
    if a[-1][0] == 0:a.pop()
    if not a:
        s+=sum(x)
        break
    if len(x) ==0:break
    r = x.pop()
    if r < a[-1][1]:
        s+=a[-1][1]
        a[-1][0]-=1
    else:
        s+=sum(x)+r
        break
print(s)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
from operator import itemgetter
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = []
for i in range(K):
    ta, tb = map(int, input().split())
    t.append([ta,tb]) 
a = sorted(t, key=itemgetter(1))
x.sort()
x = x[::-1]
s = 0
l = []
while x or a:
    if a[-1][0] == 0:a.pop()
    if not a:
        s+=sum(x)
        break
    r = x.pop()
    if r < a[-1][1]:
        s+=a[-1][1]
        a[-1][0]-=1
    else:
        s+=sum(x)+r
        break
print(s)
Problem p03053 (python)

Fixed submission:
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
    A.append([0 if i == "#" else H+W for i in list(input())])
A = np.array(A)

for i in range(H-1):
  A[i+1, :] = np.minimum(A[i, :] + 1, A[i+1, :])
for i in range(H-1,0,-1):
  A[i-1,:] = np.minimum(A[i,:]+1,A[i-1,:])
for i in range(W-1):
  A[:,i+1] = np.minimum(A[:,i]+1,A[:,i+1])
for i in range(W-1,0,-1):
  A[:,i-1] = np.minimum(A[:,i]+1,A[:,i-1])
print(np.max(A))

Buggy submission (verdict: Runtime Error):
import numpy as np

H,W = map(int,input().split())
A = []
for i in range(H):
    A.append([0 if i == "#" else H+W for i in list(input())])
A = np.array(A)

for i in range(H-1):
  A[i+1, :] = np.minimum(A[i, :] + 1, A[i+1, :])
for i in range(H-1,0,-1):
  A[i-1,:] = np.minimum(A[i,:]+1,A[i-1,:])
for i in range(W-1):
  A[:,i+1] = np.minimum(A[:,i]+1,A[:,i+1])
for i in range(W-1,0,-1):
  A[:,i-1] = np.minimum(A[:,i]+1,A[:,i-1])
print(np.max(A))
Problem p03073 (python)

Fixed submission:
a  = input()
s = 0
t = 0
k = ["0","1"]
for n,i in enumerate(a):
  if i != k[(n%2)]:
    s+=1
  if i != k[(n+1)%2]:
    t+=1
print(min(s,t))

Buggy submission (verdict: Runtime Error):
a  = input()
s = 0
t = 0
k = ["0","1"]
for n,i in enumerate(a):
  if i != k[(n%2)]:
    s+=1
  if i != k[(n%2)+1]:
    t+=1
print(min(s,t))