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

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
else:
    v1 = [v[i] for i in range(0, n, 2)]
    v2 = [v[i + 1] for i in range(0, n, 2)]

    kw1 = Counter(v1)
    kw2 = Counter(v2)

    x1 = kw1.most_common()[0][0]
    x2 = kw2.most_common()[0][0]

    if x1 != x2:
        ans = 0
        for i in v1:
            if i != x1:
                ans += 1
        for i in v2:
            if i != x2:
                ans += 1
    else:
        y1 = kw1.most_common()[1][0]
        y2 = kw2.most_common()[1][0]

        ans1 = 0
        ans2 = 0

        for i in v1:
            if i != y1:
                ans1 += 1
        for i in v2:
            if i != x2:
                ans1 += 1

        for i in v1:
            if i != x1:
                ans2 += 1
        for i in v2:
            if i != y2:
                ans2 += 1

        ans = min(ans1, ans2)

    print(ans)

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

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
else:
    v1 = [v[i] for i in range(0, n, 2)]
    v2 = [v[i + 1] for i in range(0, n, 2)]

    kw1 = Counter(v1)
    kw2 = Counter(v2)

    x1 = kw1.most_common()[0][0]
    x2 = kw2.most_common()[0][0]

    if x1 != x2:
        ans = 0
        for i in v1:
            if i != x1:
                ans += 1
        for i in v2:
            if i != x2:
                ans += 1
    else:
        y1 = kw1.most_common()[1][0]
        y2 = kw2.most_common()[1][0]

        ans1 = 0
        ans2 = 0

        for i in v1:
            if i != y1:
                ans1 += 1
        for i in v2:
            if i != x2:
                ans1 += 1

        for i in v1:
            if i != x1:
                ans2 += 1
        for i in v2:
            if i != y2:
                ans2 += 1

        ans = min(ans1, ans2)

print(ans)
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce

n, x = map(int, input().split())
xx = [abs(int(i) - x) for i in input().split()]

if n == 1:
    ans = xx[0]
else:
    ans = reduce(fractions.gcd, xx)

print(ans)

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

n, x = map(int, input().split())
xx = list(map(int, input().split()))
xx.sort()

if n == 1:
    ans = xx[0] - x
else:
    dist = [xx[i + 1] - xx[i] for i in range(n - 1)]
    ans = reduce(math.gcd, dist)

print(ans)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

limit = min(100, k)

ans = 1
for i in range(limit):
    if s[i] != '1':
        ans = s[i]
        break

print(ans)

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

if s[0] == '1':
    print(s[1])
else:
    print(s[0])
Problem p03543 (python)

Fixed submission:
n = input()

if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')

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

if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')
Problem p03565 (python)

Fixed submission:
s = input()
t = input()

n = len(s)
m = len(t)

if t in s:
    print(s.replace('?', 'a'))
else:
    ans = []
    for i in range(n - m + 1):
        bubun = s[i:i + m]
        flag = True
        for j in range(m):
            x = bubun[j]
            y = t[j]
            if x == y:
                continue
            elif x == '?':
                continue
            else:
                flag = False
                break

        if flag:
            ans.append((s[:i] + t + s[i + m:]).replace('?', 'a'))

    print(sorted(ans)[0]) if ans else print('UNRESTORABLE')

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

n = len(s)
m = len(t)

for i in range(n - m + 1):
    bubun = s[i:i + m]
    flag = True
    for j in range(m):
        x = bubun[j]
        y = t[j]
        if x == y:
            pass
        elif x == '?':
            pass
        else:
            flag = False

    if flag:
        ans = s[:i].replace('?', 'a') + t + s[i + m:].replace('?', 'a')
        break

print(ans) if flag else print('UNRESTORABLE')
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]

ans = reduce(lambda x, y: x * y // fractions.gcd(x, y), t)
print(ans)

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

n = int(input())
t = [int(input()) for _ in range(n)]

ans = reduce(lambda x, y: x * y // math.gcd(x, y), t)
print(ans)
Problem p03778 (python)

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

if b > a + w:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)

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

if b > a + w:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)
w, a, b = map(int, input().split())

if b > a + w:
    print(b - a - w)
elif b + w < a:
    print(a - b - w)
else:
    print(0)
Problem p03943 (python)

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

if a + b == c or b + c == a or c + a == b:
    print('Yes')
else:
    print('No')

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

if a + b == c or b + c == a or c + a == b:
    print('Yes')
else:
    print('No')
a, b, c = map(int, input().split())

if a + b == c or b + c == a or c + a == b:
    print('Yes')
else:
    print('No')
Problem p04013 (python)

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

dp = [[[0] * (50 * (n + 10)) for _ in range(n + 10)] for _ in range(n + 10)]
dp[0][0][0] = 1

for i in range(n):
    for use in range(n):
        for total in range(n * a):
            if dp[i][use][total]:
                dp[i + 1][use][total] += dp[i][use][total]
                dp[i + 1][use + 1][total + x[i]] += dp[i][use][total]

ans = 0
for i in range(1, n + 1):
    ans += dp[n][i][a * i]

print(ans)

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

dp = [[[0] * 3000 for _ in range(50)] for _ in range(50)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(n):
        for k in range(n * a):
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

ans = 0
for i in range(1, n):
    ans += dp[n][i][a * i]

print(ans)
Problem p04045 (python)

Fixed submission:
n, k = map(int, input().split())
d = set(input().split())

while set(list(str(n))) & d != set():
    n += 1

print(n)

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

keta = int(len(str(n)))
ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))

ans = ''
for i in reversed(range(keta)):
    val = int(str(n)[i])
    candidate = [j for j in ok if j >= val]
    if candidate:
        ans += str(min(candidate))
    else:
        ans = str(min(ok))

ans = ''.join(reversed(list(ans)))
if int(ans) < n:
    idx = ok.index(ans[0])
    if idx == len(ok) - 1:
        ans = str(min(ok)) * (keta + 1)
    else:
        ans = str(ok[idx + 1]) + str(min(ok)) * (keta - 1)

print(ans)

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

ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))

ans = ''
for i in range(len(str(n))):
    flag = False
    num = int(str(n)[i])
    candidate = [j for j in ok if j >= num]
    if candidate:
        ans += str(min(candidate))
    else:
        ans += min(ok)
        flag = True

if flag:
    ans[0] = str(min([i for i in ok if i > ans[0]]))

print(ans)

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

ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))

ans = ''
for i in range(len(str(n))):
    num = int(str(n)[i])
    ans += str(min([j for j in ok if j >= num]))

print(ans)
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split())
ans = 'No'
for a in range(x+1):
    b = x-a
    if 2*a+4*b == y:
        ans = 'Yes'

print(ans)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
ans = 'No'
for a in range(x+1):
    b = x-a
    if 2*a+4*b == Y:
        ans = 'Yes'

print(ans)
Problem p02586 (python)

Fixed submission:
R, C, K = map(int, input().split())
V = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(K):
  r, c, v = map(int, input().split())
  V[r-1][c-1] = v
M = [0] * R * C * 4 
# M[r*C*4 + c*4 + i]
# M[(r-1)*C*4 + c*4 + i]
# M[r*C*4 + (c-1)*4 + i]
# M[r][c][count in column (c)]
for r in range(R):
  for c in range(C):
    for n_pick in [0, 1] if V[r][c] else [0]:
      M[r*C*4 + c*4 +n_pick] = max(M[r*C*4 + c*4 +n_pick], n_pick*V[r][c])
      if r > 0:
        for n_prev in range(4):
          #print('R++', r, c, n_pick, n_prev)
          if M[(r-1)*C*4 + c*4 +n_prev] > 0 or n_prev == 0:
            M[r*C*4 + c*4 +n_pick]=max(M[r*C*4 + c*4 +n_pick],
              M[(r-1)*C*4 + c*4 +n_prev] + n_pick*V[r][c])
      if c > 0:
        for n_prev in range(4 - n_pick):
          #print('C++', r, c, n_pick, n_prev)
          if  M[r*C*4 + (c-1)*4 +n_prev]  > 0 or n_prev == 0:
            M[r*C*4 + c*4 +n_prev+n_pick]=max(M[r*C*4 + c*4 + n_prev+n_pick],
              M[r*C*4 + (c-1)*4 +n_prev] + n_pick*V[r][c])
    #print(candidates)
    #print(r, c, candidates, M)
    #for i in range(4):
    #  M[r][c][i] = max(candidates[i])
    #print(r, c, M)
#print(V, M)
print(max(M[((R-1)*C*4 + (C-1) *4):((R-1)*C*4 + (C-1) *4+4)]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(lambda x:int(x)-1, input().split()))
C = list(map(int, input().split()))
done = [False] * N
ans = -10**30
must_negative = all([c < 0 for c in C])
for i in range(N):
  if done[i]:
    continue
  loop = [i]
  done[loop[-1]] = True
  while not done[P[loop[-1]]]:
    loop.append(P[loop[-1]])
    done[loop[-1]] = True
    #print(loop, done)
  #print(loop)
  scores = [C[i] for i in loop]
  #print(scores)
  cumsum = [0]
  for s in scores * 2:
    cumsum.append(cumsum[-1] + s)
  #print(cumsum)
  L = len(scores)
  if cumsum[L] >= 0:
    # (L+K) // L  loops - max
    l = max(0, (K - L) // L )
    k_max = K - l * L
    #print(l, k_max)
    base_score = cumsum[L] * l
  else:
    k_max = min(K, L)
    #print(k_max)
    base_score = 0
  for i in range(L):
    for k in range(k_max+1):
      score = base_score + cumsum[i + k] - cumsum[i]
      #print(i, k, base_score, score)
      if must_negative and score == 0:
        continue
      ans = max(ans, score)
print(ans)
Problem p02618 (python)

Fixed submission:
import numpy as np
def read_input():
  D = int(input())
  c = list(map(int, input().split()))
  s = [list(map(int, input().split())) for _ in range(D)]
  return D, c, s
D, c, s = read_input()

for t in np.array(s).argmax(axis=1)+1:
  print(t)

Buggy submission (verdict: Runtime Error):
import numpy as np
import time
import random
import collections
import bisect  

start = time.time()

def insert(list, n): 
    bisect.insort(list, n)  
    return list

def read_input():
  D = int(input())
  c = list(map(int, input().split()))
  s = [list(map(int, input().split())) for _ in range(D)]
  return D, c, s
D, c, s = read_input()

c = np.array(c)
s = np.array(s)
tests = np.argmax(s, axis=1)

def get_dates_for_tests(tests):
  dates_for_tests = [list([-1]) for _ in range(26)]
  for i, t in enumerate(tests):
    dates_for_tests[t].append(i)
  for t in range(26):
    dates_for_tests[t].append(D)
  return dates_for_tests

dates_for_tests = get_dates_for_tests(tests)

def get_score(tests):
  dates_for_tests = get_dates_for_tests(tests)
  score = 0
  d = np.zeros(26, dtype=np.int64)
  for selected, S in zip(tests, s):
    d += 1
    d[selected] = 0
    score += S[selected] - (c * d).sum()
  return score

def score_diff(date, test):
  #print(date, test)
  before = tests[date]
  if test == before:
    return 0, None, None
  pos_diff = s[date, test] - s[date, before]
  new_index = bisect.bisect_left(dates_for_tests[test], date, 1)
  new_diff = c[test] * (dates_for_tests[test][new_index] - date) * (date - dates_for_tests[test][new_index-1])

  old_index = bisect.bisect_left(dates_for_tests[before], date, 1)
  #print(c[test], dates_for_tests[test])
  #print(c[before], dates_for_tests[before])
  old_diff = c[before] * (dates_for_tests[before][old_index+1] - date) * (date - dates_for_tests[before][old_index-1])
  
  total_diff = pos_diff + new_diff - old_diff
  #print(test, total_diff, pos_diff, new_diff, -old_diff)
  return total_diff, new_index, old_index

# current_score = get_score(tests)
while time.time() < start + 1.8:
  t = time.time()
  for date in range(D):
    for test in range(26):
      # date = 4
      # test = 23

      total_diff, new_index, old_index= score_diff(date, test)
      to_update = total_diff > 0
      if t < start + 1.6 and total_diff > -5000:
        to_update += random.randrange(5) == 0
      if to_update:
        # print('INCREASING')
        #print(date, tests[date], test)
        #print(c[[tests[date], test]])
        #print(s[date, [tests[date], test]])
        del dates_for_tests[tests[date]][old_index]
        insert(dates_for_tests[test], date)
        tests[date] = test

        #assert dates_for_tests == get_dates_for_tests(tests)
        #new_score = get_score(tests)
        #print(total_diff, new_score - current_score , current_score, new_score) 
        #assert new_score == current_score + total_diff
        #current_score = new_score
        # raise ValueError
        
# print(get_score(tests))
for t in tests:
  print(t+1)
Problem p02642 (python)

Fixed submission:
import itertools
N = int(input())
A = list(map(int, input().split()))
count = {}
for a in A:
  if a not in count:
    count[a] = 0
  count[a] += 1

def check(a):
  if count[a] > 1:
    return 0

  if 1 in count:
    if a == 1 and count[1] == 1:
      return 1
    return 0

  #print(a)
  ok = True
  sqr_a = 1 + int(a**0.5)
  for s in itertools.chain([2], range(3, sqr_a, 2)):
    if a % s:
      continue
    c = s
    while c < sqr_a:
      if a % c == 0 and (c in count or (a//c) in count):
        #print(a, c)
        ok = False
        break
      c *= 2
  return ok
  
ans = 0
for a in A:
  ans += check(a)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
A = list(map(int, input().split()))
count = {}
for a in A:
  if a not in count:
    count[a] = 0
  count[a] += 1

def check(a):
  if count[a] > 1:
    return 0

  if 1 in count:
    if a == 1 and count[1] == 1:
      return 1
    return 0

  #print(a)
  ok = True
  sqr_a = 1 + int(a**0.5)
  for s in itertools.chain([2], range(3, sqr_a, 2)):
    if a % s:
      continue
    c = s
    while c < sq_a:
      if a % c == 0 and (c in count or (a//c) in count):
        #print(a, c)
        ok = False
        break
      c *= 2
  return ok
  
ans = 0
for a in A:
  ans += check(a)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
A = list(map(int, input().split()))
count = {}
for a in A:
  if a not in count:
    count[a] = 0
  count[a] += 1

  

def check(a):
  if count[a] > 1:
    return 0

  if 1 in count:
    if a == 1 and count[1] == 1:
      ans += 1
    return 0

  #print(a)
  ok = True
  sq_a = 1 + int(a**0.5)
  for s in itertools.chain([2], range(3, 1+int(a**0.5), 2)):
    c = s
    if a % c:
      continue
    while c < sq_a:
      if a % c == 0 and (c in count or (a//c) in count):
        #print(a, c)
        ok = False
        break
      c *= 2
  return ok
  
ans = 0
for a in A:
  ans += check(a)
print(ans)
Problem p03759 (python)

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input())
if b - a == c - b:
  print('YES')
else:
  print('NO')
Problem p02646 (python)

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if abs(A - B) <= (V - W) * T:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if (A < 0 and B < 0) or (A > 0 and B > 0):
    D = max(A, B) - min(A, B)
elif (A > 0 and B < 0) or (A < 0 and B > 0):
    D = max(A, B) + abs(min(A, B))

check = D + (W * T) - (V * T)

if check > 0:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

V *= T
W *= T

if (A < 0 and B < 0) or (A > 0 and B > 0):
    D = max(A, B) - min(A, B)
elif (A > 0 and B < 0) or (A < 0 and B > 0):
    D = max(A, B) + abs(min(A, B))

check = D + W - V

if check > 0:
    print('NO')
else:
    print('YES')
Problem p02747 (python)

Fixed submission:
S = input().replace('hi', '*')

for s in S:
    if s != '*':
        print('No')
        exit()

print('Yes')

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

for s in S:
    if s == 'h':
        Flag = True
    elif s == 'i' and Flag == True:
        Flag = False
    else:
        Flag = False
        print('No')
        exit()

print('Yes')
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
ans = ['-1'] * N

if N == 1 and M == 0:
    ans = 0
    print(ans)
    exit()

for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == str(c):
        continue
    elif ans[s-1] == '-1':
        ans[s-1] = str(c)
    else:
        ans = -1
        print(ans)
        exit()

if N >= 2 and ans[0] == '0':
    ans = -1
    print(ans)
    exit()
elif ans[0] == '-1':
    ans[0] = '1'

ans = ''.join(ans).replace('-1', '0')

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = ['-1'] * N

for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == str(c):
        continue
    elif ans[s-1] == '-1':
        ans[s-1] = str(c)
    else:
        ans = -1
        print(ans)
        exit()

for i in range(N):
    if ans[i] == '-1':
        ans[i] = str(0)

if N == 3 and ans[0] == '0' or ans[1] == '0':
    ans = -1
    print(ans)
    exit()
elif N == 2 and ans[0] == '0':
    ans = -1
    print(ans)
    exit()
else:
    print(''.join(ans))
Problem p02900 (python)

Fixed submission:
def prime_factorize(n):
    pf = []
    while n % 2 == 0:
        pf.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            pf.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        pf.append(n)
    return pf

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

prime_A = set(prime_factorize(A))
prime_B = set(prime_factorize(B))
ans = len(prime_A & prime_B) + 1

print(ans)

Buggy submission (verdict: Runtime Error):
# ユークリッドの互除法
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

# 約数の列挙
def make_divisions(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

A, B = map(int, input().split())
num = gcd(A, B)

arr = make_divisions(num)
arr.sort()

ans = [arr[0]]
for i in range(1, len(arr)):
    if gcd(ans[i-1], arr[i]) == 1:
        ans.append(arr[i])

print(len(ans))
Problem p02995 (python)

Fixed submission:
import fractions

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

a, b, c, d = map(int, input().split())
a -= 1
cd = lcm(c, d)

upper = b - b//c - b//d + b//cd
lower = a - a//c - a//d + a//cd
ans = upper - lower

print(ans)

Buggy submission (verdict: Runtime Error):
import math
import fractions

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

a, b, c, d = map(int, input().split())
cd = lcm(c, d)
num = b - a + 1

if a <= cd <= b:
    cd_count = (b // cd) - (a // cd)
else:
    cd_count = 0

if a % c == 0:
    c_count = (b // c) - (a // c) + 1
else:
    c_count = (b // c) - (a // c)
if a % d == 0:
    d_count = (b // d) - (a // d) + 1
else:
    d_count = (b // d) - (a // d)

ans = num - c_count - d_count + cd_count

print(ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a, b, c, d = map(int, input().split())
cd = lcm(c, d)
num = b - a + 1

if a <= cd <= b:
    cd_count = (b // cd) - (a // cd)
else:
    cd_count = 0

if a % c == 0:
    c_count = (b // c) - (a // c) + 1
else:
    c_count = (b // c) - (a // c)
if a % d == 0:
    d_count = (b // d) - (a // d) + 1
else:
    d_count = (b // d) - (a // d)

ans = num - c_count - d_count + cd_count

print(ans)
Problem p03001 (python)

Fixed submission:
w, h, x, y = map(int, input().split())
ans = []

if w == x*2 and h == y*2:
    ans.append('{:.7f}'.format(w*h/2))
    ans.append(1)
else:
    ans.append('{:.7f}'.format(w*h/2))
    ans.append(0)

print(*ans, sep=' ')

Buggy submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())
ans = []

ans.append('{:.7f}'.format(w*h/2))

if w % x == 0 and h % y == 0:
    ans.append(1)
else:
    ans.append(0)

print(*ans, sep=' ')
Problem p03076 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

now_time = [a, b, c, d, e]
next_time = []

for i in now_time:
    if i % 10 == 0:
        next_time.append(i)
    else:
        while i % 10 != 0:
            i += 1
        next_time.append(i)

combined = sorted([x - y for (x, y) in zip(next_time, now_time)])

best_time = sum(next_time) - max(combined)
print(best_time)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
sur = 0

for i in range(len(l)):
    if sur < l[i] % 10:
        sur = 10 - (l[i] % 10)
        last = i
    if l[i] % 10 != 0:
        l[i] += 10 - (l[i] % 10)

order = l[:last]+l[last+1:]
ans = (sum(order))+l[last]-sur

print(ans)
Problem p03231 (python)

Fixed submission:
from fractions import gcd

def lcm(a, b):
    return (a*b) // gcd(a, b)

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

n = N // gcd(N, M)
m = M // gcd(N, M)
k = gcd(N, M)

for i in range(k):
    if S[i * n] != T[i * m]:
        print(-1)
        exit()

print(lcm(N, M))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def lcm(a, b):
    return (a*b) // gcd(a, b)

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

L = lcm(N, M)
X = [S[0]] * L
step_N = L // N
step_M = L // M

if S[0] != T[0]:
    ans = -1
elif step_N == 1 or step_M == 1:
    ans = -1
else:
    for i in range(1, N):
        X[i * step_N] = S[i]

    for i in range(1, M):
        X[i * step_M] = T[i]

    check_N = ''.join(X[::step_N])
    check_M = ''.join(X[::step_M])

    if check_N == S and check_M == T:
        ans = L
    else:
        ans = -1

print(ans)
Problem p03239 (python)

Fixed submission:
n, t = map(int, input().split())
ct = []
for i in range(n):
    ct.append(list(map(int, input().split())))
num = 1001
has_tle = False

for i in range(n):
    if t >= ct[i][1]:
        if num >= ct[i][0]:
            num = ct[i][0]
        has_tle = True

if has_tle == True:
    print(num)
else:
    print('TLE')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
ans = 1

for i in range(1, n):
    if max(h[:i]) <= h[i]:
        ans += 1

print(ans)
Problem p03274 (python)

Fixed submission:
n, k = map(int, input().split())
x = sorted(list(map(int, input().split())) + [0])
ans = 10**9 + 10

for i in range(n-k+1):
    left = i
    right = i+k
    to_right = abs(x[left]) + abs(x[right]-x[left])
    to_left = abs(x[right]) + abs(x[right]-x[left])
    if min(to_right, to_left) < ans:
        ans = min(to_right, to_left)

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9 + 10

for i in range(n-k+1):
    left = i
    right = i+k
    to_right = abs(x[left]) + abs(x[right]-x[left])
    to_left = abs(x[right]) + abs(x[right]-x[left])
    if min(to_right, to_left) < ans:
        ans = min(to_right, to_left)

print(ans)