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

Fixed submission:
N = int(input())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    cnt = curr // stocks[i]
  curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Buggy submission (verdict: Runtime Error):
N = int(intput())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
    cnt = 0
    if stocks[i] < stocks[i + 1]:
      cnt = curr // stocks[i]
    curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Buggy submission (verdict: Runtime Error):
N = int(intput())
stocks = list(map(int, input().split()))
curr = 1000
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    cnt = curr // stocks[i]
  curr += cnt * (stocks[i + 1] - stocks[i])
print(curr)

Buggy submission (verdict: Runtime Error):
N = int(intput())
stocks = list(map(int, input().split()))
for i in range(N - 1):
  cnt = 0
  if stocks[i] < stocks[i + 1]:
    pass
Problem p03088 (python)

Fixed submission:
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N + 1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
typedef long long ll;

const int maxn = 110;

int N;

vector<unordered_map<string, ll>> memo(maxn);

bool check(string last4) {
    if (last4.find("AGC") != string::npos) {
        return false;
    }
    for (int i = 0; i < 4 - 1; ++i) {
        swap(last4[i], last4[i + 1]);
        if (last4.find("AGC") != string::npos) {
            return false;
        }
        swap(last4[i], last4[i + 1]);
    }
    return true;
}

ll dfs(int cur, const string& last3) {
    if (memo[cur].count(last3)) {
        return memo[cur][last3];
    }
    if (cur == N) {
        return 1;
    }
    ll ret = 0;
    for (char c : string("ACGT")) {
        if (check(last3 + c)) {
            ret = (ret % MOD + dfs(cur + 1, last3.substr(1) + c) % MOD) % MOD;
        }
    }
    return memo[cur][last3] = ret;
}

int main() {
    cin >> N;
    cout << dfs(0, "TTT") << endl;
    return 0;
}
Problem p02573 (python)

Fixed submission:
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

dp = [-1]*n

def root(x):
    if dp[x] < 0:
        return x
    return root(dp[x])

def unite(x, y):
    rx = root(x)
    ry = root(y)
    
    if rx == ry:
        return False
        
    if dp[rx] > dp[ry]:
        rx,ry = ry,rx
        
    dp[rx] += dp[ry]
    dp[ry] = rx
    return True

def size(x):
    return -dp[root(x)]

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    unite(a,b)
    
ans = 0
for i in range(n):
    ans = max(ans, size(i))
    
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*n

def dfs(node, cml):
    if len(adjList[node])>0:
        for ngh in adjList[node]:
            if not visited[ngh]:
                visited[ngh] = True
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i]:
        visited[i] = True
        ca = dfs(i, 1)
        mca = max(mca, ca)

print(mca)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*n

def dfs(node, cml):
    visited[node] = True
    
    if adjList[node]:
        for ngh in adjList[node]:
            if not visited[ngh]:
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i]:
        ca = dfs(i, 1)
        mca = max(mca, ca)

print(mca)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*(n+1)

def dfs(node, cml):
    visited[node] = True
    
    if adjList[node]:
        for ngh in adjList[node]:
            if not visited[ngh]:
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i+1]:
        ca = dfs(i+1, 1)
        mca = max(mca, ca)

print(mca)
Problem p02994 (python)

Fixed submission:
def main():
    N, L = map(int, input().split())
    a = [L + n for n in range(N)]
    if L > 0:
        print(sum(a) - a[0])
    elif abs(L) >= N:
        print(sum(a) - a[-1])
    else:
        print(sum(a))


main()

Buggy submission (verdict: Runtime Error):
def main():
    N, L = map(int, input().split())
    a = sum([L + n for n in range(N)])
    if L > 0:
        print(a - a[0])
    elif abs(L) >= N:
        print(a - a[-1])
    else:
        print(a)


main()
Problem p02995 (python)

Fixed submission:
import fractions


def main():
    A, B, C, D = map(int, input().split())
    lcm = (C * D) // fractions.gcd(C, D)
    bc = B // C
    ac = A // C
    if A % C == 0:
        ac -= 1
    bd = B // D
    ad = A // D
    if A % D == 0:
        ad -= 1
    blcm = B // lcm
    alcm = A // lcm
    if A % lcm == 0:
        alcm -= 1
    print(B - A + 1 - ((bc - ac) + (bd - ad) - (blcm - alcm)))


main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    A, B, C, D = map(int, input().split())
    lcm = (C * D) // math.gcd(C, D)
    bc = B // C
    ac = A // C
    if A % C == 0:
        ac -= 1
    bd = B // D
    ad = A // D
    if A % D == 0:
        ad -= 1
    blcm = B // lcm
    alcm = A // lcm
    if A % lcm == 0:
        alcm -= 1
    print(B - A + 1 - ((bc - ac) + (bd - ad) - (blcm - alcm)))


main()
Problem p03032 (python)

Fixed submission:
def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    ans = 0
    for l in range(K + 1):
        for r in range(K - l + 1):
            if l + r > N:
                continue
            d = K - l - r
            s = V[:l] + V[N - r:N]
            now = 0
            now += sum(s)
            s.sort()
            for i in range(d):
                if i >= len(s):
                    break
                if s[i] > 0:
                    break
                now -= s[i]
            ans = max(ans, now)
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
def f(s, v, k):
    if k == 0:
        return sum(s)
    v1 = v[::]
    s1 = s[::]
    v2 = v[::]
    s2 = s[::]
    v3 = v[::]
    s3 = s[::]
    s3.append(v3.pop(0))
    v4 = v[::]
    s4 = s[::]
    s4.append(v4.pop(-1))
    a = -1 * (10 ** 7)
    b = -1 * (10 ** 7)
    if len(s) > 0:
        ms = min(s)
        v1.insert(0, ms)
        s1.pop(s1.index(ms))
        v2.append(ms)
        s2.pop(s2.index(ms))
        a = f(s1, v1, k - 1)
        b = f(s2, v2, k - 1)
    c = f(s3, v3, k - 1)
    d = f(s4, v4, k - 1)
    return max(a, b, c, d)


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    ans = max(f([V[0]], V[1:], K - 1), f([V[-1]], V[:-1], K - 1))
    if ans > 0:
        print(ans)
    else:
        print(0)


main()
Problem p03076 (python)

Fixed submission:
import math


def main():
    ans = 0
    t = []
    for _ in range(5):
        x = input()
        if x[-1] == '0':
            ans += int(x)
        else:
            t.append(int(x))
    if len(t) > 0:
        t.sort(key=lambda x: str(x)[-1])
        for i in range(1, len(t)):
            ans += math.ceil(t[i] / 10) * 10
        ans += t[0]
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    ans = 0
    t = []
    for _ in range(5):
        x = input()
        if x[-1] == '0':
            ans += int(x)
        else:
            t.append(int(x))
    t.sort(key=lambda x: str(x)[-1])
    for i in range(1, len(t)):
        ans += math.ceil(t[i] / 10) * 10
    ans += t[0]
    print(ans)


main()
Problem p03164 (python)

Fixed submission:
def main():
    N, W = map(int, input().split())
    Ws = []
    Vs = []
    for _ in range(N):
        w, v = map(int, input().split())
        Ws.append(w)
        Vs.append(v)
    mv = sum(Vs)
    dp = [[float('INF')] * (mv + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(mv + 1):
            if Vs[i] > j:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = min(dp[i][j], dp[i][j - Vs[i]] + Ws[i])
    ans = 0
    for r in dp:
        for v, w in enumerate(r):
            if W >= w:
                ans = max(ans, v)
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
def main():
    N, W = map(int, input().split())
    WV = []
    for _ in range(N):
        w, v = map(int, input().split())
        WV.append((w, v))
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(W + 1):
            if j >= WV[i][0]:
                dp[i + 1][j] = max(
                    dp[i][j],
                    dp[i][j - WV[i][0]] + WV[i][1]
                )
            else:
                dp[i + 1][j] = dp[i][j]
    print(dp[-1][-1])


main()
Problem p03244 (python)

Fixed submission:
def main():
    n = int(input())
    v = list(map(int, input().split()))
    e = [0 for _ in range(1, 10 ** 5 + 2)]
    o = [0 for _ in range(1, 10 ** 5 + 2)]
    for i in range(0, n, 2):
        e[v[i]] += 1
        o[v[i + 1]] += 1
    ans = 0
    if len(set(v)) == 1:
        ans = n // 2
    else:
        me = max(e)
        mo = max(o)
        mei = e.index(me)
        moi = o.index(mo)
        if mei == moi:
            e[mei] = 0
            o[moi] = 0
            ans += n - me - max(max(e), max(o))
        else:
            ans = n - max(e) - max(o)
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    v = list(map(int, input().split()))
    e = [0 for _ in range(10 ** 5)]
    o = [0 for _ in range(10 ** 5)]
    for i in range(0, n, 2):
        e[v[i]] += 1
        o[v[i + 1]] += 1
    ans = 0
    if n == max(e) + max(o):
        ans = n // 2
    else:
        if n // 2 > max(e):
            ans += n // 2 - max(e)
        if n // 2 > max(o):
            ans += n // 2 - max(o)
    print(ans)


main()
Problem p03274 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    x = list(map(int, input().split()))

    i = 0
    ans = 10 ** 8 * n
    while i < n - k + 1:
        lr = abs(x[i]) + abs(x[i] - x[i + k - 1])
        rl = abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1])
        i += 1
        ans = min(ans, lr, rl)
    print(ans)


main()

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


def check(now, k, t, logs, ans):
    if now in logs:
        return ans
    logs.append(now)
    if k == 0:
        return min(ans, t)
    if len(x) > now + 1:
        ans = min(ans, check(now + 1, k - 1, t +
                             abs(x[now + 1] - x[now]), logs[::], ans))
    if now - 1 >= 0:
        ans = min(ans, check(now - 1, k - 1, t +
                             abs(x[now - 1] - x[now]), logs[::], ans))
    return ans


def main():
    ans = abs(sum(x))
    for i, v in enumerate(x):
        ans = min(ans, check(i, k - 1, abs(v), [], ans))
    print(ans)


main()

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


def check(now, k, t, logs, ans):
    if now in logs:
        return ans
    logs.append(now)
    if k == 0:
        return min(ans, t)

    if len(x) > now + 1:
        ans = min(ans, check(now + 1, k - 1, t +
                             abs(x[now + 1] - x[now]), logs[::], ans))
    if now - 1 >= 0:
        ans = min(ans, check(now - 1, k - 1, t +
                             abs(x[now - 1] - x[now]), logs[::], ans))
    return ans


def main():
    ans = abs(sum(x))
    for i, v in enumerate(x):
        ans = min(ans, check(i, k - 1, abs(v), [], ans))
    print(ans)


main()
Problem p03480 (python)

Fixed submission:
def main():
    s = input()
    i = j = len(s) // 2
    if len(s) % 2 == 0:
        j -= 1
    ss = s[j]
    while len(s) > i and j >= 0 and ss == s[i] and ss == s[j]:
        i += 1
        j -= 1
    print(i)


main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    if len(s) % 2 == 1:
        sl = len(s) // 2 + 1
    else:
        sl = len(s) // 2
    ss = s[-sl:sl]
    for i in range(sl, len(s) + 1):
        ss = s[-i - 1] + ss + s[i]
        if ss.count('0') == len(ss) or ss.count('1') == len(ss):
            continue
        print(i)
        return


main()
Problem p03488 (python)

Fixed submission:
def main():
    s = input()
    x, y = map(int, input().split())
    sl = s.split('T')
    dx = list(map(len, sl[::2]))
    dy = list(map(len, sl[1::2]))
    nx = dx.pop(0)
    ny = 0
    dx.sort(reverse=True)
    dy.sort(reverse=True)
    for xx in dx:
        if x >= nx:
            nx += xx
        else:
            nx -= xx
    for yy in dy:
        if y >= ny:
            ny += yy
        else:
            ny -= yy
    print('YNeos'[nx != x or ny != y::2])


main()

Buggy submission (verdict: Runtime Error):
s = input()
gx, gy = map(int, input().split())


def dfs(x, y, si, f):
    if len(s) == si:
        if (x, y) == (gx, gy):
            return True
        return False
    ans = False
    if s[si] == 'T':
        return dfs(x, y, si + 1, not f)
    if f:
        for xx, yy in [(x + 1, y), (x - 1, y)]:
            ans = ans or dfs(xx, yy, si + 1, f)
    else:
        for xx, yy in [(x, y + 1), (x, y - 1)]:
            ans = ans or dfs(xx, yy, si + 1, f)
    return ans


def main():
    if dfs(0, 0, 0, True):
        print('Yes')
    else:
        print('No')


main()

Buggy submission (verdict: Runtime Error):
def dfs(x, y, gx, gy, s, f):
    if len(s) == 0:
        if (x, y) == (gx, gy):
            return True
        return False
    ans = False
    if s[0] == 'T':
        if f:
            ans = ans or dfs(x, y, gx, gy, s[1:], not f)
        else:
            ans = ans or dfs(x, y, gx, gy, s[1:], not f)
    else:
        if f:
            for xx, yy in [(x + 1, y), (x - 1, y)]:
                ans = ans or dfs(xx, yy, gx, gy, s[1:], f)
        else:
            for xx, yy in [(x, y + 1), (x, y - 1)]:
                ans = ans or dfs(xx, yy, gx, gy, s[1:], f)
    return ans


def main():
    s = input()
    x, y = map(int, input().split())
    if dfs(0, 0, x, y, s, True):
        print('Yes')
    else:
        print('No')


main()

Buggy submission (verdict: Runtime Error):
def dfs(x, y, gx, gy, s, f):
    if len(s) == 0:
        if (x, y) == (gx, gy):
            return True
        return False
    ans = False
    if s[0] == 'T':
        if f:
            for xx, yy in [(x, y + 1), (x, y - 1)]:
                ans = ans or dfs(xx, yy, gx, gy, s[1:], f)
        else:
            for xx, yy in [(x + 1, y), (x - 1, y)]:
                ans = ans or dfs(xx, yy, gx, gy, s[1:], f)
    else:
        if f:
            for xx, yy in [(x + 1, y), (x - 1, y)]:
                ans = ans or dfs(xx, yy, gx, gy, s[1:], f)
        else:
            for xx, yy in [(x, y + 1), (x, y - 1)]:
                ans = ans or dfs(xx, yy, gx, gy, s[1:], f)
    return ans


def main():
    s = input()
    x, y = map(int, input().split())
    if dfs(0, 0, x, y, s, True):
        print('Yes')
    else:
        print('No')


main()
Problem p03544 (python)

Fixed submission:
def main():
    N = int(input())
    la = 2
    lb = 1
    for _ in range(N):
        lc = la + lb
        la = lb
        lb = lc
    print(la)


main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    la = 2
    lb = 1
    for _ in range(N - 1):
        lc = la + lb
        la = lb
        lb = lc
    print(lc)


main()
Problem p03599 (python)

Fixed submission:
def main():
    A, B, C, D, E, F = map(int, input().split())
    xl = []
    yl = []
    for i in range(31):
        for j in range(31):
            x = 100 * A * i + 100 * B * j
            if F >= x and x > 0 and x not in xl:
                xl.append(x)
    for i in range(F):
        for j in range(F):
            y = C * i + D * j
            if F >= y and y > 0 and y not in yl:
                yl.append(y)
    ax = 3001
    ay = 0
    for x in xl:
        for y in yl:
            if F >= x + y and E / (E + 100) >= y / (x + y) and y / (x + y) > ay / (ax + ay):
                ax = x
                ay = y
    if ax == 3001:
        print(100 * A, 0, end=' ')
    else:
        print(ax + ay, ay, end=' ')


main()

Buggy submission (verdict: Runtime Error):
def main():
    A, B, C, D, E, F = map(int, input().split())
    xl = []
    yl = []
    for i in range(F):
        for j in range(F):
            x = 100 * A * i + 100 * B * j
            if F >= x and x not in xl:
                xl.append(x)
    for i in range(F):
        for j in range(F):
            y = C * i + D * j
            if F >= y and y not in yl:
                yl.append(y)
    ax = float('INF')
    ay = 0
    for x in xl:
        for y in yl:
            if F >= x + y and E / (E + 100) >= y / (x + y) and y / (x + y) > ay / (ax + ay):
                ax = x
                ay = y
    print(ax + ay, ay, end=' ')


main()
Problem p03625 (python)

Fixed submission:
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    i = 0
    d = []
    while N - 1 > i:
        if len(d) == 2:
            break
        if A[i] == A[i + 1]:
            d.append(A[i])
            i += 1
        i += 1
    if (len(d) == 2):
        print(d[0] * d[1])
    else:
        print(0)


main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    i = 0
    d = []
    while N - 1 > i:
        if len(d) == 2:
            break
        if A[i] == A[i + 1]:
            d.append(A[i])
            i += 1
        i += 1
    print(d[0] * d[1])


main()
Problem p03638 (python)

Fixed submission:
def main():
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))
    ans = [[0] * W for _ in range(H)]
    i = 0
    j = 0
    d = 1
    for n in range(N):
        for _ in range(A[n]):
            ans[i][j] = str(n + 1)
            if (0 > d and j == 0) or (d > 0 and j == W - 1):
                i += 1
                d *= -1
                continue
            j += d
    for r in ans:
        print(' '.join(r))


main()

Buggy submission (verdict: Runtime Error):
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    b1 = 0
    b2 = 0
    b4 = 0
    for a in A:
        if a == 2:
            b2 += 1
            continue
        if a // 2 > 1 and a % 2 == 0:
            b4 += 1
            continue
        b1 += 1
    if b2 > 0:
        if b4 >= b1:
            print('Yes')
            return
    else:
        if b4 + 1 >= b1:
            print('Yes')
            return
    print('No')


main()
Problem p03695 (python)

Fixed submission:
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 + 1)
    d = [0] * (4800 // 400 + 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


main()

Buggy submission (verdict: Runtime Error):
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 - 1)
    d = [0] * (4800 // 400 - 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


main()

Buggy submission (verdict: Runtime Error):
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [0] * (4800 // 400)
    mx = 0
    for a in A:
        c[a // 400] = True
        if a >= 3200:
            mx += 1
    print(max(c[:3200 // 400].count(True), mx),
          c[:3200 // 400].count(True) + mx)


main()
Problem p03854 (python)

Fixed submission:
S = input()
targets = ['dream', 'dreamer', 'erase', 'eraser']

i = len(S)
while True:
    if i == 0:
        print('YES')
        exit()
    for tg in targets:
        if S[i - len(tg):i][::-1] == tg[::-1]:
            i -= len(tg)
            break
    else:
        print('NO')
        exit()

Buggy submission (verdict: Runtime Error):
S = input()
targets = ['dream', 'dreamer', 'erase', 'eraser']


def fn(i):
    if i == 0:
        print('YES')
        exit()
    for tg in targets:
        if S[i - len(tg):i][::-1] == tg[::-1]:
            fn(i - len(tg))
    print('No')
    exit()


fn(len(S))

Buggy submission (verdict: Runtime Error):
S = input()
targets = ['dream', 'dreamer', 'erase', 'eraser']


def fn(i):
    if len(S) == i:
        print('YES')
        exit()
    for tg in targets:
        if S[i: i + len(tg)] == tg:
            fn(i + len(tg))


fn(0)
print('No')
Problem p02641 (python)

Fixed submission:
import numpy as np
import sys
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

p.sort()

p0 = [0]
j = 0
for i in range(1,100):
    if p[j]!=i:
        p0.append(i)
    elif p[j] == i:
        j+=1
    if j == N:
        for i0 in range(i+1,100):
            p0.append(i0)
        break
p0.append(101)
p1 = [0 for i in range(len(p0))]
for i in range(len(p0)):
    p1[i] = p0[i]-X
    p1[i] = np.abs(p1[i])
    
ii = np.argmin(p1)

print(p0[ii])

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

p.sort()

p0 = []
j = 0
for i in range(1,100):
    if p[j]!=i:
        p0.append(i)
    elif p[j] == i:
        j+=1
    if j == N:
        for i0 in range(i+1,100):
            p0.append(i0)
        break

p1 = [0 for i in range(len(p0))]
for i in range(len(p0)):
    p1[i] = p0[i]-X
    p1[i] = np.abs(p1[i])
    
ii = np.argmin(p1)

print(p0[ii])

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

p.sort()

p0 = []
j = 0
for i in range(1,100):
    if p[j]!=i:
        p0.append(i)
    elif p[j] == i:
        j+=1
    if j == N:
        for i0 in range(i+1,100):
            p0.append(i0)
        break

p1 = [0 for i in range(len(p0))]
for i in range(len(p0)):
    p1[i] = p0[i]-X
    p1[i] = np.abs(p1[i])
    
ii = np.argmin(p1)

print(p0[ii])
Problem p02642 (python)

Fixed submission:
import math
N = int(input())
A = list(map(int,input().split()))
M = max(A)
cnt = [0 for i in range(M)]
for i in range(N):
    if cnt[A[i]-1] != 0:
        cnt[A[i]-1] = 2
    else:
        j = A[i]-1
        while j<M:
            cnt[j] += 1
            j += A[i]

ans = 0
for i in range(N):
    if cnt[A[i]-1] == 1:
        ans += 1
        
print(ans)

Buggy submission (verdict: Runtime Error):
for i in range(1e6):
  i**2