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

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

p_y_li = [list(map(int, (input() + " {}".format(i)).split())) for i in range(m)]

p_y_li.sort(key = lambda x : x[1])

li = [0 for _ in range(n)]
for i in range(m):
    ans = ""
    p = p_y_li[i][0]
    li[p-1] += 1
    x = li[p-1]
    ans = str(p).zfill(6) + str(x).zfill(6)
    p_y_li[i].append(ans)

p_y_li.sort(key = lambda x : x[2])
for i in p_y_li:
    print(i[3])

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

p_y_li = [list(map(int, (input() + " {}".format(i)).split())) for i in range(m)]

p_y_li.sort(key = lambda x : x[1])

li = [0 for _ in range(m)]
for i in range(m):
    ans = ""
    p = p_y_li[i][0]
    li[p-1] += 1
    x = li[p-1]
    ans = str(p).zfill(6) + str(x).zfill(6)
    p_y_li[i].append(ans)

p_y_li.sort(key = lambda x : x[2])
for i in p_y_li:
    print(i[3])
Problem p03272 (python)

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

print(n-i+1)

Buggy submission (verdict: Runtime Error):

n, k = map(int, input().split())
li = list(map(int, input().split()))
li.append(0)
li.sort()
zero_index = li.index(0)
if zero_index == 0:
    print(li[k])
elif zero_index == len(li) -1:
    print(abs(li[-k-1]))
else:
    near_zero_small = li[zero_index-1]
    near_zero_big = li[zero_index+1]
    li.pop(zero_index)
    ans = 0
    cost = 0
    for i in range(n):
        minimam = li[i]
        maximam = li[i+k-1]
        if (minimam > 0 and maximam > 0 ):
            if minimam == near_zero_big:
                cost = maximam
        elif (minimam < 0 and maximam < 0 ):
            if minimam == near_zero_big:
                cost = abs(minimam)
        else:
            cost = min(abs(minimam), maximam)*2 + max(abs(minimam), maximam)
        if ans > cost or ans == 0:
            ans = cost
    print(ans)
Problem p03315 (python)

Fixed submission:
s = input()
ans = 0
for i in s:
    if i == "+":
        ans += 1
    else:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
input(s)
ans = 0
for i in s:
    if i == "+":
        ans += 1
    else:
        ans-=1
print(ans)
Problem p02833 (python)

Fixed submission:
n = int(input())
if n % 2 == 1:
  print(0)
else:
  first = 10
  count = 0
  if n >= first:
    while n >= first:
      count += n //first
      first = 5 *first
  
  print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
  print(0)
else:
  first = 10
  count = 0
  if n >= first:
    while n >= first:
      count += n //first
      first = 5 *first
  
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
  print(0)
else:
  first = 10
  count = 0
  while n >= first:
    count += n //first
    first = 5 *first
print(count)
Problem p02881 (python)

Fixed submission:
import math
n = input()
n = int(n)
spl_list = [1]
for i in range(1,round(math.sqrt(n)) + 1):
  if n % i == 0:
    spl_list.append(i)

max_i = max(spl_list)
max_j = n / max_i
print(round(max_i + max_j -2))

Buggy submission (verdict: Runtime Error):
import math
n = input()
n = int(n)
spl_list = [1]
for i in range(1,round(math.sqrt(n)) + 1):
  if n % i == 0:
    spl_list.append(i)

max_i = max(spl_list)
max_j = n / max_i
print(round(max_i + maxj -2))
Problem p02912 (python)

Fixed submission:
n,m = map(int,input().split())
import math
a_list = list(map(int,input().split()))
for i in range(n):
  a_list[i] = -1 * a_list[i]
import heapq
heapq.heapify(a_list)
for j in range(m):
  
  a = heapq.heappop(a_list)
  a = math.ceil(a/2)
  heapq.heappush(a_list,a)


print(-1 * sum(a_list))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
a_array = np.array([map(int,input().split())])
for i in range(m):

  a_array[np.argmax(a_array)] = a_array[np.argmax(a_array)]//2
   
print(np.sum(a_array))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
a_array = np.array([map(int,input().split())])
for i in range(m):

  a_array[np.argmax(a_array)] = a_array[np.argmax(a_array)]//2
   
print(np.sum(a_array))
Problem p02916 (python)

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
result = sum(b_list)
dif_list = []
for i in range(n -1):
  if a_list[i + 1] == a_list[i] + 1:
    dif_list.append(1)
  else:
    dif_list.append(0)
for m in range(len(dif_list)):
   if dif_list[m] == 1:
    result += c_list[a_list[m] -1]
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
result = sum(b_list)
dif_list = []
for i in range(n -1):
  if a_list[i + 1] == a_list[i] + 1:
    dif_list.append(1)
  else:
    dif_list.append(0)
for m in range(len(dif_list)):
  if dif_list[m] == 1:
    result += c_list[m + 1]
print(result)
Problem p02935 (python)

Fixed submission:
n = int(input())
v_list = list(map(int,input().split()))
while len(v_list) >= 3:
  v_list.sort()
  new_v = (v_list[0] + v_list[1]) /2
  v_list.pop(0)
  v_list.pop(0)
  v_list.append(new_v)
print((v_list[0] + v_list[1]) / 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
v_list = list(map(int,input().split()))
while len(v_list) >= 3:
  v_list.sort()
  new_v = (V_list[0] + v_list[1]) /2
  v_list.pop(0)
  v_list.pop(0)
  v_list.append(new_v)
print((v_list[0] + v_list[1]) / 2)
Problem p02990 (python)

Fixed submission:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
for i in range(1,k+1):
    if n - k + 1 >= i:
      print(comb(n - k + 1,i) * comb(k-1,i-1) % (10**9 + 7))
    else:
      print(0)

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
for i in range(1,k+1):
  print(comb(n - k + 1,i) * comb(k-1,i-1) % (10**9 + 7))
Problem p03038 (python)

Fixed submission:
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
b_c_list = []
for i in range(m):
  b_c_list.append(list(map(int,input().split())))

b_c_list.sort(key=lambda x: x[1],reverse = True)
                  
count = 0
d = []
for b_c in b_c_list:
  for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
    if count >= n:
      break
  if count >= n:
    break
    

for i in range(min(n,len(d))):
  if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
    
print(sum(a_list))

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

b_c_list.sort(key=lambda x: x[1],reverse = True)
                  
count = 0
d = []
for b_c in b_c_list:
  for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
  if count == n:
    break
    

for i in range(n):
  if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
    
print(sum(a_list))
Problem p03209 (python)

Fixed submission:
n,x = map(int,input().split())
a_list = [1]
p_list = [1]
for i in range(n):
  a_list.append(a_list[-1] * 2 + 3)
  p_list.append(p_list[-1] * 2 + 1)
def dfs(n,x):
  if x == 1:
    return 0
  if n == 1:
    if x ==2:
      return 1
    if x == 3 :
      return 2
    if x == 4 or x == 5:
      return 3
  elif 1 < x  and x <= a_list[n-1] +1:
    return dfs(n-1,x-1)
  elif x == a_list[n-1] + 2:
    return p_list[n-1] + 1
  elif a_list[n-1] + 2 < x and x <= 2 * a_list[n-1] + 2:
    return p_list[n-1] + 1 + dfs(n-1,x - (a_list[n-1] + 2))
  elif x == 2 * a_list[n-1] + 3:
    return 2 * p_list[n-1] + 1

print(dfs(n,x))

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
a_list = [1]
p_list = [1]
for i in range(n):
  a_list.append(a_list[-1] * 2 + 3)
  p_list.append(p_list[-1] * 2 + 1)
def dfs(n,x):
  if x == 1:
    return 0
  if n == 1:
    if x ==2:
      return 1
    if x == 3 :
      return 2
    if x == 4 or x == 5:
      return 3
  elif 1 < x  and x <= a_list[n-1] +1:
    return dfs(n-1,x-1)
  elif x == a_list[n-1] + 2:
    return p_list[n-1] + 1
  elif a_list[n-1] + 2 < x and x <= 2 * a_list[n-1] + 2:
    return p_list[n-1] + 1 + dfs(n-1,x - (a_list[n-1] + 2))
  elif x == 2 * a_list[i-1] + 3:
    return 2 * p_list[n-1] + 1

print(dfs(n,x))

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
a_list = [1]
p_list = [1]
for i in range(n):
  a_list.append(a_list[-1] * 2 + 3)
  p_list.append(p_list[-1] * 2 + 1)
def dfs(n,x):
  if x == 1:
    return 0
  elif 1 < x  and x <= a_list[n-1] +1:
    return dfs(n-1,x-1)
  elif x == a_list[n-1] + 2:
    return p_list[n-1] + 1
  elif a_list[n-1] + 2 < x and x <= 2 * a_list[n-1] + 2:
    return p_list[n-1] + 1 + dfs(n-1,x - (a_list[n-1] + 2))
  elif x == 2 * a_list[i-1] + 3:
    return 2 * p_list[n-1] + 1

print(dfs(n,x))
Problem p03329 (python)

Fixed submission:
n = int(input())
cand = [1]
for i in range(1,7):
    cand.append(6**i)
for j in range(1,6):
  cand.append(9**j)
cand.sort()
dp = []
for c in cand:
  hoge = []
  for i in range(n+1):
    if i % c == 0:
      hoge.append(i//c)
    else:
      hoge.append(i)
  dp.append(hoge)
for a in range(1,12):
  for b in range(1,n+1):
    if b >= cand[a]:
    	dp[a][b] = min(dp[a-1][b],dp[a][b - cand[a]] + 1)
    else:
      dp[a][b]  = dp[a-1][b]
      
print(dp[-1][n])

Buggy submission (verdict: Runtime Error):
n = input().split()
cand = [1]
for i in range(1,6):
  for j in range(1,7):
    cand.append(6**j)
    cand.append(9**i)
import bisect  
count = 0
cand.sort()
while n > 0:
	index = bisect.bisect_left(cand, n)
    if index != 0
      n = n - cand[index-1]
      count += 1
    else:
      n -= 1
      count += 1
print(count)
Problem p03835 (python)

Fixed submission:
k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
    if 0 <= s-i-m <= k:
      counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
	if 0 <= s -i- m <= k:
      counter+= 1
print(counter)

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
counter = 0
for i in range(k+1):
  for m in range(k+1):
	if 0 <= (s -i- m) <= k:
      counter+= 1
print(counter)
Problem p02659 (python)

Fixed submission:
from math import floor

A, B = input().split()
A = int(A)
B = float(B)
B = round(B*100)
print (A*B // 100)

Buggy submission (verdict: Runtime Error):
1000000000000000 9.99
Problem p02881 (python)

Fixed submission:
from math import sqrt
n = int(input())
minSoFar = 10**12+1

for a in range(1, int(sqrt(n))+1):
    if n % a == 0:
        b = n // a
        minSoFar = min(minSoFar, a+b-2)
print(minSoFar)

Buggy submission (verdict: Runtime Error):
from math import sqrt
from functools import reduce
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*b//gcd(a, b)
n = int(input())
n2 = n
pfs = []
isP = True
i = 2
while i <= int(sqrt(n)):
    while n % i == 0:
        pfs.append(i)
        n //= i
        isP = False
    i += 1
pfs.append(n)
"print (pfs)
if isP:
    ans =  (n2-1)
elif len(pfs) > 2:
    l = reduce(lcm, pfs)
    ans = l-1 + n2//l-1
else:
    ans = pfs[-1]-1 + n2//pfs[-1]-1
print (ans)
Problem p03013 (python)

Fixed submission:
n, m = map(int, raw_input().split())

def solve(n, m):
    dp = [0] * (n + 1)
    ai = 0
    a = -1
    dp[0] = 1
    if ai < m:
        a = int(raw_input())
    if a == 1:
        ai += 1
        if ai < m:
            a = int(raw_input())
        dp[1] = -1
    else:
        dp[1] = 1

    for i in range(2, n+1):
        if i == a:
            ai += 1
            if ai < m:
                a = int(raw_input())
            dp[i] = -1
        else:
            if dp[i-2] != -1:
                dp[i] = dp[i-2]
            if dp[i-1] != -1:
                dp[i] += dp[i-1]
    return dp[n] % (10**9+7)
print solve(n, m)

Buggy submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())
A = [int(raw_input()) for i in range(m)]
def solve(n, A):
  dp = [0] * (n + 1)
  ai = 0
  if ai < len(A) and A[ai] == 1:
    dp[1] = -1
    ai += 1
  else:
    dp[1] = 1
  if ai < len(A) and A[ai] == 2:
    dp[2] = -1
    ai += 1
  elif dp[1] != -1:
    dp[2] = 2
  else:
    dp[2] = 1
  for i in range(3, n + 1):
    if ai < len(A) and A[ai] == i:
      dp[i] = -1
      ai += 1
      continue
    if dp[i-2] != -1:
      dp[i] = dp[i-2] 
    if dp[i-1] != -1:
      dp[i] += dp[i-1]
  return dp[n] % (10**9+7)
print solve(n, A)
Problem p03137 (python)

Fixed submission:
from heapq import heapify, heappop, heappush, nsmallest
n, m = map(int, raw_input().split())
X = map(int, raw_input().split())
X.sort()
if m == 1:
    print 0
    exit()
elif n == 1:
    print X[-1] - X[0]
    exit()
heap = []
heapify(heap)
for i in range(1, m):
    diff = X[i] - X[i-1]
    if len(heap) >= n - 1 and heap[0][0] < diff:
        heappop(heap)
        heappush(heap, (diff, X[i-1], X[i]))
    elif len(heap) < n - 1:
        heappush(heap, (diff, X[i-1], X[i]))
    else:
        continue
heap.sort(key=lambda X : X[1])
cp = X[0]
move = 0
for j in range(len(heap)):
    diff, left, right = heap[j]
    move += left - cp
    cp = right
move += (X[-1] - cp)
print move

Buggy submission (verdict: Runtime Error):
from heapq import heapify, heappop, heappush, nsmallest
n, m = map(int, raw_input().split())
X = map(int, raw_input().split())
X.sort()
heap = []
for i in range(1, m):
    diff = X[i] - X[i-1]
    if len(heap) >= n - 1 and nsmallest(1, heap)[0][0] < diff:
        heappop(heap)
        heappush(heap, (diff, X[i-1], X[i]))
    elif len(heap) < n - 1:
        heappush(heap, (diff, X[i-1], X[i]))
    else:
        continue
heap.sort(key=lambda X : X[1])
cp = X[0]
move = 0
for j in range(len(heap)):
    diff, left, right = heap[j]
    move += left - cp
    cp = right
move += (X[-1] - cp)
print move
Problem p02990 (python)

Fixed submission:
import numpy as np

global mod
mod = 10 ** 9 + 7

def mpow(x, n):  # x^nをmod取りながら返す
    ans = 1
    while n != 0:
        if n & 1:
            ans = ans * x % mod
        x = x * x % mod
        n = n >> 1

    return ans

n, k = map(int, input().split())

ai = n - k + 1
print(ai)

for i in range(2, k +1):
    if n - k + 1 < i:
        print(0)
        continue

    ai = ai * (n - k - i + 2) * (k - i + 1) % mod
    ai = ai * mpow(i*(i-1), mod-2) % mod

    print(ai)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10 ** 9 + 7

ai = n - k + 1
print(ai)

for i in range(2, k +1):
    if n - k + 1 < i:
        print(0)
        continue

    ai = int(ai * (n - k - i + 2) * (k - i + 1) / (i * (i - 1)))
    print(ai % mod)
Problem p03038 (python)

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

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

X = []

for i in range(0, M):
    B, C = map(int, input().split())
    X.append([C, B])

X.sort(reverse=True)

A.sort()

index = 0
l = 0
a = 0
k = X[a][0]

while index < N and a < M and A[index] < k:
    A[index] = k;
    index += 1;
    l += 1;
    if(l == X[a][1]):
        a += 1
        if a >= M:
            break
        k = X[a][0]
        l = 0

print(sum(A))

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

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

X = []

for i in range(0, M):
    B, C = map(int, input().split())
    X.append([C, B])

X.sort(reverse=True)

A.sort()

index = 0
l = 0
a = 0
k = X[a][0]

while A[index] < k and index < N and a < M:
    A[index] = k;
    index += 1;
    l += 1;
    if(l == X[a][1]):
        a += 1
        if a >= M:
            break
        k = X[a][0]
        l = 0

print(sum(A))
Problem p02623 (python)

Fixed submission:
N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta - 1 >= 0:
    ta -= int(A[cnta - 1])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta >= 0:
    ta -= int(A[cnta])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)
Problem p02629 (python)

Fixed submission:
n = int(input())
ans = ""
while n > 0:
    re = n % 26
    if re != 0:
        ans = chr(ord('a') + (re - 1)) + ans
        n = n // 26
    else:
        ans = 'z' + ans;
        n = n // 26 - 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = ""
while n > 0:
    re = n % 26
    if re != 0:
        ans = chr(ord('a') + (re - 1)) + ans
        n = n // 26
    else:
        ans = 'z' + ans;
        n = n / 26 - 1
print(ans)
Problem p02711 (python)

Fixed submission:
N=int(input(""))
if N % 10 == 7 or (N - N % 10) / 10 % 10 == 7 or (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(Input(""))
if N % 10 == 7 || (N - N % 10) / 10 % 10 == 7 || (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=Input("")
if N % 10 == 7 || (N - N % 10) / 10 % 10 == 7 || (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")
Problem p02771 (python)

Fixed submission:
x=input()
y=x.split()

if y[0] == y[1] :
    if y[0] == y[2]:
        print("No")
    else:
        print("Yes")
elif y[0] == y[2] :
    print("Yes")
elif y[2] == y[1] :
        print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x=input()
y=x.split()

if y[0] == y[1] :
    if y[0] == y[2]:
        print("No")
    else:
        print("Yes")
elif y[0] == y[2] :
    print("Yes")
elif y[2] == y[1] :
        print("Yes")
else:
    print("No)

Buggy submission (verdict: Runtime Error):
x=input()
y=x.split()
if y[0] = y[1] :
    if y[0] = y[2]:
        print("No")
    else:
        print("Yes")
elif y[2] = y[1] :
        print("Yes")

Buggy submission (verdict: Runtime Error):
x=input()
y=x.split("  ")
if y[0] = y[1] :
    if y[0] = y[2]:
        print("No")
    else:
        print("Yes")
elif y[2] = y[1] :
        print("Yes")
Problem p02596 (python)

Fixed submission:
n = int(input())
flag = True
a = 7
for i in range(n):
  if a % n == 0:
    print(i+1)
    flag = False
    break
  a = (10*a + 7)%n
if flag:
	print(-1)

Buggy submission (verdict: Runtime Error):
n = input()
if n%2==0 or n%5==0:
  print(-1)
else:
  i = len(str(n))
  seven = int(i*"7")
  while seven % n != 0:
    i += 1
    seven = int(i*"7")
    if i > 100:
      break
  print(i)
Problem p03013 (python)

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

if M == 0:
    a = [-1]

inf = 1000000007
index = 0
n_way = [0 for i in range(N+2)]
n_way[0] = 1

for i in range(N):
    if a[index] == i:
        index += 1
        index = min(index,len(a)-1)
    else:
        n_way[i+1] += n_way[i]
        n_way[i+1] = n_way[i+1]%inf
        n_way[i+2] += n_way[i]
        n_way[i+2] = n_way[i+2]%inf

print(n_way[N])

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

inf = 1000000007
index = 0
n_way = [0 for i in range(N+2)]
n_way[0] = 1

for i in range(N):
    if a[index] == i:
        index += 1
        index = min(index,len(a)-1)
    else:
        n_way[i+1] += n_way[i]
        n_way[i+1] = n_way[i+1]%inf
        n_way[i+2] += n_way[i]
        n_way[i+2] = n_way[i+2]%inf

print(n_way[N])
Problem p03038 (python)

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

CB.sort(reverse=True)

cnt = 0
goukei = 0
flag = True
flag2 = False
for i in range(M):
    Bi,Ci = CB[i][1],CB[i][0]
    # Bi = min(Bi,N-cnt-1)
    if Bi+cnt >= N:
        Bi = N-cnt-1
        flag2 = True

    if sortedA[cnt+Bi] <= Ci:
        if flag2:
            cnt += Bi
            goukei += (Bi+1)*Ci
            flag = False
            break
        else:
            cnt += Bi
            goukei += Bi*Ci
    elif sortedA[cnt] >= Ci:
        goukei += sum(sortedA[cnt:])
        flag = False
        break
    else:
        for x in sortedA[cnt:cnt+Bi+1]:
            if x <= Ci:
                goukei += Ci
            else:
                goukei += x
        goukei += sum(sortedA[cnt+Bi+1:])
        flag = False
        break
if flag:
  goukei += sum(sortedA[cnt:])

print(goukei)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
sortedA = sorted(A)
CB = []
for i in range(M):
    B,C = map(int,input().split())
    CB.append([C,B])

CB.sort(reverse=True)

cnt = 0
goukei = 0
flag = True
flag2 = False
for i in range(M):
    Bi,Ci = CB[i][1],CB[i][0]
    # Bi = min(Bi,N-cnt-1)
    if Bi+cnt >= N:
        Bi = N-cnt-1
        flag2 = True
            
    if sortedA[cnt+Bi] <= Ci:
        if flag2:
            cnt += Bi+1
            goukei += (Bi+1)*Ci
        else:
            cnt += Bi
            goukei += Bi*Ci
    elif sortedA[cnt] >= Ci:
        goukei += sum(sortedA[cnt:])
        flag = False
        break
    else:
        for x in sortedA[cnt:cnt+Bi+1]:
            if x <= Ci:
                goukei += Ci
            else:
                goukei += x
        goukei += sum(sortedA[cnt+Bi+1:])
        flag = False
        break
if flag:
  goukei += sum(sortedA[cnt:])

print(goukei)
Problem p02659 (python)

Fixed submission:
a = input().split()
for i in range(2):
    a[i] = int(a[i]) if i == 0 else round(float(a[i])*100)
print(int(a[0] * a[1] // 100))

Buggy submission (verdict: Runtime Error):
a = input().split()
for i in range(2):
    a[i] = int(a[i]) if i == 0 else float(a[i]*100)
print(int(a[0] * a[1] / 100))

Buggy submission (verdict: Runtime Error):
#A, B = map(float, input().split())
a = input().split()
for i in range(2):
    a[i] = int(a[i]) if i == 0 else float(a[i]*100)
print(int(a[0] * a[1] / 100))
#print(type(a[0]))
#print(type(a[1]))
Problem p02915 (python)

Fixed submission:
def main():
  n = int(input())
  print(n**3)
 
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
main():
  n = int(input())
  print(n**3)

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

Fixed submission:
k = int(input())
power = 0
cnt = 1
if k == 1 or k == 7:
  print(1)
elif k%2 == 0 or k%5 == 0:
  print(-1)
elif k%7 == 0:
  l = 9*k/7
  a = 1
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+= 1
  print(cnt)
else:
  a = 1
  l = 9*k
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+=1
  print(cnt)

Buggy submission (verdict: Runtime Error):
k = int(input())
power = 0
cnt = 1
if k == 1 or k == 7:
  print(1)
elif k%2 == 0 or k%5 == 0:
  print(-1)
elif k%7 == 0:
  l = k/7
  a = 1
  while(true):
    a = (10*a)%l
    if a == 1:
      break
    cnt+= 1
  print(cnt)
else:
  a = 1
  l = 9*k
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+=1
  print(cnt)

Buggy submission (verdict: Runtime Error):
k = int(input())
power = 0
cnt = 1
if k == 1:
  print(1)
elif k%2 == 0 or k%5 == 0:
  print(-1)
elif k%7 == 0:
  l = k/7
  a = 1
  while(true):
    a = (10*a)%l
    if a == 1:
      break
    cnt+= 1
  print(cnt)
else:
  a = 1
  l = 9*k
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+=1
  print(cnt)