Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

n, m = map(int, input().split())
s = input()
t = input()
l = lcm(n, m)
ans = [""] * l
for i in range(n):
    ans[i * l // n] = s[i]
for i in range(m):
    if ans[i * l // m] and ans[i * l // m] != t[i]:
        print(-1)
        exit()
print(l)

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

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

n, m = map(int, input().split())
s = input()
t = input()
L = lcm(n, m)
l = lcm(L // n, L // m)
for i in range(0, L, l):
    if s[i // (L // n)] != t[i // (L // m)]:
        print(-1)
        exit()
print(L)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

n, m = map(int, input().split())
s = input()
t = input()
if n == m and s == t:
    print(n)
elif max(n, m) % min(n, m) == 0:
    print(-1)
else:
    LCM = lcm(n, m)
    for i in range(1, m + 1):
        L = LCM * i
        x = ["" for i in range(L)]
        no = 0
        for i in range(n):
            x[i * L // n] = s[i]
        for i in range(m):
            if x[i * L // m] and x[i * L // m] != t[i]:
                no = 1
                break
            else:
                x[i * L // m] = t[i]
        if no:
            continue
        print(L)
        exit()

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

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

n, m = map(int, input().split())
s = input()
t = input()
L = lcm(n, m)
l = lcm(L // n, L // m)
for i in range(0, L, l):
    if s[i // (L // n)] != t[i // (L // m)]:
        print(-1)
        exit()
print(L)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
s = input()
t = input()
if max(n, m) % min(n, m) == 0:
    print(-1)
else:
    for L in range(n, n * m + 1, n):
        if L % m == 0:
            x = ["" for i in range(L)]
            no = 0
            for i in range(n):
                x[i * L // n] = s[i]
            for i in range(m):
                if x[i * L // m] and x[i * L // m] != t[i]:
                    no = 1
                    break
                else:
                    x[i * L // m] = t[i]
            if no:
                continue
            print(L)
            exit()
    print(-1)

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

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

n, m = map(int, input().split())
s = input()
t = input()
L = lcm(n, m)
l = lcm(L // n, L // m)
for i in range(0, L, l):
    if s[i // (L // n)] != t[i // (L // m)]:
        print(-1)
        exit()
print(L)
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n + 1):
            if i == n:
                break
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                break
        if n == 1:
            break
print("{} {} {}".format(cx, cy, H[0]))


Fixed submission:
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for t in range(n):
    if h[t] >= 1:
        break
for cx, cy in itertools.product(range(101), range(101)):
    H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
    if H < 1:
        continue
    for i in range(n + 1):
        if i == n:
            break
        if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
            break
    if i == n:
        break
print("{} {} {}".format(cx, cy, H))
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a).most_common(2)
bc = collections.Counter(b).most_common(2)
if ac[0][0] != bc[0][0]:
    print(n - ac[0][1] - bc[0][1])
else:
    print(n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1]))

Fixed submission:
import collections

n = int(input())
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(ac.items(), key=lambda x: x[1], reverse=True)
bc = sorted(bc.items(), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
    if len(ac) == len(bc) and len(ac) == 1:
        print(ac[0][1])
        exit()
    i = 0
    while ac[i][1] == bc[i][1]:
        i += 1
        if i == len(ac) - 1 or i == len(bc) - 1:
            break
    if ac[i][1] > bc[i][1]:
        ac.remove(ac[i])
        bc.remove(bc[0])
    elif ac[i][1] < bc[i][1]:
        ac.remove(ac[0])
        bc.remove(bc[i])
    else:
        ac.remove(ac[0])
        bc.remove(bc[1])
else:
    ac.remove(ac[0])
    bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
    ans += ac[i][1]
for i in range(len(bc)):
    ans += bc[i][1]
print(ans)

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

n = int(input())
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(ac.items(), key=lambda x: x[1], reverse=True)
bc = sorted(bc.items(), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
    if len(ac) == len(bc) and len(ac) == 1:
        print(ac[0][1])
        exit()
    i = 0
    while ac[i][1] == bc[i][1]:
        i += 1
    if ac[i][1] > bc[i][1]:
        ac.remove(ac[i])
        bc.remove(bc[0])
    elif ac[i][1] < bc[i][1]:
        ac.remove(ac[0])
        bc.remove(bc[i])
else:
    ac.remove(ac[0])
    bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
    ans += ac[i][1]
for i in range(len(bc)):
    ans += bc[i][1]
print(ans)


Fixed submission:
import collections

n = int(input())
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a)
bc = collections.Counter(b)
ac = sorted(ac.items(), key=lambda x: x[1], reverse=True)
bc = sorted(bc.items(), key=lambda x: x[1], reverse=True)
if ac[0][0] == bc[0][0]:
    if len(ac) == len(bc) and len(ac) == 1:
        print(ac[0][1])
        exit()
    i = 0
    while ac[i][1] == bc[i][1]:
        i += 1
        if i == len(ac) - 1 or i == len(bc) - 1:
            break
    if ac[i][1] > bc[i][1]:
        ac.remove(ac[i])
        bc.remove(bc[0])
    elif ac[i][1] < bc[i][1]:
        ac.remove(ac[0])
        bc.remove(bc[i])
    else:
        ac.remove(ac[0])
        bc.remove(bc[1])
else:
    ac.remove(ac[0])
    bc.remove(bc[0])
ans = 0
for i in range(len(ac)):
    ans += ac[i][1]
for i in range(len(bc)):
    ans += bc[i][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from functools import reduce
from operator import mul

def make_divisor_list(n):
    if n < 1:
        return []
    elif n == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, n // 2 + 1):
            if n % i == 0:
                divisor_list.append(i)
        divisor_list.append(n)

        return divisor_list

n, m = map(int, input().split())
d = []
for i in make_divisor_list(m):
    d += [i] * n
count = 0
ans = []
for v in itertools.permutations(d, n):
    if reduce(mul, v) == m:
        if not v in ans:
            ans.append(v)
            count += 1
print(count)

Fixed submission:
mod = 1000000007

# aのp乗を求めるアルゴリズム
# p=62のとき、pの変化は、62->31->30->15->14->7->6->3->2->1->0
# と、半分半分になっていく
# よって、計算量はO(logp)になる
def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        # pが偶数のとき
        halfP = p // 2
        half = modpow(a, halfP)

        # a^(p/2) をhalfとして、half*halfを計算
        return half * half % mod
    else:
        # pが奇数のときは、
        # pを偶数にするために1減らす
        return a * modpow(a, p - 1) % mod


# (10*9*8) / (3*2*1)
# 10*9*8 -> ansMul
# 3*2*1 -> ansDiv
def calcComb(a, b):
    if b > a - b:
        return calcComb(a, a - b)
    ansMul = 1
    ansDiv = 1
    for i in range(b):
        ansMul *= (a - i)
        ansDiv *= (i + 1)
        ansMul %= mod
        ansDiv %= mod
    # ansMul / ansDivをやりたい
    # ansDivの逆元を使って求める
    ans = ansMul * modpow(ansDiv, mod - 2) % mod
    return ans


n, m = map(int, input().split())
MNkori = m
ans = 1
i = 2
while i * i <= MNkori:
    cnt = 0
    while MNkori % i == 0:
        cnt += 1
        MNkori //= i
    # cntが2^Xとか3^XのXの部分
    ans *= calcComb(n + cnt - 1, n - 1) # N-1はcntと同じ
    ans %= mod
    i += 1
if MNkori != 1:
    # 最後に素数が残ってる分を処理する
    ans *= calcComb(n, n - 1)  # N-1はcntと同じ
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
ans = 0
ansl = []
for i in range(h):
    for j in range(w - 1):
        if a[i][j] % 2 == 1 and a[i][j] >= 1:
            a[i][j + 1] += 1
            a[i][j] -= 1
            ans += 1
            ansl.append([i + 1, j + 1, i + 1, j + 2])
for k in range(h):
    if a[k][-1] % 2 == 1:
        a[i + 1][j] += 1
        a[i][j] -= 1
        ans += 1
        ansl.append([i + 1, j + 1, i + 2, j + 1])
print(ans)
for i in ansl:
    i = list(map(str, i))
    print(" ".join(i))

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
ans = 0
ansl = []
for i in range(h):
    for j in range(w):
        if a[i][j] % 2 == 1 and a[i][j] >= 1:
            if j + 1 < w:
                a[i][j + 1] += 1
                a[i][j] -= 1
                ans += 1
                ansl.append([i + 1, j + 1, i + 1, j + 2])
for k in range(h):
    if a[k][-1] % 2 == 1:
        if k + 1 < h:
            a[k + 1][-1] += 1
            a[k][-1] -= 1
            ans += 1
            ansl.append([k + 1, w, k + 2, w])
print(ans)
for i in ansl:
    i = list(map(str, i))
    print(" ".join(i))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

s = []
for a in range(1, n + 1):
    if (2 * a) % k == 0:
        s.append(a)

count = 0
for a in s:
    for b in s:
        for c in s:
            if (a + b) % k == 0 and (b + c) % k == 0 and (c + a) % k == 0:
                count += 1

print(count)

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

s = []
for a in range(1, n + 1):
    if (2 * a) % k == 0:
        s.append(a)

t = []
for a in range(1, n + 1):
    if a % k == 0:
        t.append(a)

print((len(s) - len(t)) ** 3 + len(t) ** 3)
Buggy python submission (verdict: Runtime Error):
import bisect
n, k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x, 0)
a = sorted(map(abs, x[:z]))
b = x[z:]
ans = float("inf")
if a and b:
    for i in range(min([k, len(a), len(b)])):
        ans = min(ans, min(a[i], b[k - i - 2]) * 2 + max(a[i], b[k - i - 2]))
    print(ans)
elif a:
    print(a[k - 1])
else:
    print(b[k - 1])

Fixed submission:
import bisect
n, k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x, 0)
a = sorted(map(abs, x[:z]))
b = x[z:]
ans = float("inf")
if a and b:
    for i in range(min(k, len(a))):
        if k - i - 2 >= len(b):
            continue
        ans = min(ans, min(a[i], b[k - i - 2]) * 2 + max(a[i], b[k - i - 2]))
    print(ans)
elif a:
    print(a[k - 1])
else:
    print(b[k - 1])
Buggy python submission (verdict: Runtime Error):
s = list(map(int, list(str(input()))))
k = int(input())
i = 0
while s[i] == 1:
  i += 1
if k <= i:
  print(1)
else:
  print(s[i])

Fixed submission:
s = list(map(int, list(str(input()))))
k = int(input())
i = 0
if s.count(1) == len(s):
  print(1)
else:
  while s[i] == 1:
    i += 1
  if k <= i:
    print(1)
  else:
    print(s[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
ans = 0
for i in range(n):
    ans += sum(list(map(lambda x: not (x - a_t[i]) % m, a_t[i + 1:])))
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
dict = {}
for i in range(n + 1):
    b = a_t[i] % m
    if b in dict:
        dict[b] += 1
    else:
        dict[b] = 1
ans = 0
for i in dict.values():
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
ans = 0
for i in range(n + 1):
    for j in range(i + 1, n + 1):
        b = a_t[j] - a_t[i]
        if not b % m:
            ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
dict = {}
for i in range(n + 1):
    b = a_t[i] % m
    if b in dict:
        dict[b] += 1
    else:
        dict[b] = 1
ans = 0
for i in dict.values():
    ans += i * (i - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for l in range(n):
  for r in range(l, n):
    if sum(a[l:r+1]) % m == 0:
      ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
dict = {}
for i in range(n + 1):
    b = a_t[i] % m
    if b in dict:
        dict[b] += 1
    else:
        dict[b] = 1
ans = 0
for i in dict.values():
    ans += i * (i - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import reduce

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

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

def lcm(n):
  return reduce(lcm_base, n)

f = 0
for i in a:
  f += (lcm(a) - 1) % i

print(int(f))


Fixed submission:
n = int(input())
print(sum(list(map(int, input().split()))) - n)

Buggy python submission (verdict: Runtime Error):
from functools import reduce

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

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

def lcm(n):
  return reduce(lcm_base, n)

f = 0
for i in a:
  f += lcm(a) - 1 % i

print(int(f))


Fixed submission:
n = int(input())
print(sum(list(map(int, input().split()))) - n)

Buggy python submission (verdict: Runtime Error):
from functools import reduce

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

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

def lcm(n):
  return reduce(lcm_base, n)

f = 0
m = lcm(a) - 1
for i in a:
  f += m % i

print(int(f))

Fixed submission:
n = int(input())
print(sum(list(map(int, input().split()))) - n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = []
for b in range(-(n // 2), n // 2):
  total = 0
  for i in range(n):
    total += abs(a[i] - (b + i + 1))
  ans.append(total)
print(min(ans))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
B = []
ans = 0
for i in range(n):
  B.append(a[i] - i - 1)
b = sorted(B)[len(B) // 2]
for i in range(n):
  ans += abs(B[i] - b)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
if s % sum(map(int, list(s))):
  print("No")
else:
  print("Yes")

Fixed submission:
s = input()
if int(s) % sum(map(int, list(s))):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = float("inf")
for i in range(n):
    move = 0
    move += s[:i].count("W")
    move += s[i + 1:].count("E")
    ans = min(ans, move)
print(ans)

Fixed submission:
n = int(input())
s = list(input())
for i in range(n):
    if i:
        s[i] = s[i - 1] + int(s[i] == "E")
    else:
        s[i] = int(s[i] == "E")
s.append(s[n - 1])
ans = float("inf")
for i in range(n):
    rightE = s[n] - s[i]
    if i == 0:
        ans = min(ans, rightE)
    else:
        leftW = i - s[i - 1]
        ans = min(ans, leftW + rightE)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = float("inf")
for i in range(n):
    move = 0
    for j in range(n):
        if j < i and s[j] == "W":
            move += 1
        elif j > i and s[j] == "E":
            move += 1
    ans = min(ans, move)
print(ans)

Fixed submission:
n = int(input())
s = list(input())
for i in range(n):
    if i:
        s[i] = s[i - 1] + int(s[i] == "E")
    else:
        s[i] = int(s[i] == "E")
s.append(s[n - 1])
ans = float("inf")
for i in range(n):
    rightE = s[n] - s[i]
    if i == 0:
        ans = min(ans, rightE)
    else:
        leftW = i - s[i - 1]
        ans = min(ans, leftW + rightE)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        sub.append(s[i:j])
print(sorted(list(set(sub)))[k])

Fixed submission:
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.append(s[i:j])
print(sorted(set(sub))[k])

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
k = int(input())
a = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    a.add("".join(s[i:j + 1]))
a = sorted(a)
print(a[k - 1])

Fixed submission:
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.append(s[i:j])
print(sorted(set(sub))[k])

Buggy python submission (verdict: Runtime Error):
s = list(input())
k = int(input())
a = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    a.add(s[i:j + 1])
a = sorted(a)
print(a[k - 1])

Fixed submission:
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.append(s[i:j])
print(sorted(set(sub))[k])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
sub = set()
flag = False
for i in range(len(s)):
    for j in range(len(s) - i):
        sub.add(s[j:j + i + 1])
print(sorted(list(sub))[k - 1])

Fixed submission:
s = input()
k = int(input())
sub = set()
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.add(s[i:j])
print(sorted(list(sub))[k])
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
k = int(input())
for i in range(k):
  if a >= b and a >= c:
    a *= 2
  elif b >= a and b >= c:
    b *= 2
  else:
    c *= 2
print(sum(a, b, c))

Fixed submission:
a, b, c = map(int, input().split())
k = int(input())
for i in range(k):
  if a >= b and a >= c:
    a *= 2
  elif b >= a and b >= c:
    b *= 2
  else:
    c *= 2
print(sum([a, b, c]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i, n + 1):
        if sum(a[i:j]) == 0 and len(a[i:j]) > 0:
            ans += 1
print(ans)

Fixed submission:
import collections

n = int(input())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = collections.Counter(sorted(a_t))
ans = 0
for i in a_t.values():
    ans += i * (i - 1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)
a = xs[n // 2 - 1]
b = xs[n // 2]
for i in range(n):
    if xs.index(x[i]) < n // 2:
        print(b)
    else:
        print(a)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)
a = xs[n // 2 - 1]
b = xs[n // 2]
for i in x:
    if i <= a:
        print(b)
    else:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)
for i in range(n):
    xa = xs[::]
    xa.remove(x[i])
    print(xa[n // 2 - 1])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)
a = xs[n // 2 - 1]
b = xs[n // 2]
for i in x:
    if i <= a:
        print(b)
    else:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
for i in range(n):
    print(sorted(x[:i] + x[i + 1:])[n // 2 - 1])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)
a = xs[n // 2 - 1]
b = xs[n // 2]
for i in x:
    if i <= a:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
n = list(range(a, b + 1))
s = set()
for i in n[:k]:
  s.add(i)
for j in n[-k:]:
  s.add(j)
for k in sorted(list(s)):
  print(k)

Fixed submission:
a, b, k = map(int, input().split())
if (b - a + 1) > 2 * k:
  for i in range(a, a + k):
    print(i)
  for j in range(b - k + 1, b + 1):
    print(j)
else:
  for n in range(a, b + 1):
    print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
cost = []
for i in range(n + 1):
    cost.append(abs(a[i + 1] - a[i]))
for i in range(n):
    ans = abs(a[i + 2] - a[i])
    ans += sum(cost[:i]) + sum(cost[i + 2:])
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
cost = []
for i in range(n + 1):
    cost.append(abs(a[i + 1] - a[i]))
cost_t = [0]
for i in range(n + 1):
    cost_t.append(cost[i] + cost_t[i])
for i in range(n):
    ans = abs(a[i + 2] - a[i])
    ans += cost_t[i] + cost_t[-1] - cost_t[i + 2]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
if x == y:
  print(-1)
else:
  i = 1
  n = x
  while n % y == 0:
    n = i * x
    i += 1
  print(n)

Fixed submission:
x, y = map(int, input().split())
if x % y == 0:
  print(-1)
else:
  i = 1
  n = x
  while n % y == 0:
    n = i * x
    i += 1
  print(n)

Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
if x == y:
  print(-1)
else:
  n = 0
  while n % x != 0 or n % y == 0:
    n += 1
  print(n)

Fixed submission:
x, y = map(int, input().split())
if x % y == 0:
  print(-1)
else:
  i = 1
  n = x
  while n % y == 0:
    n = i * x
    i += 1
  print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    C, S, F = map(int, input().split())
    c.append(C)
    s.append(S)
    f.append(F)
for i in range(n - 1):
    ans = s[i] + c[i]
    for j in range(i + 1, n - 1):
        noru = s[j]
        while noru < ans:
            noru += f[j]
        ans += noru - ans + c[j]
    print(ans)
print(0)

Fixed submission:
n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    C, S, F = map(int, input().split())
    c.append(C)
    s.append(S)
    f.append(F)
for i in range(n - 1):
    ans = 0
    for j in range(i, n - 1):
        if ans < s[j]:
            ans = s[j]
        elif ans % f[j] == 0:
            pass
        else:
            ans += f[j] - ans % f[j]
        ans += c[j]
    print(ans)
print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1, n):
    if n < i ** 2:
        break
print((i - 1) ** 2)

Fixed submission:
n = int(input())
i = 1
while n >= i * i:
    i += 1
print((i - 1) * (i - 1))