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

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

for x in range(K+1):
  for y in range(K+1):
    if S - x - y <= K and S -x-y >=0:
      answer += 1
 
print(answer)

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

for x in range(K+1):
  for y in range(K+1):
	if S - x - y <= K:
    	answer += 1
 
print(answer)
Problem p03221 (python)

Fixed submission:
# AtCoder Beginner Contest 113-C
if __name__ == "__main__":
    N, M = map(int, input().split())
    city_list = []
    for i in range(M):
        city_list.append(list(map(int, input().split())))
    pref = {}
    pref_sort = {}
    for i in range(M):
        key = city_list[i][0]
        val = city_list[i][1]
        if str(key) in pref:
            pref[str(key)].append(val)
        else:
            pref[str(key)] = [val]
    ans = {}
    for key, val in pref.items():
        val.sort()
        for i in range(len(val)):
            ans[(key, val[i])] = str(key).zfill(6) + str(i+1).zfill(6)
    for key, val in city_list:
        print(ans[str(key), val])

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    N, M = map(int, input().split())
    city_list = []
    for i in range(M):
        city_list.append(list(map(int, input().split())))
    pref = {}
    pref_sort = {}
    for i in range(M):
        key = city_list[i][0]
        val = city_list[i][1]
        if str(key) in pref:
            pref[str(key)].append(val)
        else:
            pref[str(key)] = [val]
    ans = {}
    for i in range(N):
        pref[str(i+1)].sort()
    for i in range(M):
        key = city_list[i][0]
        val = city_list[i][1]
        output = str(key).zfill(6) + str(pref[str(key)].index(val)+1).zfill(6)
        print(output)
Problem p03329 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()

dp = [99999999] * (n + 1)
dp[0] = 0
for i in range(1, n + 1):
    dp[i] = dp[i - 1] + 1
    k = 6
    while i - k >= 0:
        dp[i] = min(dp[i], dp[i - k] + 1)
        k *= 6
    k = 9
    while i - k >= 0:
        dp[i] = min(dp[i], dp[i - k] + 1)
        k *= 9
print(dp[n])

Buggy submission (verdict: Runtime Error):
import sys
if __name__ == "__main__":
    N = int(input())
    drow_lst = [59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1]
#    drow_lst = [7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1]
    min = 1000000
    buf_lst = []
    for ele in drow_lst:
        if ele <= N:
            buf_lst.append(ele)
    drow_lst = buf_lst
    for i in range(len(drow_lst)):
        cnt = 0
        buf = N
        buf_drow_lst = drow_lst[i:len(drow_lst)]
        check = []
#        print(buf_drow_lst)
        for ele in buf_drow_lst:
#            print("buf"+str(buf))
#            print("ele"+str(ele))
            if buf % 9 == 0:
                check_buf = cnt + (buf // 9)
                check.append(check_buf)
            if buf % 6 == 0:
                check_buf = cnt + (buf // 6)
                check.append(check_buf)
            if buf >= ele:
                cnt += buf // ele
#                print("cnt"+str(cnt))
                buf = buf % ele
        if min > cnt:
            min = cnt
#        print(check)
        if len(check) > 0 and min > min(check):
            min = min(check)
    print(min)
Problem p03346 (python)

Fixed submission:
import sys
if __name__ == "__main__":
    N = int(input())
    P = []
    Q = [0]*(N+1)
    for i in range(1, N+1):
        p = int(input())
        Q[p] = i

    # 1 4 5 2 3 -> 4 5を移動
    # 1 4 5 3 2 -> 3 4 5 を移動
    # 5 2 1 3 4 -> 1 5 を移動
    cur = 1
    max_cur = 1
    for i in range(1, N):
        if Q[i] < Q[i+1]:
            cur += 1
            max_cur = max(cur, max_cur)
        else:
            cur = 1
    print(N - max_cur)

Buggy submission (verdict: Runtime Error):
import sys
if __name__ == "__main__":
    N = int(input())
    P = []
    Q = [0]*(N+1)
    for i in range(1, N+1):
        p = int(input())
        Q[p] = i

    # 1 4 5 2 3 -> 4 5を移動
    # 1 4 5 3 2 -> 3 4 5 を移動
    # 5 2 1 3 4 -> 1 5 を移動
    cur = 1
    max_cur = 1
    for i in range(1, N):
        if Q[i] < Q[i+1]:
            cur += 1
            max = max(cur, max_cur)
        else:
            cur = 1
    print(N - max_cur)

Buggy submission (verdict: Runtime Error):
import sys
if __name__ == "__main__":
    N = int(input())
    P = []
    Q = [0]*(N+1)
    for i in range(N):
        p = int(input())
        Q[p] = i

    # 1 4 5 2 3 -> 4 5を移動
    # 1 4 5 3 2 -> 3 4 5 を移動
    # 5 2 1 3 4 -> 1 5 を移動
    cur = 1
    max_cur = 1
    for i in range(1, N):
        if Q[i] < Q[i+1]:
            cur += 1
            max = max(cur, max_cur)
        else:
            cur = 1
    print(N - max_cur)
Problem p03137 (python)

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

move = 0

if n >= m:
  print(move)
elif n==1:
  move = max(x) - min(x)
  print(move)
else:
  x_diff = [None]*(m-1)
  for i in range(m-1):
    x_diff[i] = [i+1, x[i+1] - x[i]]
  x_diff = sorted(x_diff, key=lambda x:-x[1])
  sep = sorted(x_diff[:n-1])
  for j in range(n):
    if j==0:
      move += max(x[0:sep[j][0]])-min(x[0:sep[j][0]])
    elif j==n-1:
      move += max(x[sep[j-1][0]:])-min(x[sep[j-1][0]:])
    else:
      move += max(x[sep[j-1][0]:sep[j][0]])-min(x[sep[j-1][0]:sep[j][0]])
  print(move)

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

move = 0

if n >= m:
  print(move)
elif n==1:
  move = max(x) - min(x)
  print(move)
else:
  x_diff = [None]*(m-1)
  for i in range(m-1):
    x_diff[i] = [i+1, x[i+1] - x[i]]
  x_diff = sorted(x_diff, key=lambda x:-x[1])
  for j in range(n):
    if j==0:
      move += max(x[0:x_diff[j][0]])-min(x[0:x_diff[j][0]])
    elif j==n-1:
      move += max(x[x_diff[j-1][0]:])-min(x[x_diff[j-1][0]:])
    else:
      move += max(x[x_diff[j-1][0]:x_diff[j][0]])-min(x[x_diff[j-1][0]:x_diff[j][0]])
  print(move)
Problem p03242 (python)

Fixed submission:
#!/usr/bin/env python

s = input()
for c in s:
    if c == "9":
        print("1", end="")
    else:
        print("9", end="")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

s = inputs()
for c in s:
    if c == "9":
        print("1", end="")
    else:
        print("9", end="")
Problem p03208 (python)

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

h = [int(input()) for i in range(n)]
h.sort()

cand = [0]*(n-k+1)
cand[0] = h[k-1] - h[0]


for j in range(1,n-k+1):
    cand[j] = h[k+j-1] - h[j]

print(min(cand))

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

h = [int(input()) for i in range(n)]
h.sort()

cand = [0]*(n-k+1)
cand[0] = h[k-1] - h[0]


for j in range(1,n-k+1):
    cand[i] = cand[i-1] + h[k+i-1] - h[i]

print(min(cand))
Problem p03315 (python)

Fixed submission:
s = input()
l = len(s)

p = 0
m = 0

for i in range(l):
    if s[i] == '+':
        p = p + 1
    else:
        m = m + 1

print(p - m)

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

pole = 0
for i in range(n):
    if a[i] == 1:
        pole = i

l = pole
r = n - 1 - pole

for i in range(k - 1):
    if l % (k - 1) == i:
        if k - i - 1 >= r:
            if l == 0:
                print(0)
            else:
                print(1 + int(l / (k - 1)))
        else:
            if l == 0:
                print(1 + int((r - k + i + 1) / (k - 1)))
            else:
                print(1 + int(l / (k - 1)) + 1 + int((r - k + i + 1) / (k - 1)))
Problem p03207 (python)

Fixed submission:
N = int(input())

p = [0] * N
for i in range(N):
    p[i] = int(input())

m = 0
for i in range(N):
    if p[i] > m:
        m = p[i]

print(sum(p) - m // 2)

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

p = [0] * N
for i in range(N):
    p[i].append(int(input()))

m = 0
for i in range(N):
    if p[i] > m:
        m = p[i]

print(sum(p) - m // 2)
Problem p03186 (python)

Fixed submission:
def main():
  a,b,c = input().split(' ')
  a = int(a)
  b = int(b)
  c = int(c)
  if c>a+b:
    print(a+b+1+b)
  else:
    print(c+b)

if __name__=="__main__":
  main()

Buggy submission (verdict: Runtime Error):
a,b,c = input().split(' ')
if c>a+b:
  return a+b+1+b
return c+b
Problem p03209 (python)

Fixed submission:
def abc115_d():
    n, x = map(int, input().split())
    l = [1] * 51
    p = [1] * 51
    for i in range(50):
        l[i + 1] = 2 * l[i] + 3
        p[i + 1] = p[i] * 2 + 1

    ans = 0
    while n:
        if x == l[n]:
            ans += p[n]
            break
        elif x > (l[n] // 2):
            ans += p[n - 1] + 1
            x -= (l[n - 1] + 2)
            n -= 1
        else:
            x -= 1
            n -= 1
    if x == 1:
        ans += 1

    print(ans)


abc115_d()

Buggy submission (verdict: Runtime Error):
def abc115_d():
    n, x = map(int, input().split())
    burger = "P"
    for i in range(n):
        burger = ("B" + burger + "P" + burger + "B")[:x]

    print(burger.count("P"))


abc115_d()

Buggy submission (verdict: Runtime Error):
def abc115_d():
    n, x = map(int, input().split())
    burgers = ["P"] * (n+1)
    for i in range(n):
        burgers[i+1] = "B" + burgers[i] + "P" + burgers[i] + "B"

    print(burgers[n][:x].count("P"))


abc115_d()
Problem p03774 (python)

Fixed submission:
def abc057_b():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    cd = [list(map(int, input().split())) for _ in range(m)]

    for i in range(n):
        tmp_index = 0
        d = 10 ** 9
        for j in range(m):
            tmp_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            if tmp_d < d:
                tmp_index = j
                d = tmp_d
        print(tmp_index + 1)


abc057_b()

Buggy submission (verdict: Runtime Error):
def abc057_b():
    from math import inf
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    cd = [list(map(int, input().split())) for _ in range(m)]

    for i in range(n):
        tmp_index = 0
        d = inf
        for j in range(m):
            tmp_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            if tmp_d < d:
                tmp_index = j
                d = tmp_d
        print(tmp_index + 1)


abc057_b()
Problem p03201 (python)

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

answer = 0
count = {}

for nb in nbs:
    count[nb] = count.get(nb, 0) + 1

for nb in sorted(count.keys(), reverse=True):
    searching = (1 << nb.bit_length()) - nb
    nb_count = count[nb]
    sr_count = count.get(searching, 0)
    if sr_count:
        if nb == searching:
            increment = nb_count // 2
        else:
            increment = nb_count if nb_count < sr_count else sr_count
            count[searching] -= increment
        answer += increment

print(answer)

Buggy submission (verdict: Runtime Error):
import sys

def main(l):
    u = set()
    l = list(sorted(l))
    for i, a in enumerate(reversed(l)):
        searching = (1 << a.bit_length()) - a
        for j, b in enumerate(l[:-i-1]):
            if b == searching and not j in u:
                u.add(j)
                break

    return len(u)


if __name__ == '__main__':
    main(map(int, sys.stdin))
Problem p03207 (python)

Fixed submission:
N = int(input())
p = [int(input()) for i in range(N)]
A = 0
max=99

for i in range(N):
    if p[i] > max:
        max = p[i]
        m = i

p[m] = p[m]/2


for i in range(N):
    A += p[i]

print(int(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
p = int([input() for i in range(N)])
max=100

for i in range(N):
    if p(i) > max:
        max=p(i)
        m=i

p(m) = p(m)/2

for i in range(N):
    A += p(i)

print(A)
Problem p03207 (python)

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

m=max(p)
for i in range(n):
    if p[i]==m:
        p[i]=int(m)/2
        break

print(int(sum(p)))

Buggy submission (verdict: Runtime Error):
n=input()
p={}
for i in range(n):
    p.append(i)=input()

for i in range(n):
    if p[i]==max(p):
        p[i]=max(p)/2

print(int(sum(p)))
Problem p03201 (python)

Fixed submission:
import math
from collections import defaultdict

def main():
    _ = int(input())
    nums = list(map(int, input().split()))
    n = len(nums)
    nums.sort()

    nums_cnt = defaultdict(int)
    for num in nums:
        nums_cnt[num] += 1

    cnt = 0
    #print(num_bin_digits)

    for cur in reversed(range(n)):
        num = nums[cur]
        if nums_cnt[num] <= 0:
            continue

        power_of_2 = 1 << math.ceil(math.log2(num))

        pair = power_of_2 - num


        if pair != 0 and nums_cnt[pair] > 0:
            nums_cnt[pair] -= 1
            nums_cnt[num] -= 1
            cnt += 1
        elif pair == 0 and nums_cnt[num] >= 2:
            nums_cnt[num] -= 2
            cnt += 1


        '''
        idx = bisect.bisect_left(nums, pair)
        if idx >= cur or nums[idx] != pair:
            #print('continue',pair, idx)
            continue

        while used[idx]:
            idx += 1

        if nums[idx] == pair:
            used[idx] = True
            cnt += 1

        #print(idx, num, power_of_2, pair)
        #print(cnt, nums, used)
        '''

        #print(nums_cnt)

    print(cnt)

    return

main()

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

def main():
    _ = int(input())
    nums = list(map(int, input().split()))
    n = len(nums)
    nums.sort()
    used = [False] * n

    nums_cnt = defaultdict(int)
    for num in nums:
        nums_cnt[num] += 1

    cnt = 0
    #print(num_bin_digits)

    for cur in reversed(range(n)):
        if used[cur]:
            continue
        num = nums[cur]
        power_of_2 = 1 << math.ceil(math.log2(num))

        pair = power_of_2 - num

        if nums_cnt[pair] != 0:
            nums_cnt[pair] -= 1
            used[pair] = True
            cnt += 1


        '''
        idx = bisect.bisect_left(nums, pair)
        if idx >= cur or nums[idx] != pair:
            #print('continue',pair, idx)
            continue

        while used[idx]:
            idx += 1

        if nums[idx] == pair:
            used[idx] = True
            cnt += 1

        #print(idx, num, power_of_2, pair)
        #print(cnt, nums, used)
        '''

    print(cnt)

    return

main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    nums = list(map(int, input().split()))
    nums.sort()
    used = [False] * n

    num_bin_digits = [1 << len(f"{x:b}") for x in nums]
    cnt = 0

    for cur in reversed(range(n)):
        if used[cur]:
            continue

        num = nums[cur]
        power_of_2 = num_bin_digits[cur]
        pair = power_of_2 - num
        idx = -1
        if pair in nums[:cur]:
            idx = nums.index(pair)

        if idx != -1 and not used[idx]:
            used[idx] = True
            cnt += 1

    print(cnt)
    return

main()
Problem p03221 (python)

Fixed submission:
import sys

def main():
    n, m = map(int, input().split())
    lines = sys.stdin.readlines()

    cities = {}
    for i in range(m):
        p, y = map(int, lines[i].split())
        if p in cities:
            cities[p].append((i, y))
        else:
            cities[p] = [(i, y)]

    outputs = [None] * m
    for pref, city_list in cities.items():
        city_list.sort(key=lambda x: x[1])
        #print(pref, city_list)
        city_no = 1
        for city in city_list:
            outputs[city[0]] = "{:06d}{:06d}".format(pref, city_no)
            city_no += 1

    for output in outputs:
        print(output)
    return


main()

Buggy submission (verdict: Runtime Error):
import sys
def main():
    lines = sys.stdin.readlines()
    plist = [0] * 100000

    n, m = map(int, lines[0].split())
    cities={}
    for i in range(1, m+1):
        p, y = map(int, lines[i].split())
        plist[i-1] = p
        if p in cities:
            idx=0
            for item in cities[p]:
                if item[0] > y:
                    item[1] += 1
                else:
                    idx += 1
            cities[p].append([y, idx])
            pass
        else:
            cities[p] = [[y, 0]]

    for p in plist[:n+1]:
        #print(p, cities[p])
        print("{:06d}{:06d}".format(p, cities[p][0][1]+1))
        del cities[p][0]
    return

main()
Problem p03252 (python)

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

    s_dict = {}
    t_dict = {}

    for ch_s, ch_t in zip(S, T):
        if ch_t in t_dict.keys():
            if t_dict[ch_t] != ch_s:
                print("No")
                return
        else:
            t_dict[ch_t] = ch_s

        if ch_s in s_dict.keys():
            if s_dict[ch_s] != ch_t:
                print("No")
                return
        else:
            s_dict[ch_s] = ch_t
        #print("s",s_dict)
        #print("t",t_dict)

    print('Yes')
    return


main()

Buggy submission (verdict: Runtime Error):
def main():
    S = input()
    T = input()

    DICT = {}

    for ch_s, ch_t in zip(S, T):
        #print(ch_s, ch_t)
        if ch_s in DICT.keys():
            #print('swap')
            ch_s = DICT[ch_s]

        if ch_t in DICT.values():
            #print(DICT)
            print(ch_s, ch_t, DICT[ch_t])
            if DICT[ch_t] != ch_t:
                print('No')
                return
        DICT[ch_s] = ch_t
    print('Yes')
    return


main()
Problem p03426 (python)

Fixed submission:
if __name__ == '__main__':
    h, w, d = map(int, input().split())
    f = [list(map(int, input().split())) for _ in range(h)]

    # f => (y, x) mapping
    c_map = [0] * (h * w)
    for y in range(h):
        for x in range(w):
            c_map[f[y][x] - 1] = (y, x)

    # cost accumulation
    d_map = [0] * (h * w)
    for i in range(d, h * w):
        y, x = c_map[i]
        y2, x2 = c_map[i - d]
        d_map[i] = d_map[i - d] + abs(y2 - y) + abs(x2 - x)

    results = []
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        results.append(d_map[r - 1] - d_map[l - 1])

    print("\n".join(map(str, results)))

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


def move_and_compute_cost(field, h, d, l, r):
    if l == r:
        return 0

    ff = field.ravel()
    # create l to r route
    route = np.arange(l, r + 1, d)

    indices = np.arange(len(ff))
    cond = np.isin(ff, route)

    indices = indices[cond]
    ff = ff[cond]
    v = indices[ff.argsort()]

    points = np.vstack([v // h, v % h]).T
    next_points = np.vstack([points[1:], points[-1]])

    cost = np.abs(points - next_points).sum()
    return cost


if __name__ == '__main__':
    h, w, d = [int(v) for v in input().split()]

    # read field
    field = np.empty((h, w), dtype=int)
    for i in range(h):
        line = [int(v) for v in input().split()]
        field[i, :] = line

    ls, rs = [], []
    q = int(input())
    for i in range(q):
        line = [int(v) for v in input().split()]
        ls.append(line[0])
        rs.append(line[1])

    costs = [move_and_compute_cost(field, h, d, l, r) for l, r in zip(ls, rs)]
    for c in costs:
        print(c)

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


def move_and_compute_cost(field, d, l, r, cost):
    if l == r:
        return cost

    curr_y, curr_x = np.where(field == l)
    curr_y, curr_x = curr_y[0], curr_x[0]

    next_y, next_x = np.where(field == l + d)
    next_y, next_x = next_y[0], next_x[0]

    cost += abs(next_y - curr_y) + abs(next_x - curr_x)
    return move_and_compute_cost(field, d, l + d, r, cost)


if __name__ == '__main__':
    h, w, d = [int(v) for v in input().split()]

    # read field
    field = np.empty((h, w), dtype=int)
    for i in range(h):
        line = [int(v) for v in input().split()]
        field[i, :] = line

    ls, rs = [], []
    q = int(input())
    for i in range(q):
        line = [int(v) for v in input().split()]
        ls.append(line[0])
        rs.append(line[1])

    costs = [move_and_compute_cost(field, d, l, r, 0) for l, r in zip(ls, rs)]
    for c in costs:
        print(c)
Problem p03208 (python)

Fixed submission:

def solve():
    N, K = map(int, input().split())
    data = [int(input()) for _ in range(N)]
    data.sort()
    ans = []
    cnt = 0
    while True:
        if data[cnt] >= data[-cnt-K]:
            break
        h_max1 = data[cnt + K - 1]
        h_min1 = data[cnt]
        h_max2 = data[-cnt-1]
        h_min2 = data[-cnt - K]
        tmp1 = h_max1 - h_min1
        tmp2 = h_max2 - h_min2
        ans.append(tmp1)
        ans.append(tmp2)
        cnt = cnt + 1
        if data[cnt] >= data[-cnt-K]:
            break

    print(min(ans))


solve()

Buggy submission (verdict: Runtime Error):

def solve():
    N, K = map(int, input().split())
    data = [int(input()) for _ in range(N)]
    data.sort()
    ans = []
    cnt = 0
    while True:
        h_max1 = data[cnt + K - 1]
        h_min1 = data[cnt]
        h_max2 = data[-cnt-1]
        h_min2 = data[-cnt - K]
        tmp1 = h_max1 - h_min1
        tmp2 = h_max2 - h_min2
        ans.append(tmp1)
        ans.append(tmp2)
        cnt = cnt + 1
        if data[cnt] == data[-cnt-K]:
            break

    print(min(ans))


solve()

Buggy submission (verdict: Runtime Error):

def solve():
    N, K = map(int, input().split())
    data = [int(input()) for _ in range(N)]
    data.sort()
    ans = []
    cnt = 0
    while True:
        h_max1 = data[cnt + K - 1]
        h_min1 = data[cnt]
        h_max2 = data[-cnt-1]
        h_min2 = data[-cnt - K]
        tmp1 = h_max1 - h_min1
        tmp2 = h_max2 - h_min2
        ans.append(tmp1)
        ans.append(tmp2)
        cnt = cnt + 1
        if data[cnt] == data[-cnt-K]:
            break

    print(min(ans))


solve()
Problem p03315 (python)

Fixed submission:
a=input()
b=[]

for i in range(len(a)):
    if a[i]=='+':
        b.append(1)
    else:
        b.append(-1)

        
print(sum(b))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int, input().split())
print(a+b+c+d)
Problem p03307 (python)

Fixed submission:
a = int(input())

if a % 2 == 0:
    b = a
else:
    b = 2*a
print(b)

Buggy submission (verdict: Runtime Error):
from statistics import *



n = int(input())
list = input().split()

for i in range(n):
    list[i] = int(list[i]) - (i + 1)

b = int(median(list))

for i in range(n):
    list[i] = abs(list[i] - b)

print(sum(list))

Buggy submission (verdict: Runtime Error):
if a % 2 == 0:
    b = a
else:
    b = 2*a
print(b)
Problem p03803 (python)

Fixed submission:
a = ['2','3','4','5','6','7','8','9','10','11','12','13','1']
al,bo = map(str,raw_input().split())
if a.index(al) > a.index(bo):
    print 'Alice'
elif a.index(al) < a.index(bo):
    print 'Bob'
else:
    print 'Draw'

Buggy submission (verdict: Runtime Error):
a = ['2','3','4','5','6','7','8','9','10','11','12','13']
al,bo = map(str,raw_input().split())
if a.index(al) > a.index(bo):
    print 'Alice'
elif a.index(al) < a.index(bo):
    print 'Bob'
else:
    print 'Draw'
Problem p03286 (python)

Fixed submission:
import math
import sys

N = int(input())
if N == 0:
    max = 1
else:
    max = math.ceil(math.log(abs(N), 2)) + 3

result = []
numerator = N
for i in range(0, max):
    if numerator % (math.pow(2, i + 1)) == 0:
        result.append(str(0))
    else:
        result.append(str(1))
        numerator -= math.pow(-2, i)

    if numerator == 0:
        break
result.reverse()
print("".join(result))

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

N = int(input())
max = math.ceil(math.log(abs(N), 2)) + 3

result = []
numerator = N
for i in range(0, max):
    if numerator % (math.pow(2, i + 1)) == 0:
        result.append(str(0))
    else:
        result.append(str(1))
        numerator -= math.pow(-2, i)

    if numerator == 0:
        break
result.reverse()
print("".join(result))