Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in range(1, len(dic)):
        count += (dic[j] - j) if dic[j] > j else dic[j]
    print(count)


if __name__=="__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    N = int(input())
    l = list(map(int,input().split(" ")))
    v = []
    c = []
    count = 0
    for i in l:
          if i not in v:
              v.append(i)
              c.append(1)
          else:
              c[v.index(i)]+=1
    for j in range(len(v)):
        count+= c[j]-v[j] if c[j]>=v[j] else c[j]
    print(count)

Fixed submission:
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    N = int(input())
    l = list(map(int,input().split(" ")))
    s = list(set(l))
    dic = {i:0 for i in range(len(s))}
    count = 0
    for i in l:
          dic[s.index(i)] +=1
    for j in range(len(dic)):
        count+= dic[j]-s[j] if s[j]<=dic[j] else dic[j]
    print(count)

Fixed submission:
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    N = int(input())
    l = list(map(int,input().split(" ")))
    s = list(set(l))
    count = 0
    for i in s:
        if l.count(i)<i:
            count+=l.count(i)
        if l.count(i)>i:
            count+=l.count(i)-i
    print(count)

Fixed submission:
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    N = int(input())
    l = list(map(int,input().split(" ")))
    count = 0
    visited_list = []
    for i in l:
        if i not in visited_list:
            visited_list.append(i)
            if l.count(i)<i:
                count+=l.count(i)
            if l.count(i)>i:
                count+=l.count(i)-i
    print(count)

Fixed submission:
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    N = int(input())
    l = list(map(int,input().split(" ")))
    count = 0
    for i in l:
        if l.count(i)<i:
            count+=l.count(i)
            while i in l:
                l.remove(i)
        if l.count(i)>i:
            count+=l.count(i)-i
            while i in l:
                l.remove(i)
    print(count)

Fixed submission:
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()