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

Fixed submission:
import math

DEBUG = False

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

if DEBUG:
    ans = 0
    for x in range(1, N+1):
        term1 = math.floor(A*x/B)
        term2 = A * math.floor(x/B)
        temp = term1 - term2
        print("x: {}, temp: {}, term1: {}, term2: {}".format(x, temp, term1, term2))
        ans = max(ans, temp)
    print(ans)

print(math.floor(A*min(B-1, N)/B)-A*math.floor(min(B-1, N)/B))

Buggy submission (verdict: Runtime Error):
import itertools

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

ans = 0
P = [[i for i in range(1, M+1)] for _ in range(N)]

# print(R)
for comb in itertools.product(*P):
    flag = True
    p = comb[0]
    for i in comb:
        if i < p:
            flag = False
            break
        p = i

    if not flag:
        continue

    # print(comb)

    temp = 0
    for abcd in ABCD:
        a, b, c, d = abcd
        if comb[b-1] - comb[a-1] == c:
            temp += d
    if temp >= ans:
        ans = temp

print(ans)
Problem p02761 (python)

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

ans = [-1] * N
if N == 1 and M == 0:
    print(0)
    exit(0)
for _ in range(M):
    sn, cn = map(int, input().split())
    if ans[sn - 1] != -1 and ans[sn - 1] != cn:
        print(-1)
        exit(0)
    if sn == 1 and cn == 0 and N > 1:
        print(-1)
        exit(0)
    ans[sn - 1] = cn
if ans[0] == -1:
    ans[0] = 1
ans = list(map(lambda x: str(0) if x == -1 else str(x), ans))
print("".join(ans))

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

S = []
C = []

condition = [-1] * M

for _ in range(M):
    s, c = map(int, input().split())
    #S.append(s)
    #C.append(C)
    if condition[s-1] != c and condition[s-1] != -1:
        print('-1')
        exit()
    condition[s-1] = c

for i, v in enumerate(condition):
    if v == -1:
        condition[i] = 0
    print(condition[i], end="")
print()

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

S = []
C = []

condition = [-1] * M

for _ in range(M):
    s, c = map(int, input().split())
    #S.append(s)
    #C.append(C)
    if condition[s-1] != c and condition[s-1] != -1:
        print('-1')
        exit()
    condition[s-1] = c

for i, v in enumerate(condition):
    if v == -1:
        condition[i] = 0
    print(condition[i], end="")
Problem p02780 (python)

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = cml_sum[K-1]
for i in range(N-K):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = cml_sum[K]
for i in range(N-K):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = cml_sum[K] - cml_sum[0]
for i in range(N-K):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

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

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = 0
for i in range(N-K+1):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)
Problem p02823 (python)

Fixed submission:
def main():
    N, A, B = map(int, input().split())
    result = N
    if (A % 2 == 0 and B % 2 == 0) or  (A % 2 == 1 and B % 2 == 1):
        result = abs(A - B) // 2
    else:
        if A - 1 < N - B:
            result = ((B - 1) - (A - 1 + 1)) // 2 + (A - 1 + 1)
        else:
            result = ((N - A) - (N - B + 1)) // 2 + (N - B + 1)

    print(int(result))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from inspect import currentframe

def main():
    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    dic_A = {k:v for (k, v) in enumerate(A)}
    sorted_dic_A = sorted(dic_A.items(), key=lambda x: x[1], reverse=True)

    B = sorted_dic_A[:P]
    P_min_val = min(B, key=lambda  x: x[1])[1]
    C = sorted_dic_A[P:]

    num_vote = M * V
    a = 0
    b = len(C)
    flag = True
    while a < b:
        def is_margin_plus(i):
            v = C[i][1]
            margin = num_vote
            margin -= M * (P-1)
            margin_list = [v+M-w for (j,w) in C if j!=i]
            mod_margin_list = list(map(lambda x: x if x < M else M, margin_list))
            margin -= M
            margin -= sum(mod_margin_list)
            # print("margin: {}".format(margin))

            return margin > 0

        i = (a + b) // 2
        # input()
        # print("(a, i, b): ({}, {}, {})".format(a, i, b))

        if is_margin_plus(i):
            # print('is_margin_plus: {}'.format(True))
            b = i
        else:
            # print('is_margin_plus: {}'.format(False))
            a = i + 1
            flag = False

    ans = a + P + 1 if flag else (a + P)
    print(ans)


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

Fixed submission:
N = int(input())
xy = []
A = []
for i in range(N):
    Ai = int(input())
    xyi = []
    for j in range(Ai):
        xyi.append(list(map(int, input().split())))
    A.append(Ai)
    xy.append(xyi)

ans = 0

for i in range(2**N):
    bin_i = format(i, '0' + str(N) + 'b')
    flag = True
    for j in range(N):
        for k in range(A[j]):
            if bin_i[j] == '1' and xy[j][k][1] != int(bin_i[xy[j][k][0]-1]):
                flag = False
                break
        if not flag:
            break

    if flag is True:
        honest = bin_i.count('1')
        if honest > ans:
            ans = honest

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
xy = []
A = []
for i in range(N):
    Ai = int(input())
    xyi = []
    for j in range(Ai):
        xyi.append(list(map(int, input().split())))
    A.append(Ai)
    xy.append(xyi)

ans = 0

for i in range(2**N):
    bin_i = format(i, '4b')
    flag = True
    for n, c in enumerate(bin_i):
        if c == '1':
            for j in range(N):
                for k in range(A[j]):
                    if xy[j][k][0] == n:
                        if xy[j][k][1] == 0:
                            flag = False
                            break
                if not flag:V
                    break
            if not flag:
                break
    if flag is True:
        honest = bin_i.count('1')
        if honest > ans:
            ans = honest

print(ans)
Problem p02838 (python)

Fixed submission:
import math

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

ans = 0
fil = 1
for i in range(60):
    num1 = len([1 for j in range(N) if A[j] & fil])
    num0 = N - num1
    ans += (num1 * num0) * fil
    fil <<= 1

print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))
digit = math.floor(math.log2(max(A))) + 1

ans = 0
fil = 1
for i in range(digit):
    num1 = len([1 for j in range(N) if A[j] & fil])
    num0 = N - num1
    ans += (num1 * num0) * fil
    fil <<= 1

print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math

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

digit = math.floor(math.log2(max(A))) + 1

ans = 0
for i in range(digit):
    num1 = len([1 for j in range(N) if A[j] & 2**i])
    num0 = N - num1

    ans += ((num1 * num0) * (2 ** i))

print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math

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

digit = math.floor(math.log2(max(A))) + 1
bin_A = [format(Ai, '0' + str(digit) + 'b') for Ai in A]

ans = 0

for i in range(digit):
    num0 = 0
    num1 = 0
    for j in range(N):
        if bin_A[j][i] == '1':
            num1 += 1
        else:
            num0 += 1
    ans += ((num1 * num0) * (2**(digit-i-1))) % (10**9+7)

print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(lambda x: int(x)%(10**9+7), input().split()))

digit = math.floor(math.log2(max(A))) + 1
bin_A = [format(Ai, '0' + str(digit) + 'b') for Ai in A]

ans = 0

for i in range(digit):
    num0 = 0
    num1 = 0
    for j in range(N):
        if bin_A[j][i] == '1':
            num1 += 1
        else:
            num0 += 1
    ans += (num1 * num0) * (2**(digit-i-1))

print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import math

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

digit = math.floor(math.log2(max(A))) + 1
bin_A = [format(Ai, '0' + str(digit) + 'b') for Ai in A]

ans = 0

for i in range(digit):
    num0 = 0
    num1 = 0
    for j in range(N):
        if bin_A[j][i] == '1':
            num1 += 1
        else:
            num0 += 1
    ans += (num1 * num0) * (2**(digit-i-1))

print(ans % (10**9 + 7))
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
MOD = 2019
ans = L*R%MOD
for i in range(L, R):
    for j  in range(i+1, R+1):
        if ans > i*j%MOD:
            ans = i*j%MOD
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
MOD = 2019
# L = 2020
# R = 2040
diff = (R - L) % MOD
new_L = L % MOD
new_R = new_L + diff
# print("diff:{}, new_L:{}, new_R:{}".format(diff, new_L, new_R))

ans = L*R%MOD
for i in range(new_L, new_R):
    for j  in range(i+1, new_R+1):
        count += 1
        if ans > i*j%MOD:
            ans = i*j%MOD
print(ans)
Problem p03150 (python)

Fixed submission:
S = input()
target = "keyence"
length = len(target)+1

# 部分文字列を取り除く方法は、
# 1. 先頭の文字列を削除
# 2. 真ん中の文字列を削除
# 3. 末尾の文字列を削除

if target in S: # 1 & 3
    print("YES")
    exit()
else: # 2
    for i in range(1, length):
      first = target[:i]
      second = target[i:]
      # print("{} + {}".format(S[0:len(first)], S[len(target)-len(second):len(target)]))
      if first in S and second in S and S.find(first) < S.rfind(second):
          if S[0:len(first)] + S[len(S)-len(second):len(S)] == target:
                print("YES")
                exit()
print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
target = "keyence"
length = len(target)+1

if target in S:
    print("YES")
    exit()
else:
    for i in range(1, length):
      first = target[:i]
      second = target[i:]
      if first in S and second in S and S.find(first) < S.rfind(second):
          if S[0:len(first)] + S[len(target)-len(second):len(target)]] == target:
                print("YES")
                exit()
print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
target = "keyence"
length = len(target)

for i in range(length):
  first = target[:i]
  second = target[i:]
  if first == '' and second in S  or first != '' first in S and second in S and S.find(first) <= S.find(second):
    print("YES")
    exit()
print("NO")
Problem p03434 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
	print(Alice-Bob)

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

if N == 1:
	print(A[0])
else:
	Alice = sum(A[0::2])
	Bob = sum(A[1::2])
    print(Alice-Bob)
Problem p03699 (python)

Fixed submission:
N = int(input())
s = []
t = []
for _ in range(N):
  tmp = int(input())
  s.append(tmp)
  if tmp % 10 != 0:
    t.append(tmp)

ans = sum(s)

if ans % 10 != 0:
  print(ans)
else:
  if not t:
    print(0)
  else:
  	print(ans - min(t))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = []
t = []
for _ in range(N):
  tmp = int(input())
  s.append(tmp)
  if tmp % 10 != 0:
    t.append(tmp)

ans = sum(s)

if s % 10 != 0:
  print(ans)
else:
  print(ans - min(t))
Problem p02630 (python)

Fixed submission:
from collections import defaultdict

d = defaultdict(int)

n = int(input())
a = [int(i) for i in input().split(" ")]
q = int(input())

operations = []

for i in range(q):
    temp = input().split(" ")
    operations.append((int(temp[0]), int(temp[1])))

for hoge in a:
    d[hoge] += 1

initial_sum = 0
for key, value in d.items():
    initial_sum += key * value

for op in operations:
    target, goto = op

    before = goto * d[goto] + target * d[target]
    d[goto] += d[target]
    d[target] = 0

    after = goto * d[goto]
    diff = after - before
    
    initial_sum += diff
    print(initial_sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split(" ")]
q = int(input())

operations = []

for i in range(q):
    temp = input().split(" ")
    operations.append((int(temp[0]), int(temp[1])))

for op in operations:
    target, goto = op

    a.sort()

    try:
        index = a.index(target)
        
        while:
            if a[index] != target:
                break;

            a[index] = target
            index += 1

        print(sum(a))

    except:
        print(sum(a))
Problem p02641 (python)

Fixed submission:
temp1 = input().split(" ")
temp1 = [int(i) for i in temp1]
x = temp1[0]
n = temp1[1]

if not n == 0:
    temp2 = input().split(" ")
    temp2 = [int(i) for i in temp2]
else:
    temp2 = input()
    temp2 = []

pn = temp2

counter = 0
while True:
    if n == 0:
        print(x)
        break

    mx = x - counter
    px = x + counter

    if not mx in pn:
        print(mx)
        break
    if not px in pn:
        print(px)
        break

    counter += 1

Buggy submission (verdict: Runtime Error):
temp1 = input().split(" ")
temp1 = [int(i) for i in temp1]
x = temp1[0]
n = temp1[1]

if not n == 0:
    temp2 = input().split(" ")
    temp2 = [int(i) for i in temp2]
else:
    temp2 = []

counter = 1
while True:
    if n == 0:
        print(x)
        break

    mx = x - counter
    px = x + counter

    if not mx in pn:
        print(mx)
        break
    if not px in pn:
        print(px)
        break

    counter += 1
Problem p02761 (python)

Fixed submission:
n,m = list(map(int,input().split()))
s = []
c = []
for i in range(m):
    ss,cc = list(map(int,input().split()))
    s.append(ss -1 )
    c.append(cc)

ans = [-1] * n
flag = True
for i in range(m):
    if ans[s[i]] == -1 :
        ans[s[i]] = c[i]
    elif ans[s[i]] != c[i]:
        flag = False

if n !=1 and  ans[0] == 0:
    flag = False

if flag :
    ans = [ str(a) if a != -1 else "0" for a in ans ]
    if n != 1 and ans[0] == "0":
        ans[0] = "1"
    print("".join(ans))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
s = []
c = []
for i in range(m):
    ss,cc = list(map(int,input().split()))
    s.append(ss -1 )
    c.append(cc)

ans = [-1] * n
flag = True
for i in range(m):
    if ans[s[i]] == -1 :
        ans[s[i]] = c[i]
    elif ans[s[i]] != c[i]:
        flag = False

if n !=1 and  ans[0] == 0:
    flag = False

if flag :
    ans = [ str(a) if a != -1 else "0" for a in ans ]
    if n != 1 and ans[0] == "0":
        ans[0] = 1
    print("".join(ans))
else:
    print(-1)
Problem p02801 (python)

Fixed submission:
b = bytearray(input().encode())[0] + 0x01
print(b.to_bytes(1, 'big' ).decode())

Buggy submission (verdict: Runtime Error):
n,k,m=(int(x) for x in input().split())
a=[int(x) for x in input().split()]

sum = 0
for ai in a:
    sum+= ai

t = m * n  - sum
if t <= 0:
    print(0)
elif t<= k:
    print(t)
else:
    print(-1)
Problem p02945 (python)

Fixed submission:
ab = [int(i)for i in input().split()]
print(max(ab[0] + ab[1],max(ab[0] * ab[1], ab[0]-ab[1])))

Buggy submission (verdict: Runtime Error):
ab = [int(i)for i in input().split()]¥
print(max(ab[0] + ab[1],max(ab[0] * ab[1], ab[0]-ab[1])))
Problem p03076 (python)

Fixed submission:
a = []
for i in range(5):
    a.append(int(input() )) 


t =0
s = 0
for m in a:
    t += int(m/10) * 10
    if m%10 != 0:
        t = t + 10
    if 10 - (m%10) > s and m%10 !=0:
        s = 10 - (m%10)

print(t - s)

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


t =0
for i,m in enumerate(a):
    t += int(m/10) * 10
    if m%10 != 0:
        t = t + 10

b = [10 - (x%10) for x in a]
b = list(filter(lambda x:x !=10, b))
print(t - max(b))
Problem p03455 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

abinput = input()
ab = abinput.split(" ")

if (int(ab[0])) & (int(ab[1])) & 1:
    print ("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


instr = input()
nq = instr.split(" ")

N = int(nq[0])
Q = int(nq[1])
balls = [chr(i) for i in range(65, 65+N)]

for i in range(N -1 ):
    for j in range(N - i  - 1):
        print("? %s %s"%(balls[j], balls[j + 1]), flush=True)
        ans = input()
        if(ans == ">") :
            balls[j + 1], balls[j] = balls[j], balls[j + 1]

print ("! %s"%"".join(balls), flush=True)
Problem p03470 (python)

Fixed submission:
N=input()
di = []
for i in range(int(N)):
    di.append(int(input()))
print(len(list(set(di))))

Buggy submission (verdict: Runtime Error):
N=input()
di = []
for i in range(N):
    di.append(input())
print(len(list(set(di))))
Problem p02628 (python)

Fixed submission:
n, k = list(map(int, input().split()))
price_arr = list(map(int, input().split()))
price_arr.sort()
sum = 0
for i in range(0,k):
  sum += price_arr[i]
print(sum)

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
price_arr = list(map(int, input.split()))
price_arr.sort()
sum = 0
for i in range(0,k):
  sum += price_arr[i]
print(sum)
Problem p02657 (python)

Fixed submission:
def mult(num):
  print(int(num[0])*int(num[1]))
  
num = input().split()
mult(num)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b)
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(min(N*A,B))

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
diff = R-L
for n in range(1):
    if diff > 2019:
        ret = 0
        break
        
    results = []
    for i in range(L, R):
        for j in range(i+1,R+1):
            results.append((i*j)%2019)
        ret = min(results)
print(ret)
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
diff = R-L
for n in range(1):
    if diff > 2019:
        ret = 0
        break
        
        [inner for outer in init for inner in outer]
    ret = min([ (i*j)%2019 for i in range(L, R) for j in range(i+1,R+1) ])
print(ret)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
results = []
for n in range(1):
    if diff > 2019:
        ret = 0
        break
    for i in range(L, R):
        for j in range(i+1,R+1):
            results.append((i*j)%2019)
        ret = min(results)
print(ret)
Problem p02999 (python)

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

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = L = list(map(int, input().split()))
count = 0
if sum(a) >= K:
    count +=1
for n in range(1,N):
    for i in range(N):
        if sum(a[i:i+n]) >= K:
            count += 1
print(count)
Problem p02641 (python)

Fixed submission:
x,n=map(int,input().split())
Ps=list(map(int,input().split()))
numlist=[]
for i in range(102):
    numlist.append(i)
for p in Ps:
    numlist.remove(p)
import bisect
a=bisect.bisect_left(numlist,x)
b=a-1
if abs(numlist[a]-x)>=abs(numlist[b]-x):
    print(numlist[b])
else:
    print(numlist[a])

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
Ps=list(map(int,input().split()))
numlist=[]
for i in range(101):
    numlist.append(i)
for p in Ps:
    numlist.remove(p)
import bisect
if numlist==[0]:
    if x<=51:
        print(0)
    else:
        print(101)
    quit()
a=bisect.bisect_left(numlist,x)
b=a-1
if abs(numlist[a]-x)>=abs(numlist[b]-x):
    print(numlist[b])
else:
    print(numlist[a])

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
Ps=list(map(int,input().split()))
numlist=[]
for i in range(101):
    numlist.append(i)
for p in Ps:
    numlist.remove(p)
import bisect
a=bisect.bisect_left(numlist,x)
b=a-1
if abs(numlist[a]-x)>=abs(numlist[b]-x):
    print(numlist[b])

else:
    print(numlist[a])
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
for i in range(len(s)):
    if s[i]!=t[i]:
        print("No")
        quit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
for i in range(len(s)):
	if s[i]!=t[i]:
    	print("No")
        quit()
print("Yes")
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n:
        return 0
    if place==n-1:
        return abs(h[n-1]-h[n])
    if place<=n-2:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        return min(a,b)
print(cost(1))

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h

def cost(place):
    if place==n:
        return 0
    elif place==n-1:
        return abs(h[n-1]-h[n])
    else:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        return min(a,b)
print(cost(1))

Buggy submission (verdict: Runtime Error):
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h

def cost(place):
    if place==n:
        return 0
    elif place==n-1:
        return abs(h[n-1]-h[n])
    else:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        if a<b:
            return a
        else:
            return b
print(cost(1))
Problem p03409 (python)

Fixed submission:
    #できなかった
n=int(input())
r=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted([list(map(int,input().split())) for i in range(n)])
ans=0
for bx,by in b:
    ypoint=-1
    index=-1
    for num,(rx,ry) in enumerate(r):
        if bx>rx and by>ry and ypoint < ry:
            ypoint=ry
            index =num
    if ypoint>=0:
        ans+=1
        r.pop(index)
print(ans)

Buggy submission (verdict: Runtime Error):
    #できなかった
n=int(input())
r=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted([list(map(int,input().split())) for i in range(n)])
ans=0
for bx by in b:
    index=-1
    ypoint=-1
    for num,(rx,ry) in enumerate(r):
        if bx>rx and by>ry and ypoint < ry:
            ypoint=ry
            index =num
        if ypoint>=0:
            ans+=1
            r.pop(index)
print(ans)
Problem p03813 (python)

Fixed submission:
x=int(input())
if x<1200:
    print("ABC")
else:
    print("ARC")

Buggy submission (verdict: Runtime Error):
x=input()
if x<1200:
    print("ABC")
else:
    print("ARC")