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

Fixed submission:
from bisect import bisect_right
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

rate = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]

idx = []

for a in A:
    idx.append(bisect_right(rate, a))

# print(idx)

c = Counter(idx)



min_c = len(c.keys())
if (7 in c.keys()) and (8 in c.keys()):
    min_c -= 1
max_c = 0
for i in range(8):
    if i in c.keys():
        max_c += 1
if 8 in c.keys():
    # min_c -= 1
    # max_c += min(8, c[8])
    max_c += c[8]
    # if max_c > 8:
    #     max_c = 8

print(min_c, max_c)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

rate = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]

idx = []

for a in A:
    idx.append(bisect_right(rate, a))

# print(idx)

c = Counter(idx)

print(c)/

min_c = len(c.keys())
if (7 in c.keys()) and (8 in c.keys()):
    min_c -= 1
max_c = 0
for i in range(8):
    if i in c.keys():
        max_c += 1
if 8 in c.keys():
    # min_c -= 1
    # max_c += min(8, c[8])
    max_c += c[8]
    # if max_c > 8:
    #     max_c = 8

print(min_c, max_c)
Problem p03760 (python)

Fixed submission:
o = list(input())
e = list(input())+['']

for i in range( len(o) ) :
  print(o[i]+e[i],end="")

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())=['']

for i in range( len(o) ) :
  print(o[i]+e[i],end="")

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())

for i in range( len(o) ) :
  print(o[i]+e[i],end="")
Problem p03796 (python)

Fixed submission:
from math import factorial

n = int(input())
ans = factorial(n) % (10 ** 9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = factorial(n) % (10 ** 9 + 7)
print(ans)
Problem p02555 (python)

Fixed submission:
N = int(input())
M = 10**9 + 7

if N < 3:
    print(0)
elif N < 6:
    print(1)
else:
    dp = [0] * (N + 1)

    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    for i in range(6, N + 1):
        dp[i] = sum(dp[3:i - 3 + 1]) + 1
        dp[i] %= M

    print(dp[-1] % M)

Buggy submission (verdict: Runtime Error):
N = int(input())
M = 10**9 + 7

dp = [0] * (N + 1)

dp[3] = 1
dp[4] = 1
dp[5] = 1
for i in range(6, N + 1):
    dp[i] = sum(dp[3:i - 3 + 1]) + 1
    dp[i] %= M

print(dp[-1] % M)
Problem p02556 (python)

Fixed submission:
N = int(input())
xs, ys = [], []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
A = [x + y for x, y in zip(xs, ys)]
B = [x - y for x, y in zip(xs, ys)]
ans = max([max(A) - min(A), max(B) - min(B)])
print(ans)

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

    xs, ys = [], []
    for _ in range(N):
        x, y = map(int, input().split())
        xs.append(x)
        ys.append(y)
    
    T, B = max(ys), min(ys)
    L, R = min(xs), max(xs)

    # print(T, B, L, R)

    if T == B:
        return abs(R - L)

    if L == R:
        return abs(T - B)

    # T, B
    top_l, top_r = 10**10, -1
    bot_l, bot_r = 10**10, -1
    for i in range(N):
        if ys[i] == T:
            top_l = min(top_l, xs[i])
            top_r = max(top_r, xs[i])
        if ys[i] == B:
            bot_l = min(bot_l, xs[i])
            bot_r = max(bot_r, xs[i])

    # print(top_l, top_r)
    # print(bot_l, bot_r)

    # L, R
    left_t, left_b = -1, 10**10
    right_t, right_b = -1, 10**10
    for i in range(N):
        if xs[i] == L:
            left_t = max(left_t, ys[i])
            left_b = min(left_b, ys[i])
        if xs[i] == R:
            right_t = max(right_t, ys[i])
            right_b = min(right_b, ys[i])

    # print(left_t, left_b)
    # print(right_t, right_b)

    ans = -1
    for i in range(N):
        if ys[i] == T:
            d1 = abs(T - B) + abs(xs[i] - bot_l)
            d2 = abs(T - B) + abs(xs[i] - bot_r)
            ans = max(ans, max(d1, d2))
        if ys[i] == B:
            d1 = abs(T - B) + abs(xs[i] - top_l)
            d2 = abs(T - B) + abs(xs[i] - top_r)
            ans = max(ans, max(d1, d2))
        if xs[i] == L:
            d1 = abs(R - L) + abs(ys[i] - right_t)
            d1 = abs(R - L) + abs(ys[i] - right_b)
            ans = max(ans, max(d1, d2))
        if xs[i] == R:
            d1 = abs(R - L) + abs(ys[i] - left_t)
            d1 = abs(R - L) + abs(ys[i] - left_b)
            ans = max(ans, max(d1, d2))
    return ans


print(solve())
Problem p02734 (python)

Fixed submission:
from sys import stdin

N, S = map(int, stdin.readline().split())
A = list(map(int,stdin.readline().split()))
M = 998244353
V = max(max(A), S)

ans = 0
cs = [0 for _ in range(V + 1)]
for i, a in enumerate(A):
    dp = [0 for _ in range(V + 1)]
    dp[a] = i + 1
    for s in range(a + 1, S + 1):
        dp[s] = cs[s - a]
    cs = [(a + b) % M for a, b in zip(cs, dp)]
    ans = (ans + (N - i) * dp[S]) % M
print(ans)

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

N, S = map(int, input().split())
A = list(map(int, input().split()))
M = 998244353

dp = np.zeros((N, S + 1), dtype=np.int64)
for i, a in enumerate(A):
    dp[i, a] = i + 1
    for s in range(a + 1, S + 1):
        dp[i, s] = dp[:i, s - a].sum() % M

ans = 0
for i in range(N):
    ans += (N - i) * dp[i, S]
    ans = ans % M
print(ans)
Problem p02632 (python)

Fixed submission:
MAX = 2*10**6
MOD = 10**9+7

fac = [0] * (MAX+1)
finv = [0] * (MAX+1)
inv = [0] * (MAX+1)

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD


if __name__ == '__main__':
    k = int(input())
    s = input()
    n = len(s)
    comb_init()
    ans = 0
    for i in range(k+1):
        val = comb(i+n-1, n-1)
        val *= pow(25, i, MOD)
        val %= MOD
        val *= pow(26, k-i, MOD)
        val %= MOD
        ans += val
        ans %= MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
MAX = 10**6
MOD = 10**9+7

fac = [0] * (MAX+1)
finv = [0] * (MAX+1)
inv = [0] * (MAX+1)

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD


if __name__ == '__main__':
    k = int(input())
    s = input()
    n = len(s)
    comb_init()
    ans = 0
    for i in range(k+1):
        val = comb(i+n-1, n-1)
        val *= pow(25, i, MOD)
        val %= MOD
        val *= pow(26, k-i, MOD)
        val %= MOD
        ans += val
        ans %= MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
MAX = 10**6
MOD = 10**9+7

fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD


if __name__ == '__main__':
    k = int(input())
    s = input()
    n = len(s)
    comb_init()
    ans = 0
    for i in range(k+1):
        val = comb(i+n-1, n-1)
        val *= pow(25, i, MOD)
        val %= MOD
        val *= pow(26, k-i, MOD)
        val %= MOD
        ans += val
        ans %= MOD
    print(ans)
Problem p02642 (python)

Fixed submission:
import numpy as np

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

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(i) for i in input().split()])

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))

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

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))

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

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    if a[i] == a[i-1]:
        if res and a[i] == res[-1]:
            res.pop()
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))
Problem p02756 (python)

Fixed submission:
from collections import deque

is_reverse = False
s = deque(input())
q = int(input())
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if (not is_reverse and query[1] == '1') or (is_reverse and query[1] == '2'):
            s.appendleft(query[2])
        else:
            s.append(query[2])
print(''.join(s)[::-1]) if is_reverse else print(''.join(s))

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        s = s[::-1]
    else:
        if query[1] == '1':
            s = query[2] + s
        else:
            s = s + query[2]
    print(s)
Problem p02838 (python)

Fixed submission:
from itertools import count

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

d_cumsum = [0] * 60
for v in a:
    for i in count():
        d_cumsum[i] += v % 2
        v //= 2
        if v == 0:
            break

res = 0
mod = 10**9 + 7
for i, d in enumerate(d_cumsum):
    res += (2**i * d * (n-d)) % mod
    res %= mod

print(res)

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

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

d_cumsum = np.zeros(60, dtype='i8')
for v in a:
    d_cumsum += np.array(list(map(int, list(format(v, '060b')))))

res = 0
mod = 10**9 + 7
for i, d in enumerate(reversed(d_cumsum)):
    res += (2**i * d * (n-d)) % mod
    res %= mod

print(res)
Problem p02900 (python)

Fixed submission:
from fractions import gcd

def divisors(n, reverse=False):
    table = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            table.append(i)
            if i != n // i:
                table.append(n // i)
    table.sort(reverse=reverse)
    return table

def common_divisors(x, y, reverse=False):
    return divisors(gcd(x, y), reverse=reverse)


a, b = map(int, input().split())

res = 0
for i in common_divisors(a, b):
    for k in range(2, int(i**0.5)+1):
        if i % k == 0:
            break
    else:
        res += 1
print(res)

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

def divisors(n, reverse=False):
    table = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            table.append(i)
            if i != n // i:
                table.append(n // i)
    table.sort(reverse=reverse)
    return table

def common_divisors(x, y, reverse=False):
    return divisors(gcd(x, y), reverse=reverse)

a, b = map(int, input().split())

d = common_divisors(a, b)
MAX_VAL = d[-1]
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

print(len([i for i in d if i == 1 or prime[i]]))
Problem p02953 (python)

Fixed submission:
n = int(input())
h = [int(i) for i in input().split()]

h2 = h[:]
can = True
for i in range(n-2, -1, -1):
    if h2[i] <= h2[i+1]:
        continue
    elif h2[i] > 1:
        h2[i] -= 1
    if not h2[i] <= h2[i+1]:
        can = False
        break

print('Yes') if can else print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]

h2 = [0] + h[:]
can = True
for i in range(1, n-1):
    if h2[i] <= h2[i+1]:
        continue
    elif h2[i]-1 > 0 and h2[i]-1 <= h2[i+i] and h2[i-1] <= h2[i]:
        h2[i] -= 1
    else:
        can = False
        break

print('Yes') if can else print('No')
Problem p02983 (python)

Fixed submission:
from sys import maxsize

l, r = [int(i) for i in input().split()]

min = maxsize
m = l
while m <= r:
    n = m + 1
    while n <= r:
        mod = m * n % 2019
        if mod < min:
            min = mod
        if mod == 0:
            break
        n += 1
    else:
        m += 1
        continue
    break

print(min)

Buggy submission (verdict: Runtime Error):
from sys import maxsize
from itertools import combinations

l, r = [int(i) for i in input().split()]

min = maxsize
for i, k in combinations(range(l, r+1), 2):
    mod = i * k % 2019
    if mod < min:
        min = mod
    if mod == 0:
        break

print(min)
Problem p03128 (python)

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

a.sort(reverse=True)
num_of_matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    val = -1
    for aa in a:
        if i - num_of_matches[aa] < 0:
            continue
        if i - num_of_matches[aa] == 0:
            val = 1
        elif dp[i - num_of_matches[aa]] > 0:
            val = max(val, dp[i - num_of_matches[aa]] + 1)
    dp[i] = val

res = ''
remain = dp[n]
match = n
while match > 0:
    for i in range(m):
        if match - num_of_matches[a[i]] >= 0 and remain - 1 == dp[match-num_of_matches[a[i]]]:
            match -= num_of_matches[a[i]]
            remain -= 1
            res += str(a[i])
            break
print(res)

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

a.sort(reverse=True)
num_of_matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    val = -1
    for aa in a:
        if i - num_of_matches[aa] < 0:
            continue
        if i - num_of_matches[aa] == 0:
            val = 1
        elif dp[i - num_of_matches[aa]] > 0:
            val = max(val, dp[i - num_of_matches[aa]] + 1)
    dp[i] = val

res = ''
remain = dp[n]
match = n
while match > 0:
    for i in range(m):
        if remain - 1 == dp[match-num_of_matches[a[i]]] and match - num_of_matches[a[i]] >= 0:
            match -= num_of_matches[a[i]]
            remain -= 1
            res += str(a[i])
            break
print(res)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
num_of_matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# a = [(i, num_of_matches[i]) for i in map(int, input().split())]
a = list(map(int, input().split()))

a.sort(reverse=True)
dp = [-1] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    val = -1
    for aa in a:
        if i - num_of_matches[aa] < 0:
            continue
        if i - num_of_matches[aa] == 0:
            val = 1
        elif dp[i - num_of_matches[aa]] > 0:
            val = max(val, dp[i - num_of_matches[aa]] + 1)
    dp[i] = val

res = ''
remain = dp[n]
match = n
while match > 0:
    for i in range(m):
        if remain - 1 == dp[match-num_of_matches[a[i]]]:
            match -= num_of_matches[a[i]]
            remain -= 1
            res += str(a[i])
            break
print(res)
Problem p03645 (python)

Fixed submission:
import numpy as np

n, m = map(int, input().split())
from_1 = np.zeros(n+1, dtype=np.int)
to_n = np.zeros(n+1, dtype=np.int)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        from_1[b] = 1
    elif b == n:
        to_n[a] = 1

print('IMPOSSIBLE') if np.sum(from_1*to_n) == 0 else print('POSSIBLE')

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

n, m = map(int, input().split())
g = np.zeros((n, n), dtype=np.int)
for _ in range(m):
    a, b = map(int, input().split())
    g[a-1, b-1] = 1
    g[b-1, a-1] = 1

res = 'IMPOSSIBLE'
for i in range(n):
    if g[n-1, i] == 0:
        continue
    if g[i, 0] == 1:
        res = 'POSSIBLE'
        break

print(res)

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

n, m = map(int, input().split())
g = np.zeros((n, n), dtype=int)
for _ in range(m):
    a, b = map(int, input().split())
    g[a-1, b-1] = 1
    g[b-1, a-1] = 1

res = 'IMPOSSIBLE'
for i in range(n):
    if g[n-1, i] == 0:
        continue
    if g[i, 0] == 1:
        res = 'POSSIBLE'
        break

print(res)
Problem p02630 (python)

Fixed submission:
n = int(input())
a = input().split()
alist = set()
adic = {}
su = 0

for i in a:
    su += int(i)
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        su = su + (c * adic[b]) - (b * adic[b])
        adic[b] = 0

    ans.append(su)
for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()
alist = set()
adic = {}
for i in a:
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        adic[b] = 0
        su = 0
        for j in adic:
            su += j * adic[j]
    ans.append(su)
for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()
alist = set()
adic = {}
for i in a:
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        adic[b] = 0
        su = 0
        for j in adic:
            su += j * adic[j]
    ans.append(su)
for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()
alist = set()
adic = {}
for i in a:
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        adic[b] = 0
        su = 0
        for j in adic:
            su += j * adic[j]
    ans.append(su)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input().split()
alist = set()
adic = {}
for i in a:
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []
#tt = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        adic[b] = 0
        su = 0
        for j in adic:
            su += j * adic[j]
    #ans.append(sum(adic.values()))
    ans.append(su)
    #tt.append(adic)
    #print(adic)

print(ans)
#print(tt)
Problem p02642 (python)

Fixed submission:
n = int(input())

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

aMax = a[-1]
l = len(a)
count = 0
k = 0
kSet = set()

for i in range(n):
    value = a[i]
    if not(value in kSet):
        if i != 0 and a[i-1] == value:
            count -= 1
            kSet.add(value)
            continue
        count += 1
        j = 2
        k = 0
        while k < aMax:
            k = a[i] * j
            kSet.add(k)
            j += 1
    #if value ** 2 > aMax:
    #    break

print(count)

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

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

aMax = a[-1]
l = len(a)
count = 0
k = 0
kSet = set()

for i in range(n):
    value = a[i]
    if not(value in kSet):
        if a[i+1] == value:
            count -= 1
        count += 1
        j = 1
        k = 0
        while k < aMax:
            k = a[i] * j
            kSet.add(k)
            j += 1
    #if value ** 2 > aMax:
    #    break

print(count)

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

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

aMax = a[-1]
l = len(a)
count = 0

while 1:
    aMin = a.pop(0)
    if aMin == a[0]:
        count -= 1
    count += 1
    l -= 1
    delList = []
    if l == 0:
        break
    for k in a:
        if k % aMin == 0:
            delList.append(k)
    for k in delList:
        a.remove(k)
        l -= 1
    if aMin ** 2 > aMax:
        count += l
        break

print(count)
Problem p02678 (python)

Fixed submission:
import collections

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

coriddorList = [set() for i in range(n+1)]
deepList = [-1 for i in range(n+1)]


for i in range(m):
    a,b = list(map(int,input().split()))
    coriddorList[a].add(b)
    coriddorList[b].add(a)

checkList = [0] * (n + 1)
ansList = [0] * (n + 1)
checkList[1] = 1
q = collections.deque()
q.appendleft(1)

while len(q) > 0:
    value = q.pop()
    for k in coriddorList[value]:
        if checkList[k] == 0:
            checkList[k] = 1
            ansList[k] = value
            q.appendleft(k)

print("Yes")
for i in range(2,n+1):
    print(ansList[i])

Buggy submission (verdict: Runtime Error):
s = input().split()

n = int(s[0])
m = int(s[1])

ld = {}
root = []

for i in range(m):
    t = input().split()
    if int(t[0]) in ld:
       ld[int(t[0])].add(int(t[1]))
    else:
       ld[int(t[0])] = {int(t[1])}
    if int(t[1]) in ld:
        ld[int(t[1])].add(int(t[0]))
    else:
        ld[int(t[1])] = {int(t[0])}
    root.append({int(t[0]),int(t[1])})


if sum(ld.keys()) < int(((n + 1) * n ) / 2):
    print("No")
else:
    goal = [1]
    result = {}

    for i in range(n):
        count = 0
        for j in range(m-len(goal)):
            if goal[i] in root[j-count]:
                result[int(list(root[j-count] - {goal[i]})[0])] = goal[i]
                goal.append(int(list(root[j-count] - {goal[i]})[0]))
                #print(root[j-count])
                del root[j-count]
                count += 1
        if len(goal) >= n:
            break

    print("Yes")
    for i in range(2,n+1):
        print(result[i])

    #print(goal)
    #print(result)