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

s = input()
t = input()

lens = len(s)
lent = len(t)

# dp = [[None] * lent for _ in range(lens)]
# def dfs(aindex=0, bindex=0):
#     if aindex >= lens:
#         return 0
#     if bindex >= lent:
#         return 0
#
#     if dp[aindex][bindex] is not None:
#         return dp[aindex][bindex]
#
#     if s[aindex] == t[bindex]:
#         r = dfs(aindex + 1, bindex + 1) + 1
#     else:
#         r = max(dfs(aindex + 1, bindex), dfs(aindex, bindex + 1))
#     dp[aindex][bindex] = r
#     return r
#
# print(dfs())

shift = [1 << x for x in range(3000 + 1)]

dp = [[0] * (lent + 1) for _ in range(lens + 1)]
pattern = [[0] * (lent + 1) for _ in range(lens + 1)]
# dp = [[(0, 0) for _ in range(lent + 1)] for _ in range(lens + 1)]
for aindex in range(lens - 1, -1, -1):
    for bindex in range(lent - 1, -1, -1):
        if s[aindex] == t[bindex]:
            r = dp[aindex + 1][bindex + 1] + 1
            # p = s[aindex] + pattern[aindex + 1][bindex + 1]
            # p = (1 << aindex) + pattern[aindex + 1][bindex + 1]
            p = shift[aindex] + pattern[aindex + 1][bindex + 1]
        else:
            if dp[aindex + 1][bindex] > dp[aindex][bindex + 1]:
                r = dp[aindex + 1][bindex]
                p = pattern[aindex + 1][bindex]
            else:
                r = dp[aindex][bindex + 1]
                p = pattern[aindex][bindex + 1]
            # r = max(dp[aindex + 1][bindex], dp[aindex][bindex + 1])
        dp[aindex][bindex] = r
        pattern[aindex][bindex] = p
for aindex in range(lens):
    if (1 << aindex) & pattern[0][0]:
        print(s[aindex], end="")
# print()
# print(dp[0])
# print(pattern[0])


### FIXED CODE ###

s = input()
t = input()

lens = len(s)
lent = len(t)

# dp = [[None] * lent for _ in range(lens)]
# def dfs(aindex=0, bindex=0):
#     if aindex >= lens:
#         return 0
#     if bindex >= lent:
#         return 0
#
#     if dp[aindex][bindex] is not None:
#         return dp[aindex][bindex]
#
#     if s[aindex] == t[bindex]:
#         r = dfs(aindex + 1, bindex + 1) + 1
#     else:
#         r = max(dfs(aindex + 1, bindex), dfs(aindex, bindex + 1))
#     dp[aindex][bindex] = r
#     return r
#
# print(dfs())

shift = [1 << x for x in range(3000 + 1)]

dp = [[0] * (lent + 1) for _ in range(lens + 1)]
for aindex in range(lens - 1, -1, -1):
    for bindex in range(lent - 1, -1, -1):
        if s[aindex] == t[bindex]:
            r = dp[aindex + 1][bindex + 1] + 1
        else:
            r = max(dp[aindex + 1][bindex], dp[aindex][bindex + 1])
        dp[aindex][bindex] = r

ans = ""
ls = len(s)
lt = len(t)
ls = 0
lt = 0
while ls < lens and lt < lent:
    if dp[ls][lt] == dp[ls + 1][lt]:
        ls += 1
    elif dp[ls][lt] == dp[ls][lt + 1]:
        lt += 1
    else:
        ans += t[lt]
        ls += 1
        lt += 1
print(ans)
### BUGGY CODE ###

alphas = [chr(i).lower() for i in range(65, 65+26)]

n = int(input())

same_count = 0
sorted_list = []
for index in range(n):
  s = input()
  sorted_s = ''.join(sorted(s))
  same_count += sorted_list.count(sorted_s)

  sorted_list.append(sorted_s)
print(same_count)

### FIXED CODE ###

import math

n = int(input())

setmap = dict()
for index in range(n):
  s = input()
  sorted_s = ''.join(sorted(s))
  if setmap.get(sorted_s) is not None:
    setmap[sorted_s] = setmap[sorted_s] + 1
  else:
    setmap[sorted_s] = 1

same_count = 0
for val in setmap.values():
  if val != 1:
    same_count += int(math.factorial(val) / (2 *  math.factorial(val - 2)))
print(same_count)
### BUGGY CODE ###

# coding:utf-8
import math
import fractions

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

if K==0:
    print("N")
elif N==0 or N%K==0:
    print("0")
else:
    mi=N
    t=N
    for i in range(math.ceil(N*1.0/fractions.gcd(N,K))):
        t=abs(t-K)
        mi=min(mi,t)
    print(mi)

### FIXED CODE ###

# coding:utf-8
import math
import fractions

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

if K==0:
    print("N")
elif N==0 or N%K==0:
    print("0")
else:
    N=N%K
    print(min(N, K-N))
### BUGGY CODE ###

import numpy as np

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

dp=np.zeros((N+1),dtype=int)
dp[1]=abs(H[1]-H[0])

for i in range(1,N):
    dp[i]=min(dp[i-j]+abs(H[i-j]-H[i]) for j in range(1,min(K+1,i+1)))
        
print(dp[N-1])

### FIXED CODE ###

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

    ans=[0]*N
    ans[1]=abs(h[1]-h[0])


    for i in range(2,N):
        ans[i] = min(abs(h[i] - h[j]) + ans[j] for j in range(max(0,i-K),i))
    print(ans[N-1])
    
main()
### BUGGY CODE ###

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

prev = 1
for i in range(k):
    prev *= a[i]


for i in range(k, n):
    now = prev * a[i] // a[i-k]
    if now > prev:
        print("Yes")
    else:
        print("No")
    prev = now

### FIXED CODE ###

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

for i in range(k, n):
    if a[i] > a[i-k]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

#16:41
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(lambda x:int(x)-1, input().split())
raw = []
for _ in range(h):
  raw.append(input())
inf = 10**7
seen = [[[inf for _ in range(4)] for _ in range(w)] for _ in range(h)]
seen[x1][y1] = [0,0,0,0]

dire = [[1,0],[-1,0],[0,1],[0,-1]]
def add(x,y,di,I,J,s):
  dx,dy = dire[di]
  if J == 0:
    if 0 <= x+dx < h and 0 <= y+dy < w:
      if raw[x+dx][y+dy] == '.' and seen[x+dx][y+dy][di] > s+I:
        now.append([s+I,x+dx,y+dy,di])
        seen[x+dx][y+dy][di] = s+I
  else:
    if seen[x][y][di] > s+I:
      nex.append([s+I,x,y,di])
      seen[x][y][di] = s+I

nex = [[0,x1,y1,d] for d in range(4)]
while nex:
  now = nex
  nex = []
  for i in range(k):
    last = now
    now = []
    for sxydi in last:
      s,x,y,di = sxydi
      if seen[x][y][di] < s:
        continue
      if x == x2 and y == y2:
        print(s)
        exit()
      add(x,y,di,1-int(bool(i)),0,s)
      for d in range(4):
        if di != d:
          add(x,y,d,0,1,s)
  nex += now
print(-1)

### FIXED CODE ###

#16:41
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(lambda x:int(x)-1, input().split())
raw = []
for _ in range(h):
  raw.append(input())
inf = 10**6
seen = [[inf for _ in range(w)] for _ in range(h)]
seen[x1][y1] = 0
from heapq import heappush as push
from heapq import heappop as pop
now = [[0,x1,y1]]

while now:
  s,x,y = pop(now)
  if x == x2 and y == y2:
    print(s)
    exit()
  for i in range(1,k+1):
    if x-i == -1 or raw[x-i][y] == '@' or seen[x-i][y] < s+1:
      break
    if seen[x-i][y] != s+1:
      seen[x-i][y] = s+1
      push(now,[s+1,x-i,y])
  for i in range(1,k+1):
    if y-i == -1 or raw[x][y-i] == '@' or seen[x][y-i] < s+1:
      break
    if seen[x][y-i] != s+1:
      seen[x][y-i] = s+1
      push(now,[s+1,x,y-i])
  for i in range(1,k+1):
    if x+i == h or raw[x+i][y] == '@' or seen[x+i][y] < s+1:
      break
    if seen[x+i][y] != s+1:
      seen[x+i][y] = s+1
      push(now,[s+1,x+i,y])
  for i in range(1,k+1):
    if y+i == w or raw[x][y+i] == '@' or seen[x][y+i] < s+1:
      break
    if seen[x][y+i] != s+1:
      seen[x][y+i] = s+1
      push(now,[s+1,x,y+i])
print(-1)
### BUGGY CODE ###

def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)

    count = 0
    i = 0
    while i < n:
        x = t[i] + k
        y = min(i + c - 1, n - 1)
        while True:
            if t[y] <= x:
                break
            y -= 1

        count += 1
        i = y + 1

    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            l = v + k
            p = 1
    print(cnt)


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

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

a_2 = sorted(a)
for i in range(n):
    print(a.index(a_2[i])+1,end=" ")
    


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = [0] * n

for i in range(n):
    ans[a[i]-1] = i + 1
    
print(*ans)
### BUGGY CODE ###

#coding:utf-8
import math
import itertools
from functools import reduce

def gcd(num):
    return reduce(math.gcd, num)


if __name__ == "__main__":

    k = int(input())
    ans = 0

    num = list(range(1, k+1))
    comb = list(itertools.product(num, repeat=3))


    for i in range(len(comb)):
        ans += gcd(comb[i])

    print(ans)


### FIXED CODE ###

#coding:utf-8
from math import gcd

def main():
    k = int(input())
    ans = 0

    for a in range(1, k+1):
        for b in range(1, k+1):
            for c in range(1, k+1):
                ans += gcd(gcd(a, b), c)

    print(ans)

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

a,b,c,k = map(int,input().split())

ans=0

for i in range(k):
  
  if a > 0:
    a = a-1
    ans = ans+1
 	
  elif b > 0:
    b = b-1
  
  elif c > 0:
    c = c-1
    ans = ans -1 
    
print(ans)
 

### FIXED CODE ###

a,b,c,k = map(int,input().split())

ans=0

if a>= k:
  print(k)

elif a+b >= k:
  print(a)
  
else:
  print(a-((k-a-b)))
### BUGGY CODE ###

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

count = 0
while True:
    if n > 0 and m > 1:
        count += 1
        n -= 1
        m -= 2
    elif n == 0 and m > 3:
        count += 1
        m -= 4
    elif n == 0 and m <= 3:
        print(count)
        exit()


### FIXED CODE ###

s, c = list(map(int, input().split(" ")))

count = 0

if c >= 2 * s:
    print(s + ((c - s * 2) // 4))

else:
    count = (c - 1) // 2 if c % 2 == 1 else c // 2
    print(count)
### BUGGY CODE ###

def dp_table(*counts):  # dp[x][y]を作りたかったら dp_table(xのサイズ,yのサイズ)
    if counts:
        return [dp_table(*counts[1:]) for _ in range(counts[0])]
    else:
        return 0


def main():

    N = int(input())
    A = [int(input()) for _ in range(N)]
    mod = 998244353
    ans = pow(3, N, mod)
    sum_A = sum(A)
    dp = [[0] * (sum_A+1) for i in range(N)]
    # dp[i][j]: i番目までの中から辺をいくつか選んで、長さがjになるパターン数

    # init
    dp[0][A[0]] = 1
    dp[0][0] = 2  # 他の色のうちどちらに入れるかで2通り

    # init2
    dp2 = [[0] * (sum_A+1) for i in range(N)]  # ある二色でsum_Aを等分するパターンを数える
    dp2[0][A[0]] = 1
    dp2[0][0] = 1  # 今度は片方に集中したパターン

    # dp
    sum_now = A[0]
    for i in range(1, N):
        a = A[i]
        sum_now += a
        for length in range(sum_now+1):
            # A[i]を追加しないのなら他の２食のうちどちらに入れるかで2倍選択肢がある
            if length >= a:
                dp[i][length] = dp[i - 1][length - a] + \
                    (dp[i - 1][length] << 1)
            else:
                dp[i][length] = dp[i-1][length] << 1
            dp[i][length] %= mod

        for length in range(min(sum_now + 1, sum_A // 2 + 1)):
            if length >= a:
                dp2[i][length] = dp2[i - 1][length - a] + dp2[i - 1][length]
            else:
                dp2[i][length] = dp2[i-1][length]
            dp2[i][length] %= mod
    # print(sum(dp[N-1][sum_A//2]))
    # print(dp)
    ans -= 3*sum(dp[N-1][(sum_A+1)//2:])
    if sum_A % 2 == 0:
        ans += 3*dp2[N-1][sum_A//2]
    print(ans % mod)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def dp_table(*counts):  # dp[x][y]を作りたかったら dp_table(xのサイズ,yのサイズ)
    if counts:
        return [dp_table(*counts[1:]) for _ in range(counts[0])]
    else:
        return 0


def main():

    N = int(input())
    A = [int(input()) for _ in range(N)]
    mod = 998244353
    ans = pow(3, N, mod)
    sum_A = sum(A)
    dp = [[0] * (sum_A+1) for i in range(N)]
    # dp[i][j]: i番目までの中から辺をいくつか選んで、長さがjになるパターン数

    # init
    dp[0][A[0]] = 1
    dp[0][0] = 2  # 他の色のうちどちらに入れるかで2通り

    # init2
    dp2 = [[0] * (sum_A+1) for i in range(N)]  # ある二色でsum_Aを等分するパターンを数える
    dp2[0][A[0]] = 1
    dp2[0][0] = 1  # 今度は片方に集中したパターン

    # dp
    sum_now = A[0]
    for i in range(1, N):
        a = A[i]
        sum_now += a
        for length in range(sum_now+1):
            # A[i]を追加しないのなら他の２食のうちどちらに入れるかで2倍選択肢がある
            if length >= a:
                dp[i][length] = dp[i - 1][length - a] + \
                    (dp[i - 1][length] << 1)
            else:
                dp[i][length] = dp[i-1][length] << 1
            dp[i][length] %= mod

        for length in range(min(sum_now + 1, sum_A // 2 + 1)):
            if length >= a:
                dp2[i][length] = dp2[i - 1][length - a] + dp2[i - 1][length]
            else:
                dp2[i][length] = dp2[i-1][length]
            dp2[i][length] %= mod
    # print(sum(dp[N-1][sum_A//2]))
    # print(dp)
    ans -= 3*sum(dp[N-1][(sum_A+1)//2:])
    if sum_A % 2 == 0:
        ans += 3*dp2[N-1][sum_A//2]
    print(ans % mod)


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

from statistics import mean, median,variance,stdev

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

for i in range(n):
    print(median(x[:i]+x[i+1:]))


### FIXED CODE ###


n = int(input())
x = list(map(int, input().split()))
x_sort = x.copy()
x_sort.sort()
row = x_sort[n//2 - 1]
high = x_sort[n//2]

for i in range(n):
    if x[i] <= row:
        print(high)
    else:
        print(row)
### BUGGY CODE ###

n, k = map(int, raw_input().split(' '))

ans = 0
for i in range(n-2):
    i += 1
    for j in range(7-2):
        j += 1
        s = 0
        for ii in range(3):
            for jj in range(3):
                s += 7*(i+ii) + (j+jj) -7

        if ((s % 11) == k):
            ans +=1
print ans


### FIXED CODE ###

n, k = map(int, raw_input().split(' '))

m = n -2
ans = 5*int(m/11)
for i in xrange(m % 11):
    i += 1
    for j in xrange(7-2):
        j += 1
        s = 9*(7*i+j+1)

        if ((s % 11) == k):
            ans +=1
print ans
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [input() for i in range(H)]

queue = []
queue.append([Ch-1, Cw-1, 0])
inf = float("inf")
table = [[inf] * W for i in range(H)]
table[Ch-1][Cw-1] = 0
walk_move = [[-1, 0], [0, -1], [1, 0], [0, 1]]
magic_move = []
for i in range(-2, 3):
  for j in range(-2, 3):
    if not i and not j:
      continue
    else:
      magic_move.append([i, j])

while queue:
  x, y, cost = queue.pop(0)
  for i,j in walk_move:
    dx = x+i
    dy = y+j
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost:
      queue.insert(0, [dx, dy, cost])
      table[dx][dy] = cost
  for k,l in magic_move:
    dx = x+k
    dy = y+l
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost+1:
      queue.insert(0, [dx, dy, cost+1])
      table[dx][dy] = cost+1

ans = table[Dh-1][Dw-1]
if ans == inf:
  print("-1")
else:
  print(table[Dh-1][Dw-1])

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [input() for i in range(H)]

queue = deque()
queue.append((Ch-1, Cw-1, 0))
inf = float("inf")
table = [[inf] * W for i in range(H)]
table[Ch-1][Cw-1] = 0
walk_move = ((-1, 0), (0, -1), (1, 0), (0, 1))
magic_move = []
for i in range(-2, 3):
  for j in range(-2, 3):
    if not i and not j:
      continue
    else:
      magic_move.append([i, j])

while queue:
  x, y, cost = queue.popleft()
  for i,j in walk_move:
    dx = x+i
    dy = y+j
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost:
      queue.appendleft((dx, dy, cost))
      table[dx][dy] = cost
  for k,l in magic_move:
    dx = x+k
    dy = y+l
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost+1:
      queue.append((dx, dy, cost+1))
      table[dx][dy] = cost+1

ans = table[Dh-1][Dw-1]
if ans == inf:
  print("-1")
else:
  print(table[Dh-1][Dw-1])
### BUGGY CODE ###

import sys
from collections import deque
H, W = map(int, input().split())
gridgraph = []
for line in sys.stdin.readlines():
    line = line.rstrip()
    gridgraph.append(line)

q = deque()
visited = [[False]*W for _ in range(H)]
ans = [[1e+9]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if gridgraph[i][j] == "#":
            q.append((i, j))
            visited[i][j] = True
            ans[i][j] = 0
while len(q):
    cy, cx = q.popleft()
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        if not (cy+dy >= 0 and H-1 >= cy+dy and cx+dx >= 0 and W-1 >= cx+dx):
            continue
        if visited[cy+dy][cx+dx]:
            continue
        visited[cy+dy][cx+dx] = True
        ans[cy+dy][cx+dx] = min(ans[cy+dy][cx+dx], ans[cy][cx]+1)
        q.append((cy+dy, cx+dx))

min_value = 0
for a in ans:
    min_value = max(min_value, max(a))
print(min_value)


### FIXED CODE ###

import sys
from collections import deque
H, W = map(int, input().split())
gridgraph = []
for line in sys.stdin.readlines():
    line = line.rstrip()
    gridgraph.append(list(line))
q = deque()
visited = [[False]*W for _ in range(H)]
ans = [[1e+9]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if gridgraph[i][j] == "#":
            q.append((i, j))
            visited[i][j] = True
            ans[i][j] = 0

while len(q):
    cy, cx = q.popleft()

    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        if not (cy+dy >= 0 and H-1 >= cy+dy and cx+dx >= 0 and W-1 >= cx+dx):
            continue
        if visited[cy+dy][cx+dx]:
            continue
        visited[cy+dy][cx+dx] = True
        ans[cy+dy][cx+dx] = min(ans[cy+dy][cx+dx], ans[cy][cx]+1)
        q.append((cy+dy, cx+dx))

min_value = 0
for a in ans:
    min_value = max(min_value, max(a))
print(min_value)
### BUGGY CODE ###

# your code goes here
def solve(n):
	odd=0;
	even=0;
	if(n==0):
		return 1;
	if(n==1):
		return 0;
	while(n):
		if(n&1):
			odd+=1;
		if(n&2):
			even+=1;
		n=n>>2;
	return solve(abs(even-odd))
n=int(input())
if(solve(n)):
	print("Yes");
else:
	print("No");

### FIXED CODE ###

s=input()
ans=0;
for i in s:
  ans+=int(i)
if(ans%9==0):
	print("Yes");
else:
  print("No");
### BUGGY CODE ###

N = int(input())
X = input()

def popcount(x):
    tmp = x
    count = 0
    while tmp > 0:
        if tmp & 1 == 1:
            count += 1
        tmp >>= 1
    
    return count

def f(j):
    cnt = 0
    while j:
        j %= bin(j).count("1")
        cnt += 1
    return cnt

def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

tmp_pop_X = X.count('1')
X_tmp = int(X,2)

for i in range(N):
    if X[i] == '0':
        X_next = X_tmp + pow_k(2,N-1-i)
        X_pop_next = tmp_pop_X + 1
    else:
        X_next = X_tmp - pow_k(2,N-1-i)
        X_pop_next = tmp_pop_X - 1
        
    if X_pop_next == 0:
        print(0)
        continue
        
    X_next = X_next % X_pop_next
    ans = 1
    
    #while X_next != 0:
    #    X_next = X_next % popcount(X_next)
    #    ans += 1
    print(ans + f(X_next))

### FIXED CODE ###

n = int(input())
s = input()
x = int(s, 2)
pcx = s.count("1")
pc1 = x % (pcx - 1) if pcx > 1 else 0
pc2 = x % (pcx + 1)

def f(j):
    cnt = 0
    while j:
        j %= bin(j).count("1")
        cnt += 1
    return cnt

for i, y in enumerate(s):
    k = n - 1 - i
    if y == "0":
        print(f((pc2 + pow(2, k, pcx + 1)) % (pcx + 1)) + 1)
    elif pcx > 1:
        print(f((pc1 - pow(2, k, pcx - 1)) % (pcx - 1)) + 1)
    else:
        print(0)
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    def make_divisors(n):
        lower_divisors, upper_divisors = [], []
        i = 1
        while i * i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n // i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    N = int(input())
    print(sum([i * len(make_divisors(i)) for i in range(N + 1)]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

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

    def fanc(N):
        return N * (N + 1) // 2
    ans = 0
    for i in range(1, N + 1):
        ans += i * fanc(N // i)
    print(ans)


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

import math
from functools import reduce

k = int(input().rstrip())

def gcd(numbers):
    return reduce(math.gcd, numbers)

a = list(range(1, k + 1))
b = list(range(1, k + 1))
c = list(range(1, k + 1))

ans = 0
for i in a:
    for j in b:
        for k in c:
            ans += gcd([i, j, k])

print(ans)

### FIXED CODE ###

import math

k = int(input().rstrip())


ans = 0
for a in range(1, k + 1):
    if a == 1:
        ans += k * k
    else:
       for b in range(1, k + 1):
            if b == 1:
               ans += k
            else:
                if a == b:
                    tmp = a
                    if tmp == 1:
                        ans += k
                    else:
                        for c in range(1, k + 1):
                            if c == 1:
                                ans += 1
                            else:
                                ans += math.gcd(tmp, c)
                else:
                    tmp = math.gcd(a, b)
                    if tmp == 1:
                        ans += k
                    else:
                        for c in range(1, k + 1):
                            if c == 1:
                                ans += 1
                            else:
                                ans += math.gcd(tmp, c)

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

def fx(n):
  cnt = 0

  for i in range(1,10000):
    if (i+1+1)**2 - i*1 - 1*1 - 1*i > n: break
    for j in range(1, 10000):
      if (1+j+1)**2 - 1*j - j*1 - 1*1 > n : break
      for k in range(1, 10000):
        formula = (i+j+k)**2 - i*j - j*k - k*i
        if formula == n:
          cnt+=1
        if formula >= n:
          break
  
  return cnt


n = int(input())
for i in range(1,n+1):
  print(fx(i))



### FIXED CODE ###

def fx(n):
  s = [0]*(n+1)
  for i in range(1,10000):
    if (i+1+1)**2 - i*1 - 1*1 - 1*i > n: break
    for j in range(1, 10000):
      if (1+j+1)**2 - 1*j - j*1 - 1*1 > n : break
      for k in range(1, 10000):
        if (1+1+k)**2 - 1*1 - 1*k - k*1 > n: break
        formula = (i+j+k)**2 - i*j - j*k - k*i
        if formula <= n and formula > 0:
          s[formula] += 1
        if formula >= n:
          break
  return s


n = int(input())
s = fx(n)
for i in range(1,n+1):
  print(s[i])
### BUGGY CODE ###

N=int(input())
a=[[0 for j in range(N-1)] for i in range(N)]
for i in range(N):
  line=list(map(int,input().split()))
  for j in range(N-1):
    a[i][j]=line[j]-1
  a[i]=a[i][::-1]
    
from collections import deque
q=deque()

#seen=[[False for j in range(N)] for i in range(N)]

# 選手nが試合できるならqueに入れる
def check(i):
  if len(a[i])==0:
    return False
  j=a[i][-1]
  if a[j][-1]==i:
    q.append([i,j])
  
for i in range(N):
  check(i)
  
from collections import defaultdict

day=0
while q:
  day+=1
  q=sorted(q)
  prevQ=q.copy()
  q=deque()
  matched=defaultdict(list)
  for p in prevQ:
    i=p[0]
    j=p[1]
    if i>j:
      i,j=j,i
    if matched[i]:
      continue
    a[i].pop()
    a[j].pop()
    check(i)
    check(j)
    matched[i].append(j)
    
for i in range(N):
  if len(a[i])!=0:
    print(-1)
    break
else:
  print(day)

### FIXED CODE ###

N=int(input())
a=[[0 for j in range(N-1)] for i in range(N)]
for i in range(N):
  line=list(map(int,input().split()))
  for j in range(N-1):
    a[i][j]=line[j]-1
  a[i]=a[i][::-1]
    
q=[]

#seen=[[False for j in range(N)] for i in range(N)]

# 選手nが試合できるならqueに入れる
def check(i):
  if len(a[i])==0:
    return False
  j=a[i][-1]
  if a[j][-1]==i:
    q.append([i,j])
  
for i in range(N):
  check(i)
  
from collections import defaultdict

day=0
while q:
  day+=1
 # q=sorted(q)
  prevQ=q.copy()
  q=[]
  matched=defaultdict(list)
  for p in prevQ:
    i=p[0]
    j=p[1]
    if i>j:
      i,j=j,i
    if matched[i]:
      continue
    a[i].pop()
    a[j].pop()
    check(i)
    check(j)
    matched[i].append(j)
    
for i in range(N):
  if len(a[i])!=0:
    print(-1)
    break
else:
  print(day)