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

Fixed submission:
N, M = map(int,input().split())
A_li = list(map(int,input().split()))
CB_li = []
for i in range(M):
    B,C = map(int,input().split())
    CB_li.append([C,B])

CB_li.sort()
CB_li.reverse()

counter = 0
for i in range(M):
    li = [CB_li[i][0]]*CB_li[i][1]
    A_li.extend(li)
    counter += CB_li[i][1]
    if counter > N:
        break

A_li.sort()
ans = sum(A_li[-N:])
    
print(str(ans))

Buggy submission (verdict: Runtime Error):

N, M = list(map(int,input().split()))
A_li = list(map(int,input().split()))
CB_li = []

for i in range(M):
    B, C = list(map(int,input().split()))
    li = [C]*B
    CB_li.extend(li)

CB_li.sort()
CB_li.reverse()

A_li.sort()
A_li.reverse()

ans_li = []

for i in range(N):
    if A_li[i] < max(CB_li):
        s = sum(A_li[:i])+sum(CB_li[:N-i])
        ans_li.append(sum)
        
print(str(max(ans_li)))

Buggy submission (verdict: Runtime Error):

N, M = list(map(int,input().split()))
A_li = list(map(int,input().split()))
CB_li = []

for i in range(M):
    BandC = list(map(int,input().split()))
    BandC.reverse()
    CB_li.append(BandC)

CB_li.sort()
CB_li.reverse()
overwrite_li = []
for CB in CB_li:
    li = [CB[0]]*CB[1]
    overwrite_li.extend(li)

A_li.sort()
A_li.reverse()
j=0
for i in range(N):
    if A_li[i] < overwrite_li[j]:
        A_li[i] = overwrite_li[j]
        j+=1

ans = sum(A_li)
    
print(str(int(ans)))
Problem p03127 (python)

Fixed submission:
from fractions import gcd

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

g=0

for i in range(n):
    g=gcd(g,x[i])

print(g)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

n =int(input())
a_lis = list(map(int,input().split()))
g = 0
for i in range(a_lis):
	g = gcd(g,i)

print(g)
Problem p03208 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(int(input())for _ in range(n))
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[k+i-1]-h[i])


print(min(l))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
h = []
for i in range(n):
	h.append(int(input()))
h.sort()

ans_l = []
for i in range(n-k+1):
	ans_l.append(ans_l[i+k-1] - ans_l[i])
print(min(ans_l))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(int(input())for i in range(n))
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[k-i+1]-h[i])


print(min(l))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(int(input())for i in range(n))
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[k-i+1]-h[i])


print(min(h))
Problem p03834 (python)

Fixed submission:
# -*- coding utf-8 -*-

a,b,c = map(str,input().split(","))

print(a,b,c)

Buggy submission (verdict: Runtime Error):
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
ans=""

ans="U"*x + "R"*y
ans+="D"*x + "L"*y

ans+="L"+"U"*(x+1)+"R"*(x+1)+"D"
ans+="R"+"D"*(x+1)+"L"*(y+1)+"U"
print(ans)
Problem p03221 (python)

Fixed submission:
import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(1,n+1):
    ol[i].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], bisect.bisect_right(ol[pl[i]], yl[i])))

Buggy submission (verdict: Runtime Error):
import bisect
n,m=map(int, input().split())
pl=[0]*m
yl=[0]*m
ol=[[] for i in range(n+1)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(n):
    ol[pl[i]] = sorted(ol[pl[i]])
for i in range(m):
    x = bisect.bisect_right(ol[pl[i]], yl[i])
    print("%06d%06d" % (pl[i], x))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
pl=[0]*m
yl=[0]*m
cl=[0]*(m+1)
ol=[[] for i in range(n+1)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append((pl[i], yl[i], i))
for i in range(n):
    cnt = 1
    for o in sorted(ol[pl[i]]):
        cl[o[2]] = cnt
        cnt+=1
for i in range(m):
    print("%06d%06d" % (pl[i], cl[i]))
Problem p02990 (python)

Fixed submission:
import math
N,K = (int(x) for x in input().split())
R = N - K
mod = 10**9 + 7

def fact(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1,K+1):
  if N - K + 1 < i:
    ans = 0
  else:
    ans = fact(R+1, i)*fact(K-1,i-1)
  print(int(ans)%mod)

Buggy submission (verdict: Runtime Error):
n,k = (int(x) for x in input().split())
mod = 10**9 + 7
ans = n - k + 1
print(ans)
for i in range(1,k):
  ans = int(ans*(n-k+1-i)*(k-i)/(i*(i+1)))
  #ans = ans%mod
  print(ans%mod)

Buggy submission (verdict: Runtime Error):
N,K = (int(x) for x in input().split())
R = N - K
mod = 10**9 + 7

def fact(n, k):
  r1 = 1
  r2 = 1
  for i in range(0, k):
      r1 *= (n - i)
      r2 *= (i + 1)
  r = r1/r2
  return r

ans = fact(R+1, 1)*fact(K-1,0)
for i in range(1,K+1):
  print(int(ans)%mod)
  if N - K + 1 < i:
    ans = 0
  else:
    ans = ans*(R - i + 1)*(K - i)/(i + 1)/i

Buggy submission (verdict: Runtime Error):
N,K = (int(x) for x in input().split())
R = N - K
mod = 10**9 + 7

def fact(n, k):
  r1 = 1
  r2 = 1
  for i in range(0, k):
      r1 *= (n - i)
      r2 *= (i + 1)
  r = r1/r2
  return r

ans = fact(R+1, 1)*fact(K-1,0)
for i in range(1,K+1): 
  #ans = ans 
  print(int(ans)%mod)
  ans = ans*(R - i + 1)*(K - i)/(i + 1)/i

Buggy submission (verdict: Runtime Error):
def fact(n, k):
  r1 = 1
  r2 = 1
  for i in range(0, k):
      r1 *= (n - i)
      r2 *= (i + 1)
  r = r1/r2
  return r

N,K = (int(x) for x in input().split())
R = N - K
mod = 1000000007

for i in range(1,K+1):
  tmp1 = fact(R+1, i)%mod
  tmp2 = fact(K-1, i-1)%mod
  ans = tmp1*tmp2%mod
  print(int(ans))

Buggy submission (verdict: Runtime Error):
def fact(n, k):
  r1 = 1
  r2 = 1
  for i in range(0, k):
      r1 *= (n - i)
      r2 *= (i + 1)
  r = r1/r2
  return r

N,K = (int(x) for x in input().split())
R = N - K
mod = 1#0000007

for i in range(1,K+1):
  tmp1 = fact(R+1, i)  
  tmp2 = fact(K-1, i-1)
  ans = tmp1*tmp2%1000000007
  print(int(ans))
Problem p03012 (python)

Fixed submission:
n = int(input())
l = [int(x) for x in input().split()]

ans = 100000000000
for i in range(1,n):
  ans1 = sum(l[:i])
  ans2 = sum(l[i:])
  diff = abs(ans1 - ans2)
  if diff < ans:
    ans = diff
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(x) for x in input().split()]
sort(l)

print(n,l)
Problem p03013 (python)

Fixed submission:
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

if M == 0:
  ans = kaidan[N - 1]
else:
  ans = 1

  if a[0] - 1 > 0:
      ans *= kaidan[a[0] - 2]

  for i in range(M-1):
    if((a[i] + 1) > (a[i+1] - 1)):
      ans *= 0
    elif((a[i] + 1) == (a[i+1] - 1)):
      ans *= 1
    else:
      ans *= (kaidan[a[i+1] - a[i] - 3])

  if N - (a[M - 1] + 1) > 0:
      ans *= kaidan[N - (a[M - 1] + 2)]
      
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

ans = 1

if a[0] - 1 > 0:
    ans *= kaidan[a[0] - 2]
  
for i in range(M-1):
  if((a[i] + 1) > (a[i+1] - 1)):
    ans *= 0
  elif((a[i] + 1) == (a[i+1] - 1)):
    ans *= 1
  else:
    ans *= (kaidan[a[i+1] - a[i] - 3])

if N - (a[M - 1] + 1) > 0:
    ans *= kaidan[N - (a[M - 1] + 2)]
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a=[]
for _ in range(M):
    a.append(int(input()))
    
kaidan = [1, 2]

for i in range(2, N):
  kaidan.append(kaidan[i-1]+ kaidan[i-2])

ans = 1

if a[0] - 1 > 0:
    ans *= kaidan[a[0] - 2]
  
for i in range(M-1):
  if((a[i] + 1) > (a[i+1] - 1)):
    ans *= 0
  else:
    ans *= (kaidan[a[i+1] - a[i] - 3])

if N - (a[M - 1] + 1) > 0:
    ans *= kaidan[N - (a[M - 1] + 2)]
print(ans%1000000007)
Problem p03207 (python)

Fixed submission:
n = int(input())
p = [int(input()) for _ in range(n)]
print(sum(p) - max(p) // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for _ in range(n)]
print(p.sum() - max(p) // 2)
Problem p02912 (python)

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

from heapq import heappush, heappop
hq=[]

for a_val in a:
    # heappopで最も小さい値が取り出されるため、(-1)をかけて入れる
    heappush(hq, -a_val)
for _ in range(m):
    heappush(hq, -(heappop(hq)//(-2)))
print(-sum(hq))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=list(map(int, input().split()))

from heapq import heappush, heappop
hq=[]

for a_val in a:
    # heappopで最も小さい値が取り出されるため、(-1)をかけて入れる
    heappush(hq, -a)
for _ in range(m):
    heappush(hq, -(heappop(hq)*(-1))//(-2))
print(-sum(hq))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=list(map(int, input().split()), reverse=True)

while(m>0):
    max_index=a.index(max(a))
    a[max_index] = a[max_index]//2
    m-=1
print(sum(a))
Problem p02933 (python)

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


print(s) if a >= 3200 else print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()


print(s) if a >=
Problem p02951 (python)

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

print(max(0, c-(a-b)))

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

count = 0

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(9 + min(N,999) - 100 + 1)
elif N < 10000:
    print(9 + 900)
elif N < 100000:
    print(9 + 900 + min(N , 99999) - 10000 + 1)
else:
    print(90909)
Problem p03038 (python)

Fixed submission:
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC, key=lambda x:x[1], reverse=True)
D = [0] * N
idx = 0
for b,c in BC:
    for i in range(b):
        D[idx] = c
        idx += 1
        if idx >= N:
            break
    if idx >= N:
        break
# print(D)


# print(D)
# print(sorted(A))
# print(len(D), len(A))
for i in range(N):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC, key=lambda x:x[1], reverse=True)
D = [0] * N
idx = 0
for b,c in BC:
    for i in range(b):
        D[idx] = c
        idx += 1
        if i >= N:
            break
    if i >= N:
        break
# print(D)


# print(D)
# print(sorted(A))
# print(len(D), len(A))
for i in range(N):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC, key=lambda x:x[1], reverse=True)
D = []
for b,c in BC:
    D += [c]*b
# print(D)

for i in range(N):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
# print(sorted(A))
print(sum(A))

Buggy submission (verdict: Runtime Error):
import bisect
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC, key=lambda x:x[1], reverse=True)
D = []
for b,c in BC:
    D += [c]*b
# print(D)

for i in range(N):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
# print(sorted(A))
print(sum(A))
Problem p03053 (python)

Fixed submission:
from collections import deque

h,w = map(int, input().split())
A = [[s for s in input()] for _ in range(h)]

visited = [[-1]*(w) for _ in range(h)]
dq = deque()
directions = [[0,1],[1,0],[0,-1],[-1,0]]

# 初期配置の黒をキューに追加
for hi in range(h):
    for wi in range(w):
        if A[hi][wi] == '#':
            dq.append([hi,wi])
            visited[hi][wi] = 0

# キューが空になるまで
while dq:
    hi,wi = dq.popleft()
    for d in directions:
        nhi, nwi = hi+d[0],wi + d[1]
        # 場外ならスキップ
        if nhi<0 or nhi>=h or nwi<0 or nwi>=w: continue 
        # 「黒くしてない白マス」をキューに追加
        if visited[nhi][nwi] == -1 and A[nhi][nwi] == '.':
            dq.append([nhi,nwi])
            visited[nhi][nwi] = visited[hi][wi] + 1

ans = -1
for x in visited:
    ans = max(ans,max(x))
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

h,w = map(int, input().split())
A = [['*']*(w+2)] + [['*']+[s for s in input()]+['*'] for _ in range(h)] + [['*']*(w+2)]

dist_to_black = [[0]*w for _ in range(h)]

def bfs(sx,sy):
    dq = deque([(sy,sx,0)])
    while dq:
        y,x,n = dq.popleft()
        if A[y][x]=='#':
            return n
        elif A[y][x]=='.':
            dq.append([y+1,x,n+1])
            dq.append([y-1,x,n+1])
            dq.append([y,x+1,n+1])
            dq.append([y,x-1,n+1])

ans = -1
for i in range(h):
    for j in range(w):
        # dist_to_black[i][j] = bfs(i+1,j+1)
        ans = max(ans, bfs(i+1, j+1))

print(ans)
Problem p03745 (python)

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

if n==1:
    print(1)
else:
    mode = None
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if mode == None:
                mode = aa[i]<aa[i+1]
            elif (aa[i] < aa[i+1]) != mode:
                ans+=1
                mode = None
        # print(aa[i], aa[i+1], aa[i]<aa[i+1],  mode, ans)
    print(ans)

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

if n==1:
    print(1)
else:
    mode = None
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if mode == None:
                mode = aa[i]<aa[i+1]
            if (aa[i] < aa[i+1]) != mode:
                ans+=1
                mode = aa[+1]<aa[i+2]
        # print(aa[i], aa[i+1], aa[i]<aa[i+1],  mode, ans)
    print(ans)
Problem p03774 (python)

Fixed submission:
n,m = map(int, input().split())
aa = [0] * n
bb = [0] * n
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

for i in range(n):
    d = [abs(aa[i] - cc[j]) + abs(bb[i] - dd[j]) for j in range(m)]
    print(d.index(min(d))+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

distance = []
for i in range(n):
    d = [abs(aa[i] - cc[j]) + abs(bb[i] - dd[j]) for j in range(m)]
    print(d.index(min(d))+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

distance = []
for i in range(n):
    d = []
    for j in range(m):
        d_ = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])
        d.append(d_)
    distance.append(d)
for d in distance:
    print(d.index(min(d))+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

distance = []
for i in range(n):
    d = []
    for j in range(m):
        d_ = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])
        d.append(d_)
        print('({}, {})  ({}, {}) :{}'.format(aa[i],bb[i],cc[j],dd[j], d_))
    distance.append(d)
for d in distance:
    print(d.index(min(d))+1)
Problem p03805 (python)

Fixed submission:
N,M = map(int,input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a_, b_ = map(int,input().split())
    # 配列の添字としたいので-1
    a[i] = a_ -1
    b[i] = b_ -1

route = [0]*N  # 通過済
connect=[[0]*N for _ in range(N)]
def dfs(now, depth):
    # print("#"*depth,now, depth)
    # 通過済ならNG
    if route[now]: return 0
    # depth = Nなら達成
    if depth == N: return 1
    
    route[now] = 1
    ans = 0
    for i in range(N):
        if connect[now][i]:
            ans += dfs(i, depth+1)
    route[now] = 0
    return ans

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

# for xx in connect:
#     print(xx)
print(dfs(0,1))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a_, b_ = map(int,input().split())
    # 配列の添字としたいので-1
    a[i] = a_ -1
    b[i] = b_ -1

route = [0]*N  # 通過済
connect=[[0]*M for _ in range(M)]
def dfs(now, depth):
    # print("#"*depth,now, depth)
    # 通過済ならNG
    if route[now]: return 0
    # depth = Nなら達成
    if depth == N: return 1
    
    route[now] = 1
    ans = 0
    for i in range(N):
        if connect[now][i]:
            ans += dfs(i, depth+1)
    route[now] = 0
    return ans

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

# for xx in connect:
#     print(xx)
print(dfs(0,1))
Problem p03075 (python)

Fixed submission:
a = [int(input()) for i in range(6)]

# アンテナと距離に分ける
i = [a[0], a[1], a[2], a[3], a[4]]
k = a[5]

flag = False
itr = 0
while True:
  x = itr
  while True:
    x+=1
    if x >= 5:
      break
    elif(i[x] - i[itr]) > k:
      flag = True
  itr+=1
  if itr == 5:
    break
    
if flag:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(6)]

# アンテナと距離に分ける
i = [a[0], a[1], a[2], a[3], a[4]]
k = a[5]

flag = False
itr = 0
while True:
  x = itr
  while True:
    x++
    if 
      break
    else if(i[itr] - i[x]) > k:
      flag = True
  itr++
  if itr == 5
    break
    
if flag
  print(":(")
else
  print("Yay!")
Problem p02951 (python)

Fixed submission:
IN = input()
A, B, C = [int(x) for x in IN.split(" ")]
total = 0
try:
    total = C - min((A-B), C)
    print(total)
except:
    print("ERROR")

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

N = int(N)
H = [int(x) for x in H.split(" ")]
C = 0
R = 0
m = min(H[0], H[1])

while C < (N-1):
    if H[C] - H[C+1] > 1:
        R = 1
        C = N
    elif H[C] - H[C+1] == 1:
        if m > (H[C]-1):
            R = 1
            C = N
        else:
            m = min(m, H[C]-1)
            C += 1
    else:
        C+=1

if R == 0:
    print("Yes")
else:
    print("No")
Problem p02912 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

A = [-1 * i for i in A]
heapq.heapify(A)

for i in range(M):
    fst = heapq.heappop(A)
    fst = int(fst / 2)
    heapq.heappush(A, fst)
    
ans = -1 * sum(A)
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
import math

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

A.sort()
if len(A) < 2:
    ans = int(A[0] / (2**M))
else:
    fst = A[-1]
    scd = A[-2]

    while M > 0:
        if fst == scd:
            Y = 1
        else:
            Y = math.ceil(math.log2(fst/scd))
        print(Y)
        largest = A.pop(-1)
        largest = int(largest / (2**Y))
        print(largest)
        M = M - Y
        bisect.insort(A, largest)
        fst = A[-1]
        scd = A[-2]
        print(A)
    ans = sum(A)

print(ans)
Problem p02912 (python)

Fixed submission:
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
A = list(map(lambda x: int(x) * -1, input().split()))
heapify(A)

for _ in range(m):
    tmp = -1 * heappop(A)
    heappush(A, -1 * (tmp // 2))

print(-sum(A))

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

n, m = map(int, input().split())
A = input().split()
hq = []
for a in A:
    heappush(hq, -1 * int(a))

for _ in range(m):
    tmp = -1 * heappop(hq)
    print(hq)
    heappush(hq, -1 * (tmp // 2))

print(-sum(hq))
Problem p03041 (python)

Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n, k = get_li()
    s = get_lc()
    if s[k-1] == 'A':
        s[k-1] = 'a'
    elif s[k-1] == 'B':
        s[k-1] = 'b'
    else:
        s[k-1] = 'c'
    print(''.join(s))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n, k = get_li()
    s = get_str()
    if s[k-1] == 'A':
        s[k-1] = 'a'
    elif s[k-1] == 'B':
        s[k-1] = 'b'
    else:
        s[k-1] = 'c'
    print(s)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()
Problem p03767 (python)

Fixed submission:
n = int(input())
arr = list(map(int, input().strip().split()))
arr.sort(reverse=True)
print(sum(arr[1:2*n:2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = map(int, input().strip().split())
arr.sort(reverse=True)
print(sum(arr[1:2*n:2]))
Problem p02915 (python)

Fixed submission:
var = int(input())

pas = var ** 3

print(pas)

Buggy submission (verdict: Runtime Error):
var = input()

pas = var ** var

print(pas)
Problem p02915 (python)

Fixed submission:
a = int(input())
print(a*a*a)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a = N * N * N
# 出力
print(a)
Problem p02915 (python)

Fixed submission:
n = int(input())
if n >= 1 and n <= 9:
    print(n**3)

Buggy submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n < 1 or n > 9:
        continue
    else:
        print(n**3)
Problem p03012 (python)

Fixed submission:
N = input()
N = int(N)
W = [int(i) for i in input().split()]

Total = sum(W)
sub_Total = 0
for i in range(len(W)):
  pre_sub_Total = sub_Total
  sub_Total = sub_Total + W[i]
  if Total/2 < sub_Total:
    diff1 = abs(Total - 2*sub_Total)
    diff2 = abs(Total - 2*pre_sub_Total)
    break

print(min(diff1, diff2))

Buggy submission (verdict: Runtime Error):
N = input()
N = int(N)
W = [int(i) for i in input().split()]

Total = sum(W)
for i in range(len(W)):
  sub_Total = sum(W[:i])
  if Total/2 < sub_Total:
    diff1 = abs(Total - 2*sub_Total)
    diff2 = abs(Total - 2*sum(W[:i-1]))
    break
    
print(min(diff1, diff2))