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

Fixed submission:
from collections import defaultdict
from math import gcd

N = int(input())
MOD = 1000000007
d = defaultdict(int)
num_00 = 0
pow2 = [1]
for i in range(N):
  pow2.append((pow2[-1] * 2) % MOD)

def to_idx(a, b):
  if a == 0 and b != 0:
    return ((0, -1), (0, 1))
  elif a != 0 and b == 0:
    return ((-1, 0), (1, 0))
  else:
    return tuple(sorted(((a, b), (-a, -b))))

ans = 0
for i in range(N):
  a, b = map(int, input().split())
  if a*b == 0 and a != b:
    d[to_idx(a, b)] += 1
  elif a == b == 0:
    num_00 += 1
  else:
    g = gcd(a, b)
    a //= g; b //= g
    d[to_idx(a, b)] += 1

memo = []
key_set = set(d.keys())
while key_set:
  k = key_set.pop()
  v1, v2 = k
  a, b = v1
  idx = to_idx(-b, a)
  memo.append((pow2[d[k]] + pow2[d[idx]] - 1) % MOD)
  key_set.discard(idx)

ans = 1
for m in memo:
  ans *= m
  ans %= MOD

print((ans - 1 + num_00) % MOD)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from math import gcd

N = int(input())
MOD = 1000000007
d = defaultdict(int)
pow2 = [1]
for i in  range(N):
  pow2.append(pow2[-1] * 2 % MOD)

def to_idx(a, b):
  return tuple(sorted(((a, b), (-a, -b))))

ans = 0
for i in range(N):
  a, b = map(int, input().split())
  g = gcd(a, b)
  a //= g; b //= g
  d[to_idx(a, b)] += 1

memo = []
key_set = set(d.keys())
while key_set:
  k = key_set.pop()
  v1, v2 = k
  a, b = v1
  idx = to_idx(-b, a)
  memo.append((pow2[d[k]] + pow2[d[idx]] - 1) % MOD)
  key_set.discard(idx)

ans = 1
for m in memo:
  ans *= m
  ans %= MOD

print((ans - 1) % MOD)
Problem p02766 (python)

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

digit = 0
k = K
while N:
  r = N % k
  N -= r
  k *= K
  digit += 1

print(digit)

Buggy submission (verdict: Runtime Error):
import math


N, K = map(int, input().split())

ans = math.floar(1 + math.log(N)/math.log(K))
print(ans)
Problem p02851 (python)

Fixed submission:
M, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
accum = [0]
d = {0 : 1}

for i, a in enumerate(A):
  accum.append((accum[-1] + a - 1)%K)
  if i >= K - 1:
    d[accum[i-K+1]] -= 1
  
  if accum[-1] in d:
    ans += d[accum[-1]]
    d[accum[-1]] += 1
  
  else:
    d[accum[-1]] = 1

print(ans)

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

M, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
accum = np.array([], dtype=int)
for i, a in enumerate(A):
  accum += a
  accum = np.r_[accum, a]
  ans += sum((accum % K) == np.arange(i+1, 0, -1))

print(ans)
Problem p02891 (python)

Fixed submission:
S = list(input())
N = len(S)
K = int(input())
if N == 1:
  print(K//2)
  quit()

S = S + S + S
ans_first = ans_odd = ans_even = 0
for i in range(1, N):
  pre_s = S[i-1]
  s = S[i]
  if s == pre_s:
    ans_first += 1
    S[i] = '#'

for i in range(N, 2*N):
  pre_s = S[i-1]
  s = S[i]
  if s == pre_s:
    ans_even += 1
    S[i] = '#'

for i in range(2*N, 3*N):
  pre_s = S[i-1]
  s = S[i]
  if s == pre_s:
    ans_odd += 1
    S[i] = '#'

k_even = K // 2
k_odd = K - k_even - 1
print(ans_first + k_odd*ans_odd + k_even*ans_even)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())

ans = 0
for i in range(1, len(S)):
  pre_s = S[i-1]
  s = S[i]
  if s == pre_s:
    S[i] = '#'
    ans += 1

if S[1] == '#' and len(S) >= 3 and S[0] != S[2]:
  S[0], S[1] = S[1], S[0]

ans *= K
if S[0] == S[-1]:
  ans += K - 1

print(ans)
Problem p02916 (python)

Fixed submission:
import numpy as np
 
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
r = np.sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i + 1]:
    r += C[A[i]-1]

print(r)

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

r = np.sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i + 1]:
    r += C[A[i]]

print(r)
Problem p02964 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

first = [0] * (N+1)
follow_idx = [-1] * (N+1)
d = {}
for i, a in enumerate(A[::-1]):
  j = N - 1 - i
  if a in d:
    idx = d[a][-1]
    d[a].append(j)
    if first[idx + 1] < 0:
      first[j] = first[idx + 1]
      follow_idx[j] = follow_idx[idx + 1]
    else:
      first[j] = -first[idx + 1]
      follow_idx[j] = idx + 1
  else:
    first[j] = a
    d[a] = [j]
    follow_idx[j] = j + 1


indices = [-1]
s0 = first[0]
if s0 >= 0:
  indices.append(0)
else:
  s0 = -s0
  indices.append(follow_idx[0])
    
if s0 == 0:
  print('')
  quit()

d2 = {0:0, s0:1}
for k in range(2, K+1):
  idx = d[s0][-1] + 1
  s0 = first[idx]
  if s0 >= 0:
    indices.append(idx)
  else:
    s0 = -s0
    indices.append(follow_idx[idx])
  if s0 in d2:
    break
  d2[s0] = k

if len(indices) < K:
  K = d2[s0] + (K - d2[s0]) % (k - d2[s0])

if K == 0:
  print('')
  quit()

ans = []
idx = indices[K]
while idx < N:
  s = first[idx]
  if s > 0:
    ans.append(s)
  idx = follow_idx[idx]

print(*ans)

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

remain = [''] * (N+1) # 一番後ろは番兵
d = {}
for i, a in enumerate(A[::-1]):
  j = N - 1 - i
  if a in d:
    idx = d[a][-1]
    remain[j] = remain[idx+1]
    d[a].append(j)
  else:
    remain[j] = str(a) + ' ' + remain[j+1]
    d[a] = [j]

cands = []
idx = 0
for k in range(1, K+1):
  S = remain[idx]
  cands.append(S)
  if S == '':
    break
  s = int(S.split()[0])
  idx = d[s][-1] + 1

K = K % k
print(cands[K-1])

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

remain = [''] * (N+1) # 一番後ろは番兵
d = {}
for i, a in enumerate(A[::-1]):
  j = N - 1 - i
  if a in d:
    idx = d[a][-1]
    remain[j] = remain[idx+1]
    d[a].append(j)
  else:
    remain[j] = str(a) + remain[j+1]
    d[a] = [j]

cands = []
idx = 0
for k in range(1, K+1):
  S = remain[idx]
  cands.append(S)
  if S == '':
    break
  s = int(S[0])
  idx = d[s][-1] + 1

K = K % k
print(' '.join(cands[K-1]))
Problem p02990 (python)

Fixed submission:
mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
R = N - K
for i in range(1, K+1):
  print(comb(K-1, i-1, mod)*comb(R+1, i, mod) % mod)

Buggy submission (verdict: Runtime Error):
mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
 
 
def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
R = N - K

ans = [0]*K
if R == 0:
  ans[0] = 1
elif R == 1:
  ans[0] = 2
  if K >= 2:
    ans[1] = (K-1) % mod
elif R == 2:
  ans[0] = 3
  if K >= 2:
    ans[1] = (3*K - 3) % mod
    if K >= 3:
      ans[2] = (K-1)*(K-2)//2 % mod
else:
  ans[0] = R + 1
  if K >= 2:
    if R > K:
      for i in range(2, K+1):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)+comb(R-1, i)) % mod
    else:
      for i in range(2, R):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)+comb(R-1, i)) % mod
      for i in range(R, K+1):
        ans[i-1] = comb(K-1, i-1)*(comb(R-1, i-2)+2*comb(R-1, i-1)) % mod

for a in ans:
  print(a)

Buggy submission (verdict: Runtime Error):
mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

N, K = map(int, input().split())
R = N - K
for i in range(1, K+1):
  print(comb(K-1, i-1)*comb(R+1, i) % mod)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
x = [1] + [0] * N
broken = [False] * (N+1)
mod = 10**9 + 7

for i in range(M):
  a = int(input())
  broken[a] = True

if not broken[1]:
  x[1] = 1

for i in range(2, N+1):
  if broken[i]:
    continue
  
  x[i] = (x[i-1] + x[i-2]) % mod

print(x[N])

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

A = []
for i in range(M):
  A.append(int(input()))

A.sort()
ida = 0
a = A[ida]
mod = 10**9 + 7

x = [1] + [0]*N
if a == 1:
  ida += 1
  if M >= 2:
    a = A[ida]
  else:
    x[1] = 1

for i in range(2, N+1):
  if i == a:
    ida += 1
    if ida >= M:
      a = N+1
    else:
      a = A[ida]
  
    x[i] = 0
  else:
    x[i] = (x[i-1] + x[i-2]) % mod

print(x[N])
Problem p03015 (python)

Fixed submission:
MOD = 10**9 + 7
L = input()[1:]

ans = [2, 1]
for l in L:
  ans[1] *= 3
  ans[1] %= MOD
  if l == '1':
    ans[1] += ans[0]
    ans[0] *= 2
    ans[0] %= MOD

print(sum(ans) % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
L = input()[::-1]

ans = [1]
for l in L:
  if l == '1':
    if len(ans) == 1:
      ans[0] *= 3
      ans[0] %= MOD
    else:
      ans = [sum(ans) % MOD]
  
  else:
    if len(ans) == 1:
      a = ans[0]
      ans = [a, a, a*3%MOD]
    else:
      a[2] *= 3
      a[2] %= MOD

print(ans[0])
Problem p03033 (python)

Fixed submission:
import sys
from heapq import heappop, heappush

input = sys.stdin.readline
N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

for i in range(Q):
  event_list.append([int(input()), 2, 0])

ans = []
event_list.sort()
x_set = set()
x_list = []
for time, event, x in event_list:
  if event == 1:
    x_set.add(x)
    heappush(x_list, x)
  elif event == -1:
    x_set.remove(x)
  else:
    while x_list and x_list[0] not in x_set:
      heappop(x_list)
    if x_list:
      ans.append(x_list[0])
    else:
      ans.append(-1)

print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
import heapq


N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

event_list.sort()
event_list.append([10**10, 1, 10**10])
i = 0
x_set = set()
x_list = []
time = 0
for q in range(Q):
  d = int(input())
  while time <= d:
    time, event, x = event_list[i]
    if time <= d:
      if event == 1:
        x_set.add(x)
        heapq.heappush(x_list, x)
      else:
        x_set.remove(x)
      i += 1
  
  while x_list and x_list[0] not in x_set:
    _ = heapq.heappop(x_list)
  if x_list:
    prin(x_list[0])
  else:
    print(-1)
Problem p03038 (python)

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

CB = []
for i in range(M):
  b, c = map(int, input().split())
  CB.append([c, b])

D = [[a, 1] for a in A] + CB

D.sort()

ans = 0
while N > 0:
  c, b = D.pop()
  ans += min(N, b)*c
  N -= b

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
heapq.heapify(A)

CB = []
for i in range(M):
  b, c = map(int, input().split())
  CB.append([c, b])

CB.sort()
D = []
for c, b in CB:
  D += [c]*b

for i in range(N):
  d = D.pop()
  g = heapq.heappushpop(A, d)
  if d == g:
    break

print(sum(A))
Problem p03135 (python)

Fixed submission:
T, X = map(int, input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
T, X = map(int, input().split()))
print(T/X)
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
v1 = [x2 - x1, y2 - y1]
v = [-v1[1], v1[0]]

x3, y3 = x2 + v[0], y2 + v[1]
x4, y4 = x1 + v[0], y1 + v[1]

print(x3, y3, x4, y4)

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
if x1 == x2:
  if y1 < y2:
    d = y2 - y1
    x3, y3 = x2-d, y2
    x4, y4 = x1-d, y1
  else:
    d = y1 - y2
    x3, y3 = x2+d, y2
    x4, y4 = x1+d, y1
else:
  if x1 < x2:
    d = x2 - x1
    x3, y3 = x2, y2+d
    x4, y4 = x1, y1+d
  else:
    x3, y3 = x2, y2-d
    x4, y4 = x1, y1-d

print(x3, y3, x4, y4)
Problem p03776 (python)

Fixed submission:
comb_memo = {}
def comb(n, r):
  global comb_memo
  if (n, r) in comb_memo:
    return comb_memo[(n, r)]
  else:
    r = min(r, n-r)
    res = 1
    for _ in range(r):
      res *= n
      n -= 1
    for i in range(1, r+1):
      res //= i
    comb_memo[(n, r)] = res
    comb_memo[(n, n-r)] = res
    return res

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

mu = sum(v[:A]) / A
ans = 0
if v[0] == mu:
  R = v.count(v[0])
  for i in range(A, B+1):
    if i > R:
      break
    ans += comb(R, i)
else:
  min_v = v[A-1]
  n = v.count(min_v)
  need = v[:A].count(min_v)
  ans += comb(n, need)

print(mu)
print(ans)

Buggy submission (verdict: Runtime Error):
comb_memo = {}
def comb(n, r):
  global comb_memo
  if (n, r) in comb_memo:
    return comb_memo[(n, r)]
  else:
    r = min(r, n-r)
    res = 1
    for _ in range(r):
      res *= n
      n -= 1
    for i in range(1, r+1):
      res //= i
    comb_memo[(n, r)] = res
    comb_memo[(n, n-r)] = res
    return res

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

mu = sum(v[:A]) / A
if v[0] == mu:
  R = v.count(v[0])

ans = 0
if R > A:
  for i in range(A, B+1):
    if i > R:
      break
    ans += comb(R, i)
else:
  min_v = v[A-1]
  n = v.count(min_v)
  need = v[:A].count(min_v)
  ans += comb(n, need)

print(mu)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

f_memo = {0:1, 1:1}
def f(x):
  global f_memo
  if x in f_memo:
    return f_memo[x]
  else:
    res = x * f(x-1)
    f_memo[x] = res
    return res

comb_memo = {}
def comb(n, r):
  global comb_memo
  if (n, r) in comb_memo:
    return comb_memo[(n, r)]
  else:
    a = f(n)
    b = f(n-r)
    c = f(r)
    res = a // b // c
    comb_memo[(n, r)] = res
    return res


N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

mu = sum(v[:A]) / A
R = A-1
for i in range(A, N):
  if v[i] == mu:
    R = i
  else:
    break

R += 1
ans = 0
if R > A:
  for i in range(A, B+1):
    ans += comb(R, i)
else:
  min_v = v[A-1]
  n = v.count(min_v)
  need = v[:A].count(min_v)
  ans += comb(n, need)

print(mu)
print(ans)

Buggy submission (verdict: Runtime Error):
f_memo = {0:1, 1:1}
def f(x):
  global f_memo
  if x in f_memo:
    return f_memo[x]
  else:
    res = x * f(x-1)
    f_memo[x] = res
    return res

comb_memo = {}
def comb(n, r):
  global comb_memo
  if (n, r) in comb_memo:
    return comb_memo[(n, r)]
  else:
    a = f(n)
    b = f(n-r)
    c = f(r)
    res = a // b // c
    comb_memo[(n, r)] = res
    return res


N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

mu = sum(v[:A]) / A
R = A-1
for i in range(A, N):
  if v[i] == mu:
    R = i
  else:
    break

R += 1
ans = 0
if R > A:
  for i in range(A, B+1):
    ans += comb(R, i)
else:
  min_v = v[A-1]
  n = v.count(min_v)
  need = v[:A].count(min_v)
  ans += comb(n, need)

print(mu)
print(ans)
Problem p03011 (python)

Fixed submission:
#coding: utf-8

line = input()
arr = []
for i in range(3):
	arr.append(int(line.split()[i]))
ans = sum(arr) - max(arr)
print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
def factorial(n):
	output = 1
	for i in range(1,n+1):
		output = output*i
	return output

def diff(w, sign, N):
	diff = 0
	for i in range(N):
		diff = diff + w[i]*sign[i]
	return abs(diff)

def target(sign, cnt, N, factwo):
	num = cnt
	for i in reversed(range(N)):
		temp = num - factwo[i]
		if(temp >= 0):
			sign[i] = 1
		else:
			sign[i] = -1
		num = temp

N = int(input())
#N = 8
line = input()
#line = '27 23 76 2 3 5 62 52'
w = []
sign = []
factwo = []
for i in range(N):
	factwo.append(2**i)

for i in range(N):
	w.append(int(line.split()[i]))
	sign.append(1)

cnt = 0
temp = diff(w, sign, N)

while(cnt<factorial(N)):
	target(sign, cnt, N, factwo)
	x = diff(w, sign, N)
	if(temp > x):
		temp = x
	cnt = cnt + 1
	if(diff == 0):
		break

print(temp)

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

line = input()
for i in range(3):
	arr.append(int(line.split()[i]))
ans = sum(arr) - max(arr)
print(ans)
Problem p02633 (python)

Fixed submission:
X = int(input())

eikaku = X if X < 180 else X - 180
cnt = 0

ans = 0
while True:
    ans += 1
    cnt += eikaku
    if cnt % 360 == 0:
        print(ans)
        break

Buggy submission (verdict: Runtime Error):
X = int(input())
rad = 90
cnt = 0

while True:
    cnt += 1
    if rad==360:
        break
    else:
        rad += X
        rad = rad if rad < 360 else rad = 360

print(cnt)
Problem p02659 (python)

Fixed submission:
from math import ceil, floor, modf

A, B = input().split()
A = int(A)

B1 = int(B[:-3])
B2 = int(str(B)[-2:])

ans1 = A * B1
ans2 = A * B2 // 100

ans = ans1 + ans2
print(floor(ans))

Buggy submission (verdict: Runtime Error):
from math import ceil, floor
from decimal import Decimal

A, B = input().split()
A = int(A)
B = float(B)
B1 = int(B)
B2 = int(str(B)[-2:])

ans1 = Decimal(A) * Decimal(B1)
ans2 = Decimal(A) * Decimal(B2) // 100

ans = ans1 + ans2
print(ans)
Problem p02912 (python)

Fixed submission:
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Buggy submission (verdict: Runtime Error):
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = heapify([-i for i in map(int,input().split())])

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

for _ in range(M):
    A[0] = int(A[0]/2)
    if A[0]<A[1]:
        A = sorted(A, reverse=True)

print(sum(A))
Problem p02959 (python)

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

ans, kurikosi = 0, 0
for i in range(n+1):
    if i != n:
        ans += min(a[i], kurikosi+b[i])
        if a[i]<=kurikosi:
            kurikosi = b[i]
        elif kurikosi < a[i] <= kurikosi+b[i]:
            kurikosi = kurikosi+b[i] - a[i]
        else:
            kurikosi = 0
    else:
        ans += min(kurikosi, a[i])

print(ans)

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

ans, kurikosi = 0, 0
for i in range(n+1):
    if a[i]<=kurikosi:
        ans += a[i]
        kurikosi = b[i]
    elif kurikosi < a[i] <= kurikosi+b[i]:
        ans += a[i]
        kurikosi = kurikosi+b[i] - a[i]
    else:
        ans += a[i] - (kurikosi+b[i])
        kurikosi = 0

print(ans)
Problem p03011 (python)

Fixed submission:
list_ = sorted(list(map(int, input().split())))
print(list_[0]+list_[1])

Buggy submission (verdict: Runtime Error):
p, q, r = list(map(int, input().split()))
list_ = sorted(list_)

print(list_[0]+list_[1])
Problem p03038 (python)

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

dic = {}
for i in range(N):
    tmp = A[i]
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1

for _ in range(M):
    B, C = map(int, input().split())
    if C in dic:
        dic[C] += B
    else:
        dic[C] = B

dic = sorted(dic.items(), reverse=True)

ans, cnt = 0, 0
i = 0
while True:
    k, v = dic[i]
    cnt += v
    if cnt < N:
        ans += k*v
    elif cnt == N:
        ans += k*v
        break
    else:
        ans += k*(v - (cnt-N))
        break
    i += 1

print(ans)

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

bc = {}
for _ in range(M):
    B, C = map(int, input().split())
    if C in bc:
        bc[C] += B
    else:
        bc[C] = B

bc = sorted(bc.items(), reverse=True)
BC = []

for k, v in bc:
    BC.extend([k]*v)

for i in range(min(N, len(BC))):
    a = A[i]
    b = BC[i]
    A[i] = max(a, b)

print(sum(A))
Problem p02557 (python)

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

l = []
num = -1
for i in range(n):
    if a[i] == b[i]:
        l.append(i)
        num = a[i]

ind = 0
for i in range(n):
    if b[i] != num and a[i] != num and ind < len(l):
        b[i],b[l[ind]] = b[l[ind]],b[i]
        ind += 1
if ind < len(l):
    print("No")
else:
    print("Yes")
    print(*b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ca = [0]*(n+1)
cb = [0]*(n+1)
for i in a:
    ca[i] += 1
for i in b:
    cb[i] += 1
ma = 0
ind = -1
for i in range(n+1):

    if ca[i]+cb[i]> ma:
        ma = ca[i]+cb[i]
        ind = i
    if ma > n:
        print("No")
        exit()

print("Yes")
ans = [-1]*n
l = a.index(ind)+ca[ind]
s = b.index(ind)
for i in range(s,s+n):
    ans[(l+i)%n] = b[i%n]
print(*ans)