Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def solve():
    from itertools import combinations
    N, K = map(int, input().split())
    v = [tuple(map(int, input().split())) for _ in [0]*N]
    sorted_v = sorted(v)
    ans = float('inf')
    #print(v)
    
    for l in combinations(sorted_v, min(4, K)):
        xs = sorted(x for x, y in l)
        ys = sorted(y for x, y in l)
        min_x, max_x = xs[0], xs[-1]
        min_y, max_y = ys[0], ys[-1]
        if sum(1 for x, y in v if min_x <= x <= max_x and min_y <= y <= max_y) >= K:
            s = (max_x - min_x) * (max_y - min_y)
        if ans > s:
            ans = s
    
    print(ans)
    
if __name__ == '__main__':
    solve()

Fixed submission:
def solve():
    from itertools import combinations
    N, K = map(int, input().split())
    vertices = [tuple(map(int, input().split())) for _ in [0]*N]
    sorted_v = sorted(vertices)
    result = float("inf")
 
    for l in combinations(sorted_v, min(4, K)):
        xs = sorted(x for x, y in l)
        ys = sorted(y for x, y in l)
        min_x, max_x = xs[0], xs[-1]
        min_y, max_y = ys[0], ys[-1]
        if sum(1 for x, y in vertices if min_x <= x <= max_x and min_y <= y <= max_y) >= K:
            s = (max_x-min_x)*(max_y-min_y)
            if result > s:
                result = s
 
    print(result)
 
 
if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
a = []

for _ in range(N):
    x = int(sys.stdin.readline())
    if x in a:
        a.remove(x)
    else:
        a.append(x)
        
print(len(a))

Fixed submission:
from collections import defaultdict

N = int(input())

a = defaultdict(lambda: 0)

for _ in range(N):
    x = int(input())
    if a[x]:
        a[x] -= 1
    else:
        a[x] += 1

print(sum(a.values()))
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = [0] * 100001
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v+1] += 1
    cnt[v+2] += 1
print(max(cnt))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
set_a = set(a)
cnt = [0] * (max(a)+1)
ans = 0
 
for i in a:
    cnt[i] += 1
 
if len(cnt) == 1:
    print(cnt[0])
elif len(cnt) == 2:
    print(sum(cnt))
else:
    for i in range(1, max(a)):
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1])
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

a_min, a_max = min(a), max(a)
cnt = 0
p = [-1] * N

for j in range(a_min, a_max+1):
    for i in range(N):
        if j-1 <= a[i] <= j+1:
            p[i] = j
    cnt = max(cnt, p.count(j))
print(cnt)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
set_a = set(a)
cnt = [0] * (max(a)+1)
ans = 0
 
for i in a:
    cnt[i] += 1
 
if len(cnt) == 1:
    print(cnt[0])
elif len(cnt) == 2:
    print(sum(cnt))
else:
    for i in range(1, max(a)):
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1])
    print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
 
i = 0

for x in range(H):
    c = []
    for y in range(W):
        c.append(i + 1)
        a[i] -= 1
        if a[i] == 0:
            i += 1
            
    if x % 2 == 0:
        print(*c)
    else:
        print(*c[::-1])

Fixed submission:
n, m =map(int, input().split())
print((n-1) * (m-1))
Buggy python submission (verdict: Runtime Error):
N, M = int(input())
set_a, set_b = set(), set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        set_a.add(b)
    if b == N:
        set_b.add(a)

if set_a & set_b:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        set_a.add(b)
    if b == N:
        set_b.add(a)

if set_a & set_b:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.insert(0, a[i])
    else:
        b.append(a[i])
print(*b)

Fixed submission:
from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.insert(0, a[i])
    else:
        b.append(a[i])
print(*b)

Fixed submission:
from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
    if (i+1) %2 == n % 2:
        b.insert(0, a[i])
    else:
        b.append(a[i])
print(*b)

Fixed submission:
from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []

for i in range(n):
	b.append(a[i])
	b.reverse()

print(*b)


Fixed submission:
from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]

ans = h
cnt = 0

while ans:
    max_ind = ans.index(max(ans))
    ans[max_ind] -= A
    
    for i in range(len(ans)):
        if i != max_ind:
            ans[i] -= B
    ans = [x for x in ans if x > 0]
    cnt += 1

print(cnt)

Fixed submission:
from math import ceil

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]

def enough(t):
    cnt = 0
    
    for hp in h:
        cnt += ceil(max(0, (hp - B * t)/(A-B)))
        
    if cnt <= t:
        return True
    else:
        return False

high = ceil(max(h) / B)
low = 0

while high - low > 0:
    mid = (high + low) // 2
    if enough(mid):
        high = mid
    else:
        low = mid + 1

print(low)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
h.reverse()

ans = h
cnt = 0

while ans:
    ans[0] -= A
    for i in range(1, len(ans)):
        ans[i] -= B
        
    ans = [x for x in ans if x > 0]
    ans.sort()
    ans.reverse()

    cnt += 1

print(cnt)


Fixed submission:
from math import ceil

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]

def enough(t):
    cnt = 0
    
    for hp in h:
        cnt += ceil(max(0, (hp - B * t)/(A-B)))
        
    if cnt <= t:
        return True
    else:
        return False

high = ceil(max(h) / B)
low = 0

while high - low > 0:
    mid = (high + low) // 2
    if enough(mid):
        high = mid
    else:
        low = mid + 1

print(low)
Buggy python submission (verdict: Runtime Error):
10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Fixed submission:
import bisect

N, K = map(int, input().split())
d = []


for i in range(N):
    a, b = map(int, input().split())
    d.append([a,b])

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print(d[pos][0])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
d = []

for i in range(N):
    a, b = map(int, input().split())
    for j in range(b):
        d.append(a)
d.sort()

print(d[K-1])

Fixed submission:
import bisect

N, K = map(int, input().split())
d = []


for i in range(N):
    a, b = map(int, input().split())
    d.append([a,b])

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print(d[pos][0])
Buggy python submission (verdict: Runtime Error):
import sys

INF = float('inf')

def Bellmanford(n, edges, r): #r: 始点
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        flag = False
        
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                flag = True
        
        if flag and i == n-1 and t == n-1:
            return 'inf'
    
    return -d[n-1]
    

N, M = map(int, sys.stdin.readline().split())
Edges = [None] * M

for i in range(M):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    Edges[i] = (ai-1, bi-1, -ci)
    
ans = Bellmanford(N, Edges, 0)

print(ans)


Fixed submission:
import sys

INF = float('inf')

def Bellmanford(n, edges, r): #r: 始点
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        #flag = False
        
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                #flag = True
                if i == n-1 and v == n-1:
                    return 'inf'
    
    return -d[n-1]
    

N, M = map(int, sys.stdin.readline().split())
Edges = [None] * M

for i in range(M):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    Edges[i] = (ai-1, bi-1, -ci)
    
ans = Bellmanford(N, Edges, 0)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

INF = float('inf')

N, W = map(int, sys.stdin.readline().split())

items = [] * N

for i in range(N):
    w, v = map(int, sys.stdin.readline().split())
    items.append([w,v])
    
dp = [[INF for i in range(W+1)] for j in range(N+1)] #dp[i][j]: i:N+1, j: W+1, iまでの品物を用いて大きさwまでの価値の合計

for i in range(W+1):
    dp[0][i] = 0
    
for i in range(N+1):
    dp[i][0] = 0
    
for i in range(1, N+1):
    for j in range(1, W+1):
        if j - items[i-1][0] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-items[i-1][0]] + items[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])

Fixed submission:
from collections import Counter
from itertools import product

N, W = map(int, input().split())
items = {}
weight = []

for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    
    if items.get(w, None) is None:
        items[w] = []
    items[w].append(v)
    items[w] = sorted(items[w], reverse = True)

cnt = Counter(weight)

w_num = [] #各重さの個数。組み合わせのために使う。[range(0,2), range(0,3), range(0,2)]のような出力
w_set = [] # 重さは w0 <= wi <= w0+3の４通りしかない

for w in range(weight[0], weight[0] + 4):
    if cnt[w] == 0:
        continue
    
    w_num.append(range(cnt[w] + 1))
    w_set.append(w)

ans = 0

for i in product(*w_num):
    w = sum(map(lambda x: x[0] * x[1], zip(i, w_set)))
    if 1 > w or w > W:
        continue
    v = sum([sum(items[k][:j]) for j, k in zip(i, w_set)])
    if ans < v:
        ans = v

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = int(input())

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
            if not flag:
                break
        
        if flag:
            print('Yes')
            exit()

print('No')

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

A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = False
                    break
            if not flag:
                break
        
        if flag:
            print('Yes')
            exit()

print('No')
Buggy python submission (verdict: Runtime Error):
def solve():
    
    INF = float('inf')
    
    N, Ma, Mb = map(int, input().split())
    
    l = []
    for _ in range(N):
        a,b,c = map(int, input().split())
        l.append((a,b,c))
        
    #dp table: dp[i][ca][cb] 
    dp = [[[INF] * 401 for _ in range(401)] for _ in range(N+1)]
    dp[0][0][0] = 0
    
    for i in range(N):
        for ca in range(401):
            for cb in range(401):
                if dp[i][a][b] != INF:
                    dp[i+1][a][b] = min(dp[i][a][b], dp[i+1][a][b]) #薬品iを加えない場合
                    dp[i+1][a+l[i][0]][b+l[i][1]] = min(dp[i+1][a+l[i][0]][b+l[i][1]], dp[i][a][b] + l[i][2]) #薬品iを加える場合
                    
    ans = INF
    for i in range(N):
        for ca in range(401):
            for cb in range(401):
                if dp[i][a][b] != INF:
                    if a * Mb == b * Ma:
                        ans = min(ans, dp[i][a][b])
    
    print(-1 if ans == INF else ans)

if __name__ == '__main'__:
    solve()

Fixed submission:
INF = float('inf')

def solve():
    N, Ma, Mb = map(int, input().split())
    l = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        l.append((a, b, c))
 
    dp = [[[INF] * 401 for _ in range(401)] for _ in range(N + 1)]
    dp[0][0][0] = 0
    for i in range(len(l)):
        for a in range(len(dp[0])):
            for b in range(len(dp[0][0])):
                if dp[i][a][b] != INF:
                    dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
                    dp[i + 1][a + l[i][0]][b + l[i][1]] = min(dp[i + 1][a + l[i][0]][b + l[i][1]], dp[i][a][b] + l[i][2])
 
    ans = INF
    for i in range(len(dp)):
        for a in range(1, len(dp[0])):
            for b in range(1, len(dp[0][0])):
                if dp[i][a][b] != INF:
                    if Ma * b == Mb * a:
                        ans = min(ans, dp[i][a][b])
 
    print(-1 if ans == INF else ans)
 
 
if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
import sympy as sp
import math as ma
N = int(input())
dic = sp.factorint(ma.factorial(N))
key = list(dic.keys())
ans = 1
for i in range(len(dic)):
    ans *= (1 + dic[key[i]])
print(ans % 1000000007)

Fixed submission:
def isPrime(n):
	i = 2
	while i*i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

N = 1000
Prime = []

for i in range(2,N):
	if isPrime(i):
		Prime.append(i)
		
dic = {}
for i in Prime:
	dic[i] = 0

p = int(input())
for k in range(2, p+1):
	for i in Prime:
		while k % i == 0:
			k /= i
			dic[i] += 1

ans = 1
for i in Prime:
	ans *= (1+dic[i])

print(ans % 1000000007)
Buggy python submission (verdict: Runtime Error):
l = ['dream', 'dreamer', 'erase', 'eraser']
S = input()

while len(S) > 0:
	flag = False
	for d in l:
		if S.endswith(d):
			S = S[:-len(d)]
			flag = True
			break
	if flag = False:
		print('NO')
		exit()
		
print('YES')

Fixed submission:
import re

S = input()
x = r"^(dream|dreamer|erase|eraser)*$"

if re.match(x,S):
	print('YES')
else:
	print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

for i in range(1,N+1):
	for cmb in combinations(l,i):
		if sum(cmb) / i == A:
			cnt += 1

print(cnt)

Fixed submission:
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
dp = [[0 for j in range(100 * N + 1)] for i in range(N+1)]
dp[0][50 * N] = 1
for i in range(N):
	for j in range(50, 100*N + 1-50):
		dp[i+1][j] = dp[i][j] + dp[i][j - X[i]]
print(dp[N][50 * N] -1)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
print(c_b)
print(c_r)

for k_b in c_b.keys():
    if c_r.has_key(k_b):
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
        else:
            if res < c_b[k_b]:
                res = c_b[k_b]

print(res)


Fixed submission:
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r :
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
    else:
        if res < c_b[k_b]:
            res = c_b[k_b]

print(res)

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

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r:
        if res < c_b[k_b] - c_r[k_r]:
            res = c_b[k_b] - c_r[k_r]

print(res)

Fixed submission:
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r :
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
    else:
        if res < c_b[k_b]:
            res = c_b[k_b]

print(res)
Buggy python submission (verdict: Runtime Error):
N, A, B = input().split

if int(A) * int(N) > int(B):
  print(B)
else:
  print(int(A) * int(N))

Fixed submission:
N, A, B = input().split()

if int(A) * int(N) > int(B):
  print(B)
else:
  print(int(A) * int(N))
Buggy python submission (verdict: Time Limit Exceeded):
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]

compressed = True
while compressed:
    compressed = False
    for h in range(H):
        if '#' not in a[h]:
            for w in range(W):
                a[h][w] = ''
                compressed = True
    for w in range(W):
        if '#' not in [p[w] for p in a]:
            for h in range(H):
                a[h][w] = ''
                compressed = True

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Fixed submission:
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]


for h in range(H):
    if '#' not in a[h]:
        for w in range(W):
            a[h][w] = ''
for w in range(W):
    if '#' not in [p[w] for p in a]:
        for h in range(H):
            a[h][w] = ''

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Buggy python submission (verdict: Time Limit Exceeded):
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]

compressed = False
while not compressed:
    compressed = False
    for h in range(H):
        if '#' not in a[h]:
            for w in range(W):
                a[h][w] = ''
                compressed = True
    for w in range(W):
        if '#' not in [p[w] for p in a]:
            for h in range(H):
                a[h][w] = ''
                compressed = True

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Fixed submission:
# Q2
H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]


for h in range(H):
    if '#' not in a[h]:
        for w in range(W):
            a[h][w] = ''
for w in range(W):
    if '#' not in [p[w] for p in a]:
        for h in range(H):
            a[h][w] = ''

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 f, r = map(int, raw_input().split())
print(f - r + 1)

Fixed submission:
# -*- coding: utf-8 -*-
f, r = map(int, raw_input().split())
print(f - r + 1)

Buggy python submission (verdict: Runtime Error):
    l = raw_input().split()
    f = int(l[0])
    r = int(l[1])

    a = f-r+1

    print(a)

Fixed submission:
# -*- coding: utf-8 -*-
f, r = map(int, raw_input().split())
print(f - r + 1)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    if i == S:
        count += 1
        break
    for j in range(K+1):
        if i + j == S:
            count += 1
            break
        for k in range(K+1):
            if i+j+k == S:
                count += 1
print(count)

Fixed submission:
K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                count += 1
print(count)

Fixed submission:
K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
print((A-1)*(B-1))

Fixed submission:
A,B=map(int,input().split())
print((A-1)*(B-1))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
X=list(map(int,input().split()))
hidari=0
migi=N-1
if N-K!=0:
    for i in range(N-K):
      if abs(X[hidari])>=abs(X[migi]):
        hidari=hidari+1
      else:
        migi=migi-1

if X[hidari]<0 and X[migi]>0:
  if abs(X[hidari])>=abs(X[migi]):
    print(2*abs(X[migi])+abs(X[hidari]))
  else:
    print(2*abs(X[hidari])+abs(X[migi]))
else:
  if abs(X[hidari])>=abs(X[migi]):
    print(abs(X[hidari]))
  else:
    print(abs(X[migi]))

Fixed submission:
n,i=map(int,input().split(" "))
print(n-i+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
nums=[int(x) for x in input().split()]

def findMedian(nums):
    size=len(nums)
    mIndex = (size*(size+1)//2) + 1
    gap=0
    mValue=0
    while mIndex>0 and gap<size:
        start=0
        end=start+gap
        while end<size and mIndex>0:
            mIndex-=1
            mValue=nums[(start+end+1)//2]
            start+=1
            end+=1
        gap+=1
    return mValue

print(findMedian(nums))

Fixed submission:
n,i = map(int, input().split())

def findJ(num):
    return n+1-num;

print(findJ(i))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

rate = int(input("Enter your rate: "))

if rate < 1200:
    print("ABC")
elif rate >= 1200 and rate < 2800:
    print("ARC")
elif:
    print("AGC")

Fixed submission:
r = int(input())

if r < 1200:
    print("ABC");
elif r < 2800:
    print("ARC")
else:
    print("AGC")
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())

print(0 if n%k == 0 else 1)

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

print(0 if n%k == 0 else 1)
Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv
l = []

for i in range(0,3):
    l.append(int(args[i+1]))
l.sort()
print(abs(l[0]-l[1]) + abs(l[1]-l[2]))

Fixed submission:
a = list(int(i) for i in input().split())
a.sort()
print(abs(a[0]-a[1]) + abs(a[1]-a[2]))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

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


n = input()
a = list(int(i) for i in input().split())

lcm = lcm_list(a) - 1

out = 0
for i in a:
    out += lcm%i
print(out)


Fixed submission:
n = int(input())
a = list(int(i) for i in input().split())

print(sum(a)-n)