Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
for i in range(k):
    s *= a[i]

pre = s
for i in range(k, n):
    s *= a[i]
    s //= a[i-k]
    if pre < s:
        print('Yes')
    else:
        print('No')
    pre = s

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

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
mul = [1]
for i in range(n):
    mul.append(mul[i]*a[i])

total = mul[-1]
pre = mul[k]
for i in range(k+1, n+1):
    now = mul[i] // mul[i-k]
    if pre < now:
        print('Yes')
    else:
        print('No')
    pre = now

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

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for m in range(1, n+1):
    cnt = 0
    for i in range(1, int(n**0.5)+2):
        a = n - i**2
        if a >= 1:
            for j in range(1, int(a**0.5) + 2):
                b = n - i**2 - j**2
                if b >= 1:
                    for k in range(1, int(b**0.5) + 2):
                        if i**2 + j**2 + k**2 + i*j + j*k + k*i == m:
                            cnt += 1
    print(cnt)


Fixed submission:
n = 10005
f = [0]*10005
for i in range(1, int(n**0.5)):
    a = n - i**2
    if a >= 1:
        for j in range(1, int(a**0.5)):
            b = n - i**2 - j**2
            if b >= 1:
                for k in range(1, int(b**0.5)):
                    c = i**2 + j**2 + k**2 + i*j + j*k + k*i
                    if c <= 10001:
                        f[c] += 1

n = int(input())
for i in range(1, n+1):
    print(f[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for m in range(1, n+1):
    cnt = 0
    for i in range(1, int(n**0.5)+2):
        a = n - i**2
        if a >= 1:
            for j in range(1, int(a**0.5) + 2):
                b = n - i**2 - j**2
                if b >= 1:
                    for k in range(1, int(b**0.5) + 2):
                        if i**2 + j**2 + k**2 + i*j + j*k + k*i == m:
                            cnt += 1
    print(cnt)

Fixed submission:
n = 10005
f = [0]*10005
for i in range(1, int(n**0.5)):
    a = n - i**2
    if a >= 1:
        for j in range(1, int(a**0.5)):
            b = n - i**2 - j**2
            if b >= 1:
                for k in range(1, int(b**0.5)):
                    c = i**2 + j**2 + k**2 + i*j + j*k + k*i
                    if c <= 10001:
                        f[c] += 1

n = int(input())
for i in range(1, n+1):
    print(f[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = '0b' + input()

for i in range(n):
    lisx = list(x)
    lisx[i+2] = str(1 - int(lisx[i+2]))
    xx = ''.join(lisx)
    intx = int(xx, 2)
    len1 = xx.count('1')

    cnt = 0
    while True:
        if intx == 0:
            print(cnt)
            break
        
        intx = intx % len1
        xx = bin(intx)
        len1 = xx.count('1')
        cnt += 1


Fixed submission:
n = int(input())
s = input()
x = [int(i) for i in s]
pc = s.count('1')

def popcnt(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

def f(x):
    if x == 0:
        return 0
    return f(x % popcnt(x)) + 1

ans = [0]*n
for a in range(2):
    npc = pc
    if a == 0:
        npc += 1
    else:
        npc -= 1
    
    if npc <= 0:
        continue
    
    r0 = 0
    for i in range(n):
        r0 = (r0*2) % npc
        r0 += x[i]

    k = 1
    for i in range(n-1, -1, -1):
        if x[i] == a:
            r = r0
            if a == 0:
                r = (r+k) % npc
            else:
                r = (r-k+npc) % npc
            ans[i] = f(r) + 1
        k = (k*2) % npc

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = '0b' + input()

for i in range(n):
    lisx = list(x)
    lisx[i+2] = str(1 - int(lisx[i+2]))
    xx = ''.join(lisx)
    intx = int(xx, 2)
    len1 = xx.count('1')

    cnt = 0
    while True:
        if intx == 0:
            print(cnt)
            break
        
        intx = intx % len1
        xx = bin(intx)
        len1 = xx.count('1')
        cnt += 1

Fixed submission:
n = int(input())
s = input()
x = [int(i) for i in s]
pc = s.count('1')

def popcnt(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

def f(x):
    if x == 0:
        return 0
    return f(x % popcnt(x)) + 1

ans = [0]*n
for a in range(2):
    npc = pc
    if a == 0:
        npc += 1
    else:
        npc -= 1
    
    if npc <= 0:
        continue
    
    r0 = 0
    for i in range(n):
        r0 = (r0*2) % npc
        r0 += x[i]

    k = 1
    for i in range(n-1, -1, -1):
        if x[i] == a:
            r = r0
            if a == 0:
                r = (r+k) % npc
            else:
                r = (r-k+npc) % npc
            ans[i] = f(r) + 1
        k = (k*2) % npc

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = input()
n = len(s)
MOD = 10**9+7
ans = 0

fact = [1] * 2200000
invfact = [1] * 2200000
 
for i in range(1, 2200000):
    fact[i] = fact[i-1] * i % MOD
 
invfact[2200000 - 1] = pow(fact[2200000 - 1], MOD-2, MOD)
 
for i in range(2200000-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD

def comb(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

for i in range(k+1):
    b = pow(26, k-i, MOD)
    b *= pow(25, i, MOD)
    b *= comb(i+n-1, n-1)
    ans += (b % MOD)
    
print(ans%MOD)

Fixed submission:
k = int(input())
s = input()
n = len(s)
MOD = 10**9+7
ans = 0

fact = [1] * 2200000
invfact = [1] * 2200000
 
for i in range(1, 2200000):
    fact[i] = fact[i-1] * i % MOD
 
invfact[2200000 - 1] = pow(fact[2200000 - 1], MOD-2, MOD)
 
for i in range(2200000-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD

def comb(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

for i in range(k+1):
    b = pow(26, k-i, MOD)
    b *= pow(25, i, MOD)
    b *= comb(i+n-1, n-1)
    ans += (b % MOD)
    
print(ans%MOD)

Buggy python submission (verdict: Runtime Error):
k = int(input())
s = input()
n = len(s)
MOD = 10**9+7
ans = 0

def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD

N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

for i in range(k+1):
    b = pow(26, k-i, MOD)
    b *= pow(25, i, MOD)
    b *= cmb(i+n-1, n-1, MOD)
    ans += (b % MOD)
    
print(ans%MOD)

Fixed submission:
k = int(input())
s = input()
n = len(s)
MOD = 10**9+7
ans = 0

fact = [1] * 2200000
invfact = [1] * 2200000
 
for i in range(1, 2200000):
    fact[i] = fact[i-1] * i % MOD
 
invfact[2200000 - 1] = pow(fact[2200000 - 1], MOD-2, MOD)
 
for i in range(2200000-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD

def comb(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

for i in range(k+1):
    b = pow(26, k-i, MOD)
    b *= pow(25, i, MOD)
    b *= comb(i+n-1, n-1)
    ans += (b % MOD)
    
print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A.sort()

ac = A.count(1)
if ac == 1:
    print(1)
    exit()
if ac >= 2:
    print(0):
    exit()

num = [0]*1000005
for a in A:
    num[a] += 1

b = [False]*1000005
seen = [False]*1000005
cnt = 0
A = list(set(A))
A.sort()
for a in A:
    if seen[a]:
        continue

    seen[a] = True
    if b[a] == False:
        cnt += 1
        if num[a] > 1:
            cnt -= 1

    for i in range(a, 1000005, a):
        b[i] = True
print(cnt)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
A.sort()

ac = A.count(1)
if ac == 1:
    print(1)
    exit()
if ac >= 2:
    print(0)
    exit()

num = [0]*1000005
for a in A:
    num[a] += 1

b = [False]*1000005
seen = [False]*1000005
cnt = 0
A = list(set(A))
A.sort()
for a in A:
    if seen[a]:
        continue

    seen[a] = True
    if b[a] == False:
        cnt += 1
        if num[a] > 1:
            cnt -= 1

    for i in range(a, 1000005, a):
        b[i] = True
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from math import gcd
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += reduce(gcd, [i, j, k])
print(ans)

Fixed submission:
from functools import reduce
from math import gcd
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += reduce(gcd, [i, j, k])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque

def bfs(u):
    dist = [-1 for _ in range(n)]
    dist[u] = 0
    que = deque([])
    que.append(u)
    
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)

    for d in dist:
        if d == 0:
            continue
        ans[d-1] += 1
    return ans


n, x, y = map(int,input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[x-1].append(y-1)
G[y-1].append(x-1)

ans = [0]*(n-1)
for i in range(n):
    bfs(i)

for i in ans:
    print(i//2)

Fixed submission:
n, x, y = map(int,input().split())
cnt = [0 for _ in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            cnt[(x-i)+1+(j-y)] += 1
        else:
            c = min(j-i, abs(x-i)+1+abs(y-j))
            cnt[c] += 1
for i in cnt[1:]:
    print(i)
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
ans = 0
n = x+y
ma = [-1, -1, -1]
for i in range(n):
    if p:
        ma[0] = p[-1]
    if q:
        ma[1] = q[-1]
    if r:
        ma[2] = r[-1]

    if ma.index(max(ma)) == 0:
        if x:
            x -= 1
            ans += p[-1]
            p.pop()
        else:
            if r:
                if q:
                    if r[-1] > q[-1]:
                        y -= 1
                        ans += r[-1]
                        r.pop()
                    else:
                        y -= 1
                        ans += q[-1]
                        q.pop()
                else:
                    y -= 1
                    ans += r[-1]
                    r.pop()
            else:
                y -= 1
                ans += q[-1]
                q.pop()
    elif ma.index(max(ma)) == 1:
        if y:
            y -= 1
            ans += q[-1]
            q.pop()
        else:
            if r:
                if p:
                    if r[-1] > p[-1]:
                        x -= 1
                        ans += r[-1]
                        r.pop()
                    else:
                        x -= 1
                        ans += p[-1]
                        p.pop()
                else:
                    x -= 1
                    ans += r[-1]
                    r.pop()
            else:
                x -= 1
                ans += p[-1]
                p.pop()
    else:
        if p[-1] > q[-1]:
            if y:
                y -= 1
            else:
                x -= 1
        else:
            if x:
                x -= 1
            else:
                y -= 1
        ans += r[-1]
        r.pop()
print(ans)

Fixed submission:
x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
ap = p + q + r
ap.sort(reverse=True)
print(sum(ap[:x+y]))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
cnt = 0
for i in range(q):
    t = input()
    if t == '1':
        cnt = 1 - cnt
    else:
        t2, f, c = t.split()
        if cnt == 0:
            if f == '1':
                s = c+s
            else:
                s += c
        else:
            if f == '1':
                s += c
            else:
                s = c+s

if cnt == 0:
    print(s)
else:
    print(s[::-1])

Fixed submission:
s = input()
q = int(input())
cnt = 0
l = ''
r = ''
for i in range(q):
    t = input()
    if t == '1':
        cnt = 1 - cnt
    else:
        t2, f, c = t.split()
        if cnt == 0:
            if f == '1':
                l = c + l
            else:
                r += c
        else:
            if f == '1':
                r += c
            else:
                l = c + l
                
if cnt == 0:
    print(l+s+r)
else:
    print(r[::-1]+s[::-1]+l[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    t = input()
    if t == '1':
        s = s[::-1]
    else:
        t2, f, c = t.split()
        if f == '1':
            s = c+s
        else:
            s += c
print(s)            

Fixed submission:
s = input()
q = int(input())
cnt = 0
l = ''
r = ''
for i in range(q):
    t = input()
    if t == '1':
        cnt = 1 - cnt
    else:
        t2, f, c = t.split()
        if cnt == 0:
            if f == '1':
                l = c + l
            else:
                r += c
        else:
            if f == '1':
                r += c
            else:
                l = c + l
                
if cnt == 0:
    print(l+s+r)
else:
    print(r[::-1]+s[::-1]+l[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n, r)//math.factorial(r)

n, a, b = map(int,input().split())
num = 10**9+7
ans = 2**n - 1
ans -= C(n, a)
ans -= C(n, b)
print(ans%num)

Fixed submission:
n, a, b = map(int, input().split())
MOD = 10**9+7

len_inv = 2*(10**5) + 10
inv = [1]*(len_inv)

for i in range(2, len_inv):
    inv[i] = inv[MOD%i] * (MOD - MOD//i) % MOD

def comb(n, k, MOD):
    x = 1
    for i in range(k):
        x *= (n-i)
        x *= inv[i+1]
        x %= MOD
    return x

ans = pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)
ans += MOD
ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
al = 'abcdefghijklmnopqrstuvwxy'
c = input()
print(al[al.index(c)+1])

Fixed submission:
al = 'abcdefghijklmnopqrstuvwxyz'
c = input()
print(al[al.index(c)+1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
ans = 1
MOD = 1000000007
c = [0, 0, 0]
for a in A:
    cnt = c.count(a)
    ans *= cnt
    ans %= MOD
    c[c.index(a)] += 1
print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1
MOD = 1000000007
c = [0, 0, 0]
for a in A:
    cnt = c.count(a)
    if cnt == 0:
        print(0)
        exit()
    ans *= cnt
    ans %= MOD
    c[c.index(a)] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
a = [[0]*w for _ in range(h)]
cnt = 1
later = []
for i in range(h):
    if '#' not in s[i]: continue
    if i < h-1: later.append(i)
    fst = True
    for j in range(w):
        if not fst and s[i][j] == '#':
            cnt += 1
        if fst and s[i][j] == '#':
            fst = False
        a[i][j] = cnt
    cnt += 1

for i in later:
    if a[i+1][0] != 0: continue
    for j in range(w):
        k = i
        while k < h-1:
            if a[k+1][j] == 0:
                a[k+1][j] = a[k][j]
                k += 1
            else:
                break
                
if later[0] != 0:
    for i in range(later[0], 0, -1):
        for j in range(w):
            a[i-1][j] = a[i][j]
for ans in a:
    print(*ans)

Fixed submission:
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
a = [[0]*w for _ in range(h)]
cnt = 0
later = []
for i in range(h):
    if '#' not in s[i]: continue
    later.append(i)
    fst = False
    idx = -1
    for j in range(w):
        if not fst and not s[i][j] == '#':
            continue
        if not fst and s[i][j] == '#':
            idx = j
        if s[i][j] == '#':
            fst = True
            cnt += 1
        a[i][j] = cnt
    for j in range(idx):
        a[i][j] = a[i][idx]

for i in later:
    if i >= h-1: break
    for j in range(w):
        k = i
        while k < h-1:
            if a[k+1][j] == 0:
                a[k+1][j] = a[k][j]
                k += 1
            else:
                break
                
if later[0] != 0:
    for i in range(later[0], 0, -1):
        for j in range(w):
            a[i-1][j] = a[i][j]
for ans in a:
    print(*ans)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

a = 2*x - y
b = -x + 2*y
if a < 0 or b < 0:
    print(0)
    eixt()

a //= 3
b //= 3
MOD = 10**9+7
MAX_N = 10**6
fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def mod_comb_k(n,k,MOD):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] %MOD


print(mod_comb_k(a+b, a, MOD))

Fixed submission:
x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

a = 2*x - y
b = -x + 2*y
if a < 0 or b < 0:
    print(0)
    exit()

a //= 3
b //= 3
MOD = 10**9+7
MAX_N = 10**6
fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def mod_comb_k(n,k,MOD):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] %MOD


print(mod_comb_k(a+b, a, MOD))

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

a = (2*x - y)//3
b = (-x + 2*y)//3
if a < 0 or b < 0:
    print(0)
    eixt()

MOD = 10**9+7
MAX_N = 10**6
fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def mod_comb_k(n,k,MOD):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] %MOD


print(mod_comb_k(a+b, a, MOD))

Fixed submission:
x, y = map(int, input().split())
if (x+y)%3 != 0:
    print(0)
    exit()

a = 2*x - y
b = -x + 2*y
if a < 0 or b < 0:
    print(0)
    exit()

a //= 3
b //= 3
MOD = 10**9+7
MAX_N = 10**6
fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def mod_comb_k(n,k,MOD):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] %MOD


print(mod_comb_k(a+b, a, MOD))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
def is_prime(num):
    import math
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if is_prime(n):
    print(n-1)
    exit()

ans = float('inf')
for i in range(n//2, 0, -1):
    if n%i == 0:
        ans = min(ans, (i-1)+(n//i-1))
print(ans)

Fixed submission:
n = int(input())
def is_prime(num):
    import math
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if is_prime(n):
    print(n-1)
    exit()

ans = float('inf')
for i in range(int(n**0.5), 0, -1):
    if n%i == 0:
        ans = min(ans, (i-1)+(n//i-1))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
def is_prime(num):
    import math
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if is_prime(n):
    print(n-1)
    exit()

ans = float('inf')
for i in range(n//2, 0, -1):
    if n%i == 0:
        ans = min(ans, (i-1)+(n//i-1))
print(ans)

Fixed submission:
n = int(input())
def is_prime(num):
    import math
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if is_prime(n):
    print(n-1)
    exit()

ans = float('inf')
for i in range(int(n**0.5), 0, -1):
    if n%i == 0:
        ans = min(ans, (i-1)+(n//i-1))
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
for h in H:
    if h >= k:
        cn
        t += 1
print(cnt)

Fixed submission:
n, k = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
for h in H:
    if h >= k:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

def primes(max_number):
    pr = list(range(3, max_number+1, 2))
    lpr = len(pr)
    for i,n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, lpr, n):
                pr[j] = 0
    yield 2
    yield from[i for i in pr if i]

if b > a:
    a, b = b, a

cnt = 0
for i in list(primes(b)):
    if a%i == 0 and b%i == 0:
        cnt += 1
print(cnt+1)

Fixed submission:
import math
a, b = map(int, input().split())

def is_prime(num):
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if b > a:
    a, b = b, a
c = []
for i in range(1, int(math.sqrt(b))+1):
    if a%i == 0 and b%i == 0:
        if is_prime(i):
            c.append(i)
    k = b//i
    if a%k == 0:
        if is_prime(k):
            c.append(k)
print(len(set(c))+1)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

def primes(max_number):
    pr = list(range(3, max_number+1, 2))
    lpr = len(pr)
    for i,n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, lpr, n):
                pr[j] = 0
    yield 2
    yield from[i for i in pr if i]

if b > a:
    a, b = b, a
cnt = 0
for i in list(primes(a)):
    if a%i == 0 and b%i == 0:
        cnt += 1
print(cnt+1)

Fixed submission:
import math
a, b = map(int, input().split())

def is_prime(num):
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if b > a:
    a, b = b, a
c = []
for i in range(1, int(math.sqrt(b))+1):
    if a%i == 0 and b%i == 0:
        if is_prime(i):
            c.append(i)
    k = b//i
    if a%k == 0:
        if is_prime(k):
            c.append(k)
print(len(set(c))+1)