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

Fixed submission:
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a_reverse = a[::-1]
mod = 10**9+7
 
factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))
 
def comb(n, r, mod):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

plus = 0
minus = 0
cnt = 0
ind = 0
for i in range(n-k+1):
    kaisu = comb(n-i-1, k-1, mod)
    plus = (plus + (kaisu * a_reverse[ind]) % mod) % mod
    minus = (minus + (kaisu * a[ind]) % mod) % mod
    ind += 1

print((plus-minus) % mod)

Buggy submission (verdict: Runtime Error):
import math

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

mod = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
a_reverse = a[::-1]

plus = 0
minus = 0
cnt = 0
ind = 0
ceil = nCr(n, k)
kaisu = nCr(n, k-1)
while cnt < ceil:
    kaisu = int(kaisu * ((n-ind)-(k-1)) / (n-ind))
    cnt += kaisu
    plus = plus + kaisu * a_reverse[ind]
    minus = minus + kaisu * a[ind]
    ind += 1

print((plus-minus) % mod)

Buggy submission (verdict: Runtime Error):
import math

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

mod = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
a_reverse = a[::-1]

plus = 0
minus = 0
cnt = 0
ind = 0
ceil = nCr(n, k)
kaisu = nCr(n, k-1)
while cnt < ceil:
    kaisu = int(kaisu * ((n-ind)-(k-1)) / (n-ind))
    cnt += kaisu
    plus = plus + kaisu * a_reverse[ind]
    minus = minus + kaisu * a[ind]
    ind += 1

print((plus-minus) % mod)
Problem p02929 (python)

Fixed submission:
mod = 10**9 + 7
n = int(input())
s = input()

crr = 0
lst= []
for i in range(2*n):
    if s[i] == 'B':
        if crr%2 == 1:
            lst.append(-1)
            crr -= 1
        else:
            lst.append(1)
            crr += 1
    else:
        if crr%2 == 1:
            lst.append(1)
            crr += 1
        else:
            lst.append(-1)
            crr -= 1

if crr!=0 or lst[0]!=1 or lst[-1]!=-1:
    print(0)
    exit()

plus = []
pcnt = 0
minus = []
mcnt = 0
where = []
for i in range(2*n):
    if lst[i] == 1:
        pcnt += 1
    else:
        mcnt += 1
        where.append(i)
    plus.append(pcnt)
    minus.append(mcnt)

ans = 1
for i in where:
    ans *= plus[i] - minus[i] + 1
    ans %= mod

for i in range(1, n+1):
    ans *= i
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
baai = 0

def hanten(string):
    ans = ''
    for i in range(len(string)):
        if string[i] == 'B':
            ans += 'W'
        else:
            ans += 'B'
    return ans

def saiki(string, baai):
    if string == 'BB':
        return baai + 1
    elif string[0] == 'B':
        for i in range(1, len(string)):
            if i % 2 == 1 and string[i] == 'B':
                new_string = hanten(string[1:i]) + string[i+1:]
                baai = saiki(new_string, baai)
            elif i % 2 == 0 and string[i] == 'W':
                new_string = hanten(string[1:i]) + string[i+1:]
                baai = saiki(new_string, baai)
    else:
        return baai
    return baai

baai = saiki(s, 0)

ans = 1
for i in range(1, n+1):
    ans *= i
    ans = ans % (10**9+7)

ans = ans * baai % (10**9+7)
print(ans)
Problem p02936 (python)

Fixed submission:
n, q = map(int, input().split())
edges=[[] for i in range(n+1)]
for i in range(1,n):
	a, b=[int(i) for i in input().split()]
	edges[a].append(b)
	edges[b].append(a)
c = [0 for i in range(n+1)]
for i in range(q):
    p, x = map(int, input().split())
    c[p] += x

ind = [0 for i in range(n+1)]
ind[1] = 1
nxt = [1]
nxt_copy = []
while nxt != []:
    for i in nxt:
        for j in edges[i]:
            if ind[j] == 0:
                ind[j] = 1
                c[j] += c[i]
                nxt_copy.append(j)
    nxt = nxt_copy.copy()
    nxt_copy = []

c.pop(0)
print(' '.join(map(str, c)))

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

n, q = map(int, input().split())
edges=[[] for i in range(n+1)]
d_from_1=[-1 for i in range(n+1)]
ans = [0 for i in range(n+1)]

for i in range(1,n):
	a, b=[int(i) for i in input().split()]
	edges[a].append([b,1])
	edges[b].append([a,1])
def kyori_from_1(u):
	for v,w in edges[u]:
		if d_from_1[v]==-1:
			d_from_1[v]=d_from_1[u]+w
			kyori_from_1(v)

d_from_1[1]=0
kyori_from_1(1)

px = []
for i in range(q):
    p, x = map(int, input().split())
    px.append([p, x])


d_from_p = [-1 for i in range(n+1)]
def kyori_from_p(u):
	for v,w in edges[u]:
		if d_from_p[v]==-1:
			d_from_p[v]=d_from_p[u]+w
			kyori_from_p(v)

for i in range(q):
    d_from_p = [-1 for i in range(n+1)]
    d_from_p[px[i][0]] = 0
    kyori_from_p(px[i][0])
    for j in range(1, n+1):
        if px[i][0] == 1:
            ans[j] += px[i][1]
        elif d_from_1[j] >= d_from_1[px[i][0]] and d_from_p[j] < d_from_1[j]:
            ans[j] += px[i][1]

ans.pop(0)
print(' '.join(map(str, ans)))
Problem p02960 (python)

Fixed submission:
s = input()
s = s[::-1]
n = len(s)
mod = 10**9 + 7

dp = [[0 for j in range(13)] for i in range(n)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    num = int(s[0])
    dp[0][num] = 1

mul = 1
for i in range(1, n):
    mul = (mul*10) % 13
    if s[i] == '?':
        for m in range(10):
            num = (m * mul) % 13
            for j in range(13):
                dp[i][(j+num)%13] = (dp[i][(j+num)%13] + dp[i-1][j]) % mod
    else:
        num = (int(s[i]) * mul) % 13
        for j in range(13):
            dp[i][(j+num)%13] = (dp[i][(j+num)%13] + dp[i-1][j]) % mod

print(dp[n-1][5])

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

s = input()
s = s[::-1]
n = len(s)
mod = 10**9 + 7

dp = np.array([0 for j in range(13)])
if s[0] == '?':
    for i in range(10):
        dp[i] = 1
else:
    num = int(s[0])
    dp[num] = 1

for i in range(1, n):
    dp_new = np.array([0 for j in range(13)])
    if s[i] == '?':
        for m in range(10):
            num = (m * 10**i) % 13
            dp_rolled = np.roll(dp, num)
            dp_new += dp_rolled
            dp_new %= mod
    else:
        num = (int(s[i]) * 10**i) % 13
        dp_rolled = np.roll(dp, num)
        dp_new += dp_rolled
        dp_new %= mod
    dp = dp_new

print(dp[5])

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

s = input()

dp = np.zeros(shape=(len(s), 13), dtype=int)

# 初期値
digit = s[0]
ii = len(s) - 1
if digit == '?':
    for j in range(10):
        num = j * (10**ii)
        amari = num % 13
        dp[0][amari] += 1
else:
    num = int(digit) * (10**ii)
    amari = num % 13
    dp[0][amari] += 1

for i in range(1, len(s)):
    ii = len(s) - 1 - i
    digit = s[i]
    if digit == '?':
        for j in range(10):
            num = j * (10**ii)
            amari = num % 13
            for k in range(13):
                dp[i][k] += dp[i-1][k-amari]
                dp[i][k] = dp[i][k] % (10**9+7)
    else:
        num = int(digit) * (10**ii)
        amari = num % 13
        for k in range(13):
            dp[i][k] += dp[i-1][k-amari]
            dp[i][k] = dp[i][k] % (10**9+7)

print(dp[len(s)-1][5] % (10**9+7))
Problem p03031 (python)

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

ks = []
for i in range(M):
    ks.append(list(map(int, input().split())))

p = list(map(int, input().split()))

cnt = 0
for i in range(2**N):
    light = 0
    switch = format(i, '0'+str(N)+'b')
    for j in range(M):
        pj = p[j]
        kj = ks[j][0]
        on = 0
        for l in range(1, kj+1):
            if switch[ks[j][l]-1] == '1':
                on += 1
        if on % 2 == pj:
            light += 1
        else:
            break
    if light == M:
        cnt += 1

print(cnt)

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

ks = []
for i in range(M):
    ks.append(list(map(int, input().split())))

p = list(map(int, input().split()))

cnt = 0
for i in range(2**N): # スイッチの組み合わせ
    light = 0
    switch = format(i, f'0{N}b')
    for j in range(M): # j番目の電球はどうなってる？
        pj = p[j]
        kj = ks[j][0]
        on = 0
        for l in range(1, kj+1): # 指定されたスイッチ番号はon?
            if switch[ks[j][l]-1] == '1':
                on += 1
        if on % 2 == pj:
            light += 1
        else:
            break
    if light == M:
        cnt += 1

print(cnt)
Problem p03086 (python)

Fixed submission:
S = input()
L = 0
max_L = 0
 
for i in range(len(S)):
  s = S[i]
  TF = any(['A' in s, 'C' in s, 'G' in s, 'T' in s])
  if TF:
    L += 1
    if L >= max_L:
        max_L = L
  elif L >= max_L:
    max_L = L
    L = 0

print(max_L)

Buggy submission (verdict: Runtime Error):
S = input()
L = 0
max_L = 0

for i in len(S):
  s = S[i]
  TF = any(['A'==s, 'C'==s, 'G'==s, 'T'==s])
  if TF:
    L += 1
  elif L >= max_L:
    max_L = L
    L = 0

print(max_L)
Problem p03481 (python)

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

left = 0
right = 10**5
maxi = y//x
while left+1 < right:
    mid = (left+right)//2
    now = 2**mid
    if now > maxi:
        right = mid
    else:
        left = mid

print(left+1)

Buggy submission (verdict: Runtime Error):
import math

x, y = map(int, input().split())

print(int(math.log2(y/x))+1)
Problem p03964 (python)

Fixed submission:
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    n = max((t+ti-1)//ti, (a+ai-1)//ai)
    t = n*ti
    a = n*ai
print(t+a)

Buggy submission (verdict: Runtime Error):
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm/ti*ai)), t_lcm/ti*ai*math.ceil(a/(t_lcm/ti*ai))]
        new2 = [a_lcm/ai*ti*math.ceil(t/(a_lcm/ai*ti)), a_lcm*math.ceil(t/(a_lcm/ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)

Buggy submission (verdict: Runtime Error):
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm//ti*ai)), t_lcm//ti*ai*math.ceil(a/(t_lcm//ti*ai))]
        new2 = [a_lcm//ai*ti*math.ceil(t/(a_lcm//ai*ti)), a_lcm*math.ceil(t/(a_lcm//ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)

Buggy submission (verdict: Runtime Error):
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t, a = 1, 1
for i in range(n):
    ti, ai = map(int, input().split())
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm//ti*ai)), t_lcm//ti*ai*math.ceil(a/(t_lcm//ti*ai))]
        new2 = [a_lcm//ai*ti*math.ceil(t/(a_lcm//ai*ti)), a_lcm*math.ceil(t/(a_lcm//ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)
Problem p02618 (python)

Fixed submission:
D = int(input())
c = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
#T = [int(input()) for i in range(D)]
SUM = 0
last = [0] * 28
for d in range(1, D + 1):
    i = S[d - 1].index(max(S[d - 1]))
    print(i + 1)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
#T = [int(input()) for i in range(D)]
SUM = 0
last = [0] * 28
for d in range(1, D + 1):
    i = S[d].index(max(S[d]))
    print(i)
Problem p02718 (python)

Fixed submission:
import sys
N, M = map(int, sys.stdin.readline().split())
A = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
S = sum(A)
if A[M - 1] < S / (4 * M):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, sys.stdin.readline().split())
A = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
S = sum(A)
if A[M] < S / (4 * M):
    print("No")
else:
    print("Yes")
Problem p03037 (python)

Fixed submission:
import sys
N, M = map(int, sys.stdin.readline().split())
LR = sorted([list(map(int,sys.stdin.readline().split())) for i in range(M)])
L = 1
R = 10 ** 5
for i in LR:
    L = max(L, i[0])
    R = min(R, i[1])
if R - L >= 0:
    print(R - L + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, sys.stdin.readline().split())
LR = [list(map(int,sys.stdin.readline().split())) for i in range(N)]
B = list(range(0, 10 ** 5 + 1))
for i in LR:
	A = list(range(i[0], i[1]))
	B = set(A) & set(B)
print(len(B))
Problem p03435 (python)

Fixed submission:
import sys
C = [list(map(int, sys.stdin.readline().split(" "))) for i in range(3)]
for a0 in range(101):
    b0 = C[0][0] - a0
    b1 = C[0][1] - a0
    b2 = C[0][2] - a0
    if (C[1][0] - b0 == C[1][1] - b1 == C[1][2] - b2) and (C[2][0] - b0 == C[2][1] - b1 == C[2][2] - b2):
        print("Yes")
        exit()
print("No")

Buggy submission (verdict: Runtime Error):
import sys
C = [list(map(int, sys.stdin.readline().split(" "))) for i in range(3)]
for a0 in range(101):
    b1 = C[0][0] - a0
    b2 = C[0][1] - a0
    b3 = C[0][2] - a0
    if (C[1][0] - b0 == C[1][1] - b1 == C[1][2] - b2) and (C[2][0] - b0 == C[2][1] - b1 == C[2][2] - b2):
        print("Yes")
        exit()
print("No")
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split(" "))
 
A = -1
B = -1
C = -1
 
for a in range(N + 1):
  for b in range(N + 1 - a):
    c = N - a - b
    if 10000 * a + 5000 * b + 1000 * c == Y and 0 <= c:
      A = a
      B = b
      C = c
      
print(A, B, C)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split(" "))
 
A = -1
B = -1
C = -1
 
for a in range(N + 1):
  for b in range(N + 1 - a):
    c = N + 1 - a - b
    if (10000 * a + 5000 * b + 1000 * c == Y) and 
      A = a
      B = b
      C = c
      
print(A, B, C)
Problem p03494 (python)

Fixed submission:
# -*- coding: utf-8 -*-
 
N = int(input())
a = list(map(int, input().split(" ")))
c = []
 
for i in a:
  count = 0
  while not(i % 2):
    i = int(i / 2)
    count += 1
  c.append(count)
print(min(c))

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

N = int(input())
a = list(map(int, input().split(" ")))
c = []

for i in a:
  count = 0
  while not(a % 2):
    a = int(a / 2)
    count += 1
    c.append(count)
print(min(c))
Problem p03610 (python)

Fixed submission:
s = input()
ans = ""
for i in range(0, len(s), 2):
  ans = ans + s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = ""
for i in range(0, len(s), 2):
  ans = ans + i
print(ans)
Problem p03624 (python)

Fixed submission:
S = input()
L = "abcdefghijklmnopqrstuvwxyz"
for i in L:
  if i not in S:
    print(i)
    exit()
print("None")

Buggy submission (verdict: Runtime Error):
S = input()
L = "abcdefghijklmnopqrstuvwxyz"
for i in a:
  if i in S:
    print(i)
    exit()
print("None")
Problem p03644 (python)

Fixed submission:
N = int(input())
if 1 <= N <2:
  print(1)
if 2 <= N <4:
  print(2)
if 4 <= N <8:
  print(4)
if 8 <= N <16:
  print(8)
if 16 <= N <32:
  print(16)
if 32 <= N <64:
  print(32)
if 64 <= N <= 100:
  print(64)

Buggy submission (verdict: Runtime Error):

if 1 <= N <2:
  print(1)
if 2 <= N <4:
  print(2)
if 4 <= N <8:
  print(4)
if 8 <= N <16:
  print(8)
if 16 <= N <32:
  print(16)
if 32 <= N <64:
  print(32)
if 64 <= N <100:
  print(64)
Problem p03658 (python)

Fixed submission:
import sys
 
N, K = map(int, sys.stdin.readline().split(" "))
L = sorted(list(map(int, sys.stdin.readline().split(" "))), reverse=True)
print(sum(L[0:K]))

Buggy submission (verdict: Runtime Error):
import sys

N, K = map(int, sys.stdin.readline())
L = sorted(list(map(int, sys.stdin.readline().split(" "))), reverse=True)
print(sum(L[0:K]))
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split(' ')))
if a.count(0) > 0:
	print("0")
else:
	lim = int(1e18)
	mult = 1
	for v in a:
		if mult > lim:
			break
		else:
			mult *= v
	if mult > lim:
		print("-1")
	else:
		print(mult)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split(' ')))
if a.index(0) >= 0:
	print(0)
else:
	lim = int(1e18)
	mult = 1
	for v in a:
		if mult > lim:
			break
		else:
			mult *= v
	if mult > lim:
		print("-1")
	else:
		print(mult)
Problem p02696 (python)

Fixed submission:
import math
A,B,N = map(int,input().split())
C = N - N%B
ans = A*(C-1) // B - A*math.floor((C-1)/B)
if B > N:
    ans = A*N // B - A*math.floor(N/B)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B,N = map(int,input().split())
C = N - N%B
D = A*(C-1)
ans = math.floor(D/B)　-　A * math.floor((C-1)/B)
if B > N:
    ans = math.floor(A*N/B) - A*math.floor(N/B)
print(ans)
Problem p02675 (python)

Fixed submission:
N = input()
print(["p","p","h","b","h","h","p","h","p","h"][int(N[-1])]+"on")

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

d = deque()

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

dct = {}
for _ in range(M):
    a, b = map(int,input().split())
    if not a in dct:
        dct[a] = set()
    if not b in dct:
        dct[b] = set()
    dct[a].add(b)
    dct[b].add(a)

#print(dct)
answers = [0]*(N+1)

stack = deque([1,])
lst = []
while len(stack):
    s = stack.popleft()
    lst.append(s)
    #print(dct[s])
    for i in dct[s]:
        if i in lst:
            continue
        if i in stack:
            continue
        stack.append(i)
        answers[i] = s

if answers.count(0) != 2:
    print("No")
else:
    print("Yes")
    for ans in answers[2:]:
        print(ans)
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())

for i in range(X+1):
    if Y == (2 * i + 4 * (X - i)):
        print('Yes')
        exit()
else:
    print('No')

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

for i in range(X+1):
    if Y == (2 * i + 4 * (X - T)):
        print('Yes')
        exit()
else:
    print('No')
Problem p02641 (python)

Fixed submission:
X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(101):
    if X - i not in p:
        print(X - i)
        exit()
    elif X + i not in p:
        print(X + i)
        exit()

Buggy submission (verdict: Runtime Error):
X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(101):
    if X - i not in p:
        print(x - i)
        exit()
    elif X + i not in p:
        print(x + i)
        exit()
Problem p02677 (python)

Fixed submission:
from math import cos, radians, sqrt

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

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))

Buggy submission (verdict: Runtime Error):
from math import cos, radians, sqrt

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

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))
Problem p02696 (python)

Fixed submission:
A,B,N = map(int,input().split())
x = min(B-1,N)
ans = int(A*x/B) - A*int(x/B)
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,X = map(int,input().split())
print(min(B-1,N))
Problem p02713 (python)

Fixed submission:
import math
K = int(input())      
ans = 0           
for a in range(1,K+1):
    for b in range(1,K+1):
        g = math.gcd(a,b)
        for c in range(1,K+1):
            ans += math.gcd(g,c)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
K = int(input())      
ans = 0           
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += math.gcd(a,b,c)
print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = p[:X]+q[:Y]+r[:X+Y]
ans.sort(reverse=True)
su = sum(ans[:X+Y])

print(su)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
ans = 0
p.sort()
q.sort()
r.sort()
for i in range(X):
    if p[-1] >= r[-1]:
        ans += p[-1]
        del p[-1:]
        
    elif r[-1] > p[-1] >= q[-1]:
        
        ans += p[-1]
        del p[-1:]
    else:
        ans += r[-1]
        del r[-1:]    
         
for i in range(Y):
    if q[-1] >= r[-1]:
        ans += q[-1]
        del q[-1:]
        
    else:
        ans += r[-1]
        del r[-1:]
                   

print(ans)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
ans = 0
p.sort()
q.sort()
r.sort()
for i in range(X):
    if p[-1] >= r[-1]:
        ans += p[-1]
        del p[-1:]
        
    else:
        ans += r[-1]
        del r[-1:]
         
for i in range(Y):
    if q[-1] >= r[-1]:
        ans += q[-1]
        del q[-1:]
        
    else:
        ans += r[-1]
        del r[-1:]
                   

print(ans)