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

n = list(map(int, input().split()))
N, M = n[0], n[1]

import numpy as np

def main():
    M_list = []
    y_array = np.array([[10000000000]*M]*N)
    for i in range(M):
        tmp = list(map(int, input().split()))
        M_list.append(tmp[0])
        y_array[tmp[0]-1,i] = tmp[1]

    num_array = np.zeros([N,M])
    ynum_array = np.ones([N,M])
    for k in range(N):
        a = np.argsort(y_array[k])
        tmp = 1
        for l in a:
            #print(int(y_array[k][l]))
            if int(y_array[k][l]) == 10000000000:
                #print('break')
                break
            ynum_array[k][l] = tmp
            tmp += 1

    for j in range(M):
        ac = (str(M_list[j]).zfill(6)) + (str(int(ynum_array[M_list[j]-1][j])).zfill(6))
        print(ac)
        
    #print(y_array)

if __name__ == '__main__':
    main()




### FIXED CODE ###

n, m = map(int, input().split())

city_list = []
for i in range(m):
    p, y = map(int, input().split())
    city_list.append([p, y, i])

city_list.sort(key=lambda x: (x[0], x[1]))

#print(city_list)

tmp_list = [0]*m
tmp_num = 1
for num,j in enumerate(city_list):
    if num == 0:
        tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)
        j_tmp = j[0]
        tmp_num += 1
    else:
        if j[0] != j_tmp:
            j_tmp = j[0]
            tmp_num = 1
            tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)
            tmp_num += 1
        else:
            tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)
            tmp_num += 1

for k in tmp_list:
    print(k)
### BUGGY CODE ###

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def get_primes(n):
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i:: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorization(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def main():
    N = int(input())

    yakusu = [0] * (N + 1)

    primes = get_primes(N)

    ans = 0
    for i in range(1, N + 1):
        if yakusu[i] != 0:
            ans += i * yakusu[i]
            continue

        primefacts = prime_factorization(i)
        c = collections.Counter(primefacts)
        tmp = 1
        for k in c.keys():
            tmp *= c[k] + 1

        yakusu[i] = tmp
        ans += i * tmp

        for prime in primes:
            if i * prime > N:
                break
            if prime in c.keys():
                yakusu[i * prime] = (c[prime] + 2) * tmp // (c[prime] + 1)
            else:
                yakusu[i * prime] = tmp * 2

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    def num_divisors_table(n):
        table = [0] * (n + 1)

        ans = 0
        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1
            ans += table[i] * i
        return ans

    ans = num_divisors_table(N)

    print(ans)


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

frege_count, oven_count, coupon_count = map(int,input().split())	
frege_prices = list(map(int,input().split()))	
oven_prices = list(map(int,input().split()))	
coupon_list = [list(map(int, input().split())) for i in range(coupon_count)]

minprice = 200000
for f in range(frege_count):
  for o in range(oven_count):
      total_cost = frege_prices[f] +  oven_prices[o]
      if minprice > total_cost:
          minprice = total_cost
for coupon in coupon_list:
  total_cost = frege_prices[coupon[0]-1] + oven_prices[coupon[1]-1] - coupon[2]
  if minprice > total_cost:
          minprice = total_cost
print(minprice)

### FIXED CODE ###

frege_count, oven_count, coupon_count = map(int,input().split())	
frege_prices = list(map(int,input().split()))	
oven_prices = list(map(int,input().split()))	
coupon_list = [list(map(int, input().split())) for i in range(coupon_count)]

minprice = min(frege_prices) + min(oven_prices)
for coupon in coupon_list:
  total_cost = frege_prices[coupon[0]-1] + oven_prices[coupon[1]-1] - coupon[2]
  if minprice > total_cost:
          minprice = total_cost
print(minprice)
### BUGGY CODE ###

import sys
input  = sys.stdin.readline

S = input()
N = len(S)

while True:
  n = len(S)
  S = S.replace('110100','')
  S = S.replace('001011','')
  S = S.replace('111000','')
  S = S.replace('000111','')
  S = S.replace('1010','')
  S = S.replace('0101','')
  S = S.replace('1100','')
  S = S.replace('0011','')
  S = S.replace('10','')
  S = S.replace('01','')
  if n == len(S):
    break
print(N-len(S))


### FIXED CODE ###

S = input()

c0=0
c1=0
for i in S:
  if i == '0':
    c0+=1
  else:
    c1+=1

print(2*min(c0,c1))
### BUGGY CODE ###

n = int(input())
s = input()

cnt = 0

for i in range(n):
    for j in range(i, n):
        for k in range(j, n):
            if (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]) and (j - i != k - j):
                cnt += 1

print(cnt)


### FIXED CODE ###

n = int(input())
s = input()

r = s.count('R')
b = s.count('B')
g = s.count('G')

cnt = 0

for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            cnt += 1

print(r * b * g - cnt)
### BUGGY CODE ###

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
mod = 10 ** 9 + 7

dp = [0] * (1 << n)
dp[0] = 1

# 配るDP
for bit in range((1 << n) - 1):
    i = bin(bit).count('1')
    for j in range(n):
        if a[i][j] and ((bit >> j) & 1 ^ 1):
            newbit = bit | (1 << j)
            dp[newbit] += dp[bit]
            dp[newbit] %= mod
print(dp[(1 << n) - 1])


### FIXED CODE ###

mod = 10**9+7
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
dp = [0]*(1 << n)
dp[0] = 1
for i in range(1, 1 << n):
    k = bin(i).count("1")
    for j in range(n):
        if i >> j & 1 and a[k-1][j]:
            dp[i] += dp[i ^ (1 << j)]
    dp[i] %= mod
print(dp[(1 << n)-1])
### BUGGY CODE ###

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    sidelist = dict()

    for aa in a:
        if a.count(aa) >= 2:
            if aa not in sidelist:
                sidelist[aa] = 1
            else:
                sidelist[aa] += 1

    side_a = 0
    side_b = 0

    for s in sidelist:
        if sidelist[s] >= 4 and s > side_a:
            side_a = s
            side_b = s
        elif sidelist[s] >= 2:
            if side_a == 0:
                side_a = s
            elif side_b == 0:
                side_b = s
            elif s > side_a:
                side_b = side_a
                side_a = s
            elif s > side_b:
                side_b = s

    print(side_a*side_b)


### FIXED CODE ###

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    sidelist = dict()

    for aa in a:
        if aa not in sidelist:
            sidelist[aa] = 1
        else:
            sidelist[aa] += 1

    side_a = 0
    side_b = 0

    for s in sidelist:
        if sidelist[s] >= 4 and s > side_a:
            side_a = s
            side_b = s
        elif sidelist[s] >= 2:
            if s > side_a:
                side_b = side_a
                side_a = s
            elif s > side_b:
                side_b = s

    print(side_a*side_b)
### BUGGY CODE ###

n=int(input())
s=input()
w=[[0]*n for i in range(n)]
ans=chk=0
for i in range(n-1,-1,-1):
    for j in range(n-1,-1,-1):
        if s[i]==s[j]:
            if i==n-1 or j==n-1:
                w[i][j]=1
            else:
                w[i][j]=w[i+1][j+1]+1
for i in range(1,n):
    for j in range(i):
        ans=max(ans,w[i][j]-[0,w[i][j]-(i-j-w[i][j]+1)][j+w[i][j]>=i+1])
print(ans)


### FIXED CODE ###

n=int(input())
s=input()
w=[[0]*n for i in range(n)]
ans=chk=0
for i in range(n-1,-1,-1):
    for j in range(n-1,-1,-1):
        if s[i]==s[j]:
            if i==n-1 or j==n-1:
                w[i][j]=1
            else:
                w[i][j]=w[i+1][j+1]+1
for i in range(1,n):
    for j in range(i):
        #ans=max(ans,w[i][j])
        ans=max(ans,w[i][j]-[0,w[i][j]-(i-j-w[i][j]+1)][j+w[i][j]>=i+1])
print(ans)
### BUGGY CODE ###

import os, sys, re, math

N, M = [int(s) for s in input().split(' ')]

cards = [int(s) for s in input().split(' ')]
cards.sort()

bc_ary = []
for i in range(M):
    bc_ary.append([int(s) for s in input().split(' ')])

for bc in bc_ary:
    cnt = 0
    idx = 0
    while idx < N and cnt < bc[0]:
        if cards[idx] < bc[1]:
            cards[idx] = bc[1]
            cnt += 1
        idx += 1

    cards.sort()

print(sum(cards))


### FIXED CODE ###

import os, sys, re, math, heapq

N, M = [int(s) for s in input().split(' ')]

dic = {}
cards =  [int(s) for s in input().split(' ')]
for c in cards:
    if c in dic:
        dic[c] += 1
    else:
        dic[c] = 1

for i in range(M):
    b,c = [int(s) for s in input().split(' ')]
    if c in dic:
        dic[c] += b
    else:
        dic[c] = b

keys = sorted(list(dic.keys()), reverse=True)

ret = 0
for k in keys:
    ret += min(N, dic[k]) * k
    N = N - dic[k]
    if N <= 0:
        break

print(ret)
### BUGGY CODE ###

from collections import deque

n = int(input())
al = []
al.append(deque([]))
for _ in range(n):
    row = list(map(int, input().split()))
    al.append(deque(row))

# print(al)

day = 0
cnt = 0
max_cnt = n*(n-1)//2
while True:
    day += 1
    # print('-----',day)
    # print(al)
    already_fights = [False]*(n+1)
    update_flag = False
    for i in range(1,n+1):
        al_i = al[i]
        if not al_i or already_fights[i]: continue
        i_next_rival = al_i[0]

        al_rival_i = al[i_next_rival]
        if not al_rival_i or already_fights[i_next_rival]: continue
        i_next_rival_rival = al_rival_i[0]

        if i_next_rival_rival == i:
            al[i].popleft()
            al[i_next_rival].popleft()
            already_fights[i] = True
            already_fights[i_next_rival] = True
            cnt += 1
            update_flag = True
        else:
            continue
    # print(al)

    if not update_flag:
        print(-1)
        exit()

    if cnt == max_cnt:
        break

print(day)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    al = []
    al.append(deque([]))
    for _ in range(n):
        row = list(map(int, input().split()))
        al.append(deque(row))

    # print(al)

    day = 0
    cnt = 0
    max_cnt = n*(n-1)//2
    check_il = [i for i in range(1,n+1)]
    while True:
        next_check_il = check_il[:]
        check_il = []
        day += 1
        already_fights = set()
        update_flag = False
        for i in next_check_il:
            al_i = al[i]
            if not al_i or i in already_fights: continue
            i_next_rival = al_i[0]

            al_rival_i = al[i_next_rival]
            if not al_rival_i or i_next_rival in already_fights: continue
            i_next_rival_rival = al_rival_i[0]

            if i_next_rival_rival == i:
                al[i].popleft()
                al[i_next_rival].popleft()
                already_fights.add(i)
                already_fights.add(i_next_rival)
                check_il.append(i)
                check_il.append(i_next_rival)
                cnt += 1
                update_flag = True
            else:
                continue

        if not update_flag:
            print(-1)
            exit()

        if cnt == max_cnt:
            break

    print(day)


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

n = int(input())
s = list(map(int,list(input())))


ans_L = []
length = len(s)
count = 0

for i in range(1000):
    i = list(str(i).zfill(3))
    idx = 0
    #tmp_L = []
    cnt = 0
    for j in range(3):
        for k in range(idx,length):
            if str(i[j]) == str(s[k]):
                idx = k+1
                #tmp_L.append(str(i[j]))
                cnt += 1
                break

    #if len(tmp_L) == 3:
    #    ans_L.append("".join(tmp_L))
    if cnt == 3:
        count +=1

print(count)
#print(set(ans_L))

### FIXED CODE ###

n = int(input())
s = list(map(int,list(input())))


ans_L = []
length = len(s)
count = 0

for i in range(1000):
    i = list(str(i).zfill(3))
    idx = 0
    cnt = 0
    for j in range(3):
        for k in range(idx,length):
            if str(i[j]) == str(s[k]):
                idx = k+1
                cnt += 1
                break
        if cnt ==0:
            break

    #if len(tmp_L) == 3:
    #    ans_L.append("".join(tmp_L))
    if cnt == 3:
        count +=1

print(count)
#print(set(ans_L))
### BUGGY CODE ###

# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import numpy as np

n,k = map(int, sys.stdin.readline().rstrip().split())
hn = np.array(list(map(int, sys.stdin.readline().rstrip().split())))
dp = np.array([-1] * n)

dp[0] = 0
for i in range(1,n):
  ret = sys.maxsize
  for j in range(1,min(k+1,i+1)):
    ret = min(ret, dp[i-j]+abs(hn[i-j]-hn[i]))
  dp[i] = ret
print(dp[n-1])



### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import sys
import numpy as np

n,k = map(int, sys.stdin.readline().rstrip().split())
h = np.array(list(map(int, sys.stdin.readline().rstrip().split())))

dp = np.zeros(n, dtype=np.int)

for i in range(1,n):
  if i < k:
    dp[i] = np.min(dp[:i] + np.abs(h[i]-h[:i]))
  else:
    dp[i] = np.min(dp[i-k:i] + np.abs(h[i]-h[i-k:i]))

print(dp[n-1])
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
for i in range(1,n+1):
  x = A.count(i)
  i += x
  print(x)


### FIXED CODE ###

import collections

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

c = collections.Counter(A)

for i in range(1,n+1):
  print(c[i])
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[7]:


N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))


# In[8]:


ans = []
for x in A:
    if x not in ans:
        ans.append(x)
    else:
        ans.remove(x)
print(len(ans))


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[17]:


N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))


# In[18]:


import collections


# In[19]:


count = collections.Counter(A)
ans = 0
for d in count.values():
    if d%2 != 0:
        ans += 1
print(ans)


# In[ ]:
### BUGGY CODE ###

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

cnt = 0
for i in range(len(lst)):
    num = lst[i]
    if num == min(sorted(lst[:i+1])):
        cnt += 1

print(cnt)


### FIXED CODE ###

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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)
### BUGGY CODE ###

from collections import defaultdict

dic = defaultdict(int)


def count_divisors(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            dic[i] += 1
            if i != n // i:
                dic[n//i] += 1


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

for a in A:
    count_divisors(a)

for key in sorted(dic.keys(), reverse=True):
    if dic[key] in [n, n-1]:
        print(key)
        break


### FIXED CODE ###

import fractions

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

L_gcd = [0]*(n+1)
R_gcd = [0]*(n+1)

for i in range(n):
    L_gcd[i+1] = fractions.gcd(L_gcd[i], A[i])
    R_gcd[n-i-1] = fractions.gcd(R_gcd[n-i], A[n-i-1])

ans = [0]*n

for i in range(n):
    ans[i] = fractions.gcd(L_gcd[i], R_gcd[i+1])

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

def main():
    S = tuple(input())
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += 10**i*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
input = stdin.readline

def main():
    S = list(input())
    S.pop()
    m = 2019
    div_list = [0]*m
    num = 0
    for i, l in enumerate(reversed(S)):
        num += pow(10, i, m)*int(l)
        div_list[num%m] += 1

    div_list[0] += 1
    ans = 0
    for item in div_list:
        ans += int(item*(item-1)/2)

    print(ans)

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

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
 
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

consts_B, consts_W = [], []
for i in range(B+W):
  consts_B += [comb(i,B-1,Mod)]
  consts_W += [comb(i,W-1,Mod)]

p, q = 0, 0
inv = 1
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  inv *= magick
  p += consts_B[i]*inv
  q += consts_W[i]*inv

### FIXED CODE ###

B, W = map(int,input().split())
Mod = 10**9+7
magick = 500000004

inv_t = [0]+[1]
inv_2 = [0]+[magick]
for i in range(2,B+W+1):
  inv_t += [inv_t[Mod % i] * (Mod - int(Mod / i)) % Mod]
  inv_2 += [inv_2[-1]*magick % Mod]

consts_B, consts_W = [0]*(B-1)+ [1], [0]*(W-1)+[1]
for i in range(B+W):
  if i >= B: consts_B += [consts_B[-1]*(i)*inv_t[i-B+1]%Mod]
  if i >= W: consts_W += [consts_W[-1]*(i)*inv_t[i-W+1]%Mod]

p, q = 0, 0
for i in range(B+W):
  print((1-p+q)*magick%Mod)
  p += consts_B[i]*inv_2[i+1]
  q += consts_W[i]*inv_2[i+1]
### BUGGY CODE ###

def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [v for v in range(N)]

    while Q:
        d = INF
        u = None
        for x in Q:
            if D[x] < d:
                d = D[x]
                u = x
        Q.remove(u)
        for v, w in enumerate(m[u]):
            if D[v] > D[u] + w:
                D[v] = D[u] + w
    return D[t] 

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

# N < 100
m = [[1e10]*N for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1][b-1] = w
    m[b-1][a-1] = w

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)


### FIXED CODE ###

import heapq

def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [(0 if s == v else INF, v) for v in range(N)]
    heapq.heapify(Q)

    while Q:
        c, u = heapq.heappop(Q)
        if D[u] < c:
            continue
        for v, w in m[u]:
            if D[v] > D[u] + w:
                D[v] = D[u] + w
                heapq.heappush(Q, (D[u]+w, v))
    return D[t] 

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

# N < 100
m = [[] for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1].append((b-1,w))
    m[b-1].append((a-1,w))

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)
### BUGGY CODE ###

import functools
import math

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


def gcd(nums):
    return functools.reduce(math.gcd,nums)


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

K = int(input())
SUM = 0
for a in range(K):
    a += 1
    for b in range(K):
        b += 1
        for c in range(K):
            c += 1
            NUMS = [a,b,c]
            SUM += euclid(euclid(a,b),c)
            #print("{}, {}".format(NUMS,SUM))
print("{}".format(SUM))


### FIXED CODE ###


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


K = int(input())
SUM = 0
for a in range(K):
    a += 1
    for b in range(K):
        b += 1
        for c in range(K):
            c += 1
            NUMS = [a,b,c]
            SUM += euclid(euclid(a,b),c)
            #print("{}, {}".format(NUMS,SUM))
print("{}".format(SUM))
### BUGGY CODE ###


N, M, K = map(int, input().rstrip().split(' '))

comb = [0] * (N * M + 1)
comb[K-2] = 1
for i in range(K-1, N*M+1):
    comb[i] = comb[i-1] * i // (i - (K - 2))
    
comb[N*M-2] %= 1000000007

cost = 0
for d in range(1, N):
    cost += d * M**2 * (N - d) * comb[N*M-2]# comb[(N-d-1)*M]
    cost %= 1000000007
for d in range(1, M):
    cost += d * N**2 * (M - d) * comb[N*M-2]# comb[(M-d-1)*N]
    cost %= 1000000007
    
print(cost)



### FIXED CODE ###


import math

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N, M, K = map(int, input().rstrip().split(' '))

comb = cmb(N*M-2, K-2) % 1000000007

cost = 0
for d in range(1, N):
    cost += d * M**2 * (N - d) * comb
    cost %= 1000000007
for d in range(1, M):
    cost += d * N**2 * (M - d) * comb
    cost %= 1000000007
    
print(cost)
### BUGGY CODE ###

def main():
    N = int(input())
    X = [int(i) for i in input().split()]
    
    sorted_X = sorted(X)
    median_1 = sorted_X[int(N/2)-1]
    median_2 = sorted_X[int(N/2)]
    
    for i in range(N):
        remove_num = X[i]
        if(sorted_X.index(remove_num) > (N/2 - 1)):
            print(median_1)
        else:
            print(median_2)
    
if __name__=="__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    X = [int(i) for i in input().split()]
    
    sorted_X = sorted(X)
    median_1 = sorted_X[int(N/2)-1]
    median_2 = sorted_X[int(N/2)]
    
    for i in range(N):
        remove_num = X[i]
        if(remove_num > median_1):
            print(median_1)
        else:
            print(median_2)
    
if __name__=="__main__":
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

dp = [0]*(N+1)
Flag=True
while Flag:
    Flag=False
    for i in range(M):
        if dp[xy[i][1]] < dp[xy[i][0]]+1:
            dp[xy[i][1]] = dp[xy[i][0]]+1
            Flag=True
print(max(dp))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)

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

to = [[]*(N+1) for _ in range(N+1)]
for i in range(M):
    x,y=map(int,input().split())
    to[x].append(y)

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

def saiki(v):
    if dp[v]!=-1: return dp[v]
    res = 0
    for u in to[v]:
        res=max(res,saiki(u)+1)
    dp[v]=res
    return res

ans=0
for i in range(1,N+1):
    ans = max(ans,saiki(i))
print(max(dp))