Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * (n + 1) for _ in [0, 1]]
dp[0][0] = 0
dp[1][0] = -1 * 10 ** 10
for i in range(n):
    for j in [0, 1]:
        dp[j][i + 1] = max(dp[0][i] + (-1)**j * a[i],
                           dp[1][i] + (-1)**(j + 1) * a[i])
print(dp[n][0])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a_min = 0
minus_count = 0
for i in a:
    if i < 0:
        minus_count += 1
a = [abs(e) for e in a]
if minus_count % 2 != 0:
    a_min = a.pop(a.index(min(a)))
ans = sum(a) - a_min
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
minus_count = 0
for i in a:
    if i < 0:
        minus_count += 1
a = [abs(e) for e in a]
if minus_count % 2 != 0:
    a_min = a.pop(a.index(min(a)))
ans = sum(a) - a_min
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a_min = 0
minus_count = 0
for i in a:
    if i < 0:
        minus_count += 1
a = [abs(e) for e in a]
if minus_count % 2 != 0:
    a_min = a.pop(a.index(min(a)))
ans = sum(a) - a_min
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
t = []
for i in set(range(x)):
    for j in set(range(y)):
        for l in set(range(z)):
            if (i+1) * (j+1) * (l+1) <= k:
                t.append(a[i]+b[j]+c[l])
            else:
                break
t.sort(reverse=True)
for i in range(k):
    print(t[i])

Fixed submission:
s = []
for i in range(5):
    s.append(int(input()))
k = int(input())
flag = True
for x in s:
    for y in s:
        if x != y:
            z = x - y
            if z <= k:
                pass
            else:
                flag = False
if flag:
    print('Yay!')
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for i in range(x):
  for j in range(y):
    for k in range(z):
      if (i+1)*(j+1)*(k+1)<=K:
        ans.append(a[i]+b[j]+c[k])
      else:
        break
ans.sort(reverse=True)
for i in range(K):
  print(ans[i])

Fixed submission:
s = []
for i in range(5):
    s.append(int(input()))
k = int(input())
flag = True
for x in s:
    for y in s:
        if x != y:
            z = x - y
            if z <= k:
                pass
            else:
                flag = False
if flag:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
nl = set(range(nl))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = map(int, input().split())
    ans = t[l2-1] - t[l1-1]
    print(ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
nl = set(range(n))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = map(int, input().split())
    ans = t[l2-1] - t[l1-1]
    print(ans)

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


n, q = map(int, input().split())
s = input()
ql = set(range(q))
for i in ql:
    ans = 0
    l1, l2 = map(int, input().split())
    s_part = s[l1 - 1:l2]
    s_re = re.findall(r'(AC)', s_part)
    ans = len(s_re)
    print(ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
nl = set(range(n))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = map(int, input().split())
    ans = t[l2-1] - t[l1-1]
    print(ans)

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


n, q = map(int, input().split())
s = input()
ql = set(range(q))
for i in ql:
    ans = 0
    l1, l2 = map(int, input().split())
    s_part = s[l1 - 1:l2]
    s_re = re.findall(r'(AC)', s_part)
    for j in s_re:
        if j == 'AC':
            ans += 1
    else:
        print(ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
nl = set(range(n))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = map(int, input().split())
    ans = t[l2-1] - t[l1-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ql = set(range(q))
for i in ql:
    ans = 0
    l1, l2 = map(int, input().split())
    s_part = s[l1 - 1:l2]
    sl = set(range(len(s_part)))
    for j in sl:
        if s_part[j:j+2] == 'AC':
            ans += 1
    else:
        print(ans)

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
nl = set(range(n))
for i in nl:
    t[i + 1] = t[i] + (1 if s[i:i + 2] == 'AC' else 0)
ql = set(range(q))
for i in ql:
    l1, l2 = map(int, input().split())
    ans = t[l2-1] - t[l1-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = a
abl = set(range(a + 1, b + 1))
for ab in abl:
    ans = ans ^ ab
print(ans)

Fixed submission:
a, b = map(int, input().split())
if a == b:
    ans = a
elif a % 2 == 0:
    if (b - a) % 4 == 0:
        ans = 0 ^ b
    elif (b - a) % 4 == 2:
        ans = 1 ^ b
    elif (b - a) % 4 == 1:
        ans = 1
    else:
        ans = 0
else:
    if (b - a) % 4 == 0:
        ans = a ^ 0
    elif (b - a) % 4 == 2:
        ans = a ^ 1
    elif (b - a) % 4 == 1:
        ans = a ^ 0 ^ b
    else:
        ans = a ^ 1 ^ b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = a
for ab in range(a + 1, b + 1):
    ans = ans ^ ab
print(ans)

Fixed submission:
a, b = map(int, input().split())
if a == b:
    ans = a
elif a % 2 == 0:
    if (b - a) % 4 == 0:
        ans = 0 ^ b
    elif (b - a) % 4 == 2:
        ans = 1 ^ b
    elif (b - a) % 4 == 1:
        ans = 1
    else:
        ans = 0
else:
    if (b - a) % 4 == 0:
        ans = a ^ 0
    elif (b - a) % 4 == 2:
        ans = a ^ 1
    elif (b - a) % 4 == 1:
        ans = a ^ 0 ^ b
    else:
        ans = a ^ 1 ^ b
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
ans = [e for e in range(1, min(a, b) // 2 + 1) if (a % e) + (b % e) == 0]
print(ans[-k])

Fixed submission:
a, b, k = map(int, input().split())
ans = [e for e in range(1, min(a, b) + 1) if (a % e) + (b % e) == 0]
print(ans[-k])
Buggy python submission (verdict: Runtime Error):
import bisect


A, B, Q = map(int, input().split())
s = [-10 ** 9] + [int(input()) for _ in range(A)] + [10 ** 9]
t = [-10 ** 9] + [int(input()) for _ in range(B)] + [10 ** 9]
x = [int(input()) for _ in range(Q)]
for i in x:
    si = bisect.bisect_left(s, i)
    ti = bisect.bisect_left(t, i)
    s1, s2 = s[si - 1], s[si]
    t1, t2 = t[ti - 1], t[ti]
    ans = 10 ** 9
    for ss in [s1, s2]:
        for tt in [t1, t2]:
            ans = min(ans, abs(i - ss) + abs(ss - tt),
                      abs(i - tt) + abs(ss - tt))
    print(ans)

Fixed submission:
import bisect


A, B, Q = map(int, input().split())
s = [-10 ** 12] + [int(input()) for _ in range(A)] + [10 ** 12]
t = [-10 ** 12] + [int(input()) for _ in range(B)] + [10 ** 12]
x = [int(input()) for _ in range(Q)]
for i in x:
    si = bisect.bisect_left(s, i)
    ti = bisect.bisect_left(t, i)
    s1, s2 = s[si - 1], s[si]
    t1, t2 = t[ti - 1], t[ti]
    ans = 10 ** 12
    for ss in [s1, s2]:
        for tt in [t1, t2]:
            ans = min(ans, abs(i - ss) + abs(ss - tt),
                      abs(i - tt) + abs(ss - tt))
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = math.gcd(B, A[i])
print(B)

Fixed submission:
import fractions

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = fractions.gcd(B, A[i])
print(B)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 10 ** 12


def progress():
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            if (A[j] % A[i] != 0) and (A[j] // A[i]):
                A[j] %= A[i]
                progress()
            if min(A) == 1:
                break
        if min(A) == 1:
            break
    return min(A)

ans = progress()
print(ans)

Fixed submission:
import fractions

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = fractions.gcd(B, A[i])
print(B)

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

def progress():
    for i in range(N):
        hp = A[i]
        for j in range(N):
            if i == j:
                continue
            if A[i] > A[j]:
                A[i] -= A[j]
                progress()
            if min(A) == 1:
                break
        if min(A) == 1:
            break
    return min(A)

ans = progress()
print(ans)

Fixed submission:
import fractions

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = fractions.gcd(B, A[i])
print(B)

Buggy python submission (verdict: Runtime Error):
def progress():
    for i in range(N):
        hp = A[i]
        for j in range(N):
            if i == j:
                continue
            if A[i] > A[j]:
                A[i] -= A[j]
                progress()
            if min(A) == 1:
                break
        if min(A) == 1:
            break
    return min(A)

ans = progress()
print(ans)

Fixed submission:
import fractions

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = fractions.gcd(B, A[i])
print(B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
dp = [10**9] * (N + 1)


def f(i):
    if dp[i] < 10 ** 9:
        return dp[i]
    if i == 0:
        return 0
    else:
        v1 = f(i - 1) + abs(h[i] - h[i - 1])
        if i >= 2:
            v2 = f(i - 2) + abs(h[i] - h[i - 2])
        else:
            v2 = 10 ** 9
        dp[i] = min(v1, v2)
    return dp[i]


if __name__ == '__main__':
    ans = f(N - 1)
    print(ans)

Fixed submission:
def a():
    N = int(input())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
        if i > 1:
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    return dp[i]

  
if __name__ == '__main__':
    ans = a()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def b():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K + 1):
            if i >= j:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
    return dp[i]


if __name__ == '__main__':
    ans = b()
    print(ans)

Fixed submission:
def b():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K + 1):
            if i >= j:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
    return dp[i]


if __name__ == '__main__':
    ans = b()
    print(ans)
Buggy python submission (verdict: Runtime Error):
def c():
    N = int(input())
    abc = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * N for _ in range(3)]
    for i in range(N):
        dp[0][i] = max(dp[1][i - 1] + abc[i][0], dp[2][i - 1] + abc[i][0])
        dp[1][i] = max(dp[0][i - 1] + abc[i][1], dp[2][i - 1] + abc[i][1])
        dp[2][i] = max(dp[0][i - 1] + abc[i][2], dp[1][i - 1] + abc[i][2])
    return max(dp[:][i])


if __name__ == '__main__':
    ans = c()
    print(ans)

Fixed submission:
def c():
    N = int(input())
    abc = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * N for _ in range(3)]
    dp[0][0], dp[1][0], dp[2][0] = abc[0][0], abc[0][1], abc[0][2]
    i = 0
    for i in range(1, N):
        dp[0][i] = max(dp[1][i - 1] + abc[i][0], dp[2][i - 1] + abc[i][0])
        dp[1][i] = max(dp[0][i - 1] + abc[i][1], dp[2][i - 1] + abc[i][1])
        dp[2][i] = max(dp[0][i - 1] + abc[i][2], dp[1][i - 1] + abc[i][2])
    return max(dp[0][i], dp[1][i], dp[2][i])


if __name__ == '__main__':
    ans = c()
    print(ans)
Buggy python submission (verdict: Runtime Error):
def e():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    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] >= 0:
                dp[i + 1][j] = max(dp[i + 1][j],
                                   dp[i][j - wv[i][0]] + wv[i][1])
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
    return dp[-1][-1]


if __name__ == '__main__':
    ans = e()
    print(ans)


Fixed submission:
def e():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    v = [wv[i][1] for i in range(len(wv))]
    V = sum(v)
    dp = [[10 ** 9] * (V + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(V + 1):
            if j - wv[i][1] >= 0:
                dp[i + 1][j] = min(dp[i + 1][j],
                                   dp[i][j - wv[i][1]] + wv[i][0])
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
    for k, p in enumerate(dp[-1]):
        if p <= W:
            r = k
    return r


if __name__ == '__main__':
    ans = e()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def f():
    # 入力から文字列を生成していく？
    s = input()
    t = input()
    ls, lt = len(s), len(t)
    dp = [[0] * (ls + 1) for _ in range(lt + 1)]
    for i in range(lt):
        for j in range(ls):
            if s[j] == t[i]:
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
    r = ''
    i += 1
    j += 1
    while (i > 0 and j > 0):
        if dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j]:
            i -= 1
        else:
            r = s[j - 1] + r
            j -= 1
            i -= 1
    return r


if __name__ == '__main__':
    ans = f()
    print(ans)

Fixed submission:
def f():
    s = input()
    t = input()
    ls, lt = len(s), len(t)
    dp = [[0] * (ls + 1) for _ in range(lt + 1)]
    for i in range(lt):
        for j in range(ls):
            if s[j] == t[i]:
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
    r = ''
    i += 1
    j += 1
    while (i > 0 and j > 0):
        if dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j]:
            i -= 1
        else:
            r = s[j - 1] + r
            j -= 1
            i -= 1
    return r
 
 
if __name__ == '__main__':
    ans = f()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
H = []
for i in range(1, N):
    H.append(h[i] - h[i - 1])
ans = 10 ** 9
for i in range(N - 1):
    if i + K <= N:
        ans = min(ans, sum(H[i:i + K - 1]))
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
H = []
for i in range(1, N):
    H.append(h[i] - h[i - 1])
ans = sum(H[0:K - 1])
tmp = ans
for i in range(N - 1):
    if i + K < N:
        tmp = tmp + H[i + K - 1] - H[i]
        ans = min(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
AS = [0]
for i in range(N):
    AS += [AS[i] + A[i]]
AN = []
for i in range(N):
    for j in range(i, N):
        AN += [AS[j + 1] - AS[i]]
ans = 0
for i in range(41, -1, -1):
    c = 0
    p = ans + 2 ** i
    for x in AN:
        if p & x == p:
            c += 1
    if c >= K:
        ans += 2 ** i
print(ans)


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
AS = [0]
for i in range(N):
    AS += [AS[i] + A[i]]
AN = []
for i in range(N):
    for j in range(i, N):
        AN += [AS[j + 1] - AS[i]]
ans = 0
for i in range(41, -1, -1):
    c = 0
    p = ans + 2 ** i
    for x in AN:
        if p & x == p:
            c += 1
    if c >= K:
        ans += 2 ** i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
AS = [0]
for i in range(N):
    AS += [AS[i] + A[i]]
AN = []
for i in range(N):
    for j in range(i, N):
        AN += [AS[j + 1] - AS[i]]
selected = [0] * len(AN)
ans = 0
for i in range(100, -1, -1):
    c = 0
    p = ans + 2 ** i
    for x in AN:
        if p & x == p:
            c += 1
            selected[i]
    if c >= K:
        ans += 2 ** i
print(ans)


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
AS = [0]
for i in range(N):
    AS += [AS[i] + A[i]]
AN = []
for i in range(N):
    for j in range(i, N):
        AN += [AS[j + 1] - AS[i]]
ans = 0
for i in range(41, -1, -1):
    c = 0
    p = ans + 2 ** i
    for x in AN:
        if p & x == p:
            c += 1
    if c >= K:
        ans += 2 ** i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000000)


N, M = map(int, input().split())
x, y, z = [], [], []
for _ in range(N):
    xyz = list(map(int, input().split()))
    x += [xyz[0]]
    y += [xyz[1]]
    z += [xyz[2]]


def func(i, j, fx, fy, fz, v):
    if i > N - 1 or j > M - 1:
        return v
    r1 = func(i + 1, j + 1, fx + x[i], fy + y[i], fz + z[i],
              abs(fx + x[i]) + abs(fy + y[i]) + abs(fz + z[i]))
    r2 = func(i + 1, j, fx, fy, fz, v)
    v = max(r1, r2)
    return v


print(func(0, 0, 0, 0, 0, 0))


Fixed submission:
N, M = map(int, input().split())
xyz = []
ans = 0
for _ in range(N):
    xyz += [list(map(int, input().split()))]
for b in range(2 ** 3):
    pm = [1] * 3
    for j in range(3):
        if (b >> j) & 1:
            pm[j] *= -1
    r = []
    for i in range(N):
        r += [pm[0] * xyz[i][0] + pm[1] * xyz[i][1] + pm[2] * xyz[i][2]]
    r.sort(reverse=True)
    ans = max(ans, sum(r[:M]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]


def cake(i, used, x, y, z):
    if i <= N and used >= M:
        return abs(x) + abs(y) + abs(z)
    if i >= N:
        return 0
    r = cake(i+1, used, x, y, z)
    r = max(r, cake(i+1, used+1, x+xyz[i][0], y+xyz[i][1], z+xyz[i][2]))
    return r


ans = cake(0, 0, 0, 0, 0)
print(ans)


Fixed submission:
N, M = map(int, input().split())
xyz = []
ans = 0
for _ in range(N):
    xyz += [list(map(int, input().split()))]
for b in range(2 ** 3):
    pm = [1] * 3
    for j in range(3):
        if (b >> j) & 1:
            pm[j] *= -1
    r = []
    for i in range(N):
        r += [pm[0] * xyz[i][0] + pm[1] * xyz[i][1] + pm[2] * xyz[i][2]]
    r.sort(reverse=True)
    ans = max(ans, sum(r[:M]))
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]


def cake(i, used, x, y, z):
    if i <= N and used >= M:
        return abs(x) + abs(y) + abs(z)
    if i >= N:
        return 0
    r = cake(i+1, used, x, y, z)
    r = max(r, cake(i+1, used+1, x+xyz[i][0], y+xyz[i][1], z+xyz[i][2]))
    return r


ans = cake(0, 0, 0, 0, 0)
print(ans)

Fixed submission:
N, M = map(int, input().split())
xyz = []
ans = 0
for _ in range(N):
    xyz += [list(map(int, input().split()))]
for b in range(2 ** 3):
    pm = [1] * 3
    for j in range(3):
        if (b >> j) & 1:
            pm[j] *= -1
    r = []
    for i in range(N):
        r += [pm[0] * xyz[i][0] + pm[1] * xyz[i][1] + pm[2] * xyz[i][2]]
    r.sort(reverse=True)
    ans = max(ans, sum(r[:M]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A1:
    AN[a] = A.count(a)
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A:
    if not a in AN:
        AN[a] = 0
    AN[a] += 1
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A1:
    AN[a] = A.count(a)
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A:
    if not a in AN:
        AN[a] = 0
    AN[a] += 1
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')
Buggy python submission (verdict: Runtime Error):
a=input()
print(a*a)

Fixed submission:
a=int(input())
print(a*a)
Buggy python submission (verdict: Time Limit Exceeded):
string=list(input())
N=len(string)
num=[0]*(N+1)
sum0=0
if string==[">"]:
     sum0=1
else:
     for i in range(N):
          if string[i]=="<":
               num[i+1]=num[i]+1
          else:
               if num[i]==0:
                    num[i+1]=0
                    for j in range(N):
                         num[i-j]+=1
                         if ((i-j-2)<0 or string[i-j-2]=="<"):
                              if num[i-j-1]<=num[i-j]:
                                   num[i-j-1]=num[i-j]+1
                              break
     sum0=0
     for i in range(N+1):
          sum0=sum0+num[i]
print(sum0)

Fixed submission:
S = input()
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = max(a[i+1], a[i]+1)
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i], a[i+1]+1)
      
print(sum(a))

Buggy python submission (verdict: Runtime Error):
S = inp
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = max(a[i+1], a[i]+1)
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i], a[i+1]+1)
      
print(sum(a))

Fixed submission:
S = input()
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = max(a[i+1], a[i]+1)
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i], a[i+1]+1)
      
print(sum(a))
Buggy python submission (verdict: Runtime Error):
string = input()
one = 0
zero = 0
for s in string:
    if s == '1':
        ones += 1
    else:
        zeros += 1

print(2*min(one, zero))


Fixed submission:
import math

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

required = a * c
limit = b

if required <= limit:
    print(c)
else:
    print(math.floor(b / a))