Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
pp = list(map(int, input().split()))

ans = 0
answer = 0

for i in range(n-k+1):
    total = sum(pp[i:i+k])
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    answer += (1+pp[num+n])/2

print(answer)


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

answer = sum(pp[:k])
total = sum(pp[:k])

for i in range(n-k):
    total = total - pp[i] + pp[i+k]
    answer = max(answer, total)

print((answer+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
pp = list(map(int, input().split()))

ans = 0
answer = 0

for i in range(n-k+1):
    total = 0
    for j in range(k):
        j += i
        total += pp[j]
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    answer += (1+pp[num+n])/2

print(answer)


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

answer = sum(pp[:k])
total = sum(pp[:k])

for i in range(n-k):
    total = total - pp[i] + pp[i+k]
    answer = max(answer, total)

print((answer+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n, k = map(int, input().split())
pp = list(map(int, input().split()))

ls = []
ans = 0
answer = 0

for i in range(n-k+1):
    total = 0
    for j in range(k):
        j += i
        total += pp[j]
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    ls.append(pp[num+n])

for i in range(len(ls)):
    answer += (1+ls[i])/2

print(answer)


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

answer = sum(pp[:k])
total = sum(pp[:k])

for i in range(n-k):
    total = total - pp[i] + pp[i+k]
    answer = max(answer, total)

print((answer+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n, k = map(int, input().split())
pp = list(map(int, input().split()))

ans = 0

# p=1とp=2の期待値は変わらないことに注意
for i in range(n-k+1):
    total = 0
    for j in range(k):
        j += i
        total += sum([int(n) for n in range(1, pp[j]+1)])/pp[j]
    ans = max(ans, total)

print(ans)


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

answer = sum(pp[:k])
total = sum(pp[:k])

for i in range(n-k):
    total = total - pp[i] + pp[i+k]
    answer = max(answer, total)

print((answer+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = float('inf')

for i in range(1, 10**7+1):
    q, m = divmod(n, i)
    if m == 0:
        ans = min(ans, q+i)

print(ans-2)


Fixed submission:
n = int(input())


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


r = make_divisors(n)

if len(r) % 2 == 1:
    a = r[len(r)//2]
    print((a-1)+(a-1))
else:
    a = int(len(r)/2)
    print((r[a-1]-1)+(r[a]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = float('inf')

for i in range(1, 10**8+1):
    q, m = divmod(n, i)
    if m == 0:
        ans = min(ans, q+i)

print(ans-2)


Fixed submission:
n = int(input())


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


r = make_divisors(n)

if len(r) % 2 == 1:
    a = r[len(r)//2]
    print((a-1)+(a-1))
else:
    a = int(len(r)/2)
    print((r[a-1]-1)+(r[a]-1))
Buggy python submission (verdict: Runtime Error):
s = input()
if s == 'Sunny':
    print('Cloudy')
elif:
    s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

Fixed submission:
s = input()
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter, defaultdict

n, k, q = map(int, input().split())
A = [int(input()) for _ in range(q)]
C = Counter(A)
d = defaultdict(int)
for key, val in C.items():
    d[key] = k + val - q
for i in range(1, n+1):
    if i not in A:
        d[i] = k-q
for i in range(1, n+1):
    if d[i] <= 0:
        print('No')
    else:
        print('Yes')


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

menber = [0]*n
if q-k >= 0:
    for i in range(q):
        ans = int(input())
        menber[ans-1] += 1
else:
    menber = [1000000]*n

for j in menber:
    if j > q-k:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
B = list(map(int, input().split()))

cnt = B[0] + B[-1]

for i in range(0, n-2)
    cnt += min(B[i], B[i+1])

print(cnt)


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

cnt = B[0] + B[-1]

for i in range(0, n-2):
    if B[i] > B[i+1]:
        cnt += B[i+1]
    else:
        cnt += B[i]

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
H = list(map(int, input().split()))
cnt = 0

for i in range(n-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        cnt = 0
        continue
    ans = max(cnt, 0)

print(ans)


Fixed submission:
n = int(input())
H = list(map(int, input().split()))
cnt = 0
ans = 0

for i in range(n-1):
    if H[i] >= H[i+1]:
        cnt += 1
        ans = max(cnt, ans)
    else:
        cnt = 0

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
H = list(map(int, input().split()))
cnt = 0

for i in range(n-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        cnt = 0
    ans = max(cnt, 0)

print(ans)


Fixed submission:
n = int(input())
H = list(map(int, input().split()))
cnt = 0
ans = 0

for i in range(n-1):
    if H[i] >= H[i+1]:
        cnt += 1
        ans = max(cnt, ans)
    else:
        cnt = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
cnt = 0
for _ in range(n):
    for i in range(n-1):
        if A[i] > A[i+1]:
            A[i], A[i+1] = A[i+1], A[i]
            cnt += 1
AA = A*2
nn = len(AA)
out_cnt = 0
for _ in range(nn):
    for i in range(nn-1):
        if AA[i] > AA[i+1]:
            AA[i], AA[i+1] = AA[i+1], AA[i]
            out_cnt += 1
ans = (k*cnt % MOD + out_cnt * (k*(k-1)//2) % MOD) % MOD
print(ans)


Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
cnt = 0
for _ in range(n):
    for i in range(n-1):
        if A[i] > A[i+1]:
            A[i], A[i+1] = A[i+1], A[i]
            cnt += 1
AA = A*2
nn = len(AA)
out_cnt = 0
for _ in range(nn):
    for i in range(nn-1):
        if AA[i] > AA[i+1]:
            AA[i], AA[i+1] = AA[i+1], AA[i]
            out_cnt += 1
ans = (k*cnt % MOD + out_cnt * (k*(k-1)//2) % MOD) % MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
print('red' if int(input() < 3200 else input())

Fixed submission:
print('red' if int(input()) < 3200 else input())
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(v, parent):
    for v2 in edges[v]:
        if v2 == parent:
            continue
        count[v2] += count[v]
        dfs(v2, v)


dfs(0, None)
print(*count)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(v, parent):
    for v2 in edges[v]:
        if v2 == parent:
            continue
        count[v2] += count[v]
        dfs(v2, v)


dfs(0, None)
print(*count)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, q = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(v, parent):
    for v2 in edges[v]:
        if v2 == parent:
            continue
        count[v2] += count[v]
        dfs(v2, v)


dfs(0, None)
print(*count)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
edges = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

count = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(v, parent):
    for v2 in edges[v]:
        if v2 == parent:
            continue
        count[v2] += count[v]
        dfs(v2, v)


dfs(0, None)
print(*count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(input()) for _ in range(n)]
l = ls.copy()

for i in range(n):
    ls = l.copy()
    ls.pop(i)
    print(max(ls))


Fixed submission:
n = int(input())
ls = [int(input()) for _ in range(n)]
sls = sorted(ls)

for i in range(n):
    if sls[-1] == ls[i]:
        print(sls[-2])
    else:
        print(sls[-1])
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        cnt = i*j % 2019
        if cnt == 0:
            ans = 0
            break
        ans = min(cnt, ans)

print(ans)


Fixed submission:
L, R = map(int, input().split())

ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        cnt = i*j % 2019
        if cnt == 0:
            print(0)
            exit()
        ans = min(cnt, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        cnt = i*j % 2019
        ans = min(cnt, ans)

print(ans)


Fixed submission:
L, R = map(int, input().split())

ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        cnt = i*j % 2019
        if cnt == 0:
            print(0)
            exit()
        ans = min(cnt, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
ls = [i+l-1 for i in range(1, n+1)]

if l >= 0:
    ls.pop(0)
elif n >= abs(l):
    ls.pop(abs(l))
else:
    ls.pop(-1)

print(sum(ls))


Fixed submission:
n, l = map(int, input().split())
ls = [i+l-1 for i in range(1, n+1)]

ls.remove(min(ls, key=abs))
print(sum(ls))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())

cnt = 0
for i in range(a, b+1):
    cnt += 1 if (i % c) != 0 and (i % d) != 0 else 0

print(cnt)


Fixed submission:
from fractions import gcd

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


def f(n):
    x = n//c
    x += n//d
    lcm = c*d//gcd(c, d)
    x -= n//lcm
    return n-x


print(f(b)-f(a-1))

Buggy python submission (verdict: Runtime Error):
from math import gcd

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


def f(n):
    x = n//c
    x += n//d
    lcm = c*d//gcd(c, d)
    x -= n//lcm
    return n-x


print(f(b)-f(a-1))


Fixed submission:
from fractions import gcd

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


def f(n):
    x = n//c
    x += n//d
    lcm = c*d//gcd(c, d)
    x -= n//lcm
    return n-x


print(f(b)-f(a-1))

Buggy python submission (verdict: Runtime Error):
from math import gcd

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


def f(n):
    x = n//c
    x += n//d
    lcm = c*d/gcd(c, d)
    x -= n//lcm
    return n-x


print(f(b)-f(a-1))


Fixed submission:
from fractions import gcd

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


def f(n):
    x = n//c
    x += n//d
    lcm = c*d//gcd(c, d)
    x -= n//lcm
    return n-x


print(f(b)-f(a-1))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = list(map(int, input().split()))
cnt = 0

for i in range(n+1):
    cnt += L[i]
    if cnt > x:
        print(i+1)
        exit()


Fixed submission:
n, x = map(int, input().split())
L = list(map(int, input().split()))
D = [0]
cnt = 0

for i in range(n):
    cnt += L[i]
    if cnt <= x:
        D.append(cnt)

print(len(D))
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
ans = 0
for i in range(3001):
    for j in range(3001):
        v = i*r + j*g
        if n >= v and (n-v) % b == 0:
            ans += 1
print(ans)


Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(3001):
    for j in range(3001):
        v = i*r + j*g
        if n >= v and (n-v) % b == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
ls = [int(input()) for _ in range(5)]
ans = 0
num = []

for i in ls:
    ans += math.ceil(i/10)*10
    if str(i)[-1] != '0':
        num.append(str(i)[-1])

print(ans-10+min([int(i) for i in num]))


Fixed submission:
import math
ls = [int(input()) for _ in range(5)]
ans = 0
num = []

for i in ls:
    ans += math.ceil(i/10)*10
    if str(i)[-1] != '0':
        num.append(str(i)[-1])

if num:
    print(ans-10+min([int(i) for i in num]))
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
cum_sum = [0] * (n+1)

for i in range(n+1):
    cum_sum[i] = s[:i].count('AC')

for _ in range(q):
    l, r = map(int, input().split())
    print(cum_sum[r]-cum_sum[l])


Fixed submission:
n, q = map(int, input().split())
s = input()
cum_sum = [0] * (n+1)

for i in range(n):
    if s[:i+1][-2:] == 'AC':
        cum_sum[i+1] += 1
    cum_sum[i+1] += cum_sum[i]

for _ in range(q):
    l, r = map(int, input().split())
    print(cum_sum[r]-cum_sum[l])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*(10**6)
dp[0] = 0
for i in range(1, n):
    dp[i] = 10**9
    for j in range(1, k+1):
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])


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

dp = [0]*(10**6)
dp[0] = 0
for i in range(1, n):
    dp[i] = 10**9
    for j in range(1, k+1):
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())

l = []

for i in range(N):
    a = list(map(int, input().split()))
    if a[1] <= T:
        l.append(a[0])

print('TLE' if len(l) == 0 else min(l))


Fixed submission:
n = int(input())
if n == 1:
    print('Hello World')
else:
    a, b = [int(input()) for _ in range(2)]
    print(a+b)

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

l = []

for i in range(N):
    a = list(map(int, input().split()))
    if T >= a[1]:
        l.append(a[0])

print('TLE' if len(l) == 0 else min(l))

Fixed submission:
n = int(input())
if n == 1:
    print('Hello World')
else:
    a, b = [int(input()) for _ in range(2)]
    print(a+b)

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

l = []

for i in range(N):
    a = list(map(int, input().split()))
    if T >= a[1]:
        l.append(a[0])

print('TLE' if len(l) == 0 else min(l))


Fixed submission:
n = int(input())
if n == 1:
    print('Hello World')
else:
    a, b = [int(input()) for _ in range(2)]
    print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
div = m//n
INF = 10**18
ans = -INF
for i in range(1, div+1):
    if m % i != 0:
        continue
    if ans < i:
        ans = i
print(ans)


Fixed submission:
n, m = map(int, input().split())
div = m//n
INF = 10**18
ans = -INF
for i in reversed(range(1, div+1)):
    if m % i != 0:
        continue
    if ans < i:
        ans = i
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(10*a+b+c if 10*a+b+c a+10*b+c else a+10*b+c)

Fixed submission:
a, b, c = sorted(map(int, input().split()), reverse=True)
print(10*a+b+c)

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(10a+b if 10a+b>=10b+c else 10b+c)

Fixed submission:
a, b, c = sorted(map(int, input().split()), reverse=True)
print(10*a+b+c)
Buggy python submission (verdict: Runtime Error):
k = int(input())
print((k//2)*((k+1)//2)


Fixed submission:
k = int(input())
n = k//2
print(n*(n+1) if k % 2 == 1 else n**2)
Buggy python submission (verdict: Runtime Error):
k = int(input())
print((k//2)*((k+1)//2)


Fixed submission:
x1, y1, x2, y2 = map(int, input().split())

# 回転行列が王道らしい
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x1-(y2-y1)
y4 = y1+(x2-x1)

print(x3, y3, x4, y4)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
num = [0] * n
for i in range(1, n+1):
    num[i % k] += 1
ans = 0
for a in range(k):
    b = (k-a) % k
    c = (k-a) % k
    if ((b+c) % k != 0):
        continue
    ans += num[a] * num[b] * num[c]
print(ans)


Fixed submission:
n, k = map(int, input().split())
num = [0] * k
for i in range(1, n+1):
    num[i % k] += 1
ans = 0
for a in range(k):
    b = (k-a) % k
    c = (k-a) % k
    if ((b+c) % k != 0):
        continue
    ans += num[a] * num[b] * num[c]
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
num = [0] * n
for i in range(1, n+1):
    num[i % k] += 1
ans = 0
for a in range(k):
    b = (k-a) % k
    c = (k-a) % k
    if ((b+c) % k != 0):
        continue
    ans += num[a] * num[b] * num[c]
print(ans)


Fixed submission:
n, k = map(int, input().split())
num = [0] * k
for i in range(1, n+1):
    num[i % k] += 1
ans = 0
for a in range(k):
    b = (k-a) % k
    c = (k-a) % k
    if ((b+c) % k != 0):
        continue
    ans += num[a] * num[b] * num[c]
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

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


Fixed submission:

s = input()
k = int(input())

# 1の連続性を確認し終わった段階の数字を記録
cnt = 1

if len(s) == 1:
    print(s)
    exit()

for i in range(len(s)-1):
    if s[i] != '1':
        num = s[i]
        break
    if s[i] == s[i+1] == '1':
        cnt += 1

if cnt >= k:
    print(1)
else:
    print(num)
Buggy python submission (verdict: Runtime Error):
s = list(input())

bl = True

if s[0] != 'A':
    bl = False
if s[2:len(s)-1].count('C') != 1:
    bl = False
if s[0] != 'A' and s[2:len(s)-1].count('C') != 1:
    s.remove('A')
    s[2:len(s)-1].remove('C')
    if s not in 'abcdefghijkrmnopqlstuvwxyz':
        bl = False

print('AC' if bl else 'WA')


Fixed submission:
s = list(input())

bl = False
s1 = s[1]
s2 = s[2:len(s)-1]
s3 = s[-1]

if s[0] == 'A' and s[2:len(s)-1].count('C') == 1:
    s2.remove('C')
    s2 = ''.join(s2)
    ss = s1+s2+s3
    if ss.islower():
        bl = True

print('AC' if bl else 'WA')
Buggy python submission (verdict: Runtime Error):
n,m,x=map(int, input().split())
a=map(int, input().split())

left=0
right=0

for i in a:
  if x > int(i):
    left += 1
  elif x < int(i):
    righit += 1
print(min(left,right))

Fixed submission:
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

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

for i in a:
  if x > int(i):
    left += 1
  elif x < int(i):
    righit =+ 1
print(min(left,right))

Fixed submission:
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

n = int(input())
A = sorted(set(map(int, input().split())))


def comb(m, n):
    ans = factorial(m) / factorial(n) / factorial(m-n)
    return ans


max_num = A[-1]
answer = 0
for i in range(n):
    comb_num = comb(max_num, A[i])
    if answer >= comb_num:
        break
    answer = comb_num

print(max_num, A[i-1])


Fixed submission:
from math import factorial

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


max_num = A[-1]
medium = max_num / 2

diff = []
for a in A:
    diff.append(abs(medium-a))

min_index = diff.index(min(diff))
print(max_num, A[min_index])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
array = []
ans = 0

for i in set(A):
    array.append(A.count(i))

array.sort()

if len(set(A)) > k:
    num = len(array) - k
    for i in range(num):
        ans += array[i]

print(ans)


Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
array = {}
ans = 0

for a in A:
    if a in array.keys():
        array[a] += 1
    else:
        array[a] = 1

array = sorted(array.values())

if len(set(A)) > k:
    num = len(array) - k
    for i in range(num):
        ans += array[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
array = {}
ans = 0

for i in set(A):
    array[i] = A.count(i)

sort_array = sorted(array.items(), key=lambda x: x[1])


if len(sort_array) > k:
    num = len(sort_array) - k
    for i in range(num):
        ans += sort_array[i][1]

print(ans)


Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
array = {}
ans = 0

for a in A:
    if a in array.keys():
        array[a] += 1
    else:
        array[a] = 1

array = sorted(array.values())

if len(set(A)) > k:
    num = len(array) - k
    for i in range(num):
        ans += array[i]

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

for i in range(1, n):
    if i**2 <= n:
        ans = min(n, i**2)
    else:
        break

print(ans)


Fixed submission:
n = int(input())

for i in range(1, n+1):
    if i**2 <= n:
        ans = min(n, i**2)
    else:
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

cnt = 0

for a in A:
    for b in B:
        for c in C:
            if a < b < c:
                cnt += 1

print(cnt)


Fixed submission:
import bisect


n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))


cnt = 0

for b in B:
    mid = bisect.bisect_left(A, b)
    bottom = n - bisect.bisect_right(C, b)
    cnt += mid*bottom

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ls = []

for _ in range(n):
    a = int(input())
    if a not in ls:
        ls.append(a)
    else:
        ls.remove(a)

print(len(ls))


Fixed submission:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
cnt = 0

for _ in range(n):
    d[int(input())] += 1

for i in d.values():
    if i % 2 == 1:
        cnt += 1

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

n = int(input())
A = map(int, input().split())
C = defaultdict(int)
for a in A:
    C[a] += 1
C = sorted(C.items(), key=lambda x: x[1])
rods = []
for k, v in C:
    if v >= 4:
        rods.append(k, k)
        break
    if v >= 2:
        rods.append(k)
    if len(rods) == 2:
        break
if len(rods) >= 2:
    ans = rods[0]*rods[1]
else:
    ans = 0
print(ans)


Fixed submission:
from collections import Counter

n = int(input())
A = Counter(list(map(int, input().split())))
A = sorted(A.most_common(), reverse=True)
rods = []
for a in A:
    if a[1] >= 4:
        rods.append(a[0])
        rods.append(a[0])
        break
    if a[1] >= 2:
        rods.append(a[0])
    if len(rods) == 2:
        break
if len(rods) >= 2:
    ans = rods[0]*rods[1]
else:
    ans = 0
print(ans)