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

Fixed submission:
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    result = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = (i * j) % 2019
            if mod == 0:
                result = 0
                break
            elif mod < result:
                result = mod
    print(result)

Buggy submission (verdict: Runtime Error):
import itertools

L, R = map(int, input().split())
if R - L >= 2019:
    print(0)

comb = itertools.combinations(range(L, R + 1), 2)
result = float('inf')
for a, b in comb:
    mod = a * b % 2019
    if mod == 0:
        result = 0
        break
    elif mod < result:
        result = mod
print(result)

Buggy submission (verdict: Runtime Error):
import itertools

L, R = map(int, input().split())
comb = itertools.combinations(range(L, R + 1), 2)
result = float('inf')
for a, b in comb:
    mod = a * b % 2019
    if mod == 0:
        result = 0
        break
    elif mod < result:
        result = mod
print(result)

Buggy submission (verdict: Runtime Error):
import itertools

L, R = map(int, input().split())
comb = itertools.combinations(range(L, R + 1), 2)
result = float('inf')
for a, b in comb:
    mod = a * b % 2019
    if mod == 0:
        result = 0
        break
    else mod < result:
        result = mod
print(result)

Buggy submission (verdict: Runtime Error):
import itertools

L, R = map(int, input().split())
comb = itertools.combinations(range(L, R + 1), 2)
result = float('inf')
for a, b in comb:
    mod = a * b % 2019
    if mod < result:
        result = mod
print(result)

Buggy submission (verdict: Runtime Error):
import itertools

L, R = map(int, input().split())
comb = itertools.combinations(range(L, R + 1), 2)
mods = []
for a, b in comb:
    mods.append(a * b % 2019)
print(min(mods))
Problem p02995 (python)

Fixed submission:
import fractions

A, B, C, D = (int(i) for i in input().split())


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


one_to_b = B - ((B // C) + (B // D) - (B // lcm(C, D)))
one_to_a = A - 1 - ((((A - 1) // C) +
                     ((A - 1) // D) -
                     (A - 1) // lcm(C, D)))

print(one_to_b - one_to_a)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = (int(i) for i in input().split())


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


one_to_b = B - ((B // C) + (B // D) - (B // lcm(C, D)))
one_to_a = A - 1 - ((((A - 1) // C) +
                     ((A - 1) // D) -
                     (A - 1) // lcm(C, D)))

print(one_to_b - one_to_a)
Problem p02947 (python)

Fixed submission:
#coding: utf-8

from collections import Counter
N = int(input())

s_list = []
for i in range(N):
    input_string = list(input())
    input_string.sort()
    input_string = "".join(input_string)
    s_list.append(input_string)

s_list.sort()

list_counter = Counter(s_list)

count = 0
for key in list_counter.keys():
    tmp_count = list_counter[key]
    if tmp_count < 2:
        pass
    elif tmp_count == 2:
        count += 1
    else:
        permutations = tmp_count * (tmp_count - 1)
        combination = permutations/2
        count += int(combination)

print(int(count))

Buggy submission (verdict: Runtime Error):
#coding: utf-8

from math import factorial
N = int(input())

s_list = []
for i in range(N):
    input_string = list(input())
    input_string.sort()
    input_string = "".join(input_string)
    s_list.append(input_string)

count = 0
s_list.sort()
tmp_count = 0
for i in range(1, len(s_list)):
    if s_list[i-1] == s_list[i]:
        tmp_count = tmp_count + 1
    else:
        if tmp_count == 0:
            pass
        else:
            tmp_count = tmp_count + 1
            count = count + int(factorial(tmp_count) / factorial(2) / factorial(tmp_count - 2))
        tmp_count = 0

if tmp_count == 0:
    pass
else:
    tmp_count = tmp_count + 1
    count = count + int(factorial(tmp_count) / factorial(2) / factorial(tmp_count - 2))

print(count)
Problem p02952 (python)

Fixed submission:
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start

n = int_single()

r = 0
for i in range(1, n+1):
    if (len(str(i)) % 2 == 1):
        r += 1

print(r)

Buggy submission (verdict: Runtime Error):
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start

n = int_single()

r = 0
for i in range(1, n):
    if (len(str(i)) % 2 == 1):
        res += 1

print(res)
Problem p03067 (python)

Fixed submission:
A, B, C = map(int, input().split())

if A < C and C < B:
    print("Yes")
elif B < C and C < A:
    print("Yes")
else:
    print("No")

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

if A < C and C < B:
    print("Yes")
elif: B < C and C < A
    print("Yes")
else:
    print("No")
Problem p03147 (python)

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

ans = 0
while max(h):
    current_hight = 0
    for i in range(len(h)):
        if not h[i]:
            if not current_hight:
                continue
            else:
                break
        elif h[i] < current_hight:
            break
        else:
            current_hight = h[i]
            h[i] -= 1
    ans += 1

print(ans)

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

ans = 0
while max(h):
    current_hight = 0
    for i in range(len(h)):
        if not h[i]:
            if not current_hight:
                continue
            else:
                break
        elif h[i] < current_hight:
            break
        else:
            current_hight = h[i]
            h[i] -= 1
    ans += 1
    if ans == 75:

print(ans)
Problem p03262 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500000)

def gcd(a, b):
	# while b:
	# 	a, b = b, a % b
	# return a

	if b:
		return gcd(b, a % b)
	else:
		return a

def gcd_list(li):
	if len(li) > 2:
		x = gcd(li[-1], li[-2])
		li = li[:-2] + [x]
		return gcd_list(li)
	else:
		return gcd(li[0], li[1])

N, X = map(int, input().split())

x = list(map(int, input().split()))

li = [abs(i - X) for i in x]

# li = [i for i in li if i]
# li = sorted(li)
if len(li) == 1:
	print(li[0])
else:
	ans = li[0]
	for i in range(1,N):
		ans = gcd(ans, li[i])
	print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3000)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(li):
	if len(li) > 2:
		x = gcd(li[-1], li[-2])
		li = li[:-2] + [x]
		return gcd_list(li)
	else:
		return gcd(li[0], li[1])

N, X = map(int, input().split())

x = list(map(int, input().split()))

li = [abs(i - X) for i in x]

li = [i for i in li if i]

if len(li) == 1:
	print(li[0])
else:
	print(gcd_list(li))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd_list(li):
	if len(li) > 2:
		x = gcd(li[-1], li[-2])
		li = li[:-2] + [x]
		return gcd_list(li)
	else:
		return gcd(li[0], li[1])

N, X = map(int, input().split())

x = list(map(int, input().split()))

li = [abs(i - X) for i in x]

li = [i for i in li if i]

if len(li) == 1:
	print(li[0])
else:
	print(gcd_list(li))
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
A, N = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
D, N = map(int, input().split())
if (A < 9) and (B < 9):
    print("Yay!")
else:
    print(":(")
Problem p03351 (python)

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

if abs(a - c) <= d:
    print("Yes")

elif abs(a-b) <= d and abs(b-c) <= d:
    print("Yes")

else:
    print("No")

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

if abs(a - c) <= d:
    print("Yes")

elif abs(a-b) <= d and ans(b-c) <= d:
    print("Yes")

else:
    print("No")
Problem p03633 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

lcm = 1
for i in T:
    lcm = int(lcm * i // gcd(lcm, i))

print(lcm)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def lcm_li(li):
    if len(li) == 2:
        return lcm(li[0], li[1])
    else:
        x = lcm(li[0], li[1])
        x = [x] + li[2:]
        return lcm_li(x)

print(lcm_li(T))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

lcm = 1
for i in T:
    lcm = int(lcm * i / gcd(lcm, i))

print(lcm)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def lcm_li(li):
    if len(li) == 2:
        return lcm(li[0], li[1])
    else:
        x = lcm(li[0], li[1])
        x = [x] + li[2:]
        return lcm_li(x)

print(lcm_li(T))

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def lcm_li(li):
    if len(li) == 2:
        return lcm(li[0], li[1])
    else:
        x = lcm(li[0], li[1])
        x = [x] + li[2:]
        return lcm_li(x)

print(lcm_li(T))

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

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

def lcm_li(li):
    if len(li) == 2:
        return lcm(li[0], li[1])
    else:
        x = lcm(li[0], li[1])
        x = [x] + li[2:]
        return lcm_li(x)

print(lcm_li(T))
Problem p02971 (python)

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

sort = sorted(A, reverse=True)
mx = sort[0]
mxn = sort[1]

for i in range(N):
    if A[i] == mx:
        print(mxn)
    else:
        print(mx)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int(input()) for k in range(N))

mx, mxn = sorted(A, reverse=True)[:2]

result = [mxn if x==mn else mx for x in A]
print('\n'.join(map(str, result)))
Problem p02982 (python)

Fixed submission:
N, D = [int(_) for _ in input().split()]
X = []
for i in range(N):
    X.append([int(_) for _ in input().split()])

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt

ans = 0
for i in range(N):
    for j in range(i):
        d = 0
        for k in range(D):
            d += (X[i][k] - X[j][k]) ** 2
        if sqrt(d) % 1 == 0:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt

ans = 0
for i in range(N):
    for j in range(i):
        d = 0
        for k in range(D):
            d += (X[i][k] - X[j][k]) ** 2
        if sqrt(d) % 1 == 0:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

from math import sqrt
# import numpy

ans = 0
for i in range(N):
    for j in range(i):
        d = [(x[0] - x[1]) ** 2 for x in zip(X[i], X[j])]
        if sqrt(sum(d)) % 1 == 0:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

# N, D = [3, 4]
# X = [
# [-3, 7, 8, 2],
# [-12, 1, 10, 2],
# [-2, 8, 9, 3]
# ]

import math
import numpy

ans = 0
for i in range(N):
    for j in range(i):
        # print(i,j)
        d = [(x[0] - x[1]) ** 2 for x in zip(X[i], X[j])]
        if math.sqrt(sum(d)).is_integer():
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, D = [int(_) for _ in input().split()]
X = []
for i in range(D):
    X.append([int(_) for _ in input().split()])

import math

ans = 0
for i in range(5):
    for j in range(i):
        # print(i,j)
        d = X[i] - X[j]
        if math.sqrt(d.dot(d)).is_integer():
            ans += 1
print(ans)
Problem p02995 (python)

Fixed submission:
A, B, C, D = [int(_) for _ in input().split()]

def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a

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

def dvi_num2(b, c, d):
    return b - b // c - b //d + b // lcm(c, d)

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)
print(int(ans))

Buggy submission (verdict: Runtime Error):
A, B, C, D = [int(_) for _ in input().split()]

import math
def dvi_num(b, c):
    return math.floor(b / c)

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

def dvi_num2(b, c, d):
    return b - dvi_num(b,c) - dvi_num(b,d) + dvi_num(b, lcm(c, d))

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)

print(ans)

Buggy submission (verdict: Runtime Error):
A, B, C, D = [int(_) for _ in input().split()]

import math
def dvi_num(b, c):
    return math.floor(b / c)

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

def dvi_num2(b, c, d):
    return b - dvi_num(b,c) - dvi_num(b,d) + dvi_num(b, lcm(c, d))

ans = dvi_num2(B, C, D) - dvi_num2(A - 1, C, D)
print([dvi_num2(B, C, D), dvi_num2(A - 1, C, D)])

print(ans)
Problem p03061 (python)

Fixed submission:
def gcd(a, b):
    if a == 0:
        return b
    if b == 0:
        return a
    if a < b:
        return gcd(b, a)
    r = a % b
    return b if r == 0 else gcd(b, r)


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

l = [0 for i in range(n)]
for i in range(1, n):
    l[i] = gcd(a[i-1], l[i-1])

r = [0 for i in range(n)]
for i in range(n-1)[::-1]:
    r[i] = gcd(a[i+1], r[i+1])

m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))

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

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

l = [0 for i in range(n)]
for i in range(1, n):
    l[i] = gcd(a[i-1], l[i-1])

r = [0 for i in range(n)]
for i in range(n-1)[::-1]:
    r[i] = gcd(a[i+1], r[i+1])

m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))
Problem p03407 (python)

Fixed submission:
a, b, c= map(int, input().split())
if a+b<c:
  print("No")
else :
  print("Yes")

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

a = int(input())
a_list = []
b_list = []

for i in range(a):
  a_list.append(input())
a_list.append('null')

b = int(input())

for i in range(b):
  b_list.append(input())
a_count = Counter(a_list)
b_count = Counter(b_list)
a_list_no_overlap = set(a_list)
print(a_count)

point = []
for i in a_list_no_overlap:
    point.append(a_count[i]-b_count[i])

point_max = np.argmax(point)
print(point_max)
Problem p03423 (python)

Fixed submission:
N = int(input())
Num_of_Group = int(N/3)
print(Num_of_Group)

Buggy submission (verdict: Runtime Error):
N = input()
a = []
for i in range(N):
    a.append(input())
b = list(set(a))
If length(b) ==3 :
  print(3)
elso :
  print(4)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
s = a*b
if s%2==0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
int s = a*b
if s%2==0:
  print('Even')
else:
  print('Odd')
Problem p02991 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(3 * n)]
for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    # u0 -> v1
    g[3 * u].append(3 * v + 1)
    # u1 -> v2
    g[3 * u + 1].append(3 * v + 2)
    # u2 -> v0
    g[3 * u + 2].append(3 * v)

s, t = map(int, input().split())
s = 3 * (s - 1)
t = 3 * (t - 1)

depth = dict()
depth[s] = 0
q = deque([s])


while(len(q) != 0):
    v = q.popleft()
    for u in g[v]:
        if u not in depth:
            q.append(u)
            depth[u] = depth[v] + 1

print(depth[t] // 3 if t in depth else -1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from scipy.misc import comb

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

mod = int(10 ** 9 + 7)

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from scipy.special import comb

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

mod = int(10 ** 9 + 7)

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque

n, m = map(int, input().split())
g = [[] for _ in range(3 * n)]
for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    # u0 -> v1
    g[3 * u].append(3 * v + 1)
    # u1 -> v2
    g[3 * u + 1].append(3 * v + 2)
    # u2 -> v0
    g[3 * u + 2].append(3 * v)

s, t = map(int, input().split())
s = 3 * (s - 1)
t = 3 * (t - 1)

depth = dict()
depth[s] = 0
q = deque([s])


while(len(q) != 0):
    v = q.popleft()
    for u in g[v]:
        if u not in depth:
            q.append(u)
            depth[u] = depth[v] + 1

print(depth[t] // 3 if 3 in depth else -1)
Problem p02997 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = (n - 2) * (n - 1) // 2

if k > k_max:
    print(-1)
    sys.exit()

m = n - 1 + k_max - k

print(m)
cnt = 0
exit_flag = False
for i in range(1, n):
    for j in range(i + 1, n + 1):
        print(i, j)
        cnt += 1
        if cnt == m:
            exit_flag = True
            break
    if exit_flag:
        break

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = int((n - 2) * (n - 1) / 2)
k_min =

if k > k_max:
    print(-1)
    sys.exit()

edges = list()

for i in range(2, n + 1):
    edges.append((1, i))

cnt = k_max
exit_flag = False
for i in range(2, n):
    for j in range(i + 1, n + 1):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            exit_flag = True
            break
    if exit_flag:
        break

print(len(edges))
for u, v in edges:
    print(u, v)
Problem p03006 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
pairs = list()
patterns = defaultdict(int)

for _ in range(n):
    pairs.append(tuple((map(int, input().split()))))

for i in range(n):
    for j in range(n):
        if i != j:
            patterns[(pairs[i][0] - pairs[j][0], pairs[i][1] - pairs[j][1])] += 1

ans = 1
if n > 1:
    ans = n - max(patterns.values())

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
pairs = list()
patterns = defaultdict(int)

for _ in range(n):
    pairs.append(tuple((map(int, input().split()))))

for i in range(n):
    for j in range(n):
        if i != j:
            patterns[(pairs[i][0] - pairs[j][0], pairs[i][1] - pairs[j][1])] += 1

print(n - max(patterns.values()))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import defaultdict

n = int(input())
patterns = defaultdict(int)

last_x, last_y = map(int, input().split())
for _ in range(1, n):
    x, y = map(int, input().split())
    diff_x = x - last_x
    diff_y = y - last_y
    last_x, last_y = x, y
    pattern = '{0}, {1}'.format(diff_x, diff_y)
    patterns[pattern] += 1

ans = n - max(patterns.values())

print(ans)
Problem p03007 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
while len(positives) > 1:
    if positives[0] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y)

x = positives.popleft()

while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
for i in range(n - 2):
    if positives[i] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y)

x = positives.popleft()

while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
for i in range(n - 2):
    if positives[i] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

x = negatives.pop()
while len(positives) > 1:
    y = positives.popleft()
    print(x, y)
    x -= y
negatives.append(x)

x = positives.popleft()
while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
for i in range(n - 1):
    if a[i] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y)

x = positives.popleft()

while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y
Problem p03050 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())

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)

total = 0
for divisor in divisors:
    if divisor == 1:
        continue
    fav = divisor - 1
    x = n // fav
    y = n % fav
    if x == y:
        total += fav

print(total)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
s = list()
counter = {
    'ab': 0,
    'begin_b': 0,
    'end_a': 0,
    'b_to_a': 0
}

for i in range(n):
    substr = input()
    counter['ab'] += substr.count('AB')
    if substr.startswith('B'):
        if substr.endswith('A'):
            counter['b_to_a'] += 1
        else:
            counter['begin_b'] += 1
    else:
        if substr.endswith('A'):
            counter['end_a'] += 1

total = counter['ab'] + min(counter['begin_b'], counter['end_a'])
if counter['b_to_a'] > 0:
    total += (counter['b_to_a'] - 1)
    if max(counter['begin_b'], counter['end_a']) > 0:
        total += 1

print(total)