Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
maxi=-10**99 
n=int(input())
l=[int(i) for i in input().split()]
k=n
for i in range(n-1,2*n):
    z1=l[:i+1]
    z2=l[i+1:]
    #print(z1,z2)
    z1.sort(reverse=1)
    z2.sort()
  #  print(i)
   # print(sum(z1[:k]))
   # print(sum(z2[:k]))
    maxi=max(maxi,sum(z1[:k])-sum(z2[:k]))
print(maxi)


Fixed submission:
maxi=-10**99 
n=int(input())
import heapq 
l=[int(i) for i in input().split()]
k=n
sm=sum(l[0:n])
z1=[0]*(n+1)
z2=[0]*(n+1)
h=[]
z1[0]=sm 
j=1 
heapq.heapify(h)
for i in range(n):
    heapq.heappush(h,l[i])
for i in range(n,2*n):
    p=l[i]
    if p>h[0]: 
        sm+=p 
        sm-=h[0]
        heapq.heappop(h)
        heapq.heappush(h,p)
    else:
        pass 
    z1[j]=sm 
    j+=1 
sm=sum(l[2*n:3*n])
h=[]
heapq.heapify(h)
sm=0 
for i in range(2*n,3*n):
    heapq.heappush(h,-l[i])
    sm+=(l[i])
j=n 
z2[j]=sm  
j-=1 
#print(h[0])
#print(sm)
for i in range(2*n-1,n-1,-1): 
    p=-l[i]
    if p>h[0]:
        #print('jif')
        sm=sm+h[0]-p
        heapq.heappop(h)
        heapq.heappush(h,p)
        
    else:
        pass 
    z2[j]=sm 
    j-=1 
maxi=-(10**99)
#print(z1)
#print(z2)
for i in range(n+1):
    maxi=max(maxi,z1[i]-z2[i])
print(maxi)
Buggy python submission (verdict: Runtime Error):
# Python program to print all paths from a source to destination. 
cnt=0 
ans=0 
from collections import defaultdict 
from collections import Counter 
def check(arr): 
    #print(arr)
    ans=0 
    for i in range(1,len(arr)):
        ans+=e[(arr[i-1],arr[i])]
   # print(ans)
    return ans 
maxi=-10**1999  
mini=10**9 
#    sents a directed graph 
# using adjacency list representation 
class Graph: 

	def __init__(self,vertices): 
		#No. of vertices 
		self.V= vertices 
		
		# default dictionary to store graph 
		self.graph = defaultdict(list) 

	# function to add an edge to graph 
	def addEdge(self,u,v): 
		self.graph[u].append(v) 
	def printAllPathsUtil(self, u, d, visited, path):
	   
		# Mark the current node as visited and store in path 
		visited[u]= True
		path.append(u) 
		global ans 
		global maxi
		# If current vertex is same as destination, then print 
		# current path[] 
		if u ==d: 
		   # print(path)
		    if check(path): 
		        maxi=max(maxi,check(path))
		else: 
			# If current vertex is not destination 
			#Recur for all the vertices adjacent to this vertex 
			for i in self.graph[u]: 
				if visited[i]==False: 
					self.printAllPathsUtil(i, d, visited, path) 
					
		# Remove current vertex from path[] and mark it as unvisited 
		path.pop() 
		visited[u]= False


	# Prints all paths from 's' to 'd' 
	def printAllPaths(self,s, d): 

		# Mark all the vertices as not visited 
		visited =[False]*(self.V) 

		# Create an array to store paths 
		path = [] 

		# Call the recursive helper function to print all paths 
		self.printAllPathsUtil(s, d,visited, path) 



# Create a graph given in the above diagram 
n,m=map(int,input().split())
g = Graph(n)
e={}
from collections import defaultdict
di=defaultdict(list)
for i in range(m): 
    a,b,c=map(int,input().split())
    g.addEdge(a-1,b-1)
    e[(a-1,b-1)]=c 
    a-=1 
    b-=1 
    di[a].append(b)
    #g.addEdge(b-1,a-1)

s=0 
d=n-1 
q=[n-1]
vis=[0]*n 
vis[n-1]=1 
while q:
    t=q.pop(0)
    for i in di[t]:
        if not vis[i]:
            q.append(i)
            vis[i]=1 
f=1 
if vis[0]:
    f=0 
g.printAllPaths(s, d) 
print(maxi if f else 'inf')


Fixed submission:
inf=10**43
n,m=map(int,input().split())
edges=[None]*m 
for i in range(m):
    a,b,c=map(int,input().split())
    a-=1 
    b-=1 
    edges[i]=(a,b,-c)
d=[inf]*n 
f=1 
d[0]=0 
for i in range(n-1): 
    for (a,b,c) in edges: 
        if d[a]+c<d[b]:
            d[b]=d[a]+c #update distances 
#print(d)
for i in range(n):
    for (a,b,c) in edges: 
        if d[b]>d[a]+c:  #how can a->b be minimised by travelling 
                         #some other path
            if b==n-1:
                f=0
                #print(b,d[b])
            else:
                d[b]=d[a]+c 
if f:  
    print(-d[n-1])
else:
    print('inf')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>b:
    print('GREATER')
elif a<b:
    print('LESS')
else:
    print('EQUAL')

Fixed submission:
a=input()
b=input()
if len(a)>len(b):
    print('GREATER')
elif len(a)<len(b):
    print('LESS')
else:
    n=len(a)
    for i in range(n):
        if a[i]<b[i]:
            print('LESS')
            exit()
        if a[i]>b[i]:
            print('GREATER')
            exit()
    print('EQUAL')
Buggy python submission (verdict: Runtime Error):
s1=input()
s2=input()
n=len(s1)
ans=''
for i in range(n):
    ans+=s1[i]+s2[i]
print(ans)

Fixed submission:
s1=input()
s2=input()
n=len(s1)
ans=''
for i in range(min(len(s1),len(s2))):
    ans+=s1[i]+s2[i]
#print(i)
if i!=len(s1)-1:
    ans+=s1[i+1]
if i!=len(s2)-1:
    ans+=s2[i+1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,ma,mb=map(int,input().split())
dp=[[10**9 for j in range(400)]for i in range(400)]
dp[0][0]=0 
for i in range(n):
    a,b,c=map(int,input().split())
    for x in range(400):
        for y in range(400):
            if x<a or y<b:
                continue 
            dp[x][y]=min(dp[x][y],dp[x-a][y-b]+c)
mini=10**9 
for i in range(1,41):
    mini=min(mini,dp[ma*i][mb*i])
if mini>=10**9:
    print(-1)
else:
    print(mini)

Fixed submission:
def main():
    n,ma,mb = map(int,input().split())
    dp = [[[float("inf") for _ in range(401)] for _ in range(401)] for _ in range(n+1)]
    dp[0][0][0]=0

    for i in range(1,n+1):
        a,b,c = map(int,input().split())
        for j in range(401):
            for k in range(401):
                if a<=j and b<=k:
                    dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
                else:
                    dp[i][j][k] = dp[i-1][j][k]
    ans = float("inf")
    for i in range(1,401):
        for j in range(1,401):
            if i*mb == j*ma:
                ans = min(ans,dp[n][i][j])
    if ans==float("inf"):
        print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n,ma,mb=map(int,input().split())
dp=[[10**9 for j in range(400)]for i in range(400)]
dp[0][0]=0 
for i in range(n):
    a,b,c=map(int,input().split())
    for x in range(400):
        for y in range(400):
            if x<a or y<b:
                continue 
            dp[x][y]=min(dp[x][y],dp[x-a][y-b]+c)
mini=10**9 
for i in range(1,41):
    mini=min(mini,dp[ma*i][mb*i])
if mini>=10**9:
    print(-1)
else:
    print(mini)

Fixed submission:
def main():
    n,ma,mb = map(int,input().split())
    dp = [[[float("inf") for _ in range(401)] for _ in range(401)] for _ in range(n+1)]
    dp[0][0][0]=0

    for i in range(1,n+1):
        a,b,c = map(int,input().split())
        for j in range(401):
            for k in range(401):
                if a<=j and b<=k:
                    dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
                else:
                    dp[i][j][k] = dp[i-1][j][k]
    ans = float("inf")
    for i in range(1,401):
        for j in range(1,401):
            if i*mb == j*ma:
                ans = min(ans,dp[n][i][j])
    if ans==float("inf"):
        print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
s=input()
if s==s[::-1]:
    opt=n-3 
    if opt&1: 
        print('First')
    else:
        print('Second')
else: 
    print('First')

Fixed submission:
s=input()
if s[0]==s[-1]:
    opt=len(s)-3 
    if opt&1: 
        print('First')
    else:
        print('Second')
else: 
    opt=len(s)-2 
    if opt&1:
        print('First')
    else:
        print('Second')
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
t=n//2+n%2 
h=n//2 
ans=pow(k,tot) *pow(k-1,h) 
print(ans)

Fixed submission:
n,k=map(int,input().split())
tot=n//2+n%2 
h=n//2 
ans=pow(k,1) *pow(k-1,n-1) 
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
mat=[]
for i in range(n):
    mat.append(list(input()))
mat.sort(key=lambda x:x)
ans=''
for i in mat:
    ans+=i 
print(ans) 

Fixed submission:
n,m=map(int,input().split())
mat=[]
for i in range(n):
    mat.append(input())
mat.sort(key=lambda x:x)
ans=''
for i in mat:
    ans+=i 
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))[::-1]
A_sum = sum(A)

count = 0;
criteria = A_sum/(4*M)

print("No") if (A[M - 1] < criteria) else print("Yes")


Fixed submission:
inputline = list(map(lambda x:int(x), input().split(" ")))
print(inputline[2], inputline[0], inputline[1])
Buggy python submission (verdict: Runtime Error):
import collections
ds = []
N = int(input())
for _ in range(N):
    ds.append(input())
print(len(ollections.Counter(ds)))

Fixed submission:
import collections
ds = []
N = int(input())
for _ in range(N):
    ds.append(input())
print(len(collections.Counter(ds)))
Buggy python submission (verdict: Runtime Error):
def solve():
    N,H = list(map(int, input().split()))
    az = []
    bz = []
    for i in range(N):
        a,b = list(map(int, input().split()))
        az.append(a)
        bz.append(b)
        
    amax = max(az)
    bz.sort(reverse=True)
    cnt = 0
    for b in bz:
        if amax < b:
            H -= b
            cnt += 1
        if H <= 0:
            return cnt
    if H <= 0:
        return cnt)
    cnt += int(H / amax)
    cnt += min(H % amax, 1)
    return cnt
        
print(solve())

Fixed submission:
def solve():
    N,H = list(map(int, input().split()))
    az = []
    bz = []
    for i in range(N):
        a,b = list(map(int, input().split()))
        az.append(a)
        bz.append(b)
        
    amax = max(az)
    bz.sort(reverse=True)
    cnt = 0
    for b in bz:
        if amax < b:
            H -= b
            cnt += 1
        if H <= 0:
            return cnt
    if H <= 0:
        return cnt
    cnt += int(H / amax)
    cnt += min(H % amax, 1)
    return cnt
        
print(solve())
Buggy python submission (verdict: Runtime Error):
A, B, C = list(map(int, input().split()))

print(B if A*N < B else A*N)

Fixed submission:
N, A, B = list(map(int, input().split()))
 
print(B if A*N > B else A*N)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
import sys

sys.setrecursionlimit(100000)

N, X = list(map(int, input().split()))

def f(a,b):
    if a > b:
        a,b = b,a
    if a==0 or b==0:
        return 0
    if b%a is 0:
        return int(a*(2*(b/a)-1))

    return int(2*a*int(b/a) + f(a,b%a))

print(N+f(N-X, X))


Fixed submission:
#!/usr/bin/python3
N = int(input())
L = list(map(int, input().split()))

L.sort()

print(sum(L[0::2]))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
N = int(input())
L = list(map(int, input().split()))

L.sort()

print(sum(L[0::2]))


Fixed submission:
#!/usr/bin/python3
N = int(input())
L = list(map(int, input().split()))

L.sort()

print(sum(L[0::2]))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
N = int(input())
L = list(map(int, input().split()))

L.sort()

print(sum(L[0::2]))


Fixed submission:
#!/usr/bin/python3
N = int(input())
L = list(map(int, input().split()))

L.sort()

print(sum(L[0::2]))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
for i in range(n-k):
    if t[i] == t[i+k]:
        t[i+k] = "d"

t = "".join(t)
t = t.replace("r", "{}+".format(p)).replace("p", "{}+".format(s)).replace("s", "{}+".format(r)).replace("d", "0+") + "0"
print(eval(t))


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
for i in range(n-k):
    if t[i] == t[i+k]:
        t[i+k] = "d"

t = "".join(t)
t = t.replace("r", "{}+".format(p)).replace("p", "{}+".format(s)).replace("s", "{}+".format(r)).replace("d", "0+") + "0"
print(eval(t))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
for i in range(len(t)-k):
    if t[i] == t[i+k]:
        t[i+k] = "d"

t = "".join(t)
t = t.replace("r", "{}+".format(p)).replace("p", "{}+".format(s)).replace("s", "{}+".format(r)).replace("d", "0+") + "0"
print(eval(t))


Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
for i in range(n-k):
    if t[i] == t[i+k]:
        t[i+k] = "d"

t = "".join(t)
t = t.replace("r", "{}+".format(p)).replace("p", "{}+".format(s)).replace("s", "{}+".format(r)).replace("d", "0+") + "0"
print(eval(t))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

before = aaa
ans = 0
for char in s:
  if char != before:
    before = char
    ans += 1
print(ans)


Fixed submission:
n = int(input())
s = input()
 
before = 'aaa'
ans = 0
for char in s:
  if char != before:
    before = char
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
(lambda x, y: print(max(a+b, a-b, a*b)))(map(int,input().split()))

Fixed submission:
(lambda x, y: print(max(x+y, x-y, x*y)))(*map(int,input().split()))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as ct
n = int(input())
ans = 0
words = [input() for _ in range(n)]
while words:
  mas = words.pop()
  count = 0
  for word in words:
    if ct(mas) == ct(word):
      count += 1
      words.remove(word)
  if count == 1:
    ans += count
  else:
    ans += count * (count + 1) // 2
print(ans)


Fixed submission:
from collections import Counter as ct
n = int(input())
ans = 0
words = [ct(input()) for _ in range(n)]
words = ct([tuple(sorted([(x, y) for x, y in z.items()])) for z in words])

for i in words.values():
  ans += i * (i-1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
2 print(len(list(filter(lambda x: len(str(x)) % 2 == 1, range(1, int(input()) + 1)))))

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n+1):
    if 1 <= i < 10 or 100 <= i < 1000 or 10000 <= i < 100000:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import mth
n, d = map(int,input().split())
print(math.ceil(n / (2 * d + 1)))


Fixed submission:
import math
n, d = map(int,input().split())
print(math.ceil(n / (2 * d + 1)))

Buggy python submission (verdict: Runtime Error):
import mth
n, d = map(int,input().split())
print(math.seil(n / (2 * d + 1)))


Fixed submission:
import math
n, d = map(int,input().split())
print(math.ceil(n / (2 * d + 1)))
Buggy python submission (verdict: Runtime Error):
print((3*int(input())+int(input()))//2)

Fixed submission:
a, p = map(int, input().split())
print((3 * a + p) // 2)

Buggy python submission (verdict: Runtime Error):
a, p = map(int, input())
print((3 * a + p) // 2)


Fixed submission:
a, p = map(int, input().split())
print((3 * a + p) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
# Different Strokes
n = int(input())
a, b = list(), list()
for _ in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
a_sort = sorted(a)
b_sort = sorted(b)
ans = 0
while True:
    const = b_sort.pop()
    indexes = list()
    for i in range(len(b)):
        if b[i] == const:
            indexes.append(i)
    m = 0
    ind = 0
    for i in indexes:
        if a[i] >= m:
            ind = i
            m = a[i]
    ans += m
    a_sort.remove(m)
    del a[ind]
    del b[ind]
    if not a:
        exit(print(ans))

    const = a_sort.pop()
    indexes = list()
    for i in range(len(a)):
        if a[i] == const:
            indexes.append(i)
    m = 0
    ind = 0
    for i in indexes:
        if b[i] >= m:
            ind = i
            m = b[i]
    ans -= m
    b_sort.remove(m)
    del a[ind]
    del b[ind]
    if not a:
        exit(print(ans))


Fixed submission:
# Different Strokes
n = int(input())
a, b = list(), list()
ab = list()
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
    ab.append((a_, b_))
ans = 0
ab.sort(key=(lambda x: sum(x)), reverse=True)
for i, ab_ in enumerate(ab):
    if i % 2 == 0:
        ans += ab_[0]
    else:
        ans -= ab_[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
# Pyramid
n = int(input())
x, y, h = [], [], []
flag = True
ans_x, ans_y, ans_h = 0, 0, 0
for i in range(n):
    _x_, _y_, _h_ = map(int, input().split())
    if _h_ == 0:
        break
    x.append(_x_)
    y.append(_y_)
    h.append(_h_)
for cx in range(101):
    for cy in range(101):
        for j in range(n):
            h_ = h[j] + abs(x[j] - cx) + abs(y[j] - cy)
            if flag is True:
                flag = h_
            elif flag == h_:
                if j == n - 1:
                    ans_x, ans_y, ans_h = cx, cy, h_
                else:
                    pass
            else:
                flag = True
                break
print('{0} {1} {2}'.format(ans_x, ans_y, ans_h))


Fixed submission:
# Pyramid
n = int(input())
data = []
h_ = 0
for i in range(n):
    data.append(list(map(int, input().split())))
data = sorted(data, key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        for j in range(n):
            if j == 0:
                h_ = data[0][2] + abs(cx - data[0][0]) + abs(cy - data[0][1])
            else:
                if data[j][2] == max(0, h_ - abs(cx - data[j][0]) - abs(cy - data[j][1])):
                    if j == n - 1:
                        print('{0} {1} {2}'.format(cx, cy, h_))
                        exit()
                    else:
                        continue
                else:
                    break
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().slice())
if a == 2 or b == 2:
    print('No')
else:
    print('Yes')


Fixed submission:
a, b = map(int, input().split())
if a == 2 or b == 2:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n):
    if li[j][-1] != li[j+1][0]:
        print('No1')
        exit()
    for k in range(j):
        if li[j] == li[k]:
            print('No2')
            exit()
print('Yes')


Fixed submission:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k] or li[-1] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
# To Infinity
import re
s = input()
k = int(input())
ind = re.search(r'[23456789]', s)
if ind is None:
    ind = k
else:
    ind = ind.start()
if ind < k:
        print(s[ind])
else:
    print(1)


Fixed submission:
# Garden
a, b = map(int, input().split())
print(a * b - a - b + 1)
Buggy python submission (verdict: Runtime Error):
# Modulo Summation
import math
from functools import reduce


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


n = int(input())
a = list(map(int, input().split()))
m = reduce(lcm, a, 1) - 1
print(sum(map(lambda x: m % x, a)))


Fixed submission:
# Modulo Summation
input()
a = list(map(int, input().split()))
x = 1
for i in a:
    x *= i
print(sum(list(map(lambda j: (x - 1) % j, a))))
Buggy python submission (verdict: Runtime Error):
# Linear Approximation
from statistics import median
n = int(input())
a = list(map(int, input().split()))
b = []
_sum = 0
for i in range(n):
    b.append(a[i] - i - 1)
print(med)
for i in range(n):
    _sum += abs(b[i] - med)
print(int(_sum))


Fixed submission:
# Linear Approximation
from statistics import median
n = int(input())
a = list(map(int, input().split()))
b = []
_sum = 0
for i in range(n):
    b.append(a[i] - i - 1)
med = median(b)
for i in range(n):
    _sum += abs(b[i] - med)
print(int(_sum))

Buggy python submission (verdict: Time Limit Exceeded):
# Linear Approximation
from statistics import median
n = int(input())
a = sorted((lambda x: [list(map(int, x.split()))[i] - i - 1 for i in range(n)])(input()))
print(int(sum([abs(i - median(a)) for i in a])))


Fixed submission:
# Linear Approximation
from statistics import median
n = int(input())
a = list(map(int, input().split()))
b = []
_sum = 0
for i in range(n):
    b.append(a[i] - i - 1)
med = median(b)
for i in range(n):
    _sum += abs(b[i] - med)
print(int(_sum))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

p = [0] * n
for i in range(n):
    p[i] = s[:i].count('W') + s[i:].count('E')
print(min(p))


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

p = [0] * n
p[0] = s[1:].count('E')
for i in range(1, n):
    p[i] = p[i-1]
    if s[i-1] == 'W':
        p[i] += 1
    if s[i] == 'E':
        p[i] -= 1
print(min(p))
Buggy python submission (verdict: Time Limit Exceeded):
# Traveling Plan
n = int(input())
a = [0]
a += list(map(int, input().split()))
a += [0]
for i in range(n):
    ans = 0
    for j in range(n+1):
        if j == i:
            ans += abs(a[j]-a[j+2])
        elif j == i+1:
            pass
        else:
            ans += abs(a[j]-a[j+1])
    print(ans)


Fixed submission:
# Traveling Plan
n = int(input())
a = [0]
a += list(map(int, input().split()))
a += [0]
total = 0
for i in range(n+1):
    total += abs(a[i]-a[i+1])
for i in range(n):
    p = total -(abs(a[i]-a[i+1]) + abs(a[i+1]-a[i+2])) + abs(a[i]-a[i+2])
    print(p)
Buggy python submission (verdict: Time Limit Exceeded):
# Good Sequence
n = int(input())
a = list(map(int, input().split()))
a_ = set(a)
p = 0
for i in a_:
    if a.count(i) < i:
        p += a.count(i)
    elif a.count(i) > i:
        p += a.count(i) - i
print(p)


Fixed submission:
# Good Sequence
n = int(input())
a = list(map(int, input().split()))
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i, c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [1, 2, 4, 8, 16, 32, 64]
i = 0
while l[i] < n:
  i += 1
else:
  print(l[i])


Fixed submission:
n = int(input())
l = [1, 2, 4, 8, 16, 32, 64, 128]
i = 0
while l[i] <= n:
  i += 1
else:
  print(l[i-1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [(lambda x, y:(x, y))(*map(int, input().split())) for _ in range(m)]
d = {}
for x in ab:
  if x[0] in d.keys():
    d[x[0]].append(x[1])
  else:
    d[x[0]] = [x[1]]
moyo = []
for z in d[1]:
  moyo += d[z]
for z in moyo:
  if z == n:
    exit(print('POSSIBLE'))
print('IMPOSSIBLE')

Fixed submission:
n, m = map(int, input().split())
ab = [(lambda x, y:(x, y))(*map(int, input().split())) for _ in range(m)]
d = {}
for x in ab:
  if x[0] in d.keys():
    d[x[0]].append(x[1])
  else:
    d[x[0]] = [x[1]]
moyo = []
for z in d[1]:
  if z in d.keys():
    moyo += d[z]
for z in moyo:
  if z == n:
    exit(print('POSSIBLE'))
print('IMPOSSIBLE')