Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
li_q = list()
for i in range(m):
    li_q.append(tuple(input().split()))

ac_count = 0
wa_count = 0

for v in range(1, n +1):
    if (str(v), 'AC') in li_q:
        ac_count += 1
        ac_idx = li_q.index((str(v), 'AC'))
        wa_count += li_q[:ac_idx].count((str(v), 'WA'))

print(ac_count, wa_count)


Fixed submission:
n, m = map(int, input().split())
li_q = list()
for i in range(m):
    li_q.append(tuple(input().split()))

ac_count = 0
wa_count = 0

s_ac = set()
d_wa = dict()
for l in li_q:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_count += 1
            wa_count += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1

print(ac_count, wa_count)
Buggy python submission (verdict: Runtime Error):
import math

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

print((a * b) // math.gcd(a, b))


Fixed submission:
# import math
import fractions

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

print((a * b) // fractions.gcd(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
li_a = list(map(int, input().split()))
li_w = li_a
for i in range(m):
    li_w = sorted(li_w, reverse=True)
    li_w[0] = li_w[0] // 2

print(sum(li_w))


Fixed submission:
import heapq
import math

n, m = map(int, input().split())
li_a = list(map(lambda x: x * -1, (map(int, input().split()))))
heapq.heapify(li_a)


for i in range(m):
    w = heapq.heappop(li_a)
    heapq.heappush(li_a, math.ceil(w / 2))

print(sum(li_a) * -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

print(sum(range(1, n)))



Fixed submission:
n = int(input())

print((n * (n - 1))// 2)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        di[tmp] += 1

for v in di.values():
    if v > 1:
        answer += int(math.factorial(v) / 2)
print(answer)


Fixed submission:
import math

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        answer += di[tmp]
        di[tmp] += 1

print(answer)

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

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        di[tmp] += 1

for v in di.values():
    if v > 1:
        answer += (math.factorial(v) / 2)
print(answer)




Fixed submission:
import math

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        answer += di[tmp]
        di[tmp] += 1

print(answer)

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

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        di[tmp] += 1

for v in di.values():
    if v > 1:
        answer += int(math.factorial(v) / 2)
print(answer)




Fixed submission:
import math

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        answer += di[tmp]
        di[tmp] += 1

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li_a = list()
d_a = dict()

for _ in range(n):
    wk = int(input())
    li_a.append(wk)

    get = d_a.get(wk, 0)
    d_a[wk] = get + 1

for i in range(n):
    d_a_copy = d_a.copy()
    if d_a_copy.get(li_a[i], 0) == 1:
        d_a_copy.pop(li_a[i])
    print(max(d_a_copy.keys()))




Fixed submission:
n = int(input())
li_a = list()
d_a = dict()

for _ in range(n):
    wk = int(input())
    li_a.append(wk)

    get = d_a.get(wk, 0)
    d_a[wk] = get + 1

li_top2 = sorted(d_a.keys(), reverse=True)[:2]

for i in range(n):
    val = li_a[i]

    if val not in li_top2:
        print(li_top2[0])
    else:
        if val == li_top2[0] and d_a.get(val, 0) == 1:
            print(li_top2[1])
        else:
            print(li_top2[0])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li_a = list()
d_a = dict()

for _ in range(n):
    wk = int(input())
    li_a.append(wk)

    get = d_a.get(wk, 0)
    d_a[wk] = get + 1

for i in range(n):
    print(max(k for k, v in d_a.items() if not (k == li_a[i] and v == 1)))


Fixed submission:
n = int(input())
li_a = list()
d_a = dict()

for _ in range(n):
    wk = int(input())
    li_a.append(wk)

    get = d_a.get(wk, 0)
    d_a[wk] = get + 1

li_top2 = sorted(d_a.keys(), reverse=True)[:2]

for i in range(n):
    val = li_a[i]

    if val not in li_top2:
        print(li_top2[0])
    else:
        if val == li_top2[0] and d_a.get(val, 0) == 1:
            print(li_top2[1])
        else:
            print(li_top2[0])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li_a = list()
for _ in range(n):
    li_a.append(int(input()))

for i in range(n):
    li_w = li_a[::]
    li_w.pop(i)
    print(max(li_w))

Fixed submission:
n = int(input())
li_a = list()
d_a = dict()

for _ in range(n):
    wk = int(input())
    li_a.append(wk)

    get = d_a.get(wk, 0)
    d_a[wk] = get + 1

li_top2 = sorted(d_a.keys(), reverse=True)[:2]

for i in range(n):
    val = li_a[i]

    if val not in li_top2:
        print(li_top2[0])
    else:
        if val == li_top2[0] and d_a.get(val, 0) == 1:
            print(li_top2[1])
        else:
            print(li_top2[0])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

li_w = list()

for _ in range(m):
    li_w.append(tuple(map(int, input().split())))

answer = set()

for idx, w in enumerate(li_w):
    if idx == 0:
        answer = set(range(w[0], w[1] + 1))
    else:
        answer = answer.intersection(range(w[0], w[1] + 1))

print(len(answer))


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

li_w = list()

for _ in range(m):
    li_w.append(tuple(map(int, input().split())))

w_l = 0
w_r = 999999

for w in li_w:
    w_l = max(w_l, w[0])
    w_r = min(w_r, w[1])


if w_r >= w_l:
    print(w_r - w_l + 1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

counter = 0
for r in range((N // R) + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)):
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)


Fixed submission:
R, G, B, N = map(int, input().split())

counter = 0
for r in range((N // R) + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0:
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)

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

counter = 0
for r in range(N + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)):
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)


Fixed submission:
R, G, B, N = map(int, input().split())

counter = 0
for r in range((N // R) + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0:
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)

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

counter = 0
for r in range(N + 1):
    for g in range(N + 1 - (r * R)):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)):
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)


Fixed submission:
R, G, B, N = map(int, input().split())

counter = 0
for r in range((N // R) + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0:
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

answer = n

for i in range(n + 1):
    answer = min(answer, s[:i].count("#") + s[i:].count("."))

print(answer)



Fixed submission:
n = int(input())
s = input()


left_black = 0
right_white = s.count(".")
answer = left_black + right_white

for w in s:
    if w == "#":
        left_black += 1
    else:
        right_white -= 1
    answer = min(answer, left_black + right_white)

print(answer)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

mi = min(t % 10 for t in [a, b, c, d, e] if t % 10 != 0)
# print(mi)

# print([wt + (10 - (wt % 10)) if wt % 10 != 0 else wt for wt in [a, b, c, d, e]])
print(sum([wt + (10 - (wt % 10)) if wt % 10 != 0 else wt for wt in [a, b, c, d, e]]) - 10 + mi)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


ar = [t % 10 for t in [a, b, c, d, e] if t % 10 != 0]
if len(ar) == 0:
    ar.append(0)
mi = min(ar)


# print(mi)

# print([wt + (10 - (wt % 10)) if wt % 10 != 0 else wt for wt in [a, b, c, d, e]])
w = sum([wt + (10 - (wt % 10)) if wt % 10 != 0 else wt for wt in [a, b, c, d, e]])

if mi > 0:
    w = w - 10 + mi
print(w)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
li_lr = list()

li_flg = [0] * len(s)

for i in range(q):
    li_lr.append(list(map(int, input().split())))


for idx, v in enumerate(s):
    if v == 'A':
        if idx != len(s) and s[idx + 1] == 'C':
            li_flg[idx] = 1


for l in li_lr:
    li_w = li_flg[l[0] - 1: l[1]]
    if li_w[-1] == 1:
        print(sum(li_w) - 1)
    else:
        print(sum(li_w))



Fixed submission:
n, q = map(int, input().split())
s = input()
li_lr = list()

li_flg = [0] * len(s)

for i in range(q):
    li_lr.append(list(map(int, input().split())))


for idx, v in enumerate(s):
    if v == 'C' and idx != 0 and s[idx - 1] == 'A':
        li_flg[idx] = li_flg[idx - 1] + 1
    else:
        li_flg[idx] = li_flg[idx - 1]

for l in li_lr:
    print(li_flg[l[1] - 1] - li_flg[l[0] - 1])

Buggy python submission (verdict: Time Limit Exceeded):

n, q = map(int, input().split())
s = input()
li_lr = list()

li_flg = [0] * len(s)

for i in range(q):
    li_lr.append(list(map(int, input().split())))


for idx, v in enumerate(s):
    if v == 'C':
        if idx != 0 and s[idx - 1] == 'A':
            li_flg[idx] = 1


for l in li_lr:
    li_w = li_flg[l[0] - 1: l[1]]
    if li_w[0] == 1:
        print(sum(li_w) - 1)
    else:
        print(sum(li_w))



Fixed submission:
n, q = map(int, input().split())
s = input()
li_lr = list()

li_flg = [0] * len(s)

for i in range(q):
    li_lr.append(list(map(int, input().split())))


for idx, v in enumerate(s):
    if v == 'C' and idx != 0 and s[idx - 1] == 'A':
        li_flg[idx] = li_flg[idx - 1] + 1
    else:
        li_flg[idx] = li_flg[idx - 1]

for l in li_lr:
    print(li_flg[l[1] - 1] - li_flg[l[0] - 1])

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

n, q = map(int, input().split())
s = input()
li_lr = list()
pt = re.compile('AC')

for i in range(q):
    li_lr.append(list(map(int, input().split())))

for l in li_lr:
    print(len(re.findall(pt, s[l[0] - 1: l[1]])))



Fixed submission:
n, q = map(int, input().split())
s = input()
li_lr = list()

li_flg = [0] * len(s)

for i in range(q):
    li_lr.append(list(map(int, input().split())))


for idx, v in enumerate(s):
    if v == 'C' and idx != 0 and s[idx - 1] == 'A':
        li_flg[idx] = li_flg[idx - 1] + 1
    else:
        li_flg[idx] = li_flg[idx - 1]

for l in li_lr:
    print(li_flg[l[1] - 1] - li_flg[l[0] - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

li_h = list(map(int, input().split()))


li_cost = [float("inf")] * n

li_cost[0] = 0

# i = 現在の足場
for i in range(n):
    #for a in range(1, k + 1):
    w = min(k + 1, n - i)
    for a in range(1, w):
        if i + a < n:
            li_cost[i + a] = min(abs(li_h[i] - li_h[i + a]) + li_cost[i], li_cost[i + a])

print(li_cost[-1])



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

li_h = list(map(int, input().split()))


dp = [float("inf")] * n

dp[0] = 0

for i in range(1, n):
    w = i - k if i - k > 0 else 0
    dp[i] = min([cost + abs(height - li_h[i]) for cost, height in zip(dp[w:i], li_h[w:i])])

print(dp[-1])

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

li_h = list(map(int, input().split()))


li_cost = [float("inf")] * n

li_cost[0] = 0

# i = 現在の足場
for i in range(n):
    for a in range(1, k + 1):
        if i + a < n:
            li_cost[i + a] = min(abs(li_h[i] - li_h[i + a]) + li_cost[i], li_cost[i + a])

print(li_cost[-1])



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

li_h = list(map(int, input().split()))


dp = [float("inf")] * n

dp[0] = 0

for i in range(1, n):
    w = i - k if i - k > 0 else 0
    dp[i] = min([cost + abs(height - li_h[i]) for cost, height in zip(dp[w:i], li_h[w:i])])

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
li_input = list()
cities = dict()

for i in range(m):
    li_input.append(list(map(int, input().split())))

for pref in {i[0] for i in li_input}:
    t_city = list(filter(lambda x: x[0] == pref, li_input))
    for idx, city in enumerate(sorted(t_city, key=lambda x: x[1]), start=1):
        cities[str(city[1])] = idx

for c in li_input:
    print('{0:06}{1:06}'.format(c[0], cities[str(c[1])]))


Fixed submission:
n, m = map(int, input().split())
li_input = list()
counter = dict()
cities = dict()

for i in range(m):
    li_input.append(list(map(int, input().split())))

sorted_city = sorted(li_input, key=lambda x: x[1])

for c in sorted_city:
    idx = counter.get(c[0], 0)
    cities[c[1]] = idx

    # count up
    counter[c[0]] = idx + 1


for c in li_input:
    print('{0:06}{1:06}'.format(c[0], cities[c[1]] + 1))
Buggy python submission (verdict: Runtime Error):
int_k = int(input())

if int_k % 2 == 0:
    print((int_k // 2) ** 2)
else:
    print((int_k // 2) * ((int_k //2) + 1))


Fixed submission:
int_x1, int_y1, int_x2, int_y2 = map(int, input().split())

int_x3 = int_y3 = int_x4 = int_y4 = 0

int_x = int_x2 - int_x1
int_y = int_y2 - int_y1

print(int_x2 - int_y, int_y2 + int_x, int_x1 - int_y, int_y1 + int_x)
Buggy python submission (verdict: Runtime Error):
int_n = int(input())

bin_number = format(int_n, 'b')

bin_sum = sum(list(map(int, list(str(bin_number)))))

if int_n % bin_sum == 0:
    print("Yes")
else:
    print("No")



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

print([i * (100 ** d) for i in range(1, 102) if i != 100][n - 1])
Buggy python submission (verdict: Time Limit Exceeded):
# TODO:累積和を使った手法

int_n = int(input())
str_s = input()

changes = 999999

for i in range(int_n):
    member_left = str_s[:i]
    member_right = str_s[i + 1:]
    # print(i)
    # print("left:" + member_left, "right:" + member_right)

    this_change = (member_left.count("W") + member_right.count("E"))

    changes = this_change if (changes >= this_change) else changes

print(changes)





Fixed submission:
int_n = int(input())
str_s = input()

li_west = [0] * int_n
for i in range(int_n - 1):
    if str_s[i] == 'W':
        li_west[i + 1] = li_west[i] + 1
    else:
        li_west[i + 1] = li_west[i]
li_east = [0] * int_n

for i in range(int_n - 1, 0, -1):
    if str_s[i] == 'E':
        li_east[i - 1] = li_east[i] + 1
    else:
        li_east[i - 1] = li_east[i]

minimum = 999999
for i in range(int_n):
    int_w = li_west[i] + li_east[i]
    minimum = min(minimum, int_w)

print(minimum)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split())

if a == b == c:
    print(0)
    exit(0)
for i in range(k):
    w_a = b + c
    w_b = a + c
    w_c = a + b
    a = w_a
    b = w_b
    c = w_c
print(a - b)


Fixed submission:
a, b, c, k = map(int, input().split())

if k % 2 == 0:
    print(a - b if abs(a - b) < 10 ** 18 else 'Unfair')
else:
    print(b - a if abs(b - a) < 10 ** 18 else 'Unfair')
Buggy python submission (verdict: Time Limit Exceeded):
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    if len(result) == int_k and str_s[f] > result[-1][0]:
        continue
    for t in range(f + 1, len(str_s) + 1):
        pattern.add(str_s[f:t])
        result = sorted(set(result + sorted(list(pattern))[:int_k]))[:int_k]

print(result[-1])


Fixed submission:
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    for t in range(f + 1, f + 1 + int_k):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    if len(result) == int_k and str_s[f] > result[-1][0]:
        continue
    for t in range(f + 1, len(str_s) + 1):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])



Fixed submission:
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    for t in range(f + 1, f + 1 + int_k):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    for t in range(f + 1, len(str_s) + 1):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])



Fixed submission:
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    for t in range(f + 1, f + 1 + int_k):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])

Buggy python submission (verdict: Time Limit Exceeded):
str_s = input()
int_k = int(input())

pattern = set()

for f in range(len(str_s) + 1):
    for t in range(f + 1, len(str_s) + 1):
        pattern.add(str_s[f:t])

print(sorted(list(pattern))[int_k - 1])




Fixed submission:
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    for t in range(f + 1, f + 1 + int_k):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])
Buggy python submission (verdict: Runtime Error):
int_a, int_b, int_k = map(int, input().split())

ar = list(range(int_a, int_b + 1))

minset = set(range(int_a, int_a + int_k))
maxset = set(range(int_b - int_k + 1, int_b + 1))

result = list(minset | maxset)
result.sort()
for i in result:
    if int_a <= i <= int_b:
        print(i)



Fixed submission:
int_a, int_b, int_k = map(int, input().split())

minset = set(range(int_a, int_a + int_k))
maxset = set(range(int_b - int_k + 1, int_b + 1))

result = list(minset | maxset)
result.sort()
for i in result:
    if int_a <= i <= int_b:
        print(i)

Buggy python submission (verdict: Runtime Error):
int_a, int_b, int_k = map(int, input().split())

ar = list(range(int_a, int_b + 1))

minset = set(range(int_a, int_a + int_k + 1))
maxset = set(range(int_b - int_k + 1, int_b + 1))

result = list(minset | maxset)
result.sort()
for i in result:
    if int_a <= i <= int_b:
        print(i)



Fixed submission:
int_a, int_b, int_k = map(int, input().split())

minset = set(range(int_a, int_a + int_k))
maxset = set(range(int_b - int_k + 1, int_b + 1))

result = list(minset | maxset)
result.sort()
for i in result:
    if int_a <= i <= int_b:
        print(i)

Buggy python submission (verdict: Runtime Error):
int_a, int_b, int_k = map(int, input().split())

ar = list(range(int_a, int_b + 1))

minset = set(ar[:int_k])
maxset = set(ar[int_k * -1:])

result = list(minset | maxset)
result.sort()
for i in result:
    print(i)



Fixed submission:
int_a, int_b, int_k = map(int, input().split())

minset = set(range(int_a, int_a + int_k))
maxset = set(range(int_b - int_k + 1, int_b + 1))

result = list(minset | maxset)
result.sort()
for i in result:
    if int_a <= i <= int_b:
        print(i)

Buggy python submission (verdict: Runtime Error):
int_a, int_b, int_k = map(int, input().split())

ar = list(range(int_a, int_b + 1))

minset = set(ar[:int_k])
maxset = set(ar[int_k * -1:])

result = list(minset | maxset)
result.sort()
print(result)



Fixed submission:
int_a, int_b, int_k = map(int, input().split())

minset = set(range(int_a, int_a + int_k))
maxset = set(range(int_b - int_k + 1, int_b + 1))

result = list(minset | maxset)
result.sort()
for i in result:
    if int_a <= i <= int_b:
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li_a = input().split()

result = 0
for i in set(li_a):
    cnt = li_a.count(i)
    if cnt > int(i):
        result += cnt - int(i)
    elif cnt < int(i):
        result += cnt

print(result)


Fixed submission:
from collections import defaultdict

n = int(input())
li_a = input().split()

ndict = defaultdict(int)

for i in li_a:
    ndict[i] += 1

result = 0
for k in ndict.keys():
    if ndict[k] > int(k):
        result += ndict[k] - int(k)
    elif ndict[k] < int(k):
        result += ndict[k]

print(result)
Buggy python submission (verdict: Runtime Error):
sd = input()
t = input()
li_answer = list()
c_loop = len(sd) - len(t) + 1

for i in range(c_loop):
    if all((w_sd == "?" or w_sd == w_t) for w_sd, w_t in zip(sd[i:i + len(t) + 1], t)):
        s_tmp = str(sd[0:i] + t + sd[i + len(t):]).replace("?", "a")
        li_answer.append(s_tmp)

if li_answer:
    print(sorted(li_answer)[0])
else:
    print("UNRESTORABLE")


                                            ｋ


Fixed submission:
sd = input()
t = input()
li_answer = list()
c_loop = len(sd) - len(t) + 1

for i in range(c_loop):
    if all((w_sd == "?" or w_sd == w_t) for w_sd, w_t in zip(sd[i:i + len(t) + 1], t)):
        s_tmp = str(sd[0:i] + t + sd[i + len(t):]).replace("?", "a")
        li_answer.append(s_tmp)

if li_answer:
    print(sorted(li_answer)[0])
else:
    print("UNRESTORABLE")