Harryxun/stf_run huggingface dataset:
A,B=map(int,input().split())
print((A-1)*(B-1)

### FIXED CODE ###

A,B=map(int,input().split())
print((A-1)*(B-1))
n,d=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
answer=0
for i in range(1,n):
  for j in range(2,n+1):
    for y in range(d):
      count=0
      count+=(lists[j-1][y]-lists[i-1][y])**2
      n=count**(1/2)
      if n.is_integer():
        answer+=1
print(answer)

### FIXED CODE ###

n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n-1):
  for j in range(i+1,n):
    sum=0
    for dd in range(d):
      sum+=(l[i][dd]-l[j][dd])**2
    if sum**0.5==int(sum**0.5):
      cnt+=1
print(cnt)
N=input()
S = [str(input()) for i in range(N)]
print(len(set(S)))

### FIXED CODE ###

N=int(input())
S = [str(input()) for i in range(N)]
print(len(set(S)))
n,m=map(int,input().split())
a = list(map(int, input().split()))

def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=False
for i in range(n):
    if(b[i]%2!=b[0]%2):
        flag=True
x=1
if(b[0]%2==0):
    f=True
for i in range(n):
    x=lcm(x,b[i])

if(f):
    l=0
else:
    res=m//x+1
    res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)


### FIXED CODE ###

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

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

def lcm(a,b):
    return a*b//gcd(a,b)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
keta=0
buf=b[0]
while(buf%2==0):
    buf/=2
    keta+=1
for i in range(n):
    buf=b[i]
    tmp=0
    while(buf%2==0):
        buf/=2
        tmp+=1
    if(keta!=tmp):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)
from _bisect import bisect_right


def d():
    n = int(input())
    ls = list(map(int, input().split()))
    ls.sort()
    count = 0
    for i in range(n-1, -1, -1):
        for j in range(i-1, -1, -1):
            k = bisect_right(ls, ls[i]-ls[j])
            if j >= k:
                count += j - k

    print(count)
    

if __name__ == '__main__':
    d()


### FIXED CODE ###

def d():
    n = int(input())
    ls = list(map(int, input().split()))
    ls.sort()
    count = 0
    for i in range(n-1):
        k = i + 2
        for j in range(i+1, n-1):
            while k < n and ls[i] + ls[j] > ls[k]:
                k += 1
            count += k - j - 1

    print(count)


if __name__ == '__main__':
    d()
import numpy as np
from bisect import bisect_left

D = int(input())
C = np.array(list(map(int, input().split())))
S = np.array([list(map(int, input().split())) for d in range(D)])

L = np.empty(26, int)
L[:] = -1

X = [[-1] for _ in range(26)]
T = []

score = 0
for d in range(D):
    t = int(input())-1
    T.append(t)
    L[t] = d
    score += S[d, t] - np.dot(C, d-L)
    X[t].append(d)

for x in X:
    x.append(D)
    
M = int(input())
for _ in range(M):
    d, q = map(int, input().split())
    d-=1
    q-=1

    t = T[d]
    T[d] = q
    
    i = bisect_left(X[t], d)
    d_prev = X[t][i-1]
    d_next = X[t][i+1]
    
    dd = d-d_prev-1
    score += C[t]*(dd+1)*dd//2
    dd = d_next-d-1
    score += C[t]*(dd+1)*dd//2
    dd = d_next-d_prev-1
    score -= C[t]*(dd+1)*dd//2

    i = bisect_left(X[q], d)
    d_prev = X[q][i-1]
    d_next = X[q][i]
    
    dd = d-d_prev-1
    score -= C[q]*(dd+1)*dd//2
    dd = d_next-d-1
    score -= C[q]*(dd+1)*dd//2
    dd = d_next-d_prev-1
    score += C[q]*(dd+1)*dd//2

    X[t].pop(i)
    X[q].insert(i, d)

    score += S[d,q] - S[d,t]

    print(score)


### FIXED CODE ###

import numpy as np
from bisect import bisect_left

D = int(input())
C = np.array(list(map(int, input().split())))
S = np.array([list(map(int, input().split())) for d in range(D)])

L = np.empty(26, int)
L[:] = -1

X = [[-1] for _ in range(26)]
T = []

score = 0
for d in range(D):
    t = int(input())-1
    T.append(t)
    L[t] = d
    score += S[d, t] - np.dot(C, d-L)
    X[t].append(d)

for x in X:
    x.append(D)
    
M = int(input())
for _ in range(M):
    d, q = map(int, input().split())
    d-=1
    q-=1

    t = T[d]
    T[d] = q
    
    i = bisect_left(X[t], d)
    d_prev = X[t][i-1]
    d_next = X[t][i+1]
    
    dd = d-d_prev-1
    score += C[t]*(dd+1)*dd//2
    dd = d_next-d-1
    score += C[t]*(dd+1)*dd//2
    dd = d_next-d_prev-1
    score -= C[t]*(dd+1)*dd//2

    X[t].pop(i)
    
    i = bisect_left(X[q], d)
    d_prev = X[q][i-1]
    d_next = X[q][i]
    
    dd = d-d_prev-1
    score -= C[q]*(dd+1)*dd//2
    dd = d_next-d-1
    score -= C[q]*(dd+1)*dd//2
    dd = d_next-d_prev-1
    score += C[q]*(dd+1)*dd//2

    X[q].insert(i, d)

    score += S[d,q] - S[d,t]

    print(score)
n = input()
t = n.split()

result = int(n[0]) * int(n[1])

### FIXED CODE ###

from sys import stdin
A, B = list(map(float,input().split()))

result = int(A * B)

print(result)
import sys
def euc(li):
    if (li[0] == 0 or li[1] == 0):
        return li[1];
    return euc((li[0]-li[1],li[1]) if li[0]>li[1] else (li[1]-li[0],li[0]))
for line in sys.stdin:
    [a,b] = [int(x) for x in line.split()]
    gcd = euc([a,b])
    print gcd,a*b/gcd

### FIXED CODE ###

import sys
def gcd(a,b):
    if (b == 0):
        return a
    return gcd(b,a%b)
for line in sys.stdin:
    a,b = [int(x) for x in line.split()]
    d = gcd(a,b)
    print d,a*b/d
def main():
	N,K = map(int,input().split())
	H = [int(h) for h in input().split()]
	H = sorted(H,reverse=True)
	for i in range(K):
		H[i] = 0
	print(sum(H))
if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	N,K = map(int,input().split())
	H = [int(h) for h in input().split()]
	H = sorted(H,reverse=True)
	for i in range(min(K,N)):
		H[i] = 0
	print(sum(H))
if __name__ == '__main__':
	main()
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[]
# l=[a,b,c,d,e]
l.append(a)
l.append(b)
l.append(c)
l.append(d)
l.append(e)

size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit(-1)

print("Yay!")


### FIXED CODE ###

# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[]
# l=[a,b,c,d,e]
l.append(a)
l.append(b)
l.append(c)
l.append(d)
l.append(e)

size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit()

print("Yay!")
result = []

for i in range(1, N+1):
    for j in range(i, N+1):
        result.append(min(abs(j-i), abs(X-i) + 1 + abs(j-Y), abs(Y-i)+1+abs(j-X)))

for i in range(1, N):
    print(result.count(i))

### FIXED CODE ###

import itertools

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

# dp = [[float('inf')] * (N+1) for _ in range(N+1)]
# # dp[Y][X] = 1
# dp[X][Y] = 1

# for i in range(1,N+1):
#     for j in range(i,N+1):
#         if i == j:
#             dp[i][j] = 0
#         elif i == X and j == Y:
#             dp[X][Y] = 1
#         elif i <= X:
#             dp[i][j] = min(dp[i][j-1] + 1, dp[i][X] + abs(Y - j) + 1)
#         else:
#             dp[i][j] = min(dp[i][j-1]+ 1, abs(i - X)+ abs(Y - j) + 1 )

# dp = list(itertools.chain.from_iterable(dp))
# for i in range(1,N):
#     print(dp.count(i))

result = [0] * N

for i in range(1, N):
    for j in range(i+1, N+1):
        dist = min(abs(j-i), abs(X-i) + 1 + abs(j-Y), abs(Y-i)+1+abs(j-X))
        result[dist] += 1

for i in range(1, N):
    print(result[i])
a, b. c = map(int, input().split())
i = a
j = 0
while(a <= i and i <= b) :
  if(c % i == 0) :
    j += 0
  else :
    pass
print(j)



### FIXED CODE ###

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

for i in range(a, b + 1) :
    if c % i == 0 :
        s += 1
        
print(s)
import math

X, Y = map(int, input().split())
k = math.floor(math.log(Y/X, 2) + 1)
print(k)


### FIXED CODE ###

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

if A + B > C + D:
    print("Left")
elif A + B < C + D:
    print("Right")
else:
    print("Balanced")
import numpy as np
K = input().split()
N = int(K[0])
M = int(K[1])

hairetu = np.ones((N+2, M+2))

for i in range(M+2):
    hairetu[0][i] = 0
    hairetu[N+1][i] = 0
for i in range(N+2):
    hairetu[i][0] = 0
    hairetu[i][M+1] = 0

for i in range(1, N+1):
    for j in range(1, M+1):
        for k in range(-1, 2):
            for l in range(-1, 2):
                hairetu[i+k][j+l] = (-1) * hairetu[i+k][j+l]


count = 0

for i in range(1, N+1):
    for j in range(1, M+1):
        if hairetu[i][j] == -1:
            count += 1


print(count)

### FIXED CODE ###

K = input().split()
N = int(K[0])
M = int(K[1])

if N >= 2 and M >= 2:
    print((N-2)*(M-2))
elif N == 1 and M >= 2:
    print(M-2)
elif N >= 2 and M == 1:
    print(N-2)
elif N == 1 and M == 1:
    print(1)
a, b, c, k = map(int, input().split())
if a-k >= 0 or a+b-k>=0: print(a)
else :print((k-a-b)*(-1)+a)a, b, c, k = map(int, input().split())
SUM = 0
if k <= a:
    print(k)
else :
    SUM+=a
    k-=a
    k-=b
    if k <= 0:
        print(SUM)
    else :
        SUM-=k
        print(SUM)

### FIXED CODE ###

a, b, c, k = map(int, input().split())
SUM = 0
if k <= a:
    print(k)
else :
    SUM+=a
    k-=a
    k-=b
    if k <= 0:
        print(SUM)
    else :
        SUM-=k
        print(SUM)
H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
     
    max_step = 0
    for i in range(H * W):
        sy, sx = i // W, i % W
        if S[sy][sx] == "#":
            continue
     
        steps = [[-1] * W for _ in range(H)]
        steps[sy][sx] = 0
        queue = [(sy, sx)]
        while len(queue) >= 1:
            cy, cx = queue.pop(0)
            for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
                ny, nx = cy + dy, cx + dx
                if not (0 <= ny <= H - 1 and 0 <= nx <= W - 1):
                    continue
                if S[ny][nx] == "#" or steps[ny][nx] >= 0:
                    continue
                queue.append((ny, nx))
                steps[ny][nx] = steps[cy][cx] + 1
     
        ms = max(max(r) for r in steps)
        max_step = max(ms, max_step)
     
    print(max_step)

### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

max_step = 0
for i in range(H * W):
    sy, sx = i // W, i % W
    if S[sy][sx] == "#":
        continue

    steps = [[-1] * W for _ in range(H)]
    steps[sy][sx] = 0
    queue = [(sy, sx)]
    while len(queue) >= 1:
        cy, cx = queue.pop(0)
        for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ny, nx = cy + dy, cx + dx
            if not (0 <= ny <= H - 1 and 0 <= nx <= W - 1):
                continue
            if S[ny][nx] == "#" or steps[ny][nx] >= 0:
                continue
            queue.append((ny, nx))
            steps[ny][nx] = steps[cy][cx] + 1

    ms = max(max(r) for r in steps)
    max_step = max(ms, max_step)

print(max_step)
#!python
# -*- coding: utf-8 -*-

import sys

import numpy as np

sys.setswitchinterval(10**8)


next_s = ((-1, 1), (0, 1), (1, 1),
          (-1, 0), (1, 0),
          (-1, -1), (0, -1), (1, -1))


def DFS(x, y):
    if not (0 <= x < W and 0 <= y < H):
        return
    if not map_[y, x]:
        return

    map_[y, x] = 0

    for dx, dy in next_s:
        DFS(x + dx, y + dy)


while True:
    W, H = map(int, input().split())
    if W == 0 and H == 0:
        break

    map_ = np.array([list(map(int, input().split())) for h in range(H)])
    # print(map_)
    island_num = 0
    while np.amax(map_):
        x = np.argmax(map_) % W
        y = np.argmax(map_) // W
        # print(map_)
        # print("x: {} | y: {}".format(x, y))
        DFS(x, y)
        island_num += 1

    print(island_num)



### FIXED CODE ###

#!python
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10**6)


next_s = ((-1, 1), (0, 1), (1, 1),
          (-1, 0), (1, 0),
          (-1, -1), (0, -1), (1, -1))


def DFS(x, y):
    if not (0 <= x < W and 0 <= y < H):
        return
    if map_[y][x] == 0:
        return

    map_[y][x] = 0

    for dx, dy in next_s:
        DFS(x + dx, y + dy)


while True:
    W, H = map(int, input().split())
    if W == 0 and H == 0:
        break
    map_ = [list(map(int, input().split())) for h in range(H)]
    island_num = 0
    for x in range(W):
        for y in range(H):
            if map_[y][x] == 1:
                DFS(x, y)
                island_num += 1
    print(island_num)
x,n = input().split()
x = int(x)
if int(n) != 0:
  p = list(map(int, input().split()))
else:
  p = []

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
if x in all_list:
  ans = x
else:
  abs_ = 100
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)

### FIXED CODE ###

x,n = input().split()
x = int(x)
if int(n) != 0:
  p = list(map(int, input().split()))
else:
  p = []

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
all_list.insert(0,0)
all_list.insert(0,-1)
all_list.append(101)

if x in all_list:
  ans = x
else:
  abs_ = 1000
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)
a,b,c = map(int,input().split())
cnt = 0

if a == b and a== c and a%2 == 0:
    print(-1)
    exit()

while acnt%2 == 0 and bcnt%2 == 0 and ccnt%2 == 0:
    cnt+=1
    i=a
    j=b
    a=(b+c)//2
    b=(i+c)//2
    c=(i+j)//2

print(cnt)

### FIXED CODE ###

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

if a == b and a== c and a%2 == 0:
    print(-1)
    exit()

while a%2 == 0 and b%2 == 0 and c%2 == 0:
    cnt+=1
    i=a
    j=b
    a=(b+c)//2
    b=(i+c)//2
    c=(i+j)//2

print(cnt)
N,T = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x: x[1])
#print(AB)

W = T + 1
def dp(AB,W):
    N = len(AB)
    DP = [[0]*W for i in range(N+1)]
    for i in range(N):
        for w in range(W):
            if w != W:
                if AB[i][0] <= w:
                    DP[i+1][w] = max(DP[i][w-AB[i][0]]+AB[i][1],DP[i][w])
                else
                    DP[i+1][W] = DP[i][w]
            else:
                DP[i+1][w] = max(DP[i][w-1]+AB[i][1],DP[i][w])
    return DP

DP1 = dp(AB,W)

ans = DP1[N][W]
print(ans)

### FIXED CODE ###

N,T = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x: x[0])
#print(AB)

W = T + 1
def dp(AB,W):
    N = len(AB)
    DP = [[0]*W for i in range(N+1)]
    for i in range(N):
        for w in range(W):
            if w != W-1:
                if AB[i][0] <= w:
                    DP[i+1][w] = max(DP[i][w-AB[i][0]]+AB[i][1],DP[i][w])
                else:
                    DP[i+1][w] = DP[i][w]
            else:
                DP[i+1][w] = max(DP[i][w-1]+AB[i][1],DP[i][w])
    return DP

DP1 = dp(AB,W)

ans = DP1[N][T]
print(ans)
import collections

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

ans = 0
gu = v[::2]
ki = v[1::2]

gudic = collections.Counter(gu)
kidic = collections.Counter(ki)

gumax = gudic.most_common()
kimax = kidic.most_common()



if gumax[0][0] != kimax[0][0]:
    print((n // 2 - gumax[0][1]) + (n // 2 - kimax[0][1]))
else:
    if len(gumax) == len(kimax) == 1:
        print(n // 2)
    elif len(gumax) == 1 and len(kimax) >= 2:
        print((n // 2 -gumax[0][1]) + (n // 2 - kimax[1][1]))
    
    elif len(gumax) >= 2 and len(kimax) == 1:
        print((n // 2 -gumax[1][1]) + (n // 2 - kimax[0][1]))
    else: 
        one = (n // 2 - gumax[0][1]) + (n // 2 - kimax[1][1])
        ano = (n // 2 - gumax[1][1]) + (n // 2 - kimax[0][[1]])
        print(max(one, ano))

### FIXED CODE ###

import collections
N = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(N//2)
else:
    v_gu = v[::2]
    v_ki = v[1::2]
    gu_con = collections.Counter(v_gu)
    ki_con = collections.Counter(v_ki)
    gugu = gu_con.most_common()
    kiki = ki_con.most_common()
    
    if gugu[0][0] != kiki[0][0]:
        print(N-gugu[0][1]-kiki[0][1])
    
    elif len(gugu) == 1 and len(kiki) >=2:
        print(N-gugu[0][1]-kiki[1][1])
        
    elif len(gugu) >= 2 and len(kiki) == 1:
        print(N-gugu[1][1]-kiki[0][1])
    else:
        print(min(N-gugu[0][1]-kiki[1][1],N-gugu[1][1]-kiki[0][1]))
import math
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
def gcd(number):
    return reduce(math.gcd,number)
print(gcd(A))

### FIXED CODE ###

from sys import stdin
from functools import reduce
import fractions
#input = stdin.readline
N = int(input())
A = list(set(map(int,input().split())))
answer = reduce(fractions.gcd, A)
print(answer)
x = int(input())
for i in range(100000):
	if x * i % 360 == 0:
	  print(i)
	    exit()


### FIXED CODE ###

x = int(input())
for i in range(1, 100000):
  if x * i % 360 == 0:
    print(i)
    exit()
x = int(input())
if X==7 or X==5 or X==3:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

X = int(input())
if X==7 or X==5 or X==3:
    print("YES")
else:
    print("NO")
n = int(raw_input())
q= 0 
for _ in range(n):
  	u,v = raw_input().split(' ')
    u = float(u)
    h = {'BTC':380000.0, 'JPY':1.0}
    q += u * h[v]
print q

### FIXED CODE ###

n = int(raw_input())
q= 0 
for _ in range(n):
	u,v = raw_input().split(' ')
	u = float(u)
	h = {'BTC':380000.0, 'JPY':1.0}
	q += u * h[v]
print q
h,w,k = map(int, input().split())
s = [input() for _ in range(h)]
now = 1
flag = False
Ans = []
for i in range(h):
    if s[i] == "." * w:
        if i > 0: 
            Ans.append(Ans[-1])
        continue
    ans = []
    if i%2==0: x = s[i]
    else: x = s[i][::-1]
    for j in range(w):
        if x[j] == "#":
            if flag: now += 1
            else: flag = True
        ans.append(now)
    if i%2!=0: ans = ans[::-1]
    for _ in range(i+1-len(Ans)): Ans.append(ans)
for x in Ans:
    print(" ".join(list(map(str, x))))

### FIXED CODE ###

h,w,k = map(int, input().split())
S = [list(input()) for _ in range(h)]
ans = []
n = 1
cnt = 0
for i in range(h):
    if "#" in S[i]:
        ans = []
        for j in range(w):
            if S[i][j] == "#":
                for _ in range(j+1-len(ans)):
                    ans.append(str(n))
                n += 1
        if len(ans) < w:
            x = ans[-1]
            for _ in range(w-len(ans)):
                ans.append(x)
    if ans:
        for _ in range(i+1-cnt):
            print(" ".join(ans))
            cnt += 1
import sys,collections as cl,bisect as bs,copy
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return k
    else:
        return False

n = onem()

on = []
wh = [[-1 for j in range(n)] for i in range(n)]
de = cl.deque()
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
cl = [1 for i in range(n)]

while de:

    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = [1 for i in range(n)]

    elif on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        if on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        elif len(on[kkk[1]]) != 0:
            de.append([on[kkk[1]][0],kkk[1]])
        elif len(on[kkk[0]]) != 0:
            de.append([on[kkk[0]][0],kkk[0]])


print(co)


### FIXED CODE ###

import collections as cl
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-1 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
ppppp = [1 for i in range(n)]
cl = ppppp[:]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = ppppp[:]

    elif ppp[kkk[0]] != 0 and on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != 0 != 0 and ppp[kkk[0]] != 0 and on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][0],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][0],kkk[0]])


print(co)
n,k=map(int,input().split())
s=input()
s='01'+s+'10'
S=[]
E=[]
ans=[]
for i in range(n+3):
  if s[i:i+2]=='01':
    S.append(i+1)
  if s[i:i+2]=='10':
    E.append(i)
if S==[] and E==[]:
  print(n)
else:
  for j in range(len(E)-k):
    ans.append(abs(S[j]-E[j+k]))
  ans[0]-=1
  ans[len(ans)-1]-=1
  print(max(ans)+1)

### FIXED CODE ###

n,k=map(int,input().split())
s=input()
s='01'+s+'10'
S=[]
E=[]
ans=[]
for i in range(n+3):
  if s[i:i+2]=='01':
    S.append(i+1)
  if s[i:i+2]=='10':
    E.append(i)
if S==[] and E==[]:
  print(n)
else:
  for j in range(len(E)-k):
    ans.append(abs(S[j]-E[j+k]))
  if ans!=[]:
    ans[0]-=1
    ans[len(ans)-1]-=1
    print(max(ans)+1)
  else:
    print(n)
n=input()
s,a="",""
sd,ad=0,0
for i in range(len(n)):
  if i%2:
    s+="1"
    a+="0"
  else:
    s+="0"
    a+="1"
for i in range(n):
  if n[i]!=a[i]:ad+=1
  if n[i]!=s[i]:sd+=1
print(min(ad,sd))

### FIXED CODE ###

n=input()
s=""
a=""
sd,ad=0,0
for i in range(len(n)):
  if i%2:
    s+="1"
    a+="0"
  else:
    s+="0"
    a+="1"
for i in range(len(n)):
  if n[i]!=a[i]:ad+=1
  if n[i]!=s[i]:sd+=1
print(min(ad,sd))
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
 
ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
   else:
    print(ss-min(m))

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
 
ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
  else:
    print(ss-min(m))
else:
  print(ss)
n = int(input())
a = [int(input()) for _ in range(n)]

dp = [0] * n
for i in range(n):
    dp[i] = max(dp[i-1] + a[i]//2,dp[i-2] + min(a[i-1], a[i]))

print(dp[-1])


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
i = 0
while i < n:
    res = 0
    for j in range(i, n):
        if a[j] == 0: break
        res += a[j]
    ans += res // 2
    i = j + 1

print(ans)