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

Fixed submission:
N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]
sushi = sorted(sushi, key=lambda x: x[1], reverse=True)
typ = set()
lstA = []
lstB = []
for item in sushi:
    if item[0] in typ:
        item[0] = 0
        lstB.append(item[1])
    else:
        typ.add(item[0])
        item[0] = 1
        lstA.append(item[1])
ans = 0
neta = 0
for i in range(K):
    ans += sushi[i][1]
    if sushi[i][0] == 1:
        neta += 1
ans += neta ** 2
C = sum(lstA[:neta])
D = sum(lstB[:K - neta])
for i in range(neta + 1, min(K, len(lstA)) + 1):
    C += lstA[i - 1]
    D -= lstB[K - i]
    tmp = C + D + i ** 2
    ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]
sushi = sorted(sushi, key=lambda x: x[1], reverse=True)
typ = set()
lstA = []
lstB = []
for item in sushi:
    if item[0] in typ:
        item[0] = 0
        lstB.append(item[1])
    else:
        typ.append(item[0])
        item[0] = 1
        lstA.append(item[1])
ans = 0
neta = 0
for i in range(K):
    ans += sushi[i][1]
    if sushi[i][0] == 1:
        neta += 1
ans += neta ** 2
C = sum(lstA[:neta])
D = sum(lstB[:K - neta])
for i in range(neta + 1, min(K, len(lstA)) + 1):
    C += lstA[i - 1]
    D -= lstB[K - i]
    tmp = C + D + i ** 2
    ans = max(ans, tmp)
print(ans)
Problem p03160 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
DP = [float('inf')] * N
DP[0] = 0
DP[1] = abs(H[1] - H[0])
for i in range(2, N):
    DP[i] = min(DP[i - 1] + abs(H[i] - H[i - 1]), DP[i - 2] + abs(H[i] - H[i - 2]))
print(DP[N - 1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [10**18] * N
DP[0] = 0
for i in range(N - 1):
    for j in range(1, min(K + 1, N - i)):
        DP[i + j] = min(DP[i + j], DP[i] + abs(H[i + j] - H[i]))
print(DP[N - 1])

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> h(N);
    for(auto &&item : h) cin >> item;
    vector<int> c(N);
    c.at(0) = 0; c.at(1) = abs(h.at(1) - h.at(0));
    for(int i = 2; i < N; i++) c.at(i) = min(c.at(i - 1) + abs(h.at(i) - h.at(i - 1)), c.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
    cout << c.at(N - 1) << endl;
    return 0;
}
Problem p03262 (python)

Fixed submission:
from functools import reduce
def gcd(x, y):
    if not y:
        return x
    return gcd(y, x % y)
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
d = []
for i in range(N):
    d.append(x[i + 1] - x[i])
ans = reduce(gcd, d)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
d = []
for i in range(N):
    d.append(x[i + 1] - x[i])
ans = reduce(gcd, d)
print(ans)
Problem p03282 (python)

Fixed submission:
import math
S = input()
K = int(input())
M = 5 * 10 ** 15

def main():
    sum = 0
    for s in S:
        n = int(s)
        sum += (M - 1) * math.log(n)
        if sum >= math.log(K):
            print(n)
            return

def main2():
    if K <= len(S):
        for i in range(K):
            if S[i] != '1':
                print(S[i])
                return
        print('1')
        return
    else:
        for s in S:
            if s != '1':
                print(s)
                return

if __name__ == '__main__':
    main2()

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == '1':
    print(S[1])
else:
    print(S[0])
Problem p03309 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [A[i] - 1 - i for i in range(N)]
B.sort()
if N % 2 == 0:
    med = [B[int(N / 2) - 1], int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2), B[int(N / 2)]]
else:
    med = [B[int((N + 1) / 2) - 1]]
ans = 10 ** 100
for b in med:
    S = 0
    for i in range(N):
        S += abs(B[i] - b)
    ans = min(ans, S)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = [A[i] - 1 - i for i in range(N)]
B.sort()
if N % 2 == 0:
    med = [int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2)]
else:
    med = [B[int((N + 1) / 2) - 1]]
S = 0
for i in range(N):
    S += abs(B[i] - b)
print(S)
Problem p03323 (python)

Fixed submission:
A, B = list(map(int, input().split()))
if(A > 8 or B > 8):
    print(':(')
else:
    print('Yay!')

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
if(A > 8 and B > 8)
    print(':(')
else
    print('Yey!')

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
if(A > 8 and B > 8)
    print(':(')
else
    print('Yey!')
Problem p03361 (python)

Fixed submission:
def main():
    H, W = map(int, input().split())
    c = []
    c.append(['.'] * (W + 2))
    for _ in range(H):
        c.append(['.'] + list(input()) + ['.'])
    c.append(['.'] * (W + 2))
    for h in range(1, H + 2):
        for w in range(1, W + 2):
            if c[h][w] == '#':
                if c[h - 1][w] == c[h + 1][w] == c[h][w - 1] == c[h][w + 1] == '.':
                    print('No')
                    return
    print('Yes')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h, w = map(int, input().split())
    c = []
    c.append(['.'] * (w + 2))
    for _ in range(h):
        c.append(['.'] + list(input()) + ['.'])
    c.append(['.'] * (w + 2))
    for h in range(1, h + 2):
        for w in range(1, w + 2):
            if c[h][w] == '#':
                if c[h - 1][w] == c[h + 1][w] == c[h][w - 1] == c[h][w + 1] == '.':
                    print('no')
                    return
    print('yes')


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

Fixed submission:
N, C = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(N)]
timeTable = [[False for _ in range(10 ** 5)] for _ in range(C)]
time = [0 for _ in range(10 ** 6)]
for q in query:
    s, t, c = q
    for i in range(s - 1, t):
        timeTable[c - 1][i] = True
for channel in timeTable:
    for i in range(10 ** 5):
        if channel[i]:
            time[2 * i - 1] += 1
            time[2 * i] += 1
print(max(time))

Buggy submission (verdict: Runtime Error):
N, C = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(N)]
time = [0 for _ in range(2 * 10 ** 5)]
for q in query:
    s, t = q[:2]
    for i in range(2 * s - 1, 2 * t + 1):
        time[i] += 1
print(max(time))
Problem p03612 (python)

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
i = 0
ans = 0
while(i < N - 1):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
    i += 1
if p[N - 1] == N:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
i = 0
ans = 0
while(i < N - 1):
    print(p)
    print(' ' * (3 * i + 1) + str(i + 1))
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
    i += 1
if p[N - 1] == N:
    ans += 1
print(ans)
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())
if X < A:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
X, A = map(int, input().split())
if X < A:
    print(0)
else:
    print(10
Problem p03425 (python)

Fixed submission:
N=int(input())
S=[]
for _ in range(N):
    S.append(list(input()))
# print(S)

count = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}

for s in S:
    if s[0] in ['M','A','R','C','H']:
        count[s[0]] += 1

# print(count)

H=['M','A','R','C','H']
res = 0
for i in range(0,5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            cnt = count[H[i]] * count[H[j]] * count[H[k]]
            # print(i,j,k,cnt)
            res += cnt

print(res)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[]
for _ in range(N):
    S.append(list(input()))
# print(S)

count = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}

for s in S:
    if s[0] in ['M','A','R','C','H']:
        count[s[0]] += 1

# print(count)

H=['M','A','R','C','H']
res = 0
for i in range(0,N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            cnt = count[H[i]] * count[H[j]] * count[H[k]]
            # print(i,j,k,cnt)
            res += cnt

print(res)
Problem p02732 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
a = [int(x) for x in input().split()]

cnt = defaultdict(int)
for v in a:
  cnt[v] += 1

ans = 0
for v in cnt:
  ans += cnt[v]*(cnt[v]-1)//2

for v in a:
  print(ans + (cnt[v]-1)*(cnt[v]-2)//2 - cnt[v]*(cnt[v]-1)//2)

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

n = int(input())
a = [int(x) for x in input().split()]

cnt = defaultdict(int)
for v in a:
  cnt[v] += 1

ans = 0
for k, v in cnt:
  ans += v*(v-1)//2

for v in a:
  print(ans + (cnt[v]-1)*(cnt[v]-2)//2 - cnt[v]*(cnt[v]-1)//2)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = []
B = []
for _ in range(N):
    temp = int(input())
    A.append(temp)
    B.append(temp)

B.sort(reverse=True)
max_first = B[0]
max_second = B[1]

for i in range(N):
    if A[i] == max_first:
        print(max_second)
    else:
        print(max_first)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(input())

B = sorted(A, reverse=True)
max_first = B[0]
max_second = B[1]

for i in range(N):
	answer = max_first
    if A[i] == max_first:
        answer = max_second
    print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
  A.append(input())

B = sorted(A, reverse=True)
max_first = B[0]
max_second = B[1]
max_third = B[2]

for i in range(N):
  if A[i] != max_first:
    print(max_first)
  elif A[i] != max_second:
    print(max_second)
  else:
    print(max_third)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
	A.append(input())
 
B = sorted(A, reverse=True, key=number)
max_first = B[0]
max_second = B[1]
max_third = B[2]
 
for i in range(N):
	if A[i] != max_first:
		print(max_first)
    else if A[i] != max_second:
		print(max_second)
    else:
		print(max_third)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
  A.append(input())
 
B = sorted(A, reverse=True, key=number)
max_first = B[0]
max_second = B[1]
max_third = B[2]
 
for i in range(N):
    if A[i] != max_first:
        print(max_first)
    elif A[i] != max_second:
        print(max_second)
    else:
        print(max_third)
Problem p02730 (python)

Fixed submission:
S=list(input())
N=len(S)
check=True
for i in range(N//2):
    if S[i]!=S[N-1-i]:
        check=False
        break
if check==False:
    print("No")
else:
    C=False
    for i in range((N//2)//2):
        if S[i]!=S[N//2-1-i]:#0123456
          C=True
          break
    if C==True:
        print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
word=list(input())
check=True
for i in range(len(word)//2)
    if word[i]==word[len(word)-1]:
        continue:
    else:
          check=False
          braek:
if check==True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
word=list(map.string().split())
check=True
for i in range(len(word)//2)
    if word[i]==word[len(word)-1]:
        continue:
    else:
          check=False
          braek:
if check==True:
    print("Yes")
else:
    print("No")
Problem p02732 (python)

Fixed submission:
M=int(input())
N=list(input().split())
check=[0]*M
for i in range(M):
    check[int(N[i])-1]+=1
num=0
for i in range(M):
    num+=check[i]*(check[i]-1)//2
for i in range(M):
    if check[int(N[i])-1]!=2:
        print(num-(check[int(N[i])-1]-1))
    else:
        print(num-1)

Buggy submission (verdict: Runtime Error):
M=int(input())
N=list(input().split())
print(N)
check=[0,0,0,0,0,0,0,0,0,0]
for i in range(M):
    check[int(N[i])]+=1
num=0
for i in range(M):
    num+=check[i]*(check[i]-1)//2
for i in range(M):
    print(num-(check[int(N[i])]-1))
Problem p02742 (python)

Fixed submission:
h,w=map(int,input().split())
if h==1 or w==1:
  print("1")
elif h%2==0:
    print((h*w)//2)
elif w%2==0:
    print((h*w)//2)
else:
    print((w*(h//2))+(w//2)+1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if h=1 or w==1:
    print("1")
elif h%2==0:
    print((h*w)//2)
elif w%2==0:
    print((h*w)//2)
else:
    print((w*(h//2))+(w//2)+1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if h=1 or w==1:
  print("1")
elif h%2==0:
    print((h*w)//2)
elif w%2==0:
    print((h*w)//2)
else:
    print((w*(h//2))+(w//2)+1)
Problem p02783 (python)

Fixed submission:
H,N=map(int,input().split())
if H%N==0:
    print(H//N)
else:
    print((H//N)+1)

Buggy submission (verdict: Runtime Error):
H,A=map(int,input().spkit())
if H%A==0:
    print(H//A)
else:
    print((H//A)+1)
Problem p03997 (python)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
ans =  (a+b)*h//2
print(ans)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
h=input()
ans = (a+b)*h/2
print(ans)

Buggy submission (verdict: Runtime Error):
ans = (a+b)*h/2
print(ans)

Buggy submission (verdict: Runtime Error):
(a+b)*h/2
Problem p02760 (python)

Fixed submission:
a= []
for i in range(3):
  a_input = input().split()
  a.append(a_input)

n = int(input())
for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == a[j][k]:
        a[j][k] = "0"

for i in range(3):
    if a[0][i] == "0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
      exit()
    elif a[i][0] == "0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
      exit()
    elif a[0][0] == "0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
      exit()
    elif a[0][2] == "0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
      exit()
print("No")

Buggy submission (verdict: Runtime Error):
a= []
for i in range(3):
  a_input = input().split()
  a.append(int(a_input))

for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == a[j][k]:
        a[j][k] = "0"

for i in range(3):
    if a[0][i] == "0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
    elif a[i][0] == "0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
    elif a[0][0] == "0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
    elif a[0][2] == "0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
    else:
      print("No")

Buggy submission (verdict: Runtime Error):
a= []
for i in range(3):
  a_input = input().split()
  a.append(int(a_input))

for i in range(n):
  x = input()
  for j in range(3):
    for k in range(3):
      if x == int(a[j][k]):
        a[j][k] = "0"

for i in range(3):
    if a[0][i] == "0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
    elif a[i][0] == "0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
    elif a[0][0] == "0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
    elif a[0][2] == "0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
    else:
      print("No")
Problem p03844 (python)

Fixed submission:
a, op, b = map(str, input().split())
a = int(a)
b = int(b)
print(a + b if op == "+" else a - b)

Buggy submission (verdict: Runtime Error):
a, op, b = map(int, input().split())
print(a + b if op == + else a - b)

Buggy submission (verdict: Runtime Error):
a, b, c = map(str, input().split())
a = int(a)
b = int(b)
print(a + b if op == "+" else a - b)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(a + b if op == + else a - b)

Buggy submission (verdict: Runtime Error):
a = int(input())
op = str(input())
b = int(input())
print(a + b if op == "+" else a - b)

Buggy submission (verdict: Runtime Error):
a = int(input())
op = input()
b = int(input())
print(a + b if op == "+" else a - b)
Problem p04011 (python)

Fixed submission:
n,k,x,y=(int(input()) for i in range(4))
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)

Buggy submission (verdict: Runtime Error):
n,k,x,y=int(input()) for i in range(4)
if n - k > 0:
  ans = k * x + (n - k) * y
else:
  ans = n * x
print(ans)

Buggy submission (verdict: Runtime Error):
n,k,x,y=(int(input().split()) for i in range(4))
j = 0
if n > k:
   j = (n - k)  * y
print(k * x + j)

Buggy submission (verdict: Runtime Error):
N, K, X, Y = (int(input().split()) for _ in range(4))
t = 0
if N >= K:
    print(X*K + Y*(N-K))
else:
    print(X*N)

Buggy submission (verdict: Runtime Error):
n, k, x, y = (int(input().split()) for _ in range(4))
t = 0
if n - k > 0:
  t = (n  - k) * y
print(n * x + t)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input().split()) for _ in range(4)
t = 0
if n - k > 0:
  t = (n  - k) * y
print(n * x + t)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input().split()) for _ in range(4)
t = 0
if n - k > 0:
  t = (n  - k) * y
print(n * x + t)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input().split()) for _ in range(4)
t = 0
if n - k > 0:
  t = (n  - k) * y
print(k * x + t)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input().split()) for _ in range(4)
print(k * x + (k - n) * y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = [int(input().split()) for _ in range(4)]
print(k * x + (n - k) * y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input().split()) for _ in range(4)
print(k * x + (n - k) * y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input.split()) for _ in range(4)
print(k * x + (n - k) * y)
Problem p04029 (python)

Fixed submission:
count = 0
for i in range(int(input()) + 1):
  if i == 0:
    continue
  count += i
print(count)

Buggy submission (verdict: Runtime Error):
count = 0
for i range(int(input()) + 1):
  if i == 0:
    continue
  count += i
print(count)
Problem p04043 (python)

Fixed submission:
List=[int(i) for i in input().split()]
if List.count(5) == 2 and List.count(7) == 1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
List=[int(i) for i in input().split()]
if List.count(5) == 2 and List.cout(7) == 1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
List=[int(i) for i in input().split()]
if List.count(5) == 2 and List.cout(7) == 1:
  print("YES")
else:
  print("NO")
Problem p02848 (python)

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    s = input().rstrip()
    first = ord("A") - 1
    last = ord("Z")
    increment = lambda x: chr(ord(x)+n) if ord(x)+n <= last else chr(first + (ord(x)+n - last))
    new_s = "".join(map(increment, s))
    print(new_s, end="")
    


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    s = input().rsplit()
    first = ord("A") - 1
    last = ord("Z")
    increment = lambda x: chr(ord(x)+n) if ord(x)+n <= last else chr(first + (ord(x)+n - last))
    new_s = "".join(map(increment, s))
    print(new_s, end="")
    


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

Fixed submission:

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

ans = [0]

for i in range(1, n):
    j = 0 if i-k<0 else i-k
    min_cost = float('inf')
    for l in range(j, i):
        min_cost = min(min_cost, (abs(h[i] - h[l]) + ans[l]))
    
    ans.append(min_cost)

print(int(ans[-1]))

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

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

ans = np.zeros(n)

for i in range(1, n):
    j = 0 if i-k<0 else i-k
    min_cost = float('inf')
    for l in range(j, i):
        min_cost = min(min_cost, (abs(h[i] - h[l]) + ans[l]))
    
    ans[i] = min_cost

print(int(ans[-1]))

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

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

ans = np.zeros(n)

for i in range(1, n):
    j = 0 if i-k<0 else i-k
    min_cost = float('inf')
    for l in range(j, i):
        min_cost = min(min_cost, (abs(h[i] - h[l]) + ans[l]))
    
    ans[i] = min_cost

print(int(ans[-1]))
Problem p03547 (python)

Fixed submission:
a, b =input().split(" ")
 
if a == b:
    print("=")
elif a < b:
    print("<")
elif a > b:
    print(">")

Buggy submission (verdict: Runtime Error):
a, b =raw_input().split(" ")

if a == b:
print "="
elif a < b
print "<"
elif a > b
print ">"
Problem p02787 (python)

Fixed submission:
H,N=map(int,input().split())
L=[]
m=0
for i in range(N):
    T=[0,0]
    T[0],T[1]=map(int,input().split())
    L.append(T)
    m=max(m,T[0])
L=sorted(L,reverse=True)
L.insert(0,[0,0])
m+=1
DP=[[10**10 for i in range(H+1+m)] for j in range(N+1)]
DP[0][0]=0

for i in range(1,N+1):
    t=0
    DP[i][0]=0
    for j in range(H+1):
        DP[i][j]=min(DP[i][j],DP[i-1][j])
        t=min(DP[i][j],DP[i-1][j])+L[i][1]
        DP[i][j+L[i][0]]=min(DP[i][j+L[i][0]],t)
    DP[i][H]=min(DP[i][H:-1])
print(min(DP[N][H:-1]))

Buggy submission (verdict: Runtime Error):
H,N=map(int,input().split())
L=[]
for i in range(N):
    T=[0,0,0]
    T[1],T[2]=map(int,input().split())
    T[0]=T[2]/T[1]
    L.append(T)
L=sorted(L)
n=1+H//L[0][1]
m=n*L[0][2]

def DP(MAX,minN,minM,i,T,M):
    t=T
    m=M
    if(T>=MAX):
        return M
    if(T<MAX):
        t+=L[i][1]
        m+=L[i][2]
        if(m<minM):        
            tm=DP(MAX,minN,minM,i,t,m)
            if(minM>tm):
                minM=tm
    if(len(L)-1 > i):
        t=T
        m=M
        if(m<minM):
            tm=DP(MAX,minN,minM,i+1,t,m)
            if(minN>tm):
                minM=tm
    return minM

tm=DP(H,10**10,m,0,0,0)

print(tm)
Problem p02845 (python)

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

c=1
for a in A:
    c*=B[a]
    c%=1000000007
    B[a]-=1
    B[a+1]+=1

print(c)

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

c=1
for a in A:
    c*=B[a]
    c%=1000000007
    B[a]-=1
    B[a+1]+=1

print(c)
Problem p02866 (python)

Fixed submission:
import math

N = int(input())
D={}
T=list(map(int,input().split()))
if(T[0]!=0):
        print("0")
        exit()

for i in range(N):
    if D.get(T[i],None)==None:
        D[T[i]]=1
    else:
        D[T[i]]+=1

Max=max(D)
Min=min(D)
Len=len(D)
Item=sorted((D.items()))
if(Item[0][1]!=1):
        print("0")
        exit()
for i in range(Len):
    if(Item[i][0]!=i):
        print("0")
        exit()
ans=1
for i in range(1,Len):
    ans = (ans * (Item[i-1][1]**Item[i][1])) % 998244353
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
D={}
T=list(map(int,input().split()))
for i in range(N):
    if D.get(T[i],None)==None:
        D[T[i]]=1
    else:
        D[T[i]]+=1

Max=max(D)
Min=min(D)
Len=len(D)
Item=sorted((D.items()))
if(Item[i][0]!=i):
    print("0")
    exit()
ans=1
for i in range(1,Len):
    ans = (ans * (Item[i-1][1]**Item[i][1])) % 998244353
    
print(ans)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

total=0
for i in range(3):
    if(S[i]==T[i]):
        total+=1
print(total)

Buggy submission (verdict: Runtime Error):
S = int(input())
total=10*10
if(S%2==1):
    total=S*((S-1)//2)
else:
    total=(S-1)*((S-2)//2)+(S-1)

print(total)