Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

H, W, M = map(int, readline().split())

h = {}
w = {}
m = {}
for i in range(M):
    hi, wi = map(int, readline().split())
    if hi not in h:
        h[hi] = 1
        m[hi] = [wi]
    else:
        h[hi] += 1
        m[hi].append(wi)
    if wi not in w:
        w[wi] = 1
    else:
        w[wi] += 1

max_h = max(h.values())
max_w = max(w.values())
max_h_list = [kv[0] for kv in h.items() if kv[1] == max_h]
max_w_list = [kv[0] for kv in w.items() if kv[1] == max_w]

for i in max_h_list:
    for j in max_w_list:
        if j not in m[i]:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)


### FIXED CODE ###

import sys
readline = sys.stdin.readline

H, W, M = map(int, readline().split())

h = {}
w = {}
m = {}
for i in range(M):
    hi, wi = map(int, readline().split())
    if hi not in h:
        h[hi] = 1
        m[hi] = set()
        m[hi].add(wi)
    else:
        h[hi] += 1
        m[hi].add(wi)
    if wi not in w:
        w[wi] = 1
    else:
        w[wi] += 1

max_h = max(h.values())
max_w = max(w.values())
max_h_list = [kv[0] for kv in h.items() if kv[1] == max_h]
max_w_list = [kv[0] for kv in w.items() if kv[1] == max_w]

for i in max_h_list:
    for j in max_w_list:
        if j not in m[i]:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)
### BUGGY CODE ###

n,k = map(int,input().split())
p_list = list(map(int,input().split()))

max_count = 0

for i in range(n-k+1):
    count = sum(p_list[i:i+k])/2 + k/2
    max_count = max(max_count,count)

print(max_count)

### FIXED CODE ###

n,k = map(int,input().split())
p_list = list(map(int,input().split()))

max_count = 0
summary = 0
 
for i in range(n-k+1):
    if i == 0:
        summary = sum(p_list[i:i+k])
    else:
        summary += p_list[i+k-1]-p_list[i-1]
    max_count = max(max_count,summary)
 
print(max_count/2 + k/2)
### BUGGY CODE ###

N,Q = list(map(int, input().split()))
STX = [list(map(int, input().split())) for _ in range(N)]
D = [int(input()) for _ in range(Q)]

L = [(s-x-0.5, t-x-0.5,x) for s,t,x in STX] + [(d,) for d in D]
L.sort()

import heapq
hp = [] # (x,t-x)を入れる

for l in L:
  if len(l)==1:
    while hp and l[0] > hp[0][1]:
      heapq.heappop(hp)
    if hp:
      print(hp[0][0])
    else:
      print(-1)
  else:
    heapq.heappush(hp, (l[2],l[1]))

### FIXED CODE ###

N,Q = list(map(int, input().split()))
STX = [list(map(int, input().split())) for _ in range(N)]
D = [int(input()) for _ in range(Q)]

L = [(s-x-0.5, t-x-0.5,x) for s,t,x in STX] + [(d,) for d in D]
L.sort()

import heapq
hp = [] # xを入れる
memo = {} # x:t-x

for l in L:
  if len(l)==1:
    while hp and l[0] > memo[hp[0]]:
      heapq.heappop(hp)
    if hp:
      print(hp[0])
    else:
      print(-1)
  else:
    heapq.heappush(hp, l[2])
    memo[l[2]]=l[1]
### BUGGY CODE ###

from fractions import gcd

N, P = map(int, input().split())
S = input().strip()

if gcd(10, P) > 1:
    ans = 0
    for i in range(len(S)):
        s = int(S[i])
        if s % P == 0:
            ans += (i+1)
    print(ans)
else:
    p = [0]*P
    ans = 0
    for i in range(len(S)-1, -1, -1):
        s = int(S[i:])
        m = s % P
        if m == 0:
            p[m] += 1
            ans += p[m]
        else:
            ans += p[m]
            p[m] += 1

    print(ans)


### FIXED CODE ###

from fractions import gcd

N, P = map(int, input().split())
S = input().strip()

if gcd(10, P) > 1:
    ans = 0
    for i in range(len(S)):
        s = int(S[i])
        if s % P == 0:
            ans += (i+1)
    print(ans)
else:
    p = [0]*P
    ans = 0
    s = 0
    for i in range(len(S)-1, -1, -1):
        s = (s + int(S[i])*pow(10, N-1-i, P)) % P
        m = s % P
        if m == 0:
            p[m] += 1
            ans += p[m]
        else:
            ans += p[m]
            p[m] += 1

    print(ans)
### BUGGY CODE ###

N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C = 0
while H > 0:
    Ma = max(A)
    if B == []:
        C += int(-(-H//Ma))
        H = 0
    else:
        Mb = max(B)
        if Ma > Mb:
            C += int(-(-H//Ma))
            H = 0
        else:
            C += 1
            H -= Mb
            B.remove(Mb)
print(C)

### FIXED CODE ###

N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma and H > 0:
  i += 1
  H -= Mb
  if i == N:
    Mb = 0
  else:
    Mb = B[i]
if H <= 0:
  print(i)
else:
  print(i+int(-(-H//Ma)))
### BUGGY CODE ###

n = int(input())
d_l = list(map(int,input().split()))

count_l = [0] * n
for i in range(n):
    count_l[i] = d_l.count(i)

if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

n_tmp = n-1
for i in range(1,n):
    ans = ans*(count_l[i-1]**count_l[i])
    n_tmp -= count_l[i]
    if n_tmp == 0:
        break

print(ans%998244353)

### FIXED CODE ###

n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)
### BUGGY CODE ###

from sys import stdin
import itertools
import math

a,b = [int(x) for x in stdin.readline().rstrip().split()]

def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True

if a == 1:
    print(1)
    exit()

def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0 and isPrime(i) == True:
            cf.append(i)
    return cf

li2 = list(itertools.combinations(cf(a,b),2))
flat = [flatten for inner in li2 for flatten in inner]
print(len(list(set(flat))))

### FIXED CODE ###

from sys import stdin
import fractions
import bisect

a,b = [int(x) for x in stdin.readline().rstrip().split()]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

ali = set(prime_factorize(a))
bli = set(prime_factorize(b))

ali = list(ali)
bli = list(bli)

point = 0
for i in range(len(ali)):
    if ali[i] in bli:
        point += 1
print(point+1)
### BUGGY CODE ###

a,b,n=map(int, input().split())
list =[int(a*x/b)-a* int(x/b) for x in range(n+1)]
print(max(list))

### FIXED CODE ###

a,b,n = map(int, input().split())
x = min(b-1,n)
print(int(a*x/b))
### BUGGY CODE ###

X,Y=map(int,input().split())

def cmb(n,k):
    x,y=1,1
    for i in range(k):
        x*=(n-i)%mod
        y*=(k-i)%mod
    return x*pow(y,mod-2,mod)%mod

if (X+Y)%3!=0:
    print(0)
else:
    m=(2*X-Y)//3
    n=(2*Y-X)//3
    if n<0 or m<0:
        print(0)
    else:
        mod=10**9+7
        ans=cmb(n+m,min(n,m))
        print(ans)

### FIXED CODE ###

X,Y=map(int,input().split())

def cmb(n,k):
    x,y=1,1
    for i in range(k):
        x = x * (n-i)%mod
        y = y * (k-i)%mod
    return x*pow(y,mod-2,mod)%mod

if (X+Y)%3!=0:
    print(0)
else:
    m=(2*X-Y)//3
    n=(2*Y-X)//3
    if n<0 or m<0:
        print(0)
    else:
        mod=10**9+7
        ans=cmb(n+m,min(n,m))
        print(ans)
### BUGGY CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
L = []
for i in A:
  for j in range(len(L)):
    if L[j] < i:
      L[j] = i
      break
  else:
    L.append(i)
print(len(L))

### FIXED CODE ###

import bisect
n = int(input())
A = [int(input()) for _ in range(n)]
L = [-1]*n
count = 0
for i in A:
  t = bisect.bisect_left(L, i) - 1
  if L[t] == -1:
    count += 1
  L[t] = i
print(count)
### BUGGY CODE ###

l,r=map(int,input().split())
ans=l*r%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
        if ans==0:
            break
        
print(ans)

### FIXED CODE ###

l,r=map(int,input().split())
ans=l*r%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
        if ans==0:
            break
    if ans==0:
        break
print(ans)
### BUGGY CODE ###

N=int(input())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
ans=0
for j in range(N):
    tt=[]
    for k in range(N):
        if s[j]<t[k]:
            tt.append(t[k])
    for ii in range(len(tt)):
        for jj in range(N):
            if tt[ii]<u[jj]:
                ans+=1
print(ans)            

### FIXED CODE ###

import bisect
N=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:
    aa=bisect.bisect_left(a,i)
    cc=N-bisect.bisect_right(c,i)
    ans+=aa*cc
print(ans)
### BUGGY CODE ###

from operator import mul
from functools import reduce

[n,k] = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

def hyoka(j,p,b_point):
  if j == k:
    point = reduce(mul, A[0:j])
    return point
  else:
    point = b_point/A[j-k-1]*p
    
  if b_point < point:
    print('Yes')
  else:
    print('No')
  return point
b_point = 0
for j,p in enumerate(A[k-1:n+1]):
  i = j+k-1
  result = hyoka(i+1,p,b_point)
  if result > 0:
  	b_point = result


### FIXED CODE ###

[n,k] = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

for i in range(k,n):
  if A[i-k]<A[i]:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

def main():
    _ = input()
    ans = 1

    for i in map(int, input().split()):
        if i == 0:
            print(0)
            return 0
        ans *= i
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    _ = input()
    lst = list(map(int, input().split()))
    ans = 1

    if 0 in lst:
        print(0)
        exit()
    for i in lst:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1

mul = 1

for i, x in enumerate(S[::-1]):
  if x == "?":
    for k in range(10):
      for j in range(13):
        dp[i + 1][(mul * k + j) % 13] += dp[i][j]
        dp[i + 1][(mul * k + j) % 13] %= MOD
  else:
    k = int(x)
    for j in range(13):
      dp[i + 1][(mul * k + j) % 13] += dp[i][j]
      dp[i + 1][(mul * k + j) % 13] %= MOD

  mul = mul * 10

print(dp[N][5])

### FIXED CODE ###

MOD = 10 ** 9 + 7

S = input()
N = len(S)

dp = [[0] * 13 for _ in range(N + 1)]
dp[0][0] = 1

mul = 1

for i, x in enumerate(S[::-1]):
  if x == "?":
    for k in range(10):
      for j in range(13):
        jj = (mul * k + j) % 13
        dp[i + 1][jj] += dp[i][j]
        dp[i + 1][jj] %= MOD
  else:
    k = int(x)
    for j in range(13):
      jj = (mul * k + j) % 13
      dp[i + 1][jj] += dp[i][j]
      dp[i + 1][jj] %= MOD

  mul = (mul * 10) % 13

print(dp[N][5])
### BUGGY CODE ###

A, B = map(int,input().split())

while A != B:
    if A > B:
        A, B = B, A
    A += A

print(A)

### FIXED CODE ###

import math

A, B = map(int,input().split())

print((A*B)//math.gcd(A,B))
### BUGGY CODE ###

def main():
    s = list(input())
    s = s[::-1]

    l = [[[] for j in range(3)] for i in range(673)]
    l[0][0].append(0)
    mo = 0
    ten = 1
    mod = 673
    now = 0
    ans = 0
    for i in range(len(s)):
        a = int(s[i])*ten
        mo = (mo+a)%3
        now = (now+a)%mod
        if l[now][mo]:
            ans += len(l[now][mo])
        l[now][mo].append(i+1)
        ten *= 10
    print(ans)
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    s = list(input())
    s = s[::-1]

    l = [[[] for j in range(3)] for i in range(673)]
    l[0][0].append(0)
    mo = 0
    ten = 1
    mod = 673
    now = 0
    ans = 0
    for i in range(len(s)):
        a = int(s[i])*ten
        mo = (mo+a)%3
        now = (now+a)%mod
        if l[now][mo]:
            ans += len(l[now][mo])
        l[now][mo].append(i+1)
        ten *= 10
        ten %= 2019
    print(ans)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

S = list(input())
S.reverse()
N = len(S)
mod = 10 ** 9 + 7
ans = [0 for r in range(13)]
if S[0] == '?':
    ans = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]
else:
    ans[int(S[0])] = 1
for n in range(1, N):
    if S[n] == '?':
        ans = [sum([ans[(r-(d*pow(10, n, 13) % 13)) % 13]
                    for d in range(10)]) % mod for r in range(13)]
    else:
        ans = [ans[(r-(int(S[n])*pow(10, n, 13) % 13)) % 13]
               for r in range(13)]
print(ans[5])


### FIXED CODE ###

S = list(input())
S.reverse()
N = len(S)
mod = 10**9+7
dp = [[0 for r in range(13)] for n in range(N+1)]
dp[0][0] = 1
lookup = [[0 for d in range(10)] for n in range(N)]
for n in range(N):
    for d in range(10):
        lookup[n][d] = d*pow(10, n, 13) % 13
for n in range(1, N+1):
    if S[n-1] == '?':
        for d in range(10):
            for r in range(13):
                dp[n][(r+lookup[n-1][d]) % 13] += dp[n-1][r] % mod
    else:
        for r in range(13):
            dp[n][(r+lookup[n-1][int(S[n-1])]) % 13] += dp[n-1][r] % mod
print(dp[-1][5] % mod)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(n):
    b = b * a[i]

if b > 10**18:
    b = -1
print(b)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a_s = sorted(a)
b = 1
for i in range(n):
    b = b * a_s[i]
    if b > 10**18:
        b = -1
        break
    elif b == 0:
        break

print(b)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    for i in range(N):
        A_tmp = A[0: i] + A[i+1: N]
        print(max(A_tmp))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    current_max_index = A.index(current_max)
    # print('---')
    print(current_max)
    previous_max = current_max
    previous_max_index = current_max_index
    for i in range(1, N):
        # A_tmp = A[0:i] + A[i+1:N]
        if i != previous_max_index:
            current_max = max([A[i-1], previous_max])
            current_max_index = previous_max_index
        else:
            current_max = max(A[0:i] + A[i+1:N])
            current_max_index = A.index(current_max)
        print(current_max)
        previous_max = current_max
        previous_max_index = current_max_index


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
    A=sum(a[:i+1])
    if i==0:
        ans=abs(sum(a)-2*A)
    else:
        ans=min(abs(sum(a)-2*A),ans)
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=sum(a)
A=a[0]
for i in range(n-1):
    if i==0:
        ans=abs(b-2*A)
    else:
        ans=min(abs(b-2*A),ans)
    A+=a[i+1]
print(ans)
### BUGGY CODE ###

import functools
#import math
import fractions

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

#gcd_all = functools.reduce(math.gcd, A)
gcd_all = functools.reduce(fractions.gcd, A)
#print(gcd_all)

for i in range(N):
    #list = A[:i] + A[i+1:]
    #print(list)
    #gcd_1 = functools.reduce(math.gcd, list)
    gcd_1 = functools.reduce(fractions.gcd, (A[:i]+A[i+1:]))
    #print(gcd_1)
    if gcd_1 >= gcd_all:
        #index = i
        #value = gcd_1
        gcd_all = gcd_1

#A[index] = value

#print(functools.reduce(math.gcd, A))
#print(functools.reduce(fractions.gcd, A))
print(gcd_all)


### FIXED CODE ###

from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)
### BUGGY CODE ###

# coding: utf-8


def main():
    n = int(input())
    s = [input() for i in range(n)]
    e = []
    for i in range(n):
        word = [0] * 200
        for w in s[i]:
            word[ord(w)] += 1

        e.append(word)

    ans = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if e[i] == e[j]:
                ans += 1
    print(ans)

main()


### FIXED CODE ###

# coding: utf-8

def main():
    n = int(input())
    l = ["".join(sorted(input())) for i in range(n)]

    c = {}
    ans = 0
    for s in l:
        if s in c:
            c[s] = c[s] + 1
        else:
            c[s] = 0
        ans += c[s]

    print(ans)

main()
### BUGGY CODE ###

n,m=map(int,input().split())
graph=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

sign=[-1]*n
sign[0]=0
work=[]
work_next=graph[0]
for x in work_next:
    sign[x]=0


while work_next:
    work=work_next[:]
    work_next=[]
    for x in work:
        for y in graph[x]:
            if sign[y]>=0 : continue
            if y in work_next : continue
            sign[y]=x
            work_next.append(y)

if -1 in sign : print("No");exit()
print("Yes")
for i in range(1,n):
    print(sign[i]+1)

### FIXED CODE ###

n,m=map(int,input().split())
graph=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

sign=[-1]*n
sign[0]=0
work=[]
work_next=graph[0]
for x in work_next:
    sign[x]=0


while work_next:
    work=work_next[:]
    work_next=[]
    for x in work:
        for y in graph[x]:
            if sign[y]>=0 : continue
            if y in work_next : continue
            sign[y]=x
            work_next.append(y)

if -1 in sign : print("No");exit()
print("Yes")
for i in range(1,n):
    print(sign[i]+1)
### BUGGY CODE ###

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

ans=0
MOD= 1000000007

c=[0]*(n+1)
c[0]=1
if 1 in a:
    c[1]=0
else:
    c[1]=1

for i in range(2,n+1):
    c[i]+=(c[i-1]+c[i-2])%MOD
    if i in a:
        c[i]=0

print(c[n]%MOD)

### FIXED CODE ###

n,m=map(int,input().split())
a = set([int(input()) for _ in range(m)])

INF=1000000007
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
    dp[1]=0
else:
    dp[1]=1
for i in range(2,n+1):
    if i in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
    dp[i]%=INF
print(dp[n])
### BUGGY CODE ###

from collections import deque
import sys
inputs = sys.stdin.readline
N,M = map(int,input().split())
UV = [tuple(map(lambda x:int(x)-1,inputs().split())) for i in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

es = [[set() for j in range(N)] for i in range(3)]
for u,v in UV:
    es[0][u].add(v)

nex = {}
for i in range(2):
    for j in range(N):
        if hash(tuple(es[i][j])) in nex:
            es[i+1][j] = nex[hash(tuple(es[i][j]))]
            continue
        for k in es[i][j]:
            es[i+1][j] |= es[0][k]
        nex[hash(tuple(es[i][j]))] = es[i+1][j]

INF = float('inf')
dist = [INF]*N
dist[S] = 0
q = deque([S])
while q:
    v = q.popleft()
    for to in es[2][v]:
        if dist[to] != INF: continue
        dist[to] = dist[v]+1
        if to == T:
            print(dist[to])
            exit()
        q.append(to)

print(-1)

### FIXED CODE ###

from collections import deque
import sys
inputs = sys.stdin.readline
N,M = map(int,input().split())
UV = [tuple(map(lambda x:int(x)-1,inputs().split())) for i in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

es = [[] for i in range(3*N)]
for u,v in UV:
    es[u].append(v+N)
    es[u+N].append(v+2*N)
    es[u+2*N].append(v)

q = deque([S])
INF = float('inf')
dist = [INF] * (3*N)
dist[S] = 0

while q:
    v = q.popleft()
    for to in es[v]:
        if dist[to] != INF: continue
        dist[to] = dist[v] + 1
        if to==T:
            print(dist[to] // 3)
            exit()
        q.append(to)
print(-1)
### BUGGY CODE ###

from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
for k in range(K):
    imos = [0] * N
    ruiseki = [0] * (N+1)
    for i, ai in enumerate(current_arr):
        imos[max([0, i-ai])] += 1
        if i+ai+1 < N:
            imos[i+ai+1] -= 1
    for j, im in enumerate(imos):
        ruiseki[j+1] = ruiseki[j] + im
    if current_arr == ruiseki[1:]:
        break
    current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
print(*current_arr)


### FIXED CODE ###

import sys
from itertools import accumulate

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

current_arr = A
if K > 41:
    print(*([N]*N))
else:
    for _ in range(K):
        imos = [0] * N
        ruiseki = [0] * (N+1)
        for i, ai in enumerate(current_arr):
            imos[max([0, i-ai])] += 1
            if i+ai+1 < N:
                imos[i+ai+1] -= 1
        for j, im in enumerate(imos):
            ruiseki[j+1] = ruiseki[j] + im
        current_arr = ruiseki[1:]
#print(imos)
#print(ruiseki)
#print(*accumulate(imos))
    print(*current_arr)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in set(a):
    if i <= a.count(i):
        n -= i
print(n)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for k,v in d.items():
    if k <= v:
        n -= k
print(n)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(M):
    Amax = A.index(max(A))
    A[Amax] = A[Amax]//2
print(sum(A))

### FIXED CODE ###

#標準入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
#heapqをimportして、Aの要素をすべてマイナスにしてheapify
import heapq
def minus(n):
    return -n
A = list(map(minus, A))
heapq.heapify(A)
#その最小値を出力して削除し、その半分を追加することをM回やる
for i in range(M):
    heapq.heappush(A, -(-heapq.heappop(A)//2))
#Aの要素を合計してminusして出力する
print(minus(sum(A)))
### BUGGY CODE ###

import math
import bisect
import collections

N = int(input())
A = list(map(int,input().split()))
#C = collections.Counter(A)
C = {}
for a in A:
  if a in C:
    C[a] += 1
  else:
    C[a] = 1
A = sorted(list(C.keys()))
#print(C)
#print(A)

ans = 0
for i in range(len(A)-1,-1,-1):
  a = A[i]
  b = (1<<(int(math.log(a,2))+1))-a
  if a == b:
    ans += C[a]//2
    C[a] -= C[a]//2*2
  else:
    r = bisect.bisect_left(A[:i], b)
    if r < i and A[r] == b:
      mn = min(C[a],C[A[r]])
      ans += mn
      C[a] -=  mn
      C[A[r]] -= mn
print(ans)


### FIXED CODE ###

import math
import bisect
import collections

N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)
A = sorted(list(C.keys()))
#print(C)
#print(A)

ans = 0
for i in range(len(A)-1,-1,-1):
  a = A[i]
  b = (1<<(int(math.log(a,2))+1))-a
  if a == b:
    ans += C[a]//2
    C[a] -= C[a]//2*2
  else:
    r = bisect.bisect_left(A, b)
    if r < i and A[r] == b:
      mn = min(C[a],C[A[r]])
      ans += mn
      C[a] -=  mn
      C[A[r]] -= mn
print(ans)