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

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

exit_flag = False
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        exit_flag = True
        print('No')
        break

if not exit_flag:
    print('Yes')

Buggy submission (verdict: Runtime Error):
from typing import List

N = int(input())
H = list(map(int, input().split()))

for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        print('No')
        break
    if i == 1:
        print('Yes')

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

H_reversed = list(reversed(H))
for i in range(N):
    if H_reversed[i+1] - H_reversed[i] == 1:
        H_reversed[i+1] -= 1
    elif H_reversed[i+1] - H_reversed[i] > 1:
        print('No')
        break
print('Yes')
Problem p03074 (python)

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

# 累積和で実装

now = 1
cnt = 0
nums = []
for i in range(N):
    if int(S[i]) == now:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        now = 1 - now
nums.append(cnt)
if int(S[-1]) == 0:
    nums.append(0)

# print(nums)

cumulative_sum = []
M = len(nums)
sum = 0
for i in range(M):
    sum += nums[i]
    cumulative_sum.append(sum)

# print(cumulative_sum)

ans = 0
start = 0
final = 2 * K
answers = []

# M = len(nums) = len(cumulative_sum)
if M < 2 * K + 1:
    print(len(S))
    exit()
if final <= M-1:
    while(final <= M-1):
        if start == 0:
            answers.append(cumulative_sum[final])
        else:
            ans = cumulative_sum[final] - cumulative_sum[start-1]
            answers.append(ans)

        # print(start, final, ans)
        start += 2
        final += 2
    print(max(answers))
else:
    print(cumulative_sum[0])

# print(answers)

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

calc_list = [1 if S[0] == '0' else 0]
for i in range(1, len(S)):
    if S[i] == '0':
        if S[i-1] == '1':
            calc_list.append(1)
        elif S[i-1] == '0':
            calc_list.append(calc_list[i-1] + 1)
    else:
        calc_list.append(0)

print(calc_list)

def zeros(calc_list):
    zero_list = [1 if calc_list[0] == 0 else 0]
    for i in range(1, len(calc_list)):
        if calc_list[i] == 0:
            zero_list.append(zero_list[i-1] + 1)
        else:
            zero_list.append(0)

    return zero_list


max_times = max(calc_list)
for _ in range(K):
    for i in range(len(calc_list)):
        if calc_list.count(max_times) == 1:
            if calc_list[i] == max_times:
                for j in range(max_times):
                    calc_list[i-j] = 0
                break
        else:
            zero_list = zeros(calc_list))
            index = zero_list.index(max(zero_list))

    print('calc', calc_list)
    print('zeros', zeros(calc_list))
    max_times = max(calc_list)
Problem p03085 (python)

Fixed submission:
b = input()
if b == "A":
  pair = "T"
elif b == "T":
  pair = "A"
elif b == "C":
  pair = "G"
else:
  pair = "C"
print(pair)

Buggy submission (verdict: Runtime Error):
b = input()
if b == "A":
  pair = "T"
elif b == "T":
  pair = "A":
elif b == "C":
  pair = "G"
else:
  pair = "C"
print(pair)
Problem p03086 (python)

Fixed submission:
words = list(input())
binary_list = []
for word in words:
  if word == "A" or word == "T" or word == "C" or word == "G":
      binary_list.append(1)
  else:
      binary_list.append(0)
max_counter = 0
for first in range(len(binary_list)):
    counter = 0
    multi = 1
    if binary_list[first] == 1:
        while(multi):
            multi *= binary_list[first]
            if multi == 0:
                break
            counter += 1
            if counter >= max_counter:
                max_counter = counter
            if first == len(binary_list) - 1:
                break
            else:
                first += 1
print(max_counter)

Buggy submission (verdict: Runtime Error):
words = list(input())
binary_list = []
for word in words:
  if word == "A" or word == "T" or word == "C" or word == "G":
      binary_list.append(1)
  else:
      binary_list.append(0)
counter = 0
multi = 1
max_counter = 0
for first in range(len(binary_list)):
    if binary_list[first] == 1:
        while(multi):
            multi *= binary_list[first]
            if multi == 0:
                break
            first += 1
            counter += 1
            if counter >= max_counter:
                max_counter = counter
print(max_counter)
Problem p03109 (python)

Fixed submission:
date = input()

date = int(date.replace('/', ''))
if date <= 20190430:
    print("Heisei")
else:
    print("TBD")

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

date = date.replace('/', '')
if date <= 20190430:
    print("Heisei")
else:
    print("TBD")
Problem p03110 (python)

Fixed submission:
many = int(input())
sum_money = 0
for i in range(many):
    money, currency = map(str, input().split())
    if currency == 'JPY':
        sum_money += int(money)
    else:
        sum_money += 3.8e5 * float(money)

print(sum_money)

Buggy submission (verdict: Runtime Error):
many = int(input())
sum_money = 0
for i in range(many):
    money, currency = map(str, input().split())
    if currency == 'JPY':
        sum_money += int(money)
    elif currency == 'BTC':
        sum_money += float(380000 * money)
    else:
        print("Error")
print(sum_money)
Problem p03111 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
many, A, B, C = map(int, input().split())
bamboos = [int(input()) for i in range(many)]

# point: 訳が分からなくなるものは自分でルールづけをする
# 合成魔法を全て最初に行う、というルールづけ

# 解法: DFS or 4進数(4patternsで2の累乗だからできる)
# PS: DFS(深さ優先探索), BFS(幅優先探索)

infinity = 1e10

def dfs(depth, a, b, c):
    if depth == many:
        # 謎の場合分け
        if min(a, b, c) > 0:
            # 竹が何もない状態でも各竹に+10がかかっていることから-30する必要がある。
            # また、+10が一個はないとベースとなる竹がないことになるので
            # a,b,c = 0はコストを無限にすることで避ける。
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
    else:
        ret0 = dfs(depth+1, a, b, c)
        ret1 = dfs(depth+1, a+bamboos[depth], b, c) + 10
        ret2 = dfs(depth+1, a, b+bamboos[depth], c) + 10
        ret3 = dfs(depth+1, a, b, c+bamboos[depth]) + 10
        return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Problem p02645 (python)

Fixed submission:
s = input()

print(s[:3])

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = list(map(int,input().split()))
b = [0] * n

for cnt in range(k):
    if cnt > int(n/2):
        for l in range(n):
            a[l] += k - cnt
        break
    else:
        for i in range(n):
            abl = a[i] * 2 + 1
            for j in range(abl):
                lenge = i - a[i] + j
                if lenge >= 0 and lenge < n:
                    b[lenge] += 1
        a = b
        b = [0] * n

print(*a)
Problem p02767 (python)

Fixed submission:
import collections

N = int(input())
X = list(map(int,input().split()))

x = collections.Counter(X)

N = len(x)
s = min(list(x.keys()))
e = max(list(x.keys()))

xl = list(x)

m = [0]*(e+1-s)

for i in range(s, e+1):
    p = 0
    for j in range(N):
        p += pow(xl[j]-i,2) * x[xl[j]]
    m[i-s] = p

print(min(m))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
X = list(map(int,input().split()))

x = collections.Counter(X)

s = min(list(x.keys()))
e = max(list(x.keys()))

xl = list(x)

m = [0]*(e+1-s)

for i in range(s, e+1):
    p = 0
    for j in range(N):
        p += pow(xl[j]-i,2) * x[xl[j]]
    m[i-s] = p

print(min(m))
Problem p02641 (python)

Fixed submission:
import sys
import numpy as np

X,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(X)
    sys,exit()
pp = list(map(lambda x: abs(x-X), p))
pp.sort()
for i in range(1,100):
    tmp=X-pp[0]-i
    if not tmp in p:
        print(tmp)
        sys.exit()
    tmpp=X-pp[0]+i
    if not tmpp in p:
        print(tmpp)
        sys.exit()

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

X,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(X)
pp = list(map(lambda x: abs(x-X), p))
pp.sort()
for i in range(1,100):
    tmp=X-pp[0]-i
    if not tmp in p:
        print(tmp)
        sys.exit()
    tmpp=X-pp[0]+i
    if not tmpp in p:
        print(tmpp)
        sys.exit()
Problem p02646 (python)

Fixed submission:
import sys
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if v<=w:
    print('NO')
    sys.exit()
else:
    d=abs(a-b)
    s=v-w
    if d<=t*s:
        print('YES')
        sys.exit()
print('NO')

Buggy submission (verdict: Runtime Error):
import sys
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if v<=w:
    print('NO')
    sys.exit()
else:
    d=abs(a-b)
    s=v-w
    if d<=ts:
        print('YES')
        sys.exit()
print('NO')
Problem p02658 (python)

Fixed submission:
import sys
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
    sys.exit()


ans=1
for elem in A:
    ans*=elem
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=A[0]
for i in range(len(A)):
    ans*=A[i]

if ans>3=10**18:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=A[0]
for i in range(len(A)):
    ans*=A[i]

if ans>3:
    =10**18:
    print(-1)
else:
    print(ans)
Problem p02678 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import deque
 
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
q = deque()
done = [-1]*N
done[0] = 1
q.appendleft(0)
while q:
    now = q.pop()
    for to in G[now]:
        if done[to] != -1: continue
        done[to] = now+1
        q.appendleft(to)
print("Yes")
print(*done[1:], sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
import math
from colletions import deque
N, M = map(int, input().split())
G=[[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
q=deque()
done = [-1]*N
done[0]=1
q.appendleft(0)
while q:
    now=q.pop()
    for to in G[now]:
        if done[to] != -1:
            continue
        done[to]=now+1
        q.appendleft(to)
print('Yes')
print(*done[1:],sep='\n')
Problem p02713 (python)

Fixed submission:
k = int(input())
import math
from functools import reduce
total = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            total += reduce(math.gcd,(i,j,l))

print(total)

Buggy submission (verdict: Runtime Error):
k = int(input())
import fractions as f
a = [1]*3
total = 0
for i in range(1,k+1):
    total += f.gcd(a[0],a[1],a[i])
for i in range(1,k+1):
    total += f.gcd(a[0],a[i],a[2])
    if i == k:
        for j in range(1,k+1):
            total += f.gcd(a[0],a[i],a[j])
for i in range(1,k):
    total += f.gcd(a[i],a[1],a[2])
    if i == k:
        for j in range(1,k+1):
            total += f.gcd(a[i],a[1],a[j])
            if j == k:
                for l in range(1,k):
                    total += f.gcd(a[i],a[l],a[j])


print(total)
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
abc = input().split() 
abc[0],abc[1],abc[2] = abc[2],abc[0],abc[1]
print(f'{abc[0]} {abc[1]} {abc[2]}')

Buggy submission (verdict: Runtime Error):
abc = list(map(int, input().split()))
abc[0],abc[1],abc[2] = abc[2],abc[0],abc[1]
print(f'{abc[0]} {abc[1]} {abc[2]}')

Buggy submission (verdict: Runtime Error):
import copy
abc = list(map(int, input().split()))
ABC = copy.copy(abc)
ABC[0] = abc[2]
ABC[1] = abc[0]
ABC[2] = abc[1]
print(f'{ABC[0]} {ABC[1]} {ABC[2]}')

Buggy submission (verdict: Runtime Error):
import copy
abc = list(map(int, input().split()))
ABC = copy.copy(abc)
ABC[0] = abc[2]
ABC[1] = abc[0]
ABC[2] = abc[1]
print(f'{ABC[0]} {ABC[1]} {ABC[2]}')
Problem p02761 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
tmp=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if tmp[s]<0:
        tmp[s]=c
    if tmp[s]!=c:
        print(-1)
        sys.exit()
if tmp[0]==0 and n>1:
    print(-1)
    sys.exit()
if tmp[0]<0 and n>1:
    tmp[0]=1
if n==1 and tmp[0]==-1:
    tmp[0]=0
for i in range(1,n):
    if tmp[i]<0:
        tmp[i]=0
for i in tmp:
    print(i,end='')

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
tmp=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if tmp[s]<0:
        tmp[s]=c
    if tmp[s]!=c:
        print(-1)
        sys.exit()
if tmp[0]==0 and n>1:
    print(-1)
    sys.exit()
if tmp[0]<0 and n>1:
    tmp[0]=1
if n==1 and tmp[0]==-1:
    tmp[0]=0
for i in range(1,n):
    if tmp[i]<0:
        tmp[i]=0
t=''.join(tmp)
print(t)

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
tmp=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if tmp[s]<0:
        tmp[s]=c
    if tmp[s]!=c:
        print(-1)
        sys.exit()
if tmp[0]==0 n>1:
    print(-1)
    sys.exit()
if tmp[0]<0 and n>1:
    tmp[0]=1
if n==1 and tmp[0]==-1:
    tmp[0]=0
for i in range(1,n):
    if tmp[i]<0:
        tmp[i]=0
t=''.join(tmp)
print(t)

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
tmp=[0]*n
if m==0:
    print(-1)
for _ in range(m):
    s,c=map(int,input().split())
    if tmp[s-1]==0:
        tmp[s-1]=c
    elif s-1==0 and c==0:
        print(-1)
    else:
        if tmp[s-1]==c:
            continue
        else:
            print(-1)
        sys.exit()
print(100*tmp[0]+10*tmp[1]+tmp[2])
Problem p02772 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
for i in range(n):
    if A[i] %2 == 0:
        a +=1
        if A[i] %3== 0 or A[i]%5==0:
            b +=1
if a == b:
    print('APPROVED')
else:
    print('DENIED')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
for i in range(n):
    if A[i] %2 = 0:
        a +=1
        if A[i] %3= 0 or A[i]%5=0:
            b +=1
if a == b:
    print('APPROVED')
else:
    print('DENIED')
Problem p02789 (python)

Fixed submission:
n,m = map(int, input().split())
if n <= m:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n,m = map(int, input()split())
if n <= m:
    print('Yes')
else:
    print('No')
Problem p02917 (python)

Fixed submission:
N = int(input())
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
    i += 1

A[-1] = B[-1]

print(sum(A))

Buggy submission (verdict: Runtime Error):
N = input()
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,len(B)):
    A[i] = min(B[i-1],B[i])
    i += 1

A[N] = B[-1]

print(sum(A))

Buggy submission (verdict: Runtime Error):
N = input()
B = list(map(int, input().split())) 
A =[None] * N
A[0] = B[0]

for i in range(1,len(B)):
    A[i] = min(B[i-1],B[i])
    i += 1

A[N] = B[-1]

print(sum(A))
Problem p02952 (python)

Fixed submission:
import sys

n=int(input())
ans=0
for i in range(1,n+1):
    s=str(i)
    if len(s)%2==1:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

n=int(input())
ans=0
for i in range(n):
    if len(i)%2==1:
        ans+=1
print(ans)
Problem p03035 (python)

Fixed submission:
a,b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(b//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a >= 13:
    print(b)
elif 5 <= a <= 12:
    print(int(b/2))
else:
    print(0

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a >= 13:
    print(b):
elif 5 <= a <= 12:
    print(b//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a >= 13:
    print(b):
elif 5 <= a <= 12:
    print(a//2)
else:
    print(0)
Problem p03085 (python)

Fixed submission:
b=input()
if b=='A':
    print('T')
if b=='T':
    print('A')
if b=='G':
    print('C')
if b=='C':
    print('G')

Buggy submission (verdict: Runtime Error):
b=input()
if b==A:
    print(T)
if b==T:
    print(A)
if b==G:
    print(C)
if b==C:
    print(G)
Problem p02603 (python)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
cnt = 0
buy = True    

while True:
    if buy == False:
        while True:
            if cnt >= N-1:
                break
            if A[cnt+1] < A[cnt]:
                break
            cnt += 1
        if cnt >= N-1:
            break
        buy = True
        money += (stock*A[cnt])
        stock = 0
    else:
        while True:
            if cnt >= N-1:
                break
            if A[cnt+1] > A[cnt]:
                break
            cnt += 1
        if cnt >= N-1:
            break
        buy = False
        stock += (money//A[cnt])
        money %= A[cnt]
    if cnt >= N-1:
        break
money += (stock*A[-1])
print(max(money,1000))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
if A[0] < A[1]:
    stock += (money//A[0])
    money %= A[0]
    
tmp = A[0]
for i in range(1,N):
    if tmp < A[i]:
        if i == N-1:
            money += (stock*A[i])
        if A[i] < A[i+1]:
            tmp = A[i]
            continue
        money += (stock*A[i])
        stock = 0
        tmp = A[i]
    elif tmp > A[i]:
        if i == N-1:
            money += (stock*A[i])
            break
        if A[i] > A[i+1]:
            tmp = A[i]
            continue
        stock += (money//A[i])
        money %= A[i]
        tmp = A[i]
        
print(max(money,1000))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

money = 1000
stock = 0
if A[0] < A[1]:
    stock += (money//A[0])
    money %= A[0]
    
tmp = A[0]
for i in range(1,N):
    if tmp < A[i]:
        money += (stock*A[i])
        stock = 0
        tmp = A[i]
    elif tmp > A[i]:
        if i == N:
            money += (stock*A[i])
            break
        if A[i] > A[i+1]:
            tmp = A[i]
            continue
        stock += (money//A[i])
        money %= A[i]
        tmp = A[i]
        
print(max(money,1000))
Problem p02641 (python)

Fixed submission:
from sys import stdin
X, Y = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 10**9+7
P = set(list(range(-200, 200))) - set(P)
P = list(P)
P.sort(reverse=True)


ans = 0
for i in P:
    if abs(X-i) <= tmp:
        ans = i
        tmp = abs(X-i)

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
X,Y = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 10**9+7
P = set(list(range(0,101))) - set(P)
P.sort(reverse=True)


ans = 0
for i in P:
    if abs(i-X) <= tmp:
        ans = i
        tmp = abs(i-X)
        
print(ans)
Problem p02783 (python)

Fixed submission:
from sys import stdin
H,A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
while True:
    H -= A
    ans += 1
    if H <= 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
# 1-index
from sys import stdin
H, N = [int(x) for x in stdin.readline().rstrip().split()]

data = [0]*N

for i in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[i] = (A, B)
dp = [10**9]*(H+1)
dp[0] = 0

for h in range(0,H+1):
    for a,b in data:
        if h+a >= H:
            dp[H] = min(dp[h]+b,dp[H])
        else:
            dp[h+a] = min(dp[h]+b,dp[h+a])
print(dp[H])
Problem p02787 (python)

Fixed submission:
# 1-index
from sys import stdin
H, N = [int(x) for x in stdin.readline().rstrip().split()]

data = [0]*N

for i in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[i] = (A, B)
dp = [10**9]*(H+1)
dp[0] = 0

for h in range(0,H+1):
    for a,b in data:
        if h+a >= H:
            dp[H] = min(dp[h]+b,dp[H])
        else:
            dp[h+a] = min(dp[h]+b,dp[h+a])
print(dp[H])

Buggy submission (verdict: Runtime Error):
from sys import stdin
H,N = [int(x) for x in stdin.readline().rstrip().split()]
data = []
ans = 10**9
for i in range(N):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    C = A / B
    if A >= H:
        ans = min(ans,B)
    data.append((C,A,B))


dp = [10**9]*(H+1)

c,a,b = sorted(data)[::-1][0]

cnt = 0
for i in range(1,H+1):
    cnt += 1
    if cnt*a >= H:
        dp[-1] = (b*cnt)
        break
    else:
        dp[cnt*a] = (b*cnt)
        

tmp = 10**9
for j in range(H,-1,-1):
    tmp = min(dp[j],tmp)
    dp[j] = tmp

for c,a,b in data:
    dp[-1] = min(dp[-a] + b ,dp[-1])
    
for c,a,b in data:
    dp[-1] = min(dp[-2*a] + (2*b) ,dp[-1])

tmp = 10**9
for j in range(H,-1,-1):
    tmp = min(dp[j],tmp)
    dp[j] = tmp
    
print(min(ans,dp[-1]))

Buggy submission (verdict: Runtime Error):
from sys import stdin
H,N = [int(x) for x in stdin.readline().rstrip().split()]
data = []
ans = 10**9
for i in range(N):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    C = A / B
    if A >= H:
        ans = min(ans,B)
    data.append((C,A,B))


dp = [10**9]*(H+1)

c,a,b = sorted(data)[::-1][0]

cnt = 0
for i in range(1,H+1):
    cnt += 1
    if cnt*a >= H:
        dp[-1] = (b*cnt)
        break
    else:
        dp[cnt*a] = (b*cnt)
        

tmp = 10**9
for j in range(H,-1,-1):
    tmp = min(dp[j],tmp)
    dp[j] = tmp

for c,a,b in data:
    dp[-1] = min(dp[-a] + b ,dp[-1])

print(min(ans,dp[-1]))
Problem p02823 (python)

Fixed submission:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    ans1 = 0
    a1 = A
    b1 = B
    ans1 += (a1-1)
    b1 -= (a1-1)
    a1 = 1
    
    if b1 % 2 == 0:
        b1 -= 1
        ans1 += 1
    ans1 += ((b1 -1)//2)
    
    ans2 = 0
    a2 = A
    b2 = B
    ans2 += (N-B)
    a2 += (N-B)
    b2 += (N-B)
    if (a2 % 2) != (b2 % 2):
        a2 += 1
        ans2 += 1
    ans2 += ((b2 - a2)//2)
    print(min(ans1,ans2,B-1,N-A))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if (B - A) % 2 == 0:
    print(min((B-A)//2),N-A,B-1)
else:
    print(min(N-A,B-1))
Problem p02865 (python)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
if N % 2 == 0:
    print(N//2-1)
else:
    print(N//2)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
D = [int(x) for x in stdin.readline().rstrip().split()]
mod = 998244353
ans = 1
if N == 1 and D[0] == 0:
    print(1)
elif len(set(D))==1:
    print(0)
elif D.count(0) != 1:
    print(0)
elif D[0] != 0:
    print(0)
else:
    tmp = 1
    cnt = Counter(D)
    #print(cnt)
    flag = True
    for i in range(1,max(D)+1):
        #print(cnt[i],tmp)
        if i != 1 and cnt[i] != tmp:
            flag = False
        c = (tmp**cnt[i]) % mod
        ans *= c % mod
        tmp = cnt[i]
        ans = ans % mod
    if flag:
        print(1)
    else:
        print(ans % mod)