Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k ...(1)
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

def solve():
    N = int(input())

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k ...(1)
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

def solve():
    N = int(input())

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if m <= 0: continue
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    A = list(map(int, input().split()))

    # 他のAiにはあって、あるAiに唯一ない約数が答え
    
    candidates = []

    if N == 2:
        print(max(A[0], A[1]))
        return

    candidates = {}
    # まずは0番目の奴の候補を考える
    for i in range(1, A[0]+1):
        if A[0]%i == 0:
            candidates[i] = 1

    for key in candidates.keys():
        if A[1]%key != 0:
            candidates[key] -= 1

    for i in range(1, A[1]+1):
        if A[1]%i == 0:
            if not i in candidates:
                candidates[i] = 0

    import copy
    for i in range(2, N):
        copied_candidates = copy.deepcopy(candidates)
        for key in copied_candidates.keys():
            if A[i]%key == 0:
                pass
            else:
                candidates[key] -= 1
                if candidates[key] < 0:
                    candidates.pop(key)
    
    ans = 0
    for key in candidates.keys():
        ans = max(ans, key)
    
    print(ans)


    

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-
"""解説
GCD, DP, 累積和

「一つを選んで好きな数字に変えられる」とあるが、今回のケースでは「その数字を消す」と同じ。

すべてのGCDを試す

4 6 7 8 10 12 14

という数列が与えられたとき、

・4を消して、ほかの数字のGCDを計算

6 7 8 10 12 14

・6を消して、ほかの数字のGCDを計算

4 7 8 10 12 14

・7を消して、……

というのを全列挙するが、N=10**5なので、O(N**2)では計算が間に合わない。

なのでこれをもう少し高速でやりたい。

GCDは計算順序を問わない性質を利用する。

たとえば、8を消した場合

4 6 7 8 10 12 14
| 左 |× |   右  |

・左のGCD
・右のGCD
を計算し、GCD(左のGCD, 右のGCD)をやってもよい。

・左のGCDを考える
GCD(4) = L[1]
GCD(4 6) = L[2] = GCD(L[1], 6)
GCD(4 6 7) = L[3] = GCD(L[2], 7)
GCD(4 6 7 8) = L[4] = GCD(L[3], 8)
GCD(4 6 7 8 10) = L[5] = GCD(L[4], 10)

みたいな感じで計算できる。

・右のGCDについても同様に計算してやる。

この前計算ができたら、あとは累積和のように、どの数字を削除したときがGCDが最大になるのかを計算する。

"""
import copy

def solve():
    N = int(input())
    A = list(map(int, input().split()))

    def gcd(x, y):
        """ 最大公約数を求める """
        # x > y にしたい
        if y > x:
            x, y = y, x
        if y == 0:
            return x
        return gcd(x%y, y)

    # L[i] := A[i]が消されたときの左側のGCD
    L = [0]*(N+1)
    L[1] = A[0]
    for i in range(2, N):
        L[i] = gcd(L[i-1], A[i-1])

    # R[i] := A[i]が消されたときの右側のGCD
    R = [0]*(N+1)
    R[N-1] = 0
    R[N-2] = A[N-1]
    for i in range(N-3, -1, -1):
        R[i] = gcd(R[i+1], A[i+1])
    
    # 任意の数字を消したときの最大のGCDを求める
    ans = 0
    for i in range(N):
        tmp = gcd(L[i], R[i])
        ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S = input()

    kuro_num = 0
    siro_num = 0
    for moji in S:
        if moji == "#":
            kuro_num += 1
        else:
            siro_num += 1

    if siro_num == N:
        print(0)
        exit()

    # ..........############ のパターン
    rest_kuro_num = kuro_num
    rest_siro_num = siro_num
    ans = siro_num
    for i in range(0, len(S)):
        num = rest_siro_num
        if S[i] == "#":
            num += 1 + (kuro_num - rest_kuro_num)
            rest_kuro_num -= 1
        else:
            num += kuro_num - rest_kuro_num
            rest_siro_num -= 1
        ans = min(ans, num)

    print(ans)

if __name__ == "__main__":
    solve()

Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    A, B, C = list(map(int, input().split()))
    if A <= C and C <= B:
        print("Yes")
    elif A >= C and C >= B:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import math

def solve():
    menus = []
    for i in range(0, 5):
        menus.append(int(input()))
    
    # １の位が最も小さいものを最後に注文する。あとはなんでもいい
    amari = 10
    for i in range(0, 5):
        if menus[i]%10 < amari and menus[i]%10 != 0:
            last = i
            amari = menus[i]%10
    
    ans = 0
    for i in range(0, 5):
        if i == last:
            continue

        ans += menus[i]
        ans = math.ceil(ans/10) * 10
    
    ans += menus[last]
    print(ans)



if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-
import math

def solve():
    menus = []
    for i in range(0, 5):
        menus.append(int(input()))
    
    # １の位が最も小さいものを最後に注文する。あとはなんでもいい
    amari = 10
    last = 0
    for i in range(0, 5):
        if menus[i]%10 < amari and menus[i]%10 != 0:
            last = i
            amari = menus[i]%10
    
    ans = 0
    for i in range(0, 5):
        if i == last:
            continue

        ans += menus[i]
        ans = math.ceil(ans/10) * 10
    
    ans += menus[last]
    print(ans)



if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import fractions

def solve():
    N = input()
    A = list(map(int, input().split()))

    # Aの要素を使って、1以上の作成可能な最も小さい値を作る。それが答え。
    # というか最大公約数が答え。

    ans = A[0]
    for i in range(1, N):
        ans = fractions.gcd(ans, A[i])
    print(ans)

if __name__ == "__main__":
    solve()


Fixed submission:
def gcd(a, b):
    """ 最大公約数。aはbより大きいこと """
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    A.sort(reverse=True)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(ans, A[i])

    print(ans)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):

def gcd(a, b):
    lower = min(a, b)
    bigger = max(a, b)

    for i in range(lower, 0, -1):
        if a%i==0 and b%i==0:
            return i


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    d = 10**9
    for i in range(1, N):
        d = min(gcd(A[0], A[i]), d)

    print(d)


if __name__ == "__main__":
    solve()

Fixed submission:
def gcd(a, b):
    """ 最大公約数。aはbより大きいこと """
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    A.sort(reverse=True)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(ans, A[i])

    print(ans)


if __name__ == "__main__":
    solve()

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

def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    d = 10**9
    for i in range(1, N):
        d = min(math.gcd(A[0], A[i]), d)

    print(d)


if __name__ == "__main__":
    solve()

Fixed submission:
def gcd(a, b):
    """ 最大公約数。aはbより大きいこと """
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    A.sort(reverse=True)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(ans, A[i])

    print(ans)


if __name__ == "__main__":
    solve()

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

def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    d = 10**9
    for i in range(1, N):
        d = min(math.gcd(A[0], A[1]), d)

    print(d)


if __name__ == "__main__":
    solve()

Fixed submission:
def gcd(a, b):
    """ 最大公約数。aはbより大きいこと """
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    A.sort(reverse=True)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(ans, A[i])

    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
"""
問題
https://atcoder.jp/contests/dp/tasks/dp_d

解説
https://qiita.com/drken/items/dc53c683d6de8aeacf5a#d-%E5%95%8F%E9%A1%8C---knapsack-1
"""

def solve():
    N, LIMIT = list(map(int, input().split()))
    W, V = [None], [None]
    for i in range(N):
        w, v = list(map(int, input().split()))
        W.append(w)
        V.append(v)
    
    # dp[i][w] := i個目までの品物を選んだ時の、重さがwのときの価値の最大値
    dp = [[w for w in range(LIMIT+1)] for i in range(N+1)]
    for w in range(LIMIT+1):
        dp[0][w] = 0
    
    #O(N*LIMIT) = O(10**7)
    for i in range(1, N+1):
        for w in range(LIMIT+1):
            if w-W[i] >= 0:
                dp[i][w] = max(dp[i-1][w], dp[i-1][w-W[i]] + V[i])
            else:
                dp[i][w] = dp[i-1][w]

    ans = 0
    for w in range(LIMIT+1):
        ans = max(ans, dp[N][w])

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-
"""
問題
https://atcoder.jp/contests/dp/tasks/dp_d

解説
https://qiita.com/drken/items/dc53c683d6de8aeacf5a#d-%E5%95%8F%E9%A1%8C---knapsack-1
"""

def solve():
    """
    Python: TLE (´･_･`)
    """
    N, LIMIT = list(map(int, input().split()))
    W, V = [None], [None]
    for i in range(N):
        w, v = list(map(int, input().split()))
        W.append(w)
        V.append(v)
    
    # dp[i][w] := i個目までの品物を選んだ時の、重さがwのときの価値の最大値
    dp = [[w for w in range(LIMIT+1)] for i in range(N+1)]
    for w in range(LIMIT+1):
        dp[0][w] = 0
    
    #O(N*LIMIT) = O(10**7)
    for i in range(1, N+1):
        for w in range(LIMIT+1):
            if w-W[i] >= 0:
                dp[i][w] = max(dp[i-1][w], dp[i-1][w-W[i]] + V[i])
            else:
                dp[i][w] = dp[i-1][w]

    ans = 0
    for w in range(LIMIT+1):
        ans = max(ans, dp[N][w])

    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def main():
    N = input()

    if N == 1:
        print("Hello World")
        exit()
    else:
        print(int(input()) + int(input()))

if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-

def main():
    N = input()

    if N == "1":
        print("Hello World")
        exit()
    else:
        print(int(input()) + int(input()))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    S = input()
    dp = [[0 for i in range(N+1)] for j in range(N+1)]
    # dp[left][right] := 正しい方向の数
    # まずはdp[0][N]を考える
    for s in S:
        if s == "W":
            dp[0][N] += 1
    maxv = dp[0][N]
    # dpを埋める
    # dp[1][N-1], dp[2][N-2], ...
    for i in range(1, N+1):
        if S[i-1] == "E":
            diff = 1
        else:
            diff = -1
        dp[i][N-i] = dp[i-1][N-i+1] + diff
        if dp[i][N-i] >= maxv:
            maxv = dp[i][N-i]
    print(N - maxv)



Fixed submission:
# -*- coding:utf-8 -*-

def solve(N, S):
    dp = [[0 for i in range(N+1)] for j in range(N+1)]
    # dp[left][right] := 正しい方向の数
    # まずはdp[0][N]を考える
    for s in S:
        if s == "W":
            dp[0][N] += 1
    maxv = dp[0][N]
    # dpを埋める
    # dp[1][N-1], dp[2][N-2], ...
    for i in range(1, N+1):
        if S[i-1] == "E":
            diff = 1
        else:
            diff = -1
        dp[i][N-i] = dp[i-1][N-i+1] + diff
        if dp[i][N-i] >= maxv:
            maxv = dp[i][N-i]
    print(N - maxv)

def solve2(N, S):
    good = 0
    for s in S:
        if s == "W":
            good += 1
    maxv = good

    nowv = maxv
    for i in range(1, N+1):
        if S[i-1] == "E":
            diff = 1
        else:
            diff = -1
        nowv = nowv + diff
        if nowv >= maxv:
            maxv = nowv
    print(N - maxv)

if __name__ == "__main__":
    N = int(input())
    S = input()
    solve2(N, S)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import math

def solve(X):
	# b^p = xとなるxを探す
	for x in range(X, 1, -1)
    	for b in range(2, x):
    		p = math.log(x, b)
    		if float.is_integer(p):
    			return x
    	return 1

if __name__ == "__main__":
	X = int(input())
	print(solve(X))


Fixed submission:
# -*- coding:utf-8 -*-
import math

def solve(X):
	ans = X
	# b^p = ansとなるansを探す
	for b in range(2, X):
		p = math.log(ans, b) # 精度で死ぬ(log(100, 10)など)
		if float.is_integer(p):
			return ans
	return 1

def solve2(X):
	# 全探索
	for x in range(X, 1, -1):
		for p in range(2, x):
			for b in range(2, x):
				bp = b**p
				if bp == x:
					return x
				if bp >= x:
					break
	return 1

if __name__ == "__main__":
	X = int(input())
	print(solve2(X))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    Xs = list(map(int, input().split()))
    Xs_ = Xs[::]
    Xs_.sort()

    for i in range(N):
        Xs__ = Xs_[::]
        Xs__.remove(Xs[i])
        print(Xs__[int(N/2)-1])


Fixed submission:
# -*- coding:utf-8 -*-

def solver():
    # mr.zehnpaard
    from statistics import median_low, median_high

    n = int(input())
    xs = [int(x) for x in input().split()]

    m1, m2 = median_low(xs), median_high(xs)

    medians = (str(m2 if x < m2 else m1) for x in xs)
    print('\n'.join(medians))

def main():
    from statistics import median_low, median_high

    N = int(input())
    Xs = list(map(int, input().split()))
    m_low, m_high = median_low(Xs), median_high(Xs)

    for x in Xs:
        ans = m_high if x <= m_low else m_low
        print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
from math import factorial

def combination_formula(n, r):
    return factorial(n) // (factorial(r)*factorial(n-r))

def solve():
    N = int(input())
    As = list(map(int, input().split()))

    # ai > aj
    # C(ai, aj) とするとき、aiは大きければ大きいほどよいので、Asの最大値でよい
    # 問題はajをどう決めるか。とりあえず全探索？

    As.sort()
    n = As[-1]
    ans_i = 0
    max_c = combination_formula(n, As[0])
    for i in range(1, N-1):
        c = combination_formula(n, As[i])
        if c > max_c:
            max_c = c
            ans_i = i

    print(n, As[ans_i])


if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-
from math import factorial
import bisect


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    # ai > aj
    # C(ai, aj) とするとき、aiは大きければ大きいほどよいので、Asの最大値でよい
    # 問題はajをどう決めるか。
    """
    C(n,r) を毎回計算するのは計算が重い。なので計算させずに済む方法を考える。
    C(n,r) = n! / r!(n-r)! である。今、nはAsの最大値と決まっているので、定数とみなして良い。
    よって、C(n,r)が大きいとは、分子の r!(n-r)!ができるだけ小さいものである。
    r!(n-r)!を全探索で計算するのも処理が重いのでしたくない。
    ところで、n=10のとき、r!(n-r)!を、r = 1 ~ 10まで手書きで書いてみるとわかるが、

    1) 1* 9*8*7*6*5*4*3*2*1
    2) 1*2* 8*7*6*5*4*3*2*1
    3) 1*2*3* 7*6*5*4*3*2*1
    4) 1*2*3*4* 6*5*4*3*2*1
    5) 1*2*3*4*5* 5*4*3*2*1  <-これが一番小さい
    6) 1*2*3*4*5*6* 4*3*2*1  <-これは4)と同じ

    r = n//2のときが一番小さくなるっぽいことがわかる。

    そのようなrを、Asの中から探せば良い。これは二分探索で高速に探せる。
    """

    As.sort()
    n = As[-1]
    i = bisect.bisect_left(As[:-1], n//2)
    if i == 0:
        r = As[0]
    elif i == N-1:
        r = As[N-2]
    else:
        if abs(As[i-1] - n//2) < abs(As[i] - n//2):
            r = As[i-1]
        else:
            r = As[i]

    print(n, r)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B, K = list(map(int, input().split()))
    end = A + K
    if end >= B+1:
        end = B
    for i in range(A, end):
        print(i)

    start = B - K + 1
    if start <= i:
        start = i + 1
    for j in range(start, B+1):
        print(j)


Fixed submission:
#-*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B, K = list(map(int, input().split()))
    end = A + K
    if end >= B+1:
        end = B + 1
    for i in range(A, end):
        print(i)
    if end == B + 1:
        exit()

    start = B - K + 1
    if start <= i:
        start = i + 1
    for j in range(start, B+1):
        print(j)
Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B, C = list(map(int, liput().split()))
    if (A + B) >= C:
        print("Yes")
    else:
        print("No")


Fixed submission:
#-*- coding:utf-8 -*-

if __name__ == "__main__":
	A, B, C = list(map(int, input().split()))
	if A+B >= C:
		print("Yes")
	else:
		print("No")

Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-

if __name__ == "__main__":
	A, B, C = list(map(int, input.split()))
	if A+B >= C:
		print("Yes")
	else:
		print("No")


Fixed submission:
#-*- coding:utf-8 -*-

if __name__ == "__main__":
	A, B, C = list(map(int, input().split()))
	if A+B >= C:
		print("Yes")
	else:
		print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#
if __name__ == "__main__":
    l1 = input()
    l2 = input()
    l3 = input()
    print({}{}{}.format(l1[0], l2[1], l3[2]))


Fixed submission:
# -*- coding: utf-8 -*-
#
if __name__ == "__main__":
    l1 = input()
    l2 = input()
    l3 = input()
    print("{}{}{}".format(l1[0], l2[1], l3[2]))
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B = list(map(int, input().split()))
    ans = 0
    for i in range(A, B+1)
        c = str(i)
        length = len(c)
        if length%2 == 0:
            continue
        for j in range(length):
            if c[j] == c[length-1-j]:
                if j == length-1-j:
                    ans += 1
                    break
                continue
            else:
                break
        print(ans)


Fixed submission:
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B = list(map(int, list(map(float, input().split()))))
    ans = 0
    for i in range(A, B+1):
        c = str(i)
        length = len(c)
        if length%2 == 0:
            continue
        for j in range(length):
            if c[j] == c[length-1-j]:
                if j == length-1-j:
                    ans += 1
                    break
                continue
            else:
                break
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B = list(map(int, input().split()))
    ans = 0
    for i in range(A, B+1)
        c = str(i)
        if len(c)%2 == 0:
            continue
        J = len(c)
        for j in range(J):
            if c[j] == c[J-1-j]:
                if j == J-1-j:
                    ans += 1
                    break
            else:
                break
        print(ans)


Fixed submission:
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    A, B = list(map(int, list(map(float, input().split()))))
    ans = 0
    for i in range(A, B+1):
        c = str(i)
        length = len(c)
        if length%2 == 0:
            continue
        for j in range(length):
            if c[j] == c[length-1-j]:
                if j == length-1-j:
                    ans += 1
                    break
                continue
            else:
                break
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-
import math

if __name__ == "__main__":
	H, W, D = list(map(int, input().split()))
	masu_d = {}
	for i in range(H):
		inputs = list(map(int, input().split()))
		for j in range(W):
			masu_d[inputs[j]] = [i, j]

	Q = int(input())
	L = []
	R = []
	for i in range(Q):
		l, r = list(map(int, input().split()))
		L.append(l)
		R.append(r)
	# 総和計算開始
	for i in range(Q):
		ans = 0
		now_l = L[i]
		while 1:
			if now_l == R[i]:
				print(int(ans))
				break
			next_l = now_l + D
			ans += math.fabs(masu_d[now_l][0]-masu_d[next_l][0]) + math.fabs(masu_d[now_l][1]-masu_d[next_l][1])
			now_l = next_l


Fixed submission:
#-*- coding:utf-8 -*-
import math

if __name__ == "__main__":
	H, W, D = list(map(int, input().split()))
	masu = {}
	for i in range(H):
		inputs = list(map(int, input().split()))
		for j in range(W):
			masu[inputs[j]] = [i, j]

	Q = int(input())
	L = []
	R = []
	for i in range(Q):
		l, r = list(map(int, input().split()))
		L.append(l)
		R.append(r)
	# i=D+1 ~ H*W の累積和Sを求める
	S = [0] * (H*W+1)
	for i in range(D+1, H*W+1):
		S[i] = S[i-D] + abs(masu[i][0]-masu[i-D][0]) + abs(masu[i][1]-masu[i-D][1])
	# 回答する
	for i in range(Q):
		print(S[R[i]] - S[L[i]])
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

if __name__ == '__main__':
    a, b = input(map(int, input().split()))
    if (a*b)%2 == 0:
        print("Even")
    else:
        print("Odd")


Fixed submission:
# -*- coding:utf-8 -*-

if __name__ == '__main__':
    a, b = list(map(int, input().split()))
    if (a*b)%2 == 0:
        print("Even")
    else:
        print("Odd")
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def solve():
    A, B = list(map(int, input()))
    S = input()

    for i in range(len(S)):
        if i == A:
            if S[A] == "-":
                continue
            print("No")
            return 
        try:
            num = int(S[i])
        except:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    A, B = list(map(int, input().split()))
    S = input()

    for i in range(len(S)):
        if i == A:
            if S[A] == "-":
                continue
            print("No")
            return 
        try:
            int(S[i])
        except:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    a_list = list(map(int, input().split()))
    ans = 0

    # 初期設定
    ans = 0
    a_set = set(a_list)

    for a in a_set:
        c = a_list.count(a) # 要素の出現回数をカウントする
        if c < a:
            ans += c
        elif c > a:
            ans += c-a
    print(ans)


Fixed submission:
# -*- coding:utf-8 -*-

def main():
    N = int(input())
    a_list = list(map(int, input().split()))

    # 初期設定
    ans = 0
    a_set = set(a_list)

    for a in a_set:
        c = a_list.count(a) # 要素の出現回数をカウントする
        if c < a:
            ans += c
        elif c > a:
            ans += c-a
    print(ans)

def main2():
    N = int(input())
    a_list = list(map(int, input().split()))
    ans = 0

    import collections
    count_dict = collections.Counter(a_list) # キーに要素、値に出現回数の辞書

    for key in count_dict:
        diff = key - count_dict[key]
        if diff == 0:
            continue
        elif diff > 0:
            ans += count_dict[key]
        elif diff < 0:
            ans += abs(diff)
    print(ans)



if __name__ == "__main__":
    main2()