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

n = int(input())
aList = list(map(int, input().split()))
aSet = list(set(aList))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
        continue
    if aCount == a:
        continue
    if aCount < a:
        aSum += aCount
        continue
print(aSum)


### FIXED CODE ###

n = int(input())
aList = list(map(int, input().split()))
aLen = len(aList)
aSet = sorted(list(set(aList)))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
    if aCount < a:
        aSum += aCount
    aLen -= aCount
    if a > aLen:
        aSum += aLen
        break

print(aSum)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] + [1000000000] * (N-1)

for i in range(N-1):
	for j in range(1, K+1):
		if i+j <= N-1:
			if dp[i] + abs(h[i+j] - h[i]) < dp[i+j]:
				dp[i+j] = dp[i] + abs(h[i+j] - h[i])			

print(dp[-1])

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.array([0] * N)
#candi = np.array([0] * N)

for i in range(1, N):
	j = max(0, i-K)
	#print()
	#candi[j:i] = dp[j:i] + np.abs(h[i] - h[j:i])
	dp[i] = (dp[j:i] + np.abs(h[i] - h[j:i])).min()
	#print('j,i=',j,i)
	#print('dp[j:i]=',dp[j:i])
	#print('np.abs(h[i] - h[j:i]) = ', np.abs(h[i] - h[j:i]) )		
	#print('candi[j:i]=',candi[j:i])
	#dp[i] = candi[j:i].min()
	#print('dp=',dp)
				
print(dp[-1])
### BUGGY CODE ###

def main():
    N = int(input())
    A = [int(input()) for i in range(N)]

    for j in range(N):
        if j != A.index(max(A)):
            print(max(A))
        else:
            ans = [x for i, x in enumerate(A) if i != j]
            print(max(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    As = [int(input()) for _ in range(n)]

    As_sort = sorted(As)
    second, first = As_sort[-2:]
    for i in range(n):
        if As[i] == first:
            print(second)
        else:
            print(first)


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

n,k = map(int,input().split())
p = list(map(int,input().split()))
l = []
for x in p:
    tmp = 1.0+0.5*(float(x)-1.0)
    l.append(tmp)
max = 0
for i in range(n-k+1):
    tmp = sum(l[i:i+k])
    if tmp >= max:
        max = tmp
print(max)

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
l = []
for x in p:
    tmp = 1.0+0.5*(float(x)-1.0)
    l.append(tmp)
max = sum(l[:k])
now = max
for i in range(k,n):
    now = now + l[i] - l[i-k]
    if now >= max:
        max = now
print(max)
### BUGGY CODE ###

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

b1=1
b2=0
b3=0
for i in range(n):
  b1*=a[i]
  b2*=a[i]
  b3*=a[i]
  if b1>=10**9:
    b2+=b1//(10**9)
    b1%=10**9
  if b2>=10**9:
    b3+=b2//(10**9)
    b2%=10**9
  
if b3>=1 and (b1!=0 or b2!=0):
  print(-1)
else:
  print(b3*(10**18)+b2*(10**9)+b1)

### FIXED CODE ###

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)
### BUGGY CODE ###

import math
N = int(input())
def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num
A = 0
for i in range(1,N+1):
    A += i*search_divisor_num_1(i)
print(A)

### FIXED CODE ###

N = int(input())
Answer = int((1/2)*N*(N+1))
Box = [i for i in range(N+1)]
for i in range(2,N+1):
    Answer += sum(Box[i::i])
print(Answer)
### BUGGY CODE ###

n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
for j in range(1,n+1):
  print('Yes' if (k + a.count(j) - q)>0 else 'No')

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ip = [k-q]*(n+1)
for j in a:
  ip[j] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in ip[1:])
print(ans)
### BUGGY CODE ###

K = int(input())

total = 0
# 3つ同じ
for i in range(K):
  total += i+1

# 2つ同じ
for i in range(K-1):
  for j in range(i+1,K):
    if i+1 == 1:
      total += 1*6
    elif (j+1)%(i+1)==0:
      total += (i+1)*6
    else:
      tmp = 0
      for k in range(1,i+1):
        if (i+1)%k == 0 and (j+1)%k == 0:
          tmp = k
      total += tmp*6

# バラバラ
for i in range(K-2):
  for j in range(i+1,K-1):
    for k in range(j+1,K):
      if i+1 == 1:
        total += 1*6
      elif (j+1)%(i+1) == 0 and (k+1)%(i+1) == 0:
        total += (i+1)*6
      else:
        tmp = 0
        for l in range(1,i+1):
          if (i+1)%l == 0 and (j+1)%l == 0 and (k+1)%l == 0:
            tmp = l
        total += tmp*6
print(total)
  

### FIXED CODE ###

K = int(input())

total = 0
for i in range(1,K+1,1):
  for j in range(1,K+1,1):
    tmp1 = i
    tmp2 = j
    while tmp1 % tmp2 != 0:
      tmp = tmp1 % tmp2
      tmp1 = tmp2
      tmp2 = tmp
    for k in range(1,K+1,1):
      tmp1 = k
      tmp3 = tmp2
      while tmp1 % tmp3 != 0:
        tmp = tmp1 % tmp3
        tmp1 = tmp3
        tmp3 = tmp
      total += tmp3
print(total)
### BUGGY CODE ###

a, b, n = map(int, input().split())

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))
while True:
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    

ans = max(buf)
print(ans)

### FIXED CODE ###

a, b, n = map(int, input().split())

cnt = 1
buf = []
if n < b:
    buf.append(int(a * n / b) - a * (int(n / b)))
else:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))
    

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)
### BUGGY CODE ###

#解説読んだ

import math

N, L = list(map(int, input().split()))
T = [int(input()) for _ in range(N)]

K = N * (N - 1) * (N - 2) / 3 / 2
x, y = 0, 0
for i in range(N - 1):
  for j in range(i + 1, N):
    a = (T[i] + T[j]) / 2
    b = a + L / 2
    t = j - i - 1
    k = N - 2 - t
    x += k * math.cos(2 * math.pi * a / L) / K
    x += t * math.cos(2 * math.pi * b / L) / K
    y += k * math.sin(2 * math.pi * a / L) / K
    y += t * math.sin(2 * math.pi * b / L) / K
print(x, y)

### FIXED CODE ###

#解説読んだ

import math

N, L = list(map(int, input().split()))
T = [int(input()) for _ in range(N)]

K = N * (N - 1) * (N - 2) / 3 / 2
x, y = 0, 0
for i in range(N - 1):
  for j in range(i + 1, N):
    a = (T[i] + T[j]) / 2
    b = a + L / 2
    t = j - i - 1
    k = N - 2 - t
    x += k * math.cos(2 * math.pi * a / L) / K
    x += t * math.cos(2 * math.pi * b / L) / K
    y += k * math.sin(2 * math.pi * a / L) / K
    y += t * math.sin(2 * math.pi * b / L) / K
print(x, y)
### BUGGY CODE ###

N, M = [int(i) for i in input().split()]
ab = []

possible = False
for _ in range(M):
    ab.append([int(i) for i in input().split()])
    
c = []
for i, d in enumerate(ab):
    if d[1] == N:
        c.append(d[0])
        del ab[i]
    elif d[0] != 1:
        del ab[i]

for d in ab:
    if d[1] in c and d[0] == 1:
        possible = True

if possible:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

N, M = [int(i) for i in input().split()]
ab = []

possible = False
for _ in range(M):
    ab.append([int(i) for i in input().split()])
    

c = []
e = []
for d in ab:
    if d[1] == N:
        c.append(d[0])
    elif d[0] == 1:
        e.append(d[1])

if len(set(c) & set(e)):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

#coding:utf-8
import time

N,Q = map(int,input().split())
rank = [0 for i in range(N)]

class Tree:
    def __init__(self,par,key):
        self.par = par
        self.key = key

List = [Tree(i,i) for i in range(N)]
for i in range(Q):
    com, x,y = map(int,input().split())
    x1,y1 = x,y
    while List[x1].par != x1:
        x1 = List[x1].par
    a = rank[x1]
            
    while List[y1].par != y1:
        y1 = List[y1].par
    b = rank[y1]

    if com == 0:
        if a <= b:
            if a == b:
                rank[x1] += 1
            List[y1].par = x1
            
        else:
            List[x1].par = y1

    else:
        if x1 == y1:
            print("1")
        else:
            print("0")




### FIXED CODE ###

#coding:utf-8
import time

N,Q = map(int,input().split())
rank = [0 for i in range(N)]

class Tree:
    def __init__(self,par,key):
        self.par = par
        self.key = key

List = [Tree(i,i) for i in range(N)]

def unit(x,y):
    while List[x].par != x:
        x = List[x].par
    a = rank[x]
            
    while List[y].par != y:
        y = List[y].par
    b = rank[y]
    if a <= b:
        if a == b:
            rank[x] += 1
        List[y].par = x
    else:
        List[x].par = y



def Find(x,y):
    Q = []
    P = []
    while List[x].par != x:
        x = List[x].par
        Q.append(x)
            
    while List[y].par != y:
        y = List[y].par
        P.append(y)
    for xi in Q:
        List[xi].par = x
        rank[xi] = 1
    for yi in P:
        List[yi].par = y
        rank[yi] = 1
    if x == y:
        print(1)
    else:
        print(0)
    
        
for i in range(Q):
    com, x,y = map(int,input().split())

    if com == 0:
        unit(x,y)
            
    else:
        Find(x,y)
### BUGGY CODE ###

from bisect import bisect_right
import sys
input = sys.stdin.readline

def main():
    N, D, A = map(int, input().split())
    B = []

    for i in range(N):
        x, h = map(int, input().split())
        B.append((x,h))

    B.sort()
    X = [0] * N
    H = [0] * N
    for i in range(N):
        X[i], H[i] = B[i]
    ans = 0
    ok = [False] * N


    for i in range(N):
        if ok[i]:
            continue
        cnt = H[i] // A if H[i] % A == 0 else H[i] // A + 1
        ans += cnt
        ok[i] = True
        search_max = bisect_right(X, X[i] + 2 * D) - 1
        for j in range(min(i+1,N),min(search_max+1,N)):
            if ok[j]:
                continue
            H[j] -= cnt * A
            if H[j] <= 0:
                ok[j] = True
    
    print(ans)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from bisect import bisect_right
import sys
input = sys.stdin.readline

def main():
    N, D, A = map(int, input().split())
    B = []

    for i in range(N):
        x, h = map(int, input().split())
        B.append((x,h))

    B.sort()
    X = [0] * N
    H = [0] * N
    for i in range(N):
        X[i], H[i] = B[i]
    ans = 0
    ok = [False] * N
    S = [0] * (N + 1)
    for i in range(N):
        if S[i] < H[i]:
            cnt = (H[i] - S[i]) // A if (H[i] - S[i]) % A == 0 else (H[i] - S[i]) // A + 1
            ans += cnt
            search_max = bisect_right(X, X[i] + 2 * D)
            S[i] += cnt * A
            S[search_max] -= cnt * A
        
        S[i+1] += S[i]

    print(ans)



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

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

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


### FIXED CODE ###

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

ans = 0
dic1 = {}
dic2 = {}
for i in range(n):
    tmp1 = a[i] + (i + 1)
    tmp2 = -a[i] + (i + 1)
    if tmp1 in dic1:
        dic1[tmp1] += 1
    else:
        dic1[tmp1] = 1
    if tmp2 in dic2:
        dic2[tmp2] += 1
    else:
        dic2[tmp2] = 1
for key in dic1.keys():
    if key in dic2:
        ans += dic1[key] * dic2[key]
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())

if (N % K == 0):
  print('0')
else:
  while N > abs(N - K):
    N = abs(N - K)
      
  print(N)

### FIXED CODE ###

N, K = map(int, input().split())

E = N % K

if (E == 0):
  print('0')
else:
  if E < abs(E - K):
    print(E)
  else:
    print(abs(E - K))
### BUGGY CODE ###

def comp(a, b, c):
    if (c < a+b):
        return True
    else:
        return False

n = int(input())
l = []
l[:] = map(int,input().split())
l.sort()

c = 0
for i in range(0,n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if(comp(l[i], l[j], l[k])):
                c+=1
            else:
                continue
print(c)


### FIXED CODE ###

from bisect import bisect_right

n = int(input())
l = list(map(int,input().split()))
l.sort() # 昇順にソート

count = 0
for i in range(0,n-2):
    a = l[i]
    for j in range(i+1, n-1):
        ab = a+l[j]
        # bisect_left(a, x): x を a に挿入できる点を返す
        # cの最大値は a+b-1
        k = bisect_right(l, ab-1, j+1, n)
        count += k-(j+1)
print(count)
### BUGGY CODE ###

import re
s = input()

pat = re.compile('ABC')
count = 0

while True:
    st = pat.search(s)
    if st:
        tpl = re.subn('ABC', 'BCA', s)
        s = tpl[0]
        count += tpl[1]
    else:
        break

print(count)

### FIXED CODE ###

s = input()

count = 0
pre = ''
movable = 0
for i in reversed(s):
    if pre == '':
        pre = i
    elif pre == 'CB' and i == 'A':
        count += movable
    elif pre == 'CB' and i == 'C':
        pre = 'C'    
    elif pre == 'C' and i == 'B':
        movable += 1
        pre = 'CB'
    else:
        movable = 0
        pre = i   
print(count)
### BUGGY CODE ###

A, B, C = map(int, input().split())
ans = float('inf')

for i in range(1, A+1):
    ans = min(ans, abs((i*B*C)-(A-i)*B*C))

for i in range(1, B+1):
    ans = min(ans, abs((A*i*C)-A*(B-i)*C))
    
for i in range(1, B+1):
    ans = min(ans, abs((A*B*i)-A*B*(C-i)))
print(ans)

### FIXED CODE ###

A, B, C = map(int, input().split())
ans = float('inf')

if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
    print(0)
else:
    ans = min(ans, abs((A//2)*B*C - (A//2 + 1)*B*C))
    ans = min(ans, abs((B//2)*A*C - (B//2 + 1)*A*C))
    ans = min(ans, abs((C//2)*B*A - (C//2 + 1)*B*A))
    print(ans)
### BUGGY CODE ###

N_ken, M_hon = map(int, input().split())
ab = []
yen = 0
hon = M_hon

for i in range(N_ken):
    tmp = list(map(int, input().split()))
    ab.append(tmp)

ab.sort()

while (hon > 0):
    
    tmp = min(hon, ab[0][1])
    yen += ab[0][0] * tmp
    
    hon -= tmp
    ab.remove(min(ab))

print(yen)

### FIXED CODE ###

N_ken, M_hon = map(int, input().split())
ab = []
yen = 0
hon = 0

for i in range(N_ken):
    tmp = list(map(int, input().split()))
    ab.append(tmp)

ab.sort()

for a, b in ab:
    tmp = min(M_hon - hon, b)
    yen += tmp * a
    hon += tmp
    
    if (hon == M_hon):
        break

print(yen)
### BUGGY CODE ###

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

ans=1
for i in range(n):
    ans *=A[i]
if ans>10**18:print(-1);exit()
print(ans)

### FIXED CODE ###

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

ans=1
if 0 in A:print(0);exit()
for i in range(n):
    ans *=A[i]
    if ans>10**18:print(-1);exit()
print(ans)
### BUGGY CODE ###

t = int(input())
for _ in range(t):
  a, b, c, d = map(int, input().split())
  if (a < b or d < b):
    print("No")
    continue
  if (c >= b):
    print("Yes")
    continue

  lst = []
  while True:
    a %= b
    if a > c:
      print("No")
      break
    if a in lst:
      print("Yes")
      break
    lst.append(a)
    a += d

### FIXED CODE ###

def gcd(a, b):
    if b == 0:return a
    return gcd(b, a % b)

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    #exception
    if a < b or d < b:
        print("No")
        continue

    if c >= b:
        print("Yes")
        continue

    g = gcd(d, b)
    print("Yes" if b - g + a % g <= c else "No")
### BUGGY CODE ###

num = []
num = [int(i) for i in input().split()]

gate = []

for temp in range(num[1]):
    temp = []
    temp = [int(i) for i in input().split()]
    gate.append(temp)

check = [0] * num[0]

for temp in gate:
    for kazu in range(num[0]):
        if kazu + 1 < temp[0]:
            check[kazu] = 1
        elif kazu + 1 > temp[1]:
            check[kazu] = 1

print(check.count(0))

### FIXED CODE ###

import sys
input = sys.stdin.readline
num = []
num = [int(i) for i in input().split()]

syou = []
dai = []

for temp in range(num[1]):
    suuzi = []
    suuzi = [int(i) for i in input().split()]
    syou.append(suuzi[0])
    dai.append(suuzi[1])

result= min(dai) - max(syou) + 1
if result > 0:
    print(result)
else:
    print(0)
### BUGGY CODE ###

X, K, D = map(int, input().split())
abs_x = abs(X)
hikukazu = abs(X) // D
count = K - (hikukazu)
if K > hikukazu:
    if count % 2 == 0:
        hikukazu = hikukazu
    else:
        hikukazu = hikukazu + 1
else:
    hikukazu = K


for i in range(hikukazu):
    
    abs_x = abs_x - D

    # print(X)

print(abs(abs_x))

### FIXED CODE ###

X, K, D = map(int, input().split())
abs_x = abs(X)
hikukazu = abs(X) // D
count = K - (hikukazu)
if K > hikukazu:
    if count % 2 == 0:
        hikukazu = hikukazu
    else:
        hikukazu = hikukazu + 1
else:
    hikukazu = K


# for i in range(hikukazu):
    
#     abs_x = abs_x - D
abs_x = abs_x - (D*hikukazu)
    # print(X)

print(abs(abs_x))
### BUGGY CODE ###

h,w,m = map(int,input().split())
bombX = [0]*h
bombY = [0]*w
bomb = [0]*m
maxX = maxY = 0
for i in range(m):
    i,j = map(lambda x:int(x)-1, input().split())
    bomb.append((i,j))
    bombX[i] += 1
    bombY[j] += 1
    maxX = max(maxX,bombX[i])
    maxY = max(maxY,bombY[j])
maxX_index = list(i for i in range(h) if bombX[i] == maxX)
maxY_index = list(i for i in range(w) if bombY[i] == maxY)
for i in maxX_index:
    for j in maxY_index:
        if (i,j) in bomb: continue
        print(maxX+maxY)
        exit()
print(maxX+maxY-1)


### FIXED CODE ###

h,w,m = map(int,input().split())
bombX = [0]*h
bombY = [0]*w
bomb = set()
maxX = maxY = 0
for i in range(m):
    i,j = map(lambda x:int(x)-1, input().split())
    bomb.add((i,j))
    bombX[i] += 1
    bombY[j] += 1
    maxX = max(maxX,bombX[i])
    maxY = max(maxY,bombY[j])
maxX_index = list(i for i in range(h) if bombX[i] == maxX)
maxY_index = list(i for i in range(w) if bombY[i] == maxY)
for i in maxX_index:
    for j in maxY_index:
        if (i,j) in bomb: continue
        print(maxX+maxY)
        exit()
print(maxX+maxY-1)
### BUGGY CODE ###

nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]

t = 1
tl = [1]

flg = False
for i in range(len(a)):
    flg = t > a[t-1]
    t  = a[t-1]
    stl = sorted(tl)
    if flg and t in stl:
        break
    else:
        tl.append(t)

tl2 = tl[tl.index(t):len(tl)]
         
# print(tl)
# print(tl2)

ans = 0

if k <= len(tl):
    ans = tl[k]
else:
    k = k - len(tl)
    j = k % len(tl2)
    ans = tl2[j]

print(ans)

### FIXED CODE ###

nk = input().split()
n , k = int(nk[0]), int(nk[1])
a = [int(i) for i in input().split()]

t = 1
tl = [1]
ts = {1}


for i in range(len(a)):
    
    t = a[t-1]
    if t in ts:
        break
    else:
        tl.append(t)
        ts.add(t)

tl2 = tl[tl.index(t):len(tl)]
         
# print(tl)
# print(tl2)

ans = 0

if k < len(tl):
    ans = tl[k]
else:
    k = k - len(tl)
    j = k % len(tl2)
    ans = tl2[j]

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

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

hyoten_i = 1
for i, a in enumerate(A):
  hyoten_prev = hyoten_i
  hyoten_i *= a
  if i + 1 > K:
    hyoten_i = hyoten_i / A[i - K]
    print("Yes" if hyoten_i > hyoten_prev else "No")

### FIXED CODE ###

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

for i, a in enumerate(A):
  if i + 1 > K:
    if a > A[i - K]:
      print("Yes")
    else:
      print("No")
### BUGGY CODE ###

from collections import Counter

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

h = []
w = []
boms = set()
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)
    boms.add((x, y))

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)
        else:
            minus.append(0)

print(h_max + w_max + max(minus))

### FIXED CODE ###

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

k = 0
score_list = []
for i in range(N):
  position = i
  score = 0
  for k in range(K):
  	position = P[position] - 1
  	score += C[position]
  	score_list.append(score)

print(max(score_list))

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [p - 1 for p in P]
C = list(map(int, input().split()))

vis = [False] * N
ans = [-float("inf")] * N

for root in range(N):
  if vis[root]:
    continue
  vis[root] = True
  
  cycle = [root]
  costs = [C[root]]
  u = P[root]
  vis[u] = True
  
  while u != root:
    cycle.append(u)
    costs.append(C[u])
    u = P[u]
    vis[u] = True

  L = len(cycle)
  S = sum(costs)
  for i, v in enumerate(cycle):
    cnt = 0
    for step in range(1, min(L, K) + 1):
      cnt += costs[(i + step) % L]
      val1 = cnt
      val2 = cnt + (K - step) // L * S
      ans[v] = max(ans[v], val1, val2)

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

#input = ["3 5","0 0 1","0 1 2","0 2 3","1 0 2","1 1 2"]
#input = ["1 3","1 0 0","0 0 5","1 0 0"]
#input = ["2 15","1 0 1","1 0 0","1 1 1","0 0 2","1 0 1","1 0 0","1 1 1","0 1 1","1 0 1","1 0 0","1 1 1","0 1 5","1 0 1","1 0 0","1 1 1"]
output=[]

l = raw_input().split()
#l=input[0].split()

n=int(l[0])
a = range(0,n)
for i in range(0,n):
	a[i] = 2 ** 31 - 1

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
	else:
		output.append(min(a[int(l[1]):int(l[2])+1]))

for i in output:
	print i

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
def main(init=int(2**31-1), readline=stdin.readline):
    n, q = (int(s) for s in readline().split())
 
    a = [init] * n
    b = [init] * ((n // 100) + 1)
 
    for _ in range(q):
        com, x, y = (int(s) for s in readline().split())
        if com:
            bx = x - (x % 100) + 100
            by = y - (y % 100)
            if bx < by:
                m = min(min(a[x:bx]), min(b[bx//100:by//100]),
                        min(a[by:y+1]))
            else:
                m = min(a[x:y+1])
            print(m)
        else:
            a[x] = y
            bx = x - (x % 100)
            b[x//100] = min(a[bx:bx+100])
 
 
main()