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

Fixed submission:
import itertools

N = int(input())

# 頭文字Mグループ、頭文字Aグループ、のように分割する
# どの3つのグループから1人選ぶかを考える

n_initial_MARCH = [0]*5
match_initial = ["M", "A", "R", "C", "H"]
for _ in range(N):
    s = input()
    for idx in range(5):
        if s[0] == match_initial[idx]:
            n_initial_MARCH[idx] += 1

taken_indices = list(itertools.combinations([idx for idx in range(5) if n_initial_MARCH[idx] > 0], 3))

ans = 0

for groups in taken_indices:
    ans += n_initial_MARCH[groups[0]] * n_initial_MARCH[groups[1]] * n_initial_MARCH[groups[2]]

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())

# 頭文字Mグループ、頭文字Aグループ、のように分割する
# どの3つのグループから1人選ぶかを考える

n_initial_MARCH = [0]*5
match_initial = ["M", "A", "R", "C", "H"]
for _ in range(N):
    s = input()
    for idx in range(5):
        if s[0] == match_initial[idx]:
            n_initial_MARCH[idx] += 1

taken_indices = list(itertools.combinations([idx for idx in range(N) if n_initial_MARCH[idx] > 0], 3))

ans = 0

for groups in taken_indices:
    ans += n_initial_MARCH[groups[0]] * n_initial_MARCH[groups[1]] * n_initial_MARCH[groups[2]]

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())

# 頭文字Mグループ、頭文字Aグループ、のように分割する
# どの3つのグループから1人選ぶかを考える

n_initial_MARCH = [0]*5
match_initial = ["M", "A", "R", "C", "H"]
for _ in range(N):
    s = input()
    for idx in range(N):
        if s[0] == match_initial[idx]:
            n_initial_MARCH[idx] += 1

taken_indices = list(itertools.combinations([idx for idx in range(N) if n_initial_MARCH[idx] > 0], 3))

ans = 0

for groups in taken_indices:
    ans += n_initial_MARCH[groups[0]] * n_initial_MARCH[groups[1]] * n_initial_MARCH[groups[2]]

print(ans)
Problem p03450 (python)

Fixed submission:
# D - People on a Line

import sys
sys.setrecursionlimit(10000000)

N, M = map(int, sys.stdin.buffer.readline().split())
LRD = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

LRD = [[LRD[i][0]-1, LRD[i][1]-1, LRD[i][2]] for i in range(M)]

if N == 1 or M == 0:
    print("Yes")
    exit()

neighbor = [[] for _ in range(N)]
for i in range(M):
    neighbor[LRD[i][0]].append([LRD[i][1], LRD[i][2]])
    neighbor[LRD[i][1]].append([LRD[i][0], -LRD[i][2]])

x = [None] * N

def check(i):
    if x[i] == None:
        x[i] = 0
    for next_point, dist in neighbor[i]:
        if x[next_point] == None:
            x[next_point] = x[i] + dist
            check(next_point)
        elif x[next_point] != x[i] + dist:
            print('No')
            exit()

for i in range(N):
    if x[i] == None:
        check(i)

print('Yes')

Buggy submission (verdict: Runtime Error):
# D - People on a Line

import sys

N, M = map(int, sys.stdin.buffer.readline().split())
LRD = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

LRD = [[LRD[i][0]-1, LRD[i][1]-1, LRD[i][2]] for i in range(M)]

if N == 1 or M == 0:
    print("Yes")
    exit()

neighbor = [[] for _ in range(N)]
for i in range(M):
    neighbor[LRD[i][0]].append([LRD[i][1], LRD[i][2]])
    neighbor[LRD[i][1]].append([LRD[i][0], -LRD[i][2]])

x = [None] * N

def check(i):
    if x[i] == None:
        x[i] = 0
    for next_point, dist in neighbor[i]:
        if x[next_point] == None:
            x[next_point] = x[i] + dist
            check(next_point)
        elif x[next_point] != x[i] + dist:
            print('No')
            exit()

for i in range(N):
    if x[i] == None:
        check(i)

print('Yes')
Problem p03469 (python)

Fixed submission:
# A - Already 2018

S = input()
print("2018" + S[4:])

Buggy submission (verdict: Runtime Error):
N_n_osatsu, Y_sum_money = map(int, input().split())

rest_money = Y_sum_money
rest_n_osatsu = N_n_osatsu
n_each_osatsu_list = [] # 万札、五千円札、千円札の枚数の2重リスト

def skip_search(rest_money, rest_n_osatsu):  # 明らかに無理な場合、処理をスキップ
    if rest_n_osatsu*1000 > rest_money or rest_n_osatsu*10000 < rest_money:
        return True

def is_answer(n_10000, n_5000, n_1000): # 正答ならばそれを出力して終了
    if n_10000 + n_5000 + n_1000 == N_n_osatsu and n_10000*10000 + n_5000*5000 + n_1000*1000 == Y_sum_money:
        print(n_10000, n_5000, n_1000)
        exit()

for n_10000 in range(min(Y_sum_money//10000, N_n_osatsu)+1): # 万札枚数。0枚からスタート
    is_answer(n_10000, 0, 0)
    rest_money = Y_sum_money - 10000*n_10000
    rest_n_osatsu = N_n_osatsu - n_10000
    if skip_search(rest_money, rest_n_osatsu):
        break

    for n_5000 in range(min(rest_money//5000 + 1, rest_n_osatsu)+1): # 万札枚数決定後に5000円の枚数を探索。5000円0枚からスタート
        is_answer(n_10000, n_5000, 0)
        rest_money = Y_sum_money - 10000*n_10000 - 5000*n_5000
        rest_n_osatsu = N_n_osatsu - n_10000 - n_5000
        if skip_search(rest_money, rest_n_osatsu):
            break
        n_1000 = rest_money//1000
        is_answer(n_10000, n_5000, n_1000)

print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
N = int(input())
d_list = [int(input()) for _ in range(N)]
print(len(set(d_list)))
Problem p03569 (python)

Fixed submission:
s = input()

l = 0
r = len(s)-1
ans = 0

while l < r:
    if s[l] != s[r]:
        if s[l] == "x":
            ans += 1
            l += 1
        elif s[r] == "x":
            ans += 1
            r -= 1
        else:
            print(-1)
            exit()
    else:
        l += 1
        r -= 1

print(ans)

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

s_no_x = ""
for i in range(len(s)):
    if s[i] != "x":
        s_no_x += s[i]

if s_no_x != s_no_x[::-1]:
    print(-1)
    exit()

if len(s_no_x) % 2 == 0:
    non_x_count = 0
    for i in range(len(s)):
        if s[i] != "x":
            non_x_count += 1
        if non_x_count == len(s_no_x)//2:
            s1 = s[:i]
        if non_x_count == len(s_no_x)//2 + 1:
            s2 = s[i+1:]
            break
else:
    non_x_count = 0
    for i in range(len(s)):
        if s[i] != "x":
            non_x_count += 1
        if non_x_count == len(s_no_x)//2 + 1:
            s1 = s[:i]
            s2 = s[i+1:]
            break

ans = abs(len(s1) - len(s2))
for i in range(min(len(s1), len(s2))):
    if s[i] != s[-i-1]:
        ans += 1

print(ans)
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))
Problem p03651 (python)

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

A = list(set(A))
N = len(A)
A.sort()

if K > max(A):
    print("IMPOSSIBLE")
    exit()

if N == 1:
    if A[0] == K:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

min_diff = min([A[i] - A[i-1] for i in range(1,N)])

for i in range(N):
    if abs(A[i]-K) % min_diff == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

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

if N == 1:
    if A[0] == K:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

if K > max(A):
    print("IMPOSSIBLE")
    exit()

A = list(set(A))
N = len(A)
A.sort()

min_diff = min([A[i] - A[i-1] for i in range(1,N)])

for i in range(N):
    if abs(A[i]-K) % min_diff == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")
Problem p03699 (python)

Fixed submission:
# C - Bugged

N = int(input())
s = [int(input()) for _ in range(N)]

mod10 = [x%10 for x in s]
fraction = [x for x in s if x%10 > 0]

if len(set(mod10)) == 1 and mod10[0] == 0:
    print(0)
elif sum(mod10)%10 > 0:
    print(sum(s))
else:
    print(sum(s) - min(fraction))

Buggy submission (verdict: Runtime Error):
# C - Bugged
# DP Overkill

N = int(input())
s = [int(input()) for _ in range(N)]

dp = [0] + [-1]*sum(s)

while s:
    x = s.pop()
    for idx in reversed(range(len(dp))):
        if dp[idx] != -1 and idx + x <= len(dp) - 1:
            dp[idx+x] = dp[idx] + x
            
dp = set(dp)
dp.remove(-1)
dp = list(dp)
dp.sort(reverse = True)

for idx in range(len(dp)):
    if idx == len(dp) - 1:
        print(0)
    elif dp[idx] % 10 > 0:
        print(dp[idx])
        break
Problem p03740 (python)

Fixed submission:
X, Y = map(int, input().split())
print("Alice" if abs(X-Y)>=2 else "Brown")

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

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を再帰的に探索する
def recur_search(x,y,Alice_win_flg):
    if x+y > X+Y or x < 0 or y < 0:
        return
    elif [x, y] in done_memo and Alice_win_flg == 0:
        return
    elif [x,y] == [X,Y] or [x,y] == [Y,X]:
        # 1つでも勝ちパターンがあるなら先手Aliceの勝利
        if Alice_win_flg == 1:
            print("Alice")
            exit()
        else:
            done_memo.append([x, y])
            done_memo.append([y, x])
            return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

done_memo = []
recur_search(1,0,0)
recur_search(1,1,0)
print("Brown")

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

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を再帰的に探索する
def recur_search(x,y,Alice_win_flg):
    if x+y > X+Y or x < 0 or y < 0:
        return
    elif [x, y] in done_memo and Alice_win_flg == 0:
        return
    elif [x,y] == [X,Y] or [x,y] == [Y,X]:
        # 1つでも勝ちパターンがあるなら先手Aliceの勝利
        if Alice_win_flg == 1:
            print("Alice")
            exit()
        else:
            done_memo.append([x, y])
            done_memo.append([y, x])
            return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

done_memo = []
recur_search(1,0,0)
recur_search(1,1,0)
print("Brown")

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

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を探索し、与えられた状態と一致したらフラグを保存する
def recur_search(x,y,Alice_win_flg):
    if [x,y] == [X,Y] or [x,y] == [Y,X]:
        Alice_win_flg_list.append(Alice_win_flg)
        return
    elif x+y > X+Y or x < 0 or y < 0:
        return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

Alice_win_flg_list = []
recur_search(1,0,0)
recur_search(1,1,0)

# 1つでもAlice勝ちパターンがあるなら先手のAliceの勝ち
print("Alice" if sum(Alice_win_flg_list) > 0 else "Brown")
Problem p03752 (python)

Fixed submission:
# B - Buildings are Colorful!

import sys
input = sys.stdin.buffer.readline

import itertools

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

if K == 1:
    print(0)
    exit()

ans = float("inf")
for visible_building_indices in list(itertools.combinations(list(range(N)), K)):
    a = original_a.copy()
    tmp = 0

    for i in range(len(visible_building_indices)):
        try:
            h = max([a[i] for i in range(visible_building_indices[i])])
        except:
            h = 0
        if h >= a[visible_building_indices[i]]:
            tmp += h - a[visible_building_indices[i]] + 1
            a[visible_building_indices[i]] = h + 1

    ans = min(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
# B - Buildings are Colorful!

import sys
input = sys.stdin.buffer.readline

import itertools

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

if K == 1:
    print(0)
    exit()

ans = float("inf")
for visible_building_indices in list(itertools.combinations(list(range(N)), K)):
    a = original_a.copy()
    tmp = 0

    for i in range(visible_building_indices[0]):
        if a[i] >= a[visible_building_indices[i]]:
            tmp += a[i] - a[visible_building_indices[i]] + 1

    for i in range(len(visible_building_indices)-1):
        if a[visible_building_indices[i]] >= a[visible_building_indices[i+1]]:
            tmp += a[visible_building_indices[i]] - a[visible_building_indices[i+1]] + 1
            a[visible_building_indices[i+1]] = a[visible_building_indices[i]] + 1

    ans = min(ans, tmp)

print(ans)
Problem p03854 (python)

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")

Buggy submission (verdict: Runtime Error):
S_input = str(input())
add_str_tuple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_tuple:
                recur_add(T+word)
        else:
            return

recur_add("")
print("NO")

Buggy submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    elif len(T) < len(S_input):
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return
    else:
        return

recur_add("")
print("NO")

Buggy submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return None

recur_add("")
print("NO")

Buggy submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return

recur_add("")
print("NO")

Buggy submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return

recur_add("")
print("NO")
Problem p03964 (python)

Fixed submission:
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける

import math

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a, b = TA[0]
c, d = a, b

for idx in range(1,N):
    c, d = TA[idx]
    multi = max((a+c-1)//c, (b+d-1)//d)
    c *= multi
    d *= multi
    a,b = c,d
    
print(c+d)

Buggy submission (verdict: Runtime Error):
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける

import math

N = int(input())
TA = [list(map(int, input().split())) for _ in range(N)]

a, b = TA[0]

for idx in range(1,N):
    c, d = TA[idx]
    multi = max(math.ceil(a/c), math.ceil(b/d))
    c *= multi
    d *= multi
    a,b = c,d
    
print(c+d)
Problem p03633 (python)

Fixed submission:
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return a * (b // g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return int((a * b) / g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return int(a * b / g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  g = gcd(ans, t)
  ans = int(ans * (t / g))
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

N = int(input())
ans = 1
for i in range(N):
  t = int(input())
  g = gcd(ans, t)
  ans = int(ans * (t / g))
print(ans)
Problem p02922 (python)

Fixed submission:
L, R = map(int, input().split())
s = (R - 1) // (L - 1)
r = (R - 1) % (L - 1)
if r == 0:
  ans = s
else:
  ans = s + 1
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = input().split()
s = (R - 1) // ( L - 1)
ans = s + 1
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = input().split()
s = (R-1) // (L-1)
ans = s + 1
print()
Problem p02885 (python)

Fixed submission:
import sys

A, B = [int(n) for n in sys.stdin.readline().strip().split()]
print(max(A-2*B, 0))

Buggy submission (verdict: Runtime Error):
import sys

A, B = sys.stdin.readline().strip().split()
print(max(A-2B, 0))
Problem p02911 (python)

Fixed submission:
import sys
 
N, K, Q = [int(n) for n in sys.stdin.readline().strip().split()]
ans_idx = [int(sys.stdin.readline().strip()) for _ in range(Q)]
scores = [0]*N
 
for ai in ans_idx:
  scores[ai-1] += 1
scores = [K-(Q-s) for s in scores]
  
for s in scores:
  print('No' if s<=0 else 'Yes')

Buggy submission (verdict: Runtime Error):
import sys

N, K, Q = [int(n) for n in sys.stdin.readline().strip().split()]
ans_idx = [int(sys.stdin.readline().strip()) for _ in range(Q)]
scores = [0]*N

for ai in ans_idx:
  scores[ai] += 1
scores = [K-(s-Q) for s in scores]

for s in scores:
  print('No' if s<=0 else 'Yes')
Problem p02924 (python)

Fixed submission:
N = int(input())
print(N*(N-1)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N(N-1)//2)
Problem p03029 (python)

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

print(int((stdin[0]*3+stdin[1]) / 2))

Buggy submission (verdict: Runtime Error):
A, P = input().split()

print( (A*3+P) / 2)
Problem p02675 (python)

Fixed submission:
n = input()

if(n[-1] == '0' or n[-1] == '6' or n[-1] == '1' or n[-1] == '8'):
    print('pon')
elif(n[-1] == '3'):
    print('bon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
import math

a, b, h, m = map(int, input().split())

deg_h = 360 / 12
deg_m = 360 / 60

H = h * deg_h + m * (deg_h/60)
M = m * deg_m
deg = abs(H - M)

if deg > 180:
    deg = 360 - deg

rad = (deg/180) * math.pi
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(c)

Buggy submission (verdict: Runtime Error):
import math
def resolve():
    A, B, H, M = map(int, input().split())
    #短針が1時間で進む角度 30c
    deg_H = 360/12
    # 長針が1分間で進む角度 6c
    deg_M = 360/60

    hr = deg_H*H + (deg_H/60)*M
    mr = deg_M*M
    deg = abs(hr-mr)
    if deg>180:
        deg = 360- deg

    # 角度をラジアンに直す
    red = (deg/180)*math.pi
    ans = math.sqrt(A*A + B*B - 2*A*B*math.cos(red))
    print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
import math

a, b, h, m = map(int, input().split())

deg_h = 360 / 12
deg_m = 360 / 60

H = h * deg_h + m * deg_m
M = m * deg_m
deg = abs(H - M)

if deg > 180:
    deg = 360 - deg

rad = (deg/180) * math.pi
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(c)

Buggy submission (verdict: Runtime Error):
import math

a, b, h, m = map(int, input().split())

deg_h = 360 / 12
deg_m = 360 / 60

H = h * deg_h + m * deg_m
M = m * deg_m
deg = abs(H - M)

if deg > 180:
    deg = 360 - deg

rad = (deg*math.pi) / 180
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(c)

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

a, b, h, m = map(int, input().split())

H = h * 30 + m*0.5
M = m * 6

if(H > M):
    deg = H - M
    rad = (deg*np.pi) / 180
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(rad))
    print(c)
elif(H < M):
    deg = M - H
    rad = (deg*np.pi) / 180
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(rad))
    print(c)
else:
    print(b-a)

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

a, b, h, m = map(int, input().split())

H = h * 30 + m*0.5
M = m * 6

if(H > M):
    deg = H - M
    rad = (deg*np.pi) / 180
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(rad))
    print(c)
elif(H < M):
    deg = M - H
    rad = (deg*np.pi) / 180
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(rad))
    print(c)
else:
    print(b-a)

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

if( n[-1]=='0' or n[-1]=='6' or n[-1]=='1' or n[-1]=='8' ):
    print('pon')
else if( n[-1]=='3' ):
    print('bon')
else:
    print('hon')

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

if( n[-1]=='2' or n[-1]=='4' or n[-1]=='5'  or n[-1]=='7' or n[-1]=='9'):
    print('hon')
else if( n[-1]=='0' or n[-1]=='6' or n[-1]=='1' or n[-1]=='8' ):
    print('pon')
else:
    print('bon')
Problem p02839 (python)

Fixed submission:
H, W = [int(x) for x in input().split()]

A = [[0]*W for i in range(H)]
for c in [1, -1]:
    for i in range(H):
        arr = [int(x) for x in input().split()]
        for j in range(W):
            A[i][j] += arr[j] * c

M = 160*80
dp = [[0]*W for i in range(H)]
dp[0][0] = 1 << M
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i-1][j]
        if j > 0:
            dp[i][j] |= dp[i][j-1]
        a = abs(A[i][j])
        dp[i][j] = (dp[i][j] << a) | (dp[i][j] >> a)

ans = M
for i in range(2*M):
    if dp[H-1][W-1] & (1 << i) > 0:
        ans = min(ans, abs(M-i))
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def resolve():
    ofs = 6400
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [[0]*w for _ in range(h)]
    x = abs(A[0][0]-B[0][0])
    dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = 0
            if(i-1 >= 0):
                t |= dp[i-1][j]
            if(j-1 >= 0):
                t |= dp[i][j-1]
            dp[i][j] |= ((t << x) | (t >> x))

    for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):
        if(s == '1'):
            write("%d\n" % i+1)
            return


if __name__ == "__main__":
    INF = float("inf")
    MOD = 10**9+7
    resolve()