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

Fixed submission:
N, K = map(int, input().split())
n = sum([1 for x in range(K, N + 1, K)])
if K % 2 == 1:
    print(n ** 3)
else:
    m = sum([1 for x in range(K // 2, N + 1, K)])
    print(n ** 3 + m ** 3)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
ret = 0
for x in range(1, N + 1):
    for y in [y for y in range(K - x, N + 1, K) if y > 0]:
        for z in [z for z in range(K - y, N + 1, K) if z > 0]:
            cnt += 1     
            if  (z + x) % K == 0:
                ret += 1
print(ret)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
ret = 0
for x in range(1, N + 1):
    for y in [y for y in range(K - x, N + 1, K) if y > 0]:
        for z in [z for z in range(K - y, N + 1, K) if z > 0]:
            cnt += 1     
            if  (z + x) % K == 0:
                ret += 1
print(ret)
Problem p03387 (python)

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

ret = 0
while True:
    if A == B and B == C:
        print(ret)
        exit()

    ret += 1
    A, B, C = sorted([A, B, C])
    if B < C:
        A += 1
        B += 1
    elif B == C:
        A += 2

Buggy submission (verdict: Runtime Error):
A, B, C = sorted([int(x) for x in input().split()])
if A == B and B == C:
    print(0)
    exit()

ret = 0
while True:
    if A < B and B < C:
        A += 1
        B += 1
    elif A < B and B == C:
        A += 2
    elif A > B and B == C:
        B += 1
        C += 1
    else:
        # 想定外
        exit(1)

    ret += 1
    if A == B and B == C:
        print(ret)
        exit()

Buggy submission (verdict: Runtime Error):
A, B, C = sorted([int(x) for x in input().split()])
ret = 0
while True:
    if A < B and B < C:
        A += 1
        B += 1
    elif A < B and B == C:
        A += 2
    elif A > B and B == C:
        B += 1
        C += 1
    else:
        # 想定外
        exit(1)

    ret += 1
    if A == B and B == C:
        print(ret)
        exit()
Problem p03573 (python)

Fixed submission:
A, B, C = input().split()
if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)

Buggy submission (verdict: Runtime Error):

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def aaa(i, j):
    cnt = 0
    for x in [-1, 0, 1]:
        for y in [-1, 0, 1]:
            if (not 0 <= i + y < H) or (not 0 <= j + x < W):
                continue
            if S[i + y][j + x] == '#':
                cnt += 1    
    return str(cnt)

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        S[i][j] = aaa(i, j)
for s in S:
    print("".join(s))
Problem p03633 (python)

Fixed submission:
N = int(input())
lst = [1] + [int(input()) for _ in range(N)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))


ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = [int(input()) for _ in range(N)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))


ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)
Problem p03643 (python)

Fixed submission:
print('ABC' + input())

Buggy submission (verdict: Runtime Error):
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    println!("ABC{}", s.trim())
}
Problem p03645 (python)

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

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s1.add(b)
    if b == N:
        s2.add(a)

if len(s1.intersection(s2)) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
s1 = set()
s2 = set()

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s1.add(b)
    if b == N:
        s2.add(a)

for x in s1:
    if s2.count(x) >= 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
s1 = set()
s2 = set()

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        s1.append(b)
    if b == N:
        s2.append(a)

for x in s1:
    if s2.count(x) >= 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
Problem p03693 (python)

Fixed submission:
n = int(input().replace(' ', ''))
if n % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = [0] * 9

for x in [int(x) for x in input().split()]:
    if x <= 399:
        lst[0] = 1
    elif x <= 799:
        lst[1] = 1
    elif x <= 1199:
        lst[2] = 1
    elif x <= 1599:
        lst[3] = 1
    elif x <= 1999:
        lst[4] = 1
    elif x <= 2399:
        lst[5] = 1
    elif x <= 2799:
        lst[6] = 1
    elif x <= 3199:
        lst[7] = 1
    else:
        lst[8] += 1

a = sum(lst[:-1])
b = lst[8]
if a == 0 and b > 0:
    print("1 {0}".format(b))
else:
    print("{0} {1}".format(a, a + b))
Problem p03697 (python)

Fixed submission:
n = sum(map(int, input().split()))
if n < 10:
    print(n)
else:
    print('error')

Buggy submission (verdict: Runtime Error):
fn read() -> (i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = read();
    if a + b < 10 {
        println!("{}", a + b);
    } else {
        println!("error");
    }
}
Problem p03795 (python)

Fixed submission:
N = int(input())
print(N * 800 - N // 15 * 200)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if N == 0:
    print(0)
elif N >= M:
    print(M // 2)
else:
    ret = N
    M -= N * 2
    ret += M // 4
    print(ret)
Problem p03943 (python)

Fixed submission:
lst = sorted([int(x) for x in input().split()])
if lst[0] + lst[1] == lst[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
x1 = y1 = 0
x2 = W
y2 = H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    else:
        y2 = min(y2, y)

print(max(0, (x2 - x1)) * max(0, (y2 - y1)))
Problem p03962 (python)

Fixed submission:
s = set([x for x in input().split()])
print(len(s))

Buggy submission (verdict: Runtime Error):
import math
from fractions import Fraction

N = int(input())
a, b = map(int, input().split())
ret_a = a
ret_b = b
for _ in range(1, N):
    a, b = map(int, input().split())
    x = math.ceil(max(Fraction(ret_a, a), Fraction(ret_b, b)))
    ret_a = a * x
    ret_b = b * x
print(ret_a + ret_b)
Problem p04013 (python)

Fixed submission:
N, A = map(int, input().split())
lst = [int(x) - A for x in input().split()]
dp = [[0] * (100 * N + 1) for _ in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
    for j in range(50, 100 * N + 1 - 50):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][50 * N] - 1)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
lst = [int(x) - A for x in input().split()]
dp = [[0] * (2 * N + 1) for _ in range(N + 1)]
dp[0][1 * N] = 1
for i in range(N):
    for j in range(1, 2 * N + 1 - 1):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][1 * N] - 1)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
lst = [int(x) - A for x in input().split()]
dp = [[0] * (2 * N + 1) for _ in range(N + 1)]
dp[0][1 * N] = 1
for i in range(N):
    for j in range(1, 2 * N + 1 - 1):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][1 * N] - 1)

print(dp)
Problem p03474 (python)

Fixed submission:
if __name__ == '__main__':
    
    A, B = [int(x) for x in input().split(' ')]
    S = input()

    S = S.split('-')
    if len(S) != 2:
        print('No')
        exit()

    a = S[0]
    b = S[1]

    if len(a) == A:
        if len(b) == B:
            print('Yes')
            exit()

    print('No')

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    
    A, B = [int(x) for x in input().split(' ')]
    S = input()

    S = S.split('-')
    if S.length < 2:
        print('No')

    a = S[0]
    b = S[1]

    if a.length == A:
        if b.length == B:
            print('YES')
            exit()

    print('No')
Problem p02756 (python)

Fixed submission:
from collections import deque
S = deque(list(input().strip()))
Q = int(input().strip())
flag = 1
for i in range(Q):
  line = input().strip()
  if len(line) == 1:
    flag = 1 - flag
  else:
    _, F, C = line.strip().split()
    if flag:
      if int(F) == 1:
        S.appendleft(C)
      else:
        S.append(C)
    else:
      if int(F) == 1:
        S.append(C)
      else:
        S.appendleft(C)

if flag:
  print(''.join(S))
else:
  print(''.join(list(reversed(S))))

Buggy submission (verdict: Runtime Error):
from collections import deque
S = deque(list(input().strip()))
Q = int(input().strip())
flag = 1
for i in range(Q):
  line = input().strip()
  if len(line) == 1:
    flag = 1 - flag
  else:
    _, F, C = line.strip().split()
    if flag:
      if int(F) == 1:
        S.appendleft(C)
      else:
        S.append(C)
    else:
      if int(F) == 1:
        S.append(C)
      else:
        S.appendleft(C)

if flag:
  print(''.join(S))
else:
  print(''.join(S[::-1]))
Problem p03353 (python)

Fixed submission:
S = input()
K = int(input())
l = len(S)
topk = []
a = []

for i in range(l):
    for j in range(i + 1, i + K + 1):
        if j > l:
            break
        ss = S[i: j]
        a.append(ss)

print(sorted(list(set(a)))[K-1])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
l = len(S)
topk = []
vocab = set()

for i in range(l):
    for j in range(i + 1, i + K + 1):
        if j > l - 1:
            break
        ss = S[i: j]
        vocab.add(ss)

print(sorted(list(vocab))[K-1])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
l = len(S)
topk = []
vocab = set()

for idx in range(K):
    ss = S[0:idx + 1]
    if ss in vocab:
        continue
    topk.append(ss)
    vocab.add(ss)
for idx in range(1, l):
    sblen = 0
    for sblen in range(1, l - idx):
        ss = S[idx: idx + sblen]
        if ss in vocab:
            continue
        vocab.add(ss)
        if len(topk) < K:
            topk.append(ss)
            continue

        if ss > topk[-1]:
            break
        else:
            topk[-1] = ss
            topk.sort()

print(topk[K-1])
Problem p03360 (python)

Fixed submission:
a = sorted(list(map(int, input().split())), reverse=True)
N = int(input())
print((2 ** N) * a[0] + a[1] + a[2])

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split())).sorted(reversed=True)
N = int(input())
print((2 ^ N) * a[0] + a[1] + a[2])
Problem p03434 (python)

Fixed submission:
N = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)
A, B = 0, 0
for idx in range(N):
  if idx % 2 == 0:
    A += cards[idx]
  else:
    B += cards[idx]
print(A - B)

Buggy submission (verdict: Runtime Error):
N = int(input())
cards = map(int, input().split())
A, B = 0, 0
for idx in range(N):
  if idx % 2 == 0:
    A += cards[idx]
  else:
    B += cards[idx]
print(A - B)
Problem p03477 (python)

Fixed submission:
a = list(map(int, input().split()))
l, r = a[0] + a[1], a[2] + a[3]
if l > r:
  print('Left')
elif l < r:
  print('Right')
else:
  print('Balanced')

Buggy submission (verdict: Runtime Error):
l, r = int(input()) + int(input()), int(input()) + int(input())
if l > r:
  print('Left')
elif r < l:
  print('Right')
else:
  print('Balanced')
Problem p03555 (python)

Fixed submission:
print('YES' if input() == ''.join([e for e in reversed(list(input()))]) else 'NO')

Buggy submission (verdict: Runtime Error):
print('YES' if input() == ''.join([e for e in reversed(list(input()))] else 'NO')
Problem p03609 (python)

Fixed submission:
X, t = map(int, input().split())
print(max(0, X-t))

Buggy submission (verdict: Runtime Error):
print(min(int(input())-int(input()), 0))
Problem p03611 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MAX_N = int(1e5) + 1
cnts = [0 for i in range(MAX_N)]
for a in A:
  cnts[a] += 1
res = 0
for idx in range(1, len(cnts) + 1):
  tmp = sum(cnts[idx-1:idx+2])
  if tmp > res:
    res = tmp
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnts = [0 for i in range(N + 1)]
for a in A:
  cnts[a] += 1
res = 0
for idx in range(1, A - 1):
  tmp = sum(A[idx-1:idx+1])
  if tmp > res:
    res = tmp
print(res)
Problem p03612 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
res = 0
for idx in range(len(P) - 1):
    if P[idx] == idx + 1:
        P[idx], P[idx+1] = P[idx+1], P[idx]
        res += 1

if P[-1] == N:
    res += 1

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
res = 0
for idx in range(len(P)):
    if P[idx] == idx + 1:
        if idx < N:
            P[idx], P[idx+1] = P[idx+1], P[idx]
        res += 1

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
res = 0
for idx in range(len(P)):
    if P[idx] == idx + 1:
        P[idx], P[idx+1] = P[idx+1], P[idx]
        res += 1

print(res)
Problem p03633 (python)

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(A, B):
    A, B = sorted([A, B], reverse=True)
    prev_r = B
    r = A % B
    while r > 0:
        prev_r = B
        r = A % B
        A, B = B, r
    return prev_r

if N > 1:
    tmp = (T[0] * T[1]) // gcd(T[0], T[1])
    for t in T[2:]:
        tmp = (tmp * t) // gcd(tmp, t)
else:
    tmp = T[0]

print(tmp)

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

def gcd(A, B):
    A, B = sorted([A, B], reverse=True)
    prev_r = B
    r = A % B
    while r > 0:
        prev_r = B
        r = A % B
        A, B = B, r
    return prev_r

tmp = (T[0] * T[1]) // gcd(T[0], T[1])
for t in T[2:]:
    tmp = (tmp * t) // gcd(tmp, t)

print(tmp)

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

def gcd(A, B):
    A, B = sorted([A, B], reverse=True)
    r = A % B
    while r > 0:
        r = A % B
        A, B = B, r
    return max(B, 1)

tmp = (T[0] * T[1]) // gcd(T[0], T[1])
for t in T[2:]:
    tmp = (tmp * t) // gcd(tmp, t)

print(tmp)
Problem p03657 (python)

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

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
print('Possible' if (sum(list(map(int, input().split()))) % 3 == 0 else 'Impossible')
Problem p02657 (python)

Fixed submission:
t_nums= list(map(int,input().split()))
print(t_nums[0]*t_nums[1])

Buggy submission (verdict: Runtime Error):

t_nums= list(map(int(),input().split()))
print(t_nums[0]*t_nums[1])
Problem p03067 (python)

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

if ((N[0] > N[2]) and (N[1] < N[2])) or ((N[0] < N[2]) and (N[1] > N[2])):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
stones = input().rstrip()
pre_word = stones[0]
stones_list =[]
counter = 0

for i in range(N):
    stones_list.append(stones[i])

for i in range(N):
    present_word = stones_list[i]
    if pre_word == '#' and present_word =='.':
        counter += 1
    pre_word = stones_list[i]

print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
word = input()
word_list=[]
word_num = int(input())

for i in range(len(word)):
    word_list.append(word[i])
    if str(word[i]) != str(word[word_num -1]):
         word_list[i] = '*'

print(" ".join(list(map(str,word_list))))
Problem p02817 (python)

Fixed submission:
s, t = map(str, input().split(" "))
print(t+s)

Buggy submission (verdict: Runtime Error):
s, t = map(int, input().split(" "))
print(s+t)
Problem p02818 (python)

Fixed submission:
a, b, k= map(int, input().split(" "))
if a > k:
    a -= k
else:
    k-=a
    a = 0
    if b > k:
        b-=k
    else:
        b = 0

print(a, b)

Buggy submission (verdict: Runtime Error):
a, b, k= map(str, input().split(" "))
for i in range(k):
    if a > 0:
        a-=1
    elif b > 0:
        b-=1
print(a, b)
Problem p02993 (python)

Fixed submission:
s = input()
checker = True
for i in range(3):
    a , b = int(s[i]), int(s[i+1])
    if a == b:
        checker=False

if checker:
    print("Good")
else:
    print("Bad")

Buggy submission (verdict: Runtime Error):
s = int(input())
checker = True
for i in range(3):
    if s[i] == s[i+1]:
        checker=False

if checker:
    print("Good")
else:
    print("bad")
Problem p02995 (python)

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

ans = b - (b // c + b//d - b//(c*d // fractions.gcd(c, d))) - ( a - 1  - ((a-1) // c + (a-1)//d - (a-1)//(c * d //fractions.gcd(c, d))))  

print(ans)

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

ans = b - (b // c + b//d - b//(c*d // math.gcd(c, d))) - ( a - 1  - ((a-1) // c + (a-1)//d - (a-1)//(c * d //math.gcd(c, d))))  

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
now_time = 0
global tf
tf = False

def finish_work(now_time, works):
    global tf
    if len(works) == 0 or tf == True:
        tf = True
        return True
    sums = sum([i[0] for i in works]) 
    maxs = max ([i[1] for i in works])
    if maxs < sums:
        return 0
    for index, i in enumerate(works):
        if now_time + i[0] <= i[1]:
            work_list = works.copy()
            work_list.pop(index)
            finish_work(now_time + i[0], work_list)

works = []

for i in range(n):
    a = list(map(int, input().split()))
    works.append(a)

for index, i in enumerate(works):
    
    if now_time + i[0] <= i[1]:
        work_list = works.copy()
        work_list.pop(index)
        finish_work(now_time + i[0], work_list)

if tf:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
kobaisu =int( (C * D )/ math.gcd(C, D))

bk =  B - B//C - B//D + B//kobaisu

ak = (A-1) - (A-1)//C - (A-1)//D + (A-1)//kobaisu

print(bk-ak)
Problem p03030 (python)

Fixed submission:
n = int(input())

li = []
for i in range(n):
    li.append(list(map(str, input().split())))
    li[i].append(i+1)

li.sort( key = lambda li : (li[0], -int(li[1])))
for i in li:
    print(i[2])

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

li = []
for i in range(n):
    li.append(list(map(str, input().split())))
    li[i].append(i+1)

li.sort( key = lambda li : (li[0], -int(li[1])))
for i in li:
    print(li[2])
Problem p03062 (python)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
mainus_li = [i for i in li if i<0]
li = [abs(i) for i in li]
ans = sum(li)
if len(mainus_li) %2 == 1:
    ans -= 2*min(li)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
temp = li.copy()
for i in range(n-1):
    if li[i] < 0:
        li[i] *= -1
        li[i+1] *= -1
ans = sum(li)
li = temp
for i in reversed(range(1,n)):
    if li[i] < 0:
        li[i] *= -1
        li[i+1] *= -1
ans = max(ans, sum(li))
Problem p03086 (python)

Fixed submission:
s = input()
ans = 0
li = ["A", "C", "G", "T"]
count = 0
for i in s:
    if i in li:
        count += 1
    else:
        if count > ans:
            ans = count
        count = 0

if count > ans:
    ans = count
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
li = ["A", "C", "G", "T"]
count = 0
for i in s:
    if i in li:
        count += 1
    else:
        if count > ans:
            ans = count
        count = 0
if count == len(ans):
    print(count)
else:
    print(ans)
Problem p03240 (python)

Fixed submission:

n = int(input())
li = [list(map(int, input().split())) for _ in range(n)]
ans = []

for cx in range(101):
    for cy in range(101):
        for i in li:
            if i[2] != 0:
                ans.append([cx, cy, i[2] + abs(i[0]-cx) + abs(i[1] -cy)])
                break

for i in li:
    if len(ans) ==1:
        break
    if i[2] != 0:
        for j in reversed (range(len(ans[:]))):
            if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) != i[2]:
                ans.pop(j)
    if i[2] == 0:
        for j in reversed (range(len(ans[:]))):
            if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) > i[2]:
                ans.pop(j)

print(" ".join(map(str, ans[0])))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = [list(map(int, input().split())) for _ in range(n)]
ans = []

for cx in range(101):
    for cy in range(101):
        for i in li:
            if i[2] != 0:
                ans.append([cx, cy, i[2] + abs(i[0]-cx) + abs(i[1] -cy)])
                break

for i in li:
    if len(ans) ==1:
        break
    for j in reversed (range(len(ans[:]))):
        if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) != i[2]:
            ans.pop(j)


print(" ".join(map(str, ans[0])))
Problem p03262 (python)

Fixed submission:
import numpy as np
n, x = map(int, input().split())
ans = 1
def make_divisors(n):
    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)
    divisors.sort()
    return divisors
def check(n, li):
    for i in li:
        if i != 0:
            if abs(i) % n != 0:
                return False
    return True
li = list(map(int, input().split()))
li.append(x)
li = list(set(li))
li.sort()
start_index = li.index(x)
li = np.array(li)
if start_index == len(li)-1:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
        
elif start_index == 0:
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
else:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
        if ans > i:
            break

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n, x = map(int, input().split())
ans = 1
def make_divisors(n):
    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)
    divisors.sort()
    return divisors
def check(n, li):
    for i in li:
        if i != 0:
            if abs(i) % n != 0:
                return False
    return True
li = list(map(int, input().split()))
li.append(x)
li = list(set(li))
li.sort()
start_index = li.index(x)
li = np.array(li)
if start_index == len(li)-1:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[[-1]]:
        if check(i, li-x) and i > ans:
            ans = i
            break
        
elif start_index == 0:
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
else:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
        if ans > i:
            break

print(ans)