Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = input()
x, y, c = 0, S.count('.'), min(n-y, y)
for i in range(n):
  t = S[i]=='#'
  x += t
  y -= 1-t
  c = min(c, x+y)
print(c)

Fixed submission:
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)

x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  ans = min(ans, x + y)
print(ans)

Buggy python submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  t = S[i]=='#':
  x += t
  y -= not t
  c = min(c, x+y)
print(c)

Fixed submission:
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)

x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  ans = min(ans, x + y)
print(ans)

Buggy python submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  t = S[i]=='#':
  x += t
  y -= ~t
  c = min(c, x+y)
print(c)

Fixed submission:
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)

x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  ans = min(ans, x + y)
print(ans)

Buggy python submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  c = min(ans, x+y)
print(c)


Fixed submission:
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)

x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  ans = min(ans, x + y)
print(ans)

Buggy python submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  t = S[i]=='#':
  x += t
  y -= t
  c = min(c, x+y)
print(c)


Fixed submission:
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)

x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  ans = min(ans, x + y)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
def divisors(n):
    divisors = []
    for i in range(1, int(sqrt(n))+1):
        q, r = divmod(n, i)
        if r == 0:
            divisors.append(i)
            if i != q:
                divisors.append(q)
    return divisors

n, p = map(int, input().split())
x = 1
for k, v in factorint(p).items():
    x *= k ** (v//n)
print(x)

Fixed submission:
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n, p = map(int, input().split())
x = 1
for k, v in factorint(p).items():
    x *= k ** (v//n)
print(x)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from operator import mul
n, p = map(int, input().split())
print(reduce(mul, [1] + [k for k, v in factorint(p).items()  if v >= n]))

Fixed submission:
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n, p = map(int, input().split())
x = 1
for k, v in factorint(p).items():
    x *= k ** (v//n)
print(x)
Buggy python submission (verdict: Runtime Error):
n, k, H = map(int, open(0).read().split())
H.sort()
ans = 10 ** 10
for h0, h1 in zip(H, H[k-1:]):
  ans = min(ans, h1-h0)
print(ans)

Fixed submission:
n, k, *H = map(int, open(0).read().split())
H.sort()
ans = 10 ** 10
for h0, h1 in zip(H, H[k-1:]):
  ans = min(ans, h1-h0)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = set()
for x in product('753_', repeat=9):
    s = ''.join(x)
    s = s.replace('_', '')
    if '7' in s and '5' in s and '3' in s and int(s) <= n:
        A.add(s)
print(len(A))

Fixed submission:
from itertools import product
n = int(input())
A = set()
for x in product('753_', repeat=9):
    s = ''.join(x)
    s = s.replace('_', '')
    if '7' in s and '5' in s and '3' in s and int(s) <= n:
        A.add(s)
print(len(A))
Buggy python submission (verdict: Runtime Error):
inputs = open(0).readlines()
n, m = map(int, inputs[0].split())
PY = [map(int, x.split()) for x in inputs[1:]]
A = [[] for _ in range(m)]
B = []
for i, (p, y) in enumerate(PY):
    A[p-1].append([y, i])
    B.append('{:06}'.format(p))
for a in A:
    a.sort()
    for i in range(len(a)):
        B[a[i][1]] += '{:06}'.format(i+1)
print(*B, sep='\n')

Fixed submission:
inputs = open(0).readlines()
n, m = map(int, inputs[0].split())
PY = [map(int, x.split()) for x in inputs[1:]]
A = [[] for _ in range(n)]
B = [''] * m
for i, (p, y) in enumerate(PY):
    A[p-1].append([y, i])
    B[i] += '{:06}'.format(p)
for a in A:
    a.sort()
    for i in range(len(a)):
        B[a[i][1]] += '{:06}'.format(i+1)
print(*B, sep='\n')
Buggy python submission (verdict: Runtime Error):
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)
A = ['*'] * l
step = l//n
for i in range(n):
    A[i*step] = S[i]
step = l//m
for i in range(m):
    if A[i*step] == T[i] or A[i*step] == '*':
        A[i*step] = T[i]
    else:
        print(-1)
        break
else:
    print(l)

Fixed submission:
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)

d = {}
t = l//n
for i in range(n):
    d[i*t] = S[i]
t = l//m
for i in range(m):
    if i*t not in d or d[i*t] == T[i]:
        d[i*t] = T[i]
    else:
        print(-1)
        break
else:
    print(l)

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)
A = ['*'] * l
step = l//n
for i in range(n):
    A[i*step] = S[i]
step = l//m
for i in range(m):
    if A[i*step] == T[i] or A[i*step] == '*':
        A[i*step] = T[i]
    else:
        print(-1)
else:
    print(l)

Fixed submission:
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)

d = {}
t = l//n
for i in range(n):
    d[i*t] = S[i]
t = l//m
for i in range(m):
    if i*t not in d or d[i*t] == T[i]:
        d[i*t] = T[i]
    else:
        print(-1)
        break
else:
    print(l)
Buggy python submission (verdict: Runtime Error):
n, *XYH = map(int, open(0).read().split())
for cx, cy in product(range(101), repeat=2):
    B, C = set(), set()
    for x, y, h in zip(XYH[::3], XYH[1::3], XYH[2::3]):
        s = h + abs(x-cx) + abs(y-cy)
        if h:
            C.add(s)
        else:
            B.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            print(cx, cy, h)
            exit()

Fixed submission:
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

Buggy python submission (verdict: Runtime Error):
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

Fixed submission:
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

Buggy python submission (verdict: Runtime Error):
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        A.append((cx, cy, C.pop()))
print(*A.pop())

Fixed submission:
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n, *A = map(int, open(0).read().split())

a0 = Counter(A[::2]).most_common(2)
a1 = Counter(A[1::2]).most_common(2)

count = n
if a0[0][0] == a1[0][0]:
    count -= max(a0[1][1] + a1[0][1], a0[0][1] + a1[1][1])
else:
    count -= a0[0][1] + a1[0][1]
print(count)

Fixed submission:
from collections import Counter
n, *A = map(int, open(0).read().split())

a0 = Counter(A[::2]).most_common(2)
a1 = Counter(A[1::2]).most_common(2)

count = n
if a0[0][0] == a1[0][0]:
    if len(a0) == len(a1) == 1:
        count -= n//2
    elif len(a0) < len(a1):
        count -= n//2 - a1[1][1]
    elif len(a0) > len(a1):
        count -= n//2 - a0[1][1]
    else:
        count -= max(a0[1][1] + a1[0][1], a0[0][1] + a1[1][1])
else:
    count -= a0[0][1] + a1[0][1]
print(count)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
S, T = map(lambda x: x.strip(), open(0).read().split())

from collections import defaultdict
S, T = map(lambda x: x.strip(), open(0).read().split())

ds, dt = defaultdict(str), defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if not ds[s] or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if not dt[t] or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

Fixed submission:
S = input().strip()
T = input().strip()

ds = {}
dt = {}
ans = 'Yes'
for s, t in zip(S, T):
    if s not in ds or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if t not in dt or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input().strip()
T = input().strip()

ds = {}
dt = {}
ans = 'Yes'
for s, t in zip(S, T):
    if s not in ds or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if t not in dt or dt[s] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)

Fixed submission:
S = input().strip()
T = input().strip()

ds = {}
dt = {}
ans = 'Yes'
for s, t in zip(S, T):
    if s not in ds or ds[s] == t:
        ds[s] = t
    else:
        ans = 'No'
        break
    if t not in dt or dt[t] == s:
        dt[t] = s
    else:
        ans = 'No'
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import bisect
inputs = sys.stdin.readlines()

N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))

if N == 1:
    print(abs(X[0]))
else:
    ans = 2 * 10 ** 8
    idx = bisect.bisect_left(X, 0)
    Y = X[max(0, idx-K):min(N, idx+K)]
    for i in range(N-K+1):
        y1, y2 = Y[i], Y[i+K-1]
        if y1 < 0 and y2 <= 0:
            ans = min(ans, -y1)
        elif y1 < 0 and 0 < y2:
            if -y1 < y2:
                ans = min(ans, -2*y1 + y2)
            else:
                ans = min(ans, -y1 + 2*y2)
        else:
            ans = min(ans, y2)
            break
    print(ans)

Fixed submission:
import sys
inputs = sys.stdin.readlines()
 
N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))
 
if N == 1:
    print(X[0])
else:
    ans = 10 ** 9
    for i in range(N-K+1):
        x1, x2 = X[i], X[i+K-1]
        if x1 <= 0 and x2 <= 0:
            ans = min(ans, -x1)
        elif x1 <= 0 and 0 < x2:
            if -x1 < x2:
                ans = min(ans, -2*x1 + x2)
            else:
                ans = min(ans, -x1 + 2*x2)
        else:
            ans = min(ans, x2)
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
S = input().strip()
k = int(input())
for i, c in enumerate(S, 1):
  if c != '1' or i == k:
print(c)

Fixed submission:
S = input().strip()
k = int(input())
for i, c in enumerate(S, 1):
  if c != '1' or i == k:
    break
print(c)
Buggy python submission (verdict: Runtime Error):
d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
        n = ceil((g - total) / (use * 100))
        if P[use-1]-1 < n:
            continue
        count += n
        total += n * use * 100
        
    if total >= g:
        ans = min(ans, count)
print(ans) 


Fixed submission:
import sys
from math import ceil
inputs = sys.stdin.readlines()

d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
        n = min(P[use-1], ceil((g - total) / (use * 100)))
        count += n
        total += n * use * 100
    if total >= g:
        ans = min(ans, count)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from math import floor, ceil
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
b1 = round(sum(B) / n)
b2 = ceil(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
C1 = list(map(lambda x: abs(x-b1), B))
C2 = list(map(lambda x: abs(x-b2), B))
print(min(list(map(sum, [C, C1, C2])))

Fixed submission:
import sys
from statistics import median_low
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = median_low(B)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))

Buggy python submission (verdict: Runtime Error):
n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
b1 = round(sum(B) / n)
b2 = ceil(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
C1 = list(map(lambda x: abs(x-b1), B))
C2 = list(map(lambda x: abs(x-b2), B))
print(min(list(map(sum, [C, C1, C2])))

Fixed submission:
import sys
from statistics import median_low
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = median_low(B)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))

Buggy python submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))

Fixed submission:
import sys
from statistics import median_low
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = median_low(B)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))
Buggy python submission (verdict: Runtime Error):
S = input()
ans = 0
for c in S:
  if c == '+':
  	ans += 1
  else c == '-':
    ans -= 1
print(ans)

Fixed submission:
S = input()
ans = 0
for c in S:
  if c == '+':
  	ans += 1
  elif c == '-':
    ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from math import ceil
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

if n == k:
    print(1)
else:
    former = index_min(A)[0]
    latter = n - 1 - former
    ceil(former / (k-1)), ceil(latter / (k-1))
    print(ceil(former / (k-1)) + ceil(latter / (k-1)))

Fixed submission:
import sys
from math import ceil
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

print(ceil((n-k)/(k-1))+1)

Buggy python submission (verdict: Runtime Error):
import sys
from math import ceil
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

if n == k:
    print(1)
else:
    former = index_min(A)[0]
    latter = n - 1 - former
    ceil(former / (k-1)), ceil(latter / (k-1))
    print(ceil(former / (k-1)) + ceil(latter / (k-1)))

Fixed submission:
import sys
from math import ceil
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

print(ceil((n-k)/(k-1))+1)
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
from operator import add, sub

class TwoPointers:
    def __init__(self, cond, init=0, right=add, left=sub):
        self.cond = cond
        self.init = init
        self.next_right = right
        self.next_left = left
    
    def __call__(self, A):
        cond = self.cond
        next_right, next_left = self.next_right, self.next_left
        s = deepcopy(self.init)
        n = len(A)
        X = {}
        r = 0
        for l in range(n):
            while r < n and cond(s, A[r]):
                s = next_right(s, A[r])
                r += 1
                X[l] = r
            if l == r:
                r += 1
            else:
                s = next_left(s, A[l]) if l+1 != r else deepcopy(self.init)
        return list(X.items())

n, *A = map(int, open(0).read().split())
X = TwoPointer(lambda s, n: s + n == s ^ n)(A)
print(sum(r-l for l, r in X))

Fixed submission:
n, *A = map(int, open(0).read().split())

ans = s = r = 0
for l in range(n):
    while r < n:
        if s & A[r] != 0:
            break
        s += A[r]
        r += 1
    s -= A[l]
    ans += r-l
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, *A = map(int, open(0).read().split())

ans = 0
for l in range(n):
    r = l + 1
    s0 = s1 = A[l]
    while r < n and s0 == s1:
        s0 ^= A[r]
        s1 += A[r]
        if s0 != s1:
            break
        r += 1
    ans += r-l
print(ans)

Fixed submission:
n, *A = map(int, open(0).read().split())

ans = s = r = 0
for l in range(n):
    while r < n:
        if s & A[r] != 0:
            break
        s += A[r]
        r += 1
    s -= A[l]
    ans += r-l
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, *A = map(int, open(0).read().split())

f = [1] * n
for l in range(n):
    r = l + 1
    s0 = s1 = A[l]
    while r < n:
        s0 ^= A[r]
        s1 += A[r]
        if s0 != s1:
            break
        r += 1
    f[l] = r-l
print(sum(f))

Fixed submission:
n, *A = map(int, open(0).read().split())

ans = s = r = 0
for l in range(n):
    while r < n:
        if s & A[r] != 0:
            break
        s += A[r]
        r += 1
    s -= A[l]
    ans += r-l
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, *A = map(int, open(0).read().split())

f = [1] * n
for l in range(n):
    r = l + 1
    s0 = s1 = A[l]
    while r < n:
        s0 ^= A[r]
        s1 += A[r]
        if s0 != s1:
            break
        r += 1
    f[l] = r-l
print(sum(f))

Fixed submission:
n, *A = map(int, open(0).read().split())

ans = s = r = 0
for l in range(n):
    while r < n:
        if s & A[r] != 0:
            break
        s += A[r]
        r += 1
    s -= A[l]
    ans += r-l
print(ans)
Buggy python submission (verdict: Runtime Error):
print(*[x for x in sieve(55555) if x % 10 == 7][:int(input())])

Fixed submission:
from math import sqrt
def sieve(n):
    if n <= 4:
        return list(range(2, n))
    def _sieve_of_eratosthenes(n):
        limit = int(sqrt(n))+1
        table = [1] * n
        table[0] = table[1] = 0
        for i in range(2, limit):
            if table[i]:
                for j in range(i**2, n, i):
                    table[j] = 0
        return [i for i in range(2, n) if table[i]]
    return _sieve_of_eratosthenes(n)
print(*[x for x in sieve(55555) if x % 10 == 7][:int(input())])
Buggy python submission (verdict: Runtime Error):
inputs = open(0).readlines()
a, b, c, x, y = map(int, open(0).read().split())

prices = []
prices.append(a*x + b*y)
prices.append(a*abs(x-y) + 2*c*min(x, y))
prices.append(b*abs(x-y) + 2*c*min(x, y))
prices.append(2*c*max(x, y))
print(min(prices))

Fixed submission:
a, b, c, x, y = map(int, open(0).read().split())
a, b, x, y = (b, a, y, x) if x > y else (a, b, x, y)

print(min(a*x + b*y, 2*c*x + b*(y-x), 2*c*y))
Buggy python submission (verdict: Runtime Error):
n, *A = map(int, open(0).input().split())
A = [0] + A + [0]
B = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]
s = sum(B)
for i in range(1, n+1):
    print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])

Fixed submission:
n, *A = map(int, open(0).read().split())
A = [0] + A + [0]
B = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]
s = sum(B)
for i in range(1, n+1):
    print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])
Buggy python submission (verdict: Runtime Error):
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
try:
    path = nx.shortest_path(G, (0, 0), (h-1, w-1))
except NetworkXNoPath:
    print(-1)
else:
    for node in path:
        G.remove_node(node)
    print(len(G.nodes))

Fixed submission:
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
try:
    path = nx.shortest_path(G, (0, 0), (h-1, w-1))
except nx.NetworkXNoPath:
    print(-1)
else:
    for node in path:
        G.remove_node(node)
    print(len(G.nodes))

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

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
path = nx.shortest_path(G, (0, 0), (h-1, w-1))
for node in path:
    G.remove_node(node)
print(len(G.nodes))

Fixed submission:
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
try:
    path = nx.shortest_path(G, (0, 0), (h-1, w-1))
except nx.NetworkXNoPath:
    print(-1)
else:
    for node in path:
        G.remove_node(node)
    print(len(G.nodes))