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

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    div = np.zeros(N+1, np.int64)
    for n in range(1, N+1):
      div[::n] += 1
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))


### FIXED CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

def main(N, primes):
    div = np.ones(N + 1, dtype=np.int64)
    for p in primes:
        for i in range(N // p + 1):
            div[p * i] += div[i]
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, i8[:]))
    cc.compile()

from my_module import main

N = int(read())
is_prime, primes = prime_table(N + 1)
print(main(N, primes))
### BUGGY CODE ###

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

subsets = []
splits = [i for i in range(1, n)]
n -= 1
for i in range(2**n):
    x = []
    for j in range(n):
        if i&(1<<j):
            x.append(j)
    subsets.append(x)
n+=1
A = []
for i in range(n):
    A.append([int(j) for j in input()])
ans = n*m
for subset in subsets:
    cur_ans = len(subset)
    #print(subset)
    tmp = []
    col = 0
    subset.append(100000)
    running_sum = [0 for i in range(len(subset)+10)]    
    while col<m:
        row_ptr = 0    
        for row in range(n):
            if row > subset[row_ptr]:
                row_ptr += 1
            running_sum[row_ptr] += A[row][col]
            if running_sum[row_ptr] > k:
                col -= 1
                running_sum = [0 for i in range(len(subset)+10)]
                cur_ans += 1
                break
        col += 1                
    ans = min(ans, cur_ans)
print(ans)


### FIXED CODE ###

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

subsets = []
splits = [i for i in range(1, n)]
n -= 1
for i in range(2**n):
    x = []
    for j in range(n):
        if i&(1<<j):
            x.append(j)
    subsets.append(x)
n+=1
A = []
for i in range(n):
    A.append([int(j) for j in input()])
ans = n*m
for subset in subsets:
    cur_ans = len(subset)
    tmp = []
    col = 0
    subset.append(100000)
    running_sum = [0 for i in range(len(subset))]    
    while col<m:
        row_ptr = 0    
        for row in range(n):
            if row > subset[row_ptr]:
                row_ptr += 1
            running_sum[row_ptr] += A[row][col]
            if running_sum[row_ptr] > k:
                col -= 1
                running_sum = [0 for i in range(len(subset))]
                cur_ans += 1
                break
                
        col += 1                
        if cur_ans >= ans:
          break
    ans = min(ans, cur_ans)
print(ans)
### BUGGY CODE ###

S = str(input())
Q = int(input())

for q in range(0, Q):
    qi = list(input().split())

    if len(qi) == 1:
        S = S[::-1]
    else: # len(qi) == 3
        Fi, Ci = int(qi[1]), qi[2]

        if Fi == 1: # front
            S = Ci + S
        else: # Fi == 2, end
            S = S + Ci

print(S)


### FIXED CODE ###

S = str(input())
Q = int(input())

flip = False

head = ""
tail = ""

for q in range(Q):
    Ti = input()
    if Ti == '1':
        flip = not flip
    else:
        _, Fi, Ci = map(str, Ti.split())
        Fi = int(Fi)

        if (Fi^flip)&1:
            head += Ci
        else:
            tail += Ci

S = head[::-1] + S + tail
print( S if not flip else S[::-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
INF = float('inf')

def sol():
    N, M, L = map(int, input().split())
    ABC = [tuple(map(int, input().split())) for _ in range(M)]
    Q = int(input())
    ST = [tuple(map(int, input().split())) for _ in range(Q)]

    dist = [[INF] * N for _ in range(N)]
    fuel = [[INF] * N for _ in range(N)]

    for i in range(N):
        dist[i][i] = 0
        fuel[i][i] = 0

    for fr, to, cost in ABC:
        if cost > L:
            continue
        fr -= 1
        to -= 1
        dist[fr][to] = cost
        dist[to][fr] = cost

    for k in range(N):
        for i in range(N):
            for j in range(N):
                d = dist[i][k] + dist[k][j]
                dist[i][j] = min(dist[i][j], d)
                if d <= L:
                    fuel[i][j] = 1

    for k in range(N):
        for i in range(N):
            for j in range(N):
                fuel[i][j] = min(fuel[i][j], fuel[i][k] + fuel[k][j])

    ans = [fuel[start - 1][end - 1] - 1 if fuel[start - 1][end - 1] != INF else -1 for start, end in ST]
    for a in ans:
        print(a)

sol()

### FIXED CODE ###

import sys
input = sys.stdin.readline
INF = float('inf')

N, M, L = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(M)]
Q = int(input())
ST = [tuple(map(int, input().split())) for _ in range(Q)]

dist = [[INF] * N for _ in range(N)]
fuel = [[INF] * N for _ in range(N)]

for i in range(N):
    dist[i][i] = 0
    fuel[i][i] = 0

for fr, to, cost in ABC:
    if cost > L:
        continue
    fr -= 1
    to -= 1
    dist[fr][to] = cost
    dist[to][fr] = cost

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = dist[i][k] + dist[k][j]
            if dist[i][j] > d:
                dist[i][j] = d
            if d <= L:
                fuel[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = fuel[i][k] + fuel[k][j]
            if fuel[i][j] > d:
                fuel[i][j] = d

for start, end in ST:
    print(fuel[start - 1][end - 1] - 1 if fuel[start - 1][end - 1] != INF else -1)
### BUGGY CODE ###

K, S = [int(i) for i in input().split()]

cnt = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                cnt += 1

print(cnt)

### FIXED CODE ###

K, S = [int(i) for i in input().split()]


cnt = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - (x + y) 
        if z >= 0 and z <= K:
            cnt += 1

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

from collections import deque

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

a=[list('@'*w)]
for i in range(h):
    a+=[list('@'+input()+'@')]
a+=[list('@'*w)]
h+=2

xy=[(-1,0),(0,-1),(0,1),(1,0)]

def bfs(sx,sy):
    A[sx][sy]=0
    que=deque()
    que.append((sx,sy))

    while que:
        x,y=que.popleft()
        for dx,dy in xy:
            nx,ny=dx+x,dy+y
            tmp=A[x][y]+1
            if a[nx][ny]!='@':
                if A[nx][ny]<=tmp:continue
                A[nx][ny]=tmp
                que.append((nx,ny))


A=[[float('inf')]*w for i in range(h)]

res=0
for i in range(1,h-1):
    for j in range(1,w-1):
        if a[i][j]=='#':
            bfs(i,j)

S=A[1:-1]

for e in S:
    res=max(res,max(e[1:-1]))
print(res)


### FIXED CODE ###

from collections import deque

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

a=[list('@'*w)]
for i in range(h):
    a+=[list('@'+input()+'@')]
a+=[list('@'*w)]
h+=2

xy=[(-1,0),(0,-1),(0,1),(1,0)]
que=deque()

def bfs():
    res=0
    while que:
        x,y=que.popleft()
        for dx,dy in xy:
            nx,ny=dx+x,dy+y
            tmp=A[x][y]+1
            if a[nx][ny]!='@':
                if A[nx][ny]<=tmp:continue
                A[nx][ny]=tmp
                que.append((nx,ny))
                res=max(res,tmp)
    return res


A=[[float('inf')]*w for i in range(h)]

res=0
for i in range(1,h-1):
    for j in range(1,w-1):
        if a[i][j]=='#':
            A[i][j]=0
            que.append((i,j))

res=bfs()
print(res)
### BUGGY CODE ###

from collections import deque

def main():
    n = input()
    A = map(int,raw_input().split())
    q = input()
    M = map(int,raw_input().split())

    for m in M:
        qA = deque(A)
        for j in range(n):
            w = rec(m,A)
            if w:
                break
            qA.popleft()
            
        if w:
            print "yes"
        else:
            print "no"

def rec(m,A):
    Ac = deque(list(A)[:])
    Ad = deque(list(A)[:])
    r1 = rec1(m,Ac)
    r2 = rec1(m-A[0],Ad)

    if r1 or r2:
        return True
    else:
        return False

def rec1(m_new,A):
    #print A
    if m_new == 0:
        return True
    elif m_new < 0:
        return False
    else:
        if len(A) == 1:
            return False
        else:
            A.popleft()
            return rec(m_new,A)
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

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

MOD = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))

ans = 0
mem = {}
for i in range(N-1):
  for j in range(i+1, N):
    key = str(min(i,j)) + '-' + str(max(i,j))
    if key not in mem:
      mem[key] = (A[i]^A[j])%MOD
    ans += mem[key]
      
print(ans%MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

maxA_len = len(bin(maxA)[2:])
num0_each_digit = [0 for _ in range(maxA_len)]
num1_each_digit = [0 for _ in range(maxA_len)]

for i in range(N):
    for i_bit, bit in enumerate(bin(A[i])[2:].zfill(maxA_len)):
        if bit == '0':
            num0_each_digit[i_bit] += 1
            num0_each_digit[i_bit] %= MOD
        else:
            num1_each_digit[i_bit] += 1
            num1_each_digit[i_bit] %= MOD
ans = 0
for i in range(maxA_len):
    factor = (2 ** (maxA_len - i - 1)) % MOD
    ans += (num0_each_digit[i] * num1_each_digit[i] * factor) % MOD

print(ans % MOD)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

p = 1

for e in a:
  p *= e

if p > 10**18:
  print(-1)
else:
  print(p)

### FIXED CODE ###

N = int(input())
A = list(map(int,input(). split ()))
max = 10**18
if 0 in A:
  print(0)
  exit()
  
prod = 1
for a in A:
  prod *= a
  if prod > max:
    print(-1)
    exit()
print(prod)
### BUGGY CODE ###

suuji = int(input())
cntmax = 0
dst = 1
for i in range(suuji):
    suu = i
    cnt = 0
    while suu % 2 == 0:
        suu /= 2
        cnt += 1
    if cntmax < cnt:
        cntmax = cnt
        dst = i
print(dst)

### FIXED CODE ###

suuji = int(input())
srclist = [1, 2, 4, 8, 16, 32, 64, 128]
dst = 0
for i in range(len(srclist)):
    if srclist[i] > suuji:
        break
print(srclist[i-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
 
N,M = list(map(int,input().split()))
A = [int(input()) for _ in range(M)]
 
a2 = 1
a1 = 0 if 1 in A else 1 
for i in range(2,N+1):
    a = 0 if i in A else a2+a1
    a2 = a1
    a1 = a
print(1 if N == 1 else a%1000000007)


### FIXED CODE ###

n,m = map(int,input().split())
a = [ int(input()) for _ in range(m)]
M=10**9+7
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]<0:
    lis[i+2]= 0
  else:
    lis[i+2] = (lis[i+1] + lis[i])%M
print(lis[n])
### BUGGY CODE ###

# D - String Formation
S = input()
Q = int(input())
for _ in range(Q):
    t = list(input().split())
    if t[0]=='1':
        S = S[::-1]
    else:
        if t[1]=='1':
            S = t[2] + S
        else:
            S = S + t[2]
print(S)

### FIXED CODE ###

# D - String Formation
from collections import deque
S = input()
Q = int(input())
now = 1
tmp = [deque([]),deque([])]
for _ in range(Q):
    t = list(input().split())
    if t[0]=='1':
        now = 1+(now==1)
    else:
        if int(t[1])==now:
            tmp[0].append(t[2])
        else:
            tmp[1].append(t[2])
ans = ''
if now==1:
    i,j = 0,1
else:
    i,j = 1,0
while len(tmp[i])>0:
    ans += tmp[i].pop()
if now==2:
    S = S[::-1]
ans += S
while len(tmp[j])>0:
    ans += tmp[j].popleft()
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import heapq

INF = 10 ** 10

class Edge():
    def __init__(self, end, cost):
        self.end = end
        self.cost = cost

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for e in G[v]:
            if dist[e.end] > dist[v] + e.cost:
                dist[e.end] = dist[v] + e.cost
                heapq.heappush(h, (dist[e.end], e.end))
    return dist


H, W = map(int, input().split())
N = H * W
ch, cw = map(lambda x:int(x)-1, input().split())
gh, gw = map(lambda x:int(x)-1, input().split())

s = []
es = {i:[] for i in range(N)}

for h in range(H):
   s.append(input().rstrip('\n'))

for h in range(H):
    for w in range(W):
        if s[h][w] != '.':
            continue
        for dh in (-2, -1, 0, 1, 2):
            for dw in (-2, -1, 0, 1, 2):
                if dh == 0 and dw == 0:
                    continue
                nh = h + dh
                nw = w + dw
                if 0 <= nh and nh < H and 0 <= nw and nw < W and s[nh][nw] == '.':
                    a = h*W+w
                    b = nh*W+nw
                    if (dh, dw) in [(-1,0),(1,0),(0,-1),(0,1)]:
                        es[a].append(Edge(b, 0))
                    else:
                        es[a].append(Edge(b, 1))

dist = dijkstra(N, es, ch*W+cw)
if dist[gh*W+gw] == INF:
    print(-1)
else:
    print(dist[gh*W+gw])

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq

INF = 10 ** 10

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for end, cost in G[v]:
            if dist[end] > dist[v] + cost:
                dist[end] = dist[v] + cost
                heapq.heappush(h, (dist[end], end))
    return dist


H, W = map(int, input().split())
N = H * W
ch, cw = map(lambda x:int(x)-1, input().split())
gh, gw = map(lambda x:int(x)-1, input().split())

s = []
es = tuple([] for i in range(N))

for h in range(H):
   s.append(input().rstrip('\n'))

for h in range(H):
    for w in range(W):
        if s[h][w] != '.':
            continue
        a = h*W+w
        esappend = es[a].append
        for dh in (-2, -1, 0, 1, 2):
            for dw in (-2, -1, 0, 1, 2):
                if dh == 0 and dw == 0:
                    continue
                nh = h + dh
                nw = w + dw
                if 0 <= nh and nh < H and 0 <= nw and nw < W and s[nh][nw] == '.':
                    b = nh*W+nw
                    if (dh, dw) in [(-1,0),(1,0),(0,-1),(0,1)]:
                        esappend((b, 0))
                    else:
                        esappend((b, 1))

dist = dijkstra(N, es, ch*W+cw)
if dist[gh*W+gw] == INF:
    print(-1)
else:
    print(dist[gh*W+gw])
### BUGGY CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = sorted(list(map(int,input().split())))
    dp = [0]*(max(a)+1)
    for i in range(n):
        if dp[a[i]]>1:
            continue
        dp[a[i]]+=1
        j = 2
        while True:
            b = a[i]*j
            if b>max(a):
                break
            dp[b]+=1
            j+=1
    cnt = 0
    for i in range(n):
        if dp[a[i]] == 1:
            cnt+=1
    print(cnt)

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = sorted(list(map(int,input().split())))
    M = 1000005
    dp = [0]*(M)
    for i in range(n):
        if dp[a[i]] != 0:
            dp[a[i]] = 2
            continue
        for j in range(a[i],M,a[i]):
            dp[j]+=1
    cnt = 0
    for i in range(n):
        if dp[a[i]] == 1:
            cnt+=1
    print(cnt)
### BUGGY CODE ###

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

count = 0
for i in range(0, n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j]:
            count += 0
        elif 2*j-i<=n-1 and s[2*j-i] != s[i] and s[2*j-i] != s[j]:
            l = [s[k] for k in range(j+1,n) if s[k] != s[i] and s[k] != s[j]]
            count += len(l) -1
        else:
            l = [s[k] for k in range(j + 1, n) if s[k] != s[i] and s[k] != s[j]]
            count += len(l)

print(count)


### FIXED CODE ###

import math
n =  int(input())
s = list(input())

upper = s.count("R")*s.count("G")*s.count("B")

def counting(x):
  count = 0
  for i in range(1, math.ceil(x/2)):
    if s[x-1]!=s[x-1-i] and s[x-1-i]!=s[x-1-2*i] and s[x-1-2*i]!=s[x-1]:
      count += 1
    else:
      count += 0
  return count

if n>=3:
  minus = [0]*(n+1)
  if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
    minus [3] = 1
  else:
    minus [3] = 0
  for i in range(3,n):
    minus[i+1] = minus[i]+counting(i+1)
  print(int(upper-minus[n]))
else:
  print(int(0))
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
for i in range(len(a)):
    b = a.copy()
    del b[i]
    print(max(b))

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
max_a = max(a)
second_a = sorted(a)[-2]
max_count = a.count(max_a) - 1
if max_count:
    [print(max_a) for _ in range(len(a))]
else:
    [print(max_a) if a[i] != max_a else print(second_a) for i in range(len(a))]
### BUGGY CODE ###

N = int(input())
S = [list(input()) for _ in range(N)]
for i in range(N):
    S[i] = sorted(S[i])
S = sorted(S)

count = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            count += 1
        else:
            break

print(count)

### FIXED CODE ###

N = int(input())
dic = {}
s = 0
for n in range(N):
  v = ''.join(sorted(input()))
  if dic.get(v) is None:
    dic[v] = 1
  else:
    s += dic[v]
    dic[v] += 1
print(s)
### BUGGY CODE ###

N=int(input())

def luca(n):
	if n==0:
		return 2
	if n==1:
		return 1
	return luca(n-1)+luca(n-2)

print(luca(N))

### FIXED CODE ###

N=int(input())

ret=[]
def luca(n):
	global ret

	if n==0:
		return 2
	if n==1:
		return 1
	return ret[n-1]+ret[n-2]

for i in range(N+1):
	ret.append(luca(i))

print(ret[-1])
### BUGGY CODE ###

s=input()
q=int(input())
c=1
for i in range(q):
    qu=input().split()
    if qu[0]=="1":
        c*=-1
    else:
        if c==1:
            if qu[1]=="1":
                s=qu[2]+s
            else:
                s=s+qu[2]
        else:
            if qu[1]=="1":
                s=s+qu[2]
            else:
                s=qu[2]+s
if c==1:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

s=input()
q=int(input())
c=1
u=''
for i in range(q):
    inp=input()
    if inp[0]=="1":
        c*=-1
    else:
        t,f,p=inp.split()
        if (f=="1" and c!=1) or (f=="2" and c==1):
            s+=p
        else:
        	u+=p
if c!=1:
    print("".join(reversed(s))+u)
else:
    print("".join(reversed(u))+"".join(s))
### BUGGY CODE ###

import sys
 
input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
 
for _ in range(m):
    b, c = map(int, input().split())
    C = [c for i in range(b)]
    A.extend(C)
 
A = sorted(A, reverse=True)
result = [A[i] for i in range(n)]
print(sum(result))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(M)]
C = [0 for i in range(M)]
for i in range(M):
  B[i],C[i] = map(int, input().split())

import bisect
from collections import deque

for i in range(M):
  A = sorted(A)
  lm = bisect.bisect_right(A, C[i]-1)-1
  for j in range(min(B[i],lm+1)):
    A[j] = C[i]
print(sum(A))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [[] for _ in range(M)]
for i in range(M):
  BC[i] = list(map(int, input().split()))

BC.sort(key=lambda x: x[1], reverse=True)

for i in BC:
  A.extend([i[1]]*i[0])
  if len(A) > 2*N:
    break
    
A = sorted(A,reverse=True)
print(sum(A[:N]))
### BUGGY CODE ###

import sys
from collections import defaultdict
from functools import lru_cache


g = None


@lru_cache(maxsize=100000)
def f(x):
    return max((f(y) + 1 for y in g[x]), default=0)


def resolve(in_):
    global g
    n, m = map(int, next(in_).split())
    _g = defaultdict(list)
    for line in in_:
        x, y = map(int, line.split())
        _g[x - 1].append(y - 1)
    g = _g
    f.cache_clear()
    return max(f(i) for i in range(n))


def main():
    sys.setrecursionlimit(200000)
    ans = resolve(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import defaultdict


g = None
memo = None


def f(x):
    if memo[x] == -1:
        ret = 0
        for y in g[x]:
            ret = max(ret, f(y) + 1)
        memo[x] = ret
    return memo[x]


def resolve(in_):
    global g, memo
    n, m = map(int, next(in_).split())
    _g = defaultdict(list)
    for line in in_:
        x, y = map(int, line.split())
        _g[x - 1].append(y - 1)
    g = _g
    memo = [-1] * 100000
    return max(f(i) for i in range(n))


def main():
    sys.setrecursionlimit(1000000)
    ans = resolve(sys.stdin.buffer)
    print(ans)


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

n = int(input())
l = list(map(int, input().split()))
l.sort()

from scipy.misc import comb

temp = 0
for i in range(n-1):
  c = comb(l[-1], l[i], exact=True) 
  if c >= temp:
    p = l[-1]
    q = l[i]
    temp = c
print(p, q)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()


if l[-1]%2 == 0:
  s = l[-1]//2
else:
  s = (l[-1]+1)//2

temp = float('inf')
for i in range(n-1):
  t = abs(l[i]-s)
  if t <= temp:
    p = l[-1]
    q = l[i]
    temp = t
print(p, q)
### BUGGY CODE ###

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

L.sort()
diff_L=[]

for i in range(1,N-1):
    diff=[]
    for j in range(i+1,N):
        diff.append(L[j]-L[i])
    diff_L.append(diff)
    
total=0
for i in range(N-2):
    for j in range(i,N-2):
        for elem in diff_L[j]:
            if elem < L[i]:
                total += 1
            else:
                break
print(total)

### FIXED CODE ###

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

L.sort()
larger=[N]
prev=1
for i in range(N):
    larger= larger +[N-i]*(L[i]-prev)
    prev=L[i]

total=0    
for i in range(N-2):
    low=L[:i+1]
    high=L[i+1:]
    for j in range(len(high)-1):
        diff = high[j+1]-high[0]
        if diff >= len(larger):
            count = 0
        else:
            count = max(larger[diff] - (N-i-1),0)
        total += count
        
print(total)