Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  n,k = map(int,readline().split())
  h = list(map(int,readline().split()))

  dp = [float('inf')]*n
  dp[0] = 0

  for i in range(1,n):
    for j in range(min(k,i)):
      dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]))

  print(dp[n-1])
if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = map(int,readline().split())
h = list(map(int,readline().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(1,n):
  for j in range(min(k,i)):
    dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]))

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = map(int,readline().split())
h = list(map(int,readline().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(1,n):
  for j in range(min(k,i)):
    dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]))

print(dp[n-1])

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,k = map(int,readline().split())
h = list(map(int,readline().split()))

dp = [float('inf')]*n
dp[0] = 0

for i in range(1,n):
  for j in range(min(k,i)):
    dp[i] = min(dp[i], dp[i-1-j]+abs(h[i]-h[i-1-j]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
chk = []
for i in range(n):
  a = int(input())
  chk.append(a)
chk.sort()
if n%2 == 0:
  l = [i*2 for i in chk[:n//2]]
  r = [i*2 for i in chk[n//2:]]
  print(sum(r)-sum(l)+chk[n//2-1]-chk[n//2])
else:
  l = [i*2 for i in chk[:(n-1)//2]]
  r = [i*2 for i in chk[(n-1)//2+1:]]
  print(max(sum(r)-sum(l)+chk[(n-1)//2-1]-chk[(n-1)//2]),(sum(r)-sum(l)+chk[(n-1)//2]-chk[(n-1)//2+1]))

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
chk = []
for i in range(n):
  a = int(input())
  chk.append(a)
chk.sort()
if n%2 == 0:
  l = [i*2 for i in chk[:n//2]]
  r = [i*2 for i in chk[n//2:]]
  print(sum(r)-sum(l)+chk[n//2-1]-chk[n//2])
else:
  l = [i*2 for i in chk[:(n-1)//2]]
  r = [i*2 for i in chk[(n-1)//2+1:]]
  p = sum(r)-sum(l)+chk[(n-1)//2-1]-chk[(n-1)//2]
  q = sum(r)-sum(l)+chk[(n-1)//2]-chk[(n-1)//2+1]
  print(max(p,q))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = innt(input())
chk = []
for i in range(n):
  a = input()
  chk.append(a)
chk.sort()
if n%2 == 0:
  l = [i*2 for i in chk[:n//2]]
  r = [i*2 for i in chk[n//2:]]
  print(sum(r)-sum(l)+chk[n//2-1]-chk[n//2])
else:
  l = [i*2 for i in chk[:(n-1)//2]]
  r = [i*2 for i in chk[(n-1)//2+1:]]
  print(max(sum(r)-sum(l)+chk[(n-1)//2-1]-chk[(n-1)//2]),(sum(r)-sum(l)+chk[(n-1)//2]-chk[(n-1)//2+1]))

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
chk = []
for i in range(n):
  a = int(input())
  chk.append(a)
chk.sort()
if n%2 == 0:
  l = [i*2 for i in chk[:n//2]]
  r = [i*2 for i in chk[n//2:]]
  print(sum(r)-sum(l)+chk[n//2-1]-chk[n//2])
else:
  l = [i*2 for i in chk[:(n-1)//2]]
  r = [i*2 for i in chk[(n-1)//2+1:]]
  p = sum(r)-sum(l)+chk[(n-1)//2-1]-chk[(n-1)//2]
  q = sum(r)-sum(l)+chk[(n-1)//2]-chk[(n-1)//2+1]
  print(max(p,q))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

p,q,r = c[0]
if n == 1:
  print(p,q,r)
  exit()

end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    chk = abs(p-i)+abs(q-j)+r
    for num,k in enumerate(c):
      x,y,h = k
      if abs(x-i)+abs(y-j)+h != chk and h != 0:
        break
      if k == end:
        ans = (i,j,chk)

print(*ans)

Fixed submission:
n = int(input())
if n == 1:
  print('Hello World')
  exit()
else:
  a = int(input())
  b = int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

p,q,r = c[0]
if n == 1:
  print(p,q,r)
  exit()

end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    chk = abs(p-i)+abs(q-j)+r
    for num,k in enumerate(c):
      x,y,h = k
      if abs(x-i)+abs(y-j)+h != chk and h != 0:
        break
      if k == end:
        ans = (i,j,chk)

print(*ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

from operator import itemgetter
c = sorted(c,key=itemgetter(2),reverse=True)
p,q,r = c[0]
end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    if r > 0:
      chk = abs(p-i)+abs(q-j)+r
    else:
      chk = 1
    for num,k in enumerate(c):
      x,y,h = k
      if h == 0:
        if abs(x-i)+abs(y-j) < chk:
          break
      else:
        if abs(x-i)+abs(y-j)+h != chk:
          break
      if k == end:
        ans = (i,j,chk)

print(*ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

p,q,r = c[0]
c = c[1:]
for i in range(101):
  for j in range(101):
    chk = abs(p-i)+abs(q-j)+r
    for num,k in enumerate(c):
      x,y,h = k
      if abs(x-i)+abs(y-j)+h != chk:
        break
      if num == n-2:
        ans = (i,j,chk)

print(*ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

from operator import itemgetter
c = sorted(c,key=itemgetter(2),reverse=True)
p,q,r = c[0]
end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    if r > 0:
      chk = abs(p-i)+abs(q-j)+r
    else:
      chk = 1
    for num,k in enumerate(c):
      x,y,h = k
      if h == 0:
        if abs(x-i)+abs(y-j) < chk:
          break
      else:
        if abs(x-i)+abs(y-j)+h != chk:
          break
      if k == end:
        ans = (i,j,chk)

print(*ans)
Buggy python submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
  
n,m = map(int,input().split())
chk = factorization(m)
#print(chk)
def make_array_for_comb(N, mod=10**9+7):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod=10**9+7):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

mod = 10**9+7
fact, fact_inv = make_array_for_comb(n,mod)
ans = 1
for i in chk:
  ans *= comb(i[1]+n-1,i[1],mod)
  ans %= mod
if m == 1:
  ans = 1
print(ans)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
  
n,m = map(int,input().split())
chk = factorization(m)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) 
  
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

mod = 10**9+7
ans = 1
for i in chk:
  ans *= comb(i[1]+n-1,i[1],mod)
  ans %= mod
if m == 1:
  ans = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
  array = list(map(int,input().split()))
  ab.append(array)

w = [[int(i) for i in range(ab[u][0],ab[u][1])] for u in range(m)]
ans = 0
#print(w)
import collections
while True:
  d = [e for row in w for e in row]
  #print(d)
  if d == []:
    print(ans)
    break
  else:
    # collections.Counter使用時は宣言する
    c = collections.Counter(d)
    t = c.most_common()[0][0]
    ans += 1
    w = [i for i in w if not t in i]
    #print(w)

Fixed submission:
from operator import itemgetter

n, m = [int(i) for i in input().split()]

# 区間の終端でソート
ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a in ab:
    # a が removed より大きい = まだ取り除いてない
    if a[0] > removed:
        #print(a)
        removed = a[1] - 1
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
  array = list(map(int,input().split()))
  ab.append(array)

w = [[int(i) for i in range(ab[u][0],ab[u][1])] for u in range(m)]
ans = 0
#print(w)
import collections
while True:
  d = [e for row in w for e in row]
  #print(d)
  if d == []:
    print(ans)
    break
  else:
    # collections.Counter使用時は宣言する
    c = collections.Counter(d)
    t = c.most_common()[0][0]
    ans += 1
    w = [i for i in w if not t in i]
    #print(w)

Fixed submission:
from operator import itemgetter

n, m = [int(i) for i in input().split()]

# 区間の終端でソート
ab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a in ab:
    # a が removed より大きい = まだ取り除いてない
    if a[0] > removed:
        #print(a)
        removed = a[1] - 1
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
input = sys.stdin.readline
n = int(input())
a = np.array([list(input().rstrip()) for i in range(n)])
ans = 0
for i in range(n):
  c = np.roll(a,i,axis=0)
  for j in range(n):
    d = np.roll(c,j,axis=1)
    if np.array_equal(d,d.T):
      ans += 1
print(ans)

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
n = int(input())
a = np.array([list(input().rstrip()) for i in range(n)])
ans = 0
for i in range(n):
  c = np.roll(a,i,axis=0)
  if np.array_equal(c,c.T):
    ans += 1
print(ans*n)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = []
for i in range(n):
  s = list(input())
  a .append(s)
a = np.array(a)
ans = 0
for i in range(n):
  c = np.roll(a,i,axis=0)
  for j in range(n):
    d = np.roll(c,j,axis=1)
    if np.array_equal(d,d.T):
      ans += 1
print(ans)

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
n = int(input())
a = np.array([list(input().rstrip()) for i in range(n)])
ans = 0
for i in range(n):
  c = np.roll(a,i,axis=0)
  if np.array_equal(c,c.T):
    ans += 1
print(ans*n)
Buggy python submission (verdict: Runtime Error):
import math
q = int(input())
for i in range(q):
  a,b = map(int,input().split())
  if a == b:
    print(a*2-2)
    continue
  y = max(a,b)
  z = min(a,b)
  ind = int(math.sqrt(a*b))
  if ind.is_integer():
    ind -= 1
  cnt = 0
  else:
    if ind*(ind+1) < a*b:
      if ind >= z:
        cnt = 1
      if ind+1 >= y:
        cnt = 2
      print(2*ind-cnt)
    else:
      if ind >= z:
        cnt = 1
      print(2*ind-1-cnt)

Fixed submission:
q = int(input())
for i in range(q):
  a,b = map(int,input().split())
  if a == b:
    print(2*a-2)
  else:
    n= (a*b)**0.5
    d = int(n)
    if n.is_integer():
        d -= 1
    ans = d*2-1
    if d*(d+1) >= a*b:
      ans -= 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 3:
  print(2,5,63)
elif n == 4:
  print(2,5,20,63)
elif n == 6:
  print(2,4,6,12,3,9)
else:
  m = 1
  if n > 15001:
    m = (n-15000)//2
  for j in range(m,2501):
    if (n-2*j)/3 == int((n-2*j)/3) and 0 < (n-2*j)//3 <= 5000:
      x = j; y = (n-2*x)//3
      #print(x,y,2*x+3*y)
      break
  ans = []
  for i in range(2*x):
    ans.append(3+6*i)
  for j in range(3*y):
    ans.append(2+2*j)
    
  print(*ans)

Fixed submission:
n = int(input())
if n == 3:
  print(2,5,63)
elif n == 4:
  print(2,5,20,63)
elif n == 6:
  print(2,4,6,12,3,9)
elif n == 19999:
  ans = []
  for i in range(5000):
    ans.append(3+6*i)
  for j in range(15000):
    m = 2+2*j
    if m != 30:
      ans.append(m)
  print(*ans)
else:
  m = 1
  if n > 15001:
    m = (n-15000)//2
  for j in range(m,2501):
    if (n-2*j)/3 == int((n-2*j)/3) and 0 < (n-2*j)//3 <= 5000:
      x = j; y = (n-2*x)//3
      #print(x,y,2*x+3*y)
      break
  ans = []
  for i in range(2*x):
    ans.append(3+6*i)
  for j in range(3*y):
    ans.append(2+2*j)
    
  print(*ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 3:
  print(2,5,63)
elif n == 4:
  print(2,5,20,63)
elif n == 6:
  print(2,4,6,12,3,9)
else:
  m = 1
  if n > 15001:
    m = (n-15000)//2
  for j in range(m,2501):
    if (n-2*j)/3 == int((n-2*j)/3) and (n-2*j)//3 <= 5000:
      x = j; y = (n-2*x)//3
      #print(x,y,2*x+3*y)
      break
  ans = []
  for i in range(2*x):
    ans.append(3+6*i)
  for j in range(3*y):
    ans.append(2+2*j)
    
  print(*ans)

Fixed submission:
n = int(input())
if n == 3:
  print(2,5,63)
elif n == 4:
  print(2,5,20,63)
elif n == 6:
  print(2,4,6,12,3,9)
elif n == 19999:
  ans = []
  for i in range(5000):
    ans.append(3+6*i)
  for j in range(15000):
    m = 2+2*j
    if m != 30:
      ans.append(m)
  print(*ans)
else:
  m = 1
  if n > 15001:
    m = (n-15000)//2
  for j in range(m,2501):
    if (n-2*j)/3 == int((n-2*j)/3) and 0 < (n-2*j)//3 <= 5000:
      x = j; y = (n-2*x)//3
      #print(x,y,2*x+3*y)
      break
  ans = []
  for i in range(2*x):
    ans.append(3+6*i)
  for j in range(3*y):
    ans.append(2+2*j)
    
  print(*ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
from collections import Counter
c = Counter()
for i in range(n):
  c.update[{input():1}]
  
m = int(input())
for i in range(m):
  s = input()
  if c[s] >= 1:
    c.update[{s:-1}]
    
print(c.most_common()[0][1])

Fixed submission:
n = int(input())
from collections import Counter
c = Counter()
for i in range(n):
  a = input()
  c.update({a:1})
  
m = int(input())
for i in range(m):
  s = input()
  if c[s] >= 1:
    c.update({s:-1})
    
print(c.most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
from bisect import bisect
n = int(input())
a = [tuple(map(int,input().split())) for i in range(n)]
b = [tuple(map(int,input().split())) for i in range(n)]
a.sort(key=itemgetter(1))
a.sort(key=itemgetter(0))
b.sort(key=itemgetter(1))
b.sort(key=itemgetter(0))

ans = 0
for l,r in b:
  ind = bisect(a,(l-1,r-1))
  chk = 0
  for i in range(ind):
    if a[i][1] < r:
      chk = max(chk,a[i][1])
      if chk == a[i][1]:
        d = i
  if ind > 0:
    ans += 1
    k = a[d]
    a.remove(k)
print(ans)

Fixed submission:
from operator import itemgetter
from bisect import bisect
n = int(input())
a = [tuple(map(int,input().split())) for i in range(n)]
b = [tuple(map(int,input().split())) for i in range(n)]
a.sort(key=itemgetter(1))
a.sort(key=itemgetter(0))
b.sort(key=itemgetter(1))
b.sort(key=itemgetter(0))

ans = 0
for l,r in b:
  ind = bisect(a,(l-1,r-1))
  chk = 0
  d = -1
  for i in range(min(len(a),ind)):
    if a[i][1] < r:
      chk = max(chk,a[i][1])
      if chk == a[i][1]:
        d = i
  if d >= 0:
    ans += 1
    k = a[d]
    a.remove(k)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
while True:
  t = b&(-b)
  if (s+1)//2 <= t.bit_length()-1 <= s:
    print(t.bit_length()-1)
    break
  b ^= t

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
b &= 2**(s+1)-2**((s-1)//2)
while True:
  t = b&(-b)
  #print(i,t,b)
  if (s+1)//2 <= t.bit_length()-1 <= s:
    print(t.bit_length()-1)
    break
  b ^= t

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
while True:
  t = b&(-b)
  if (s+1)//2 <= t.bit_length()-1 <= s:
    print(t.bit_length()-1)
    break
  b ^= t

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
b &= 2**(s+1)-2**((s-1)//2)
while True:
  t = b&(-b)
  #print(i,t,b)
  if (s+1)//2 <= t.bit_length()-1 <= s:
    print(t.bit_length()-1)
    break
  b ^= t

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 0
for i in a:
  b |= b<<i
  b |= 1<<i
  
def all_bit_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8) 
    x = x + (x >> 16) 
    x = x + (x >> 32) 
    return x & 0x0000007f
  

l = all_bit_count(b)
for i in range((l+1)//2):
  t = b&(-b)
  b ^= t
  
print(t.bit_length()-1)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
b &= 2**(s+1)-2**((s-1)//2)
while True:
  t = b&(-b)
  #print(i,t,b)
  if (s+1)//2 <= t.bit_length()-1 <= s:
    print(t.bit_length()-1)
    break
  b ^= t
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
import collections
c = collections.Counter(a)
for i in range(1,max(a)+1):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [i for i in a if i <= 10**5]
ans = len(a)-len(b)
import collections
c = collections.Counter(b)
for i in range(0,10**5+1):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
import collections
c = collections.Counter(a)
for i in range(10**9):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [i for i in a if i <= 10**5]
ans = len(a)-len(b)
import collections
c = collections.Counter(b)
for i in range(0,10**5+1):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
b = [i for i in a if i <= 10**5]
#for i in a:
  #if i > 10**5:
    #break
  #else:
    #b.append(i)
ans = len(a)-len(b)
for i in range(1,10**5+1):
  if b.count(i) == i or 0:
    continue
  elif b.count(i) < i:
    ans += b.count(i)
  elif b.count(i) > i:
    ans += b.count(i)-i
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [i for i in a if i <= 10**5]
ans = len(a)-len(b)
import collections
c = collections.Counter(b)
for i in range(0,10**5+1):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
b = []
for i in a:
  if i > 10**5:
    break
  else:
    b.append(i)
ans = len(a)-len(b)
for i in range(1,10**5+1):
  if b.count(i) == i or 0:
    continue
  elif b.count(i) < i:
    ans += b.count(i)
  elif b.count(i) > i:
    ans += b.count(i)-i
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [i for i in a if i <= 10**5]
ans = len(a)-len(b)
import collections
c = collections.Counter(b)
for i in range(0,10**5+1):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def warshall_floyd(d,s):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d[s][1]

h,w = map(int,input().split())

d = [[10**4]*10 for i in range(10)] 
for i in range(10):
    a = list(map(int,input().split()))
    for j in range(10):
      d[i][j] = a[j]
for i in range(10):
    d[i][i] = 0
    
ans = 0
for _ in range(h):
  c = list(map(int,input().split()))
  for i in c:
    if i != 1 and i != -1:
      ans += warshall_floyd(d,i)
      
print(ans)

Fixed submission:
def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

h,w = map(int,input().split())

d = [[10**4]*10 for i in range(10)] 
for i in range(10):
    a = list(map(int,input().split()))
    for j in range(10):
      d[i][j] = a[j]
for i in range(10):
    d[i][i] = 0
    
ans = 0
chk = tuple(warshall_floyd(d))
for _ in range(h):
  c = list(map(int,input().split()))
  for i in c:
    if i != 1 and i != -1:
      ans += chk[i][1]
      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
  for j in range(n):
    if a[i] < b[j]:
      for k in range(n):
        if b[j] < c[k]:
          ans += n-k
          break
    j += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = 0
a = tuple(a); b = tuple(b); c = tuple(c)
a = sorted(a)
b = sorted(b,reverse=True)
c = sorted(c)

import bisect
chk_b = [0]*n
for i,bi in enumerate(b):
  y = bisect.bisect_right(c, bi)
  chk_b[i] = max(0,n-y) + chk_b[i-1]
  
chk_b = tuple(chk_b)
b = sorted(b)
for i in a:
  x = bisect.bisect_right(b, i)
  if x <= n-1:
    ans += chk_b[n-1-x]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
  for j in range(n):
    if a[i] < b[j]:
      for k in range(n):
        if b[j] < c[k]:
          ans += n-k
          break
    j += 1
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = 0
a = tuple(a); b = tuple(b); c = tuple(c)
a = sorted(a)
b = sorted(b,reverse=True)
c = sorted(c)

import bisect
chk_b = [0]*n
for i,bi in enumerate(b):
  y = bisect.bisect_right(c, bi)
  chk_b[i] = max(0,n-y) + chk_b[i-1]
  
chk_b = tuple(chk_b)
b = sorted(b)
for i in a:
  x = bisect.bisect_right(b, i)
  if x <= n-1:
    ans += chk_b[n-1-x]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
import math
U = math.ceil(3*N/4)
D = math.ceil(N/4)
if N % 2 == 0:
  print(N,N,N//2)
else:
  if D%2 == 1:
    D += 1
  h = -1
  for n in range(D,3500):
    if h > 0:
      break
    for w in range(n,3500):
      #print(h,n,w)
      if w*n*N/(4*n*w-w*N-n*N) == int(w*n*N/(4*n*w-w*N-n*N)):
        h = w*n*N//(4*n*w-w*N-n*N)
        ans = (w*n*N//(4*n*w-w*N-n*N),n,w)
        break
        
print(ans)

Fixed submission:
N = int(input())
import math
U = math.ceil(3*N/4)
D = math.ceil(N/4)
if N % 2 == 0:
  ans = (N,N,N//2)
else:
  if D%2 == 1:
    D += 1
  h = -1
  for n in range(D,3500):
    if h > 0:
      break
    for w in range(n,3500):
      #print(h,n,w)
      if w*n*N/(4*n*w-w*N-n*N) == int(w*n*N/(4*n*w-w*N-n*N)):
        h = w*n*N//(4*n*w-w*N-n*N)
        ans = (w*n*N//(4*n*w-w*N-n*N),n,w)
        break
        
print(*ans)