Harryxun/stf_run huggingface dataset:
zn=int(input())
p=[int(i) for i in input().split()]
count=0
for i in range(n-1):
    for j in range(i+1,n):
        #print(p[i],p[j])
        if p[i]>p[j]:
            count+=1
if count>=3:
    print("NO")
else:
    print("YES")


### FIXED CODE ###

n=int(input())
p=[int(i) for i in input().split()]
count=0
P=sorted(p)
for i in range(n):
    if p[i]!=P[i]:
        count+=1
if count==2 or count==0:
    print("YES")
else:
    print("NO")
import itertools


def resolve():
    n, m = map(int, input().split())
    S = [[0] * m for i in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        S[a - 1][b - 1] = 1
        S[b - 1][a - 1] = 1

    ans = 0
    for p in itertools.permutations(range(n)):
        if p == (0, 2, 3, 4, 5, 6, 1):
            pass
        if p[0] != 0:
            break
        tmp = 1
        for i in range(n-1):
            tmp *= S[p[i]][p[i + 1]]
        if tmp == 0:
            break
        ans += tmp

    print(ans)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

# サンプルコード計算量お試し

import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
def f(b, n):
    if n < b:
        return n
    else:
        q, r = divmod(n, b)
        return f(b, q) + r

n = int(input())
s = int(input())
if n == s:
    print(n+1)
else:
    b = 2
    while b*b <= n:
        if f(b, n) == s:
            print(b)
            break
        b += 1
    else:
        p = 1
        ans = 10**13
        while p*p <= n:
            b = (n - s) // p + 1
            if f(b, n) == s:
                ans = min(ans, b)
            p += 1
        if ans == 10**13:
            print(-1)
        else:
            print(ans)

### FIXED CODE ###

def f(b, n):
    if n < b:
        return n
    else:
        q, r = divmod(n, b)
        return f(b, q) + r

n = int(input())
s = int(input())
if n == s:
    print(n+1)
else:
    b = 2
    while b*b <= n:
        if f(b, n) == s:
            print(b)
            break
        b += 1
    else:
        p = 1
        ans = 10**13
        while p*p <= n:
            b = (n - s) // p + 1
            if p < b and s - p < b and f(b, n) == s:
                ans = min(ans, b)
            p += 1
        if ans == 10**13:
            print(-1)
        else:
            print(ans)
import numpy as np
%time N, M =map(int, input().split())
%time A = np.array(list(map(int, input().split())))
#print(A)
log_A = np.log2(A)

for i in range(M):
    maximum =  log_A.argmax()
    log_A[maximum] = log_A[maximum]-1
    #print(A)
A = np.power(2, log_A)
%time A = np.trunc(A)
print(int(A.sum()))


### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print(-sum(a))
n = int(input())
h = list(map(int,input().split(' ')))

n-=1
inf = int(1e9+5)

dp = {}
def frog1(i):
    if i==n:
        return 0
    if i in dp:
        return dp[i]
    
    a = 0
    b = 0
    if i+1>n:
        a = inf
    else:
        a = frog1(i+1)+abs(h[i]-h[i+1])

    if i+2>n:
        b = inf
    else:
        b = frog1(i+2)+abs(h[i]-h[i+2])
    dp[i] = min(a,b)
    return dp[i]
print(frog1(0))


### FIXED CODE ###

import math
n = int(input())
h = list(map(int,input().split(' ')))
'''
n-=1
inf = int(1e9+5)

dp = {}
def frog1(i):
    if i==n:
        return 0
    if i in dp:
        return dp[i]
    
    a = 0
    b = 0
    if i+1>n:
        a = inf
    else:
        a = frog1(i+1)+abs(h[i]-h[i+1])

    if i+2>n:
        b = inf
    else:
        b = frog1(i+2)+abs(h[i]-h[i+2])
    dp[i] = min(a,b)
    return dp[i]
'''
def solve(n,h):
    dp = [0]*n
    for i in reversed(range(0,n-1)):
        if i==n-1:
            dp[i] = 0
        else:
            if i==n-2:
                dp[i] = abs(h[n-1]-h[n-2])
                continue
            a = 0
            b = 0
            if i+1<=n-1:
                a = dp[i+1]+abs(h[i]-h[i+1])
            if i+2<=n-1:
                b = dp[i+2]+abs(h[i]-h[i+2])  
            dp[i] = min(a,b)
    return dp[0]
print(solve(n,h))
n=int(input())
l=[0 for i in range(2*10**5)]
r=[0 for i in range(2*10**5)]
c=1
a=0
if n!=0:
  k=[int(i) for i in input().split()]
for i in range(n):
  l[k[i]+c]+=1 
  if -k[i]+c>=0 and -k[i]+c<=2*10**5:
    r[-k[i]+c]+=1
  c+=1
for i in range(n):
  a+=l[i]*r[i]
print(a)

### FIXED CODE ###

n=int(input())
l=[0 for i in range(2*10**5+1)]
r=[0 for i in range(2*10**5+1)]
c=1
a=0
if n!=0:
  k=[int(i) for i in input().split()]
for i in range(n):
  if k[i]+c<=2*10**5:
    l[k[i]+c]+=1 
  if -k[i]+c>=0 and -k[i]+c<=2*10**5:
    r[-k[i]+c]+=1
  c+=1
for i in range(n):
  a+=l[i]*r[i]
print(a)
a, b = int(input())

if a < b:
    print("a < b")

elif a > b:
    print("a > b")

else:
    print("a == b")


### FIXED CODE ###

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

if a < b:
    print("a < b")

elif a > b:
    print("a > b")

else:
    print("a == b")
import heapq
n,m=map(int,input().split())
ab=[]
for i in range(m+2):
    ab.append([])
for i in range(n):
    a,b=map(int,input().split())
    ab[a].append(-b)
h = []
s=0
for i in range(1,m+2):
    for v in ab[i]:
        heapq.heappush(h,v)
    if len(h)!=0:
        s-=heapq.heappop(h)
print(s)

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
ab=[]
for i in range(m+1):
    ab.append([])
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        ab[a].append(b)
h = []
s=0
for i in range(1,m+1):
    for v in ab[i]:
        heapq.heappush(h,-1*v)
    if len(h)>0:
        s+=-1*heapq.heappop(h)
print(s)
n = int(input())
x = input()
ones = 0
for i in x:
    if i=='1':
        ones += 1
mods = [0, 0]
for i in range(n):
    if x[n-i-1]=='1':
        if ones-1>0:
            mods[0] += pow(2, i, ones-1)
        mods[1] += pow(2, i, ones+1)
mods[0] %= ones-1
mods[1] %= ones+1
def f(x):
    if x==0:
        return 1
    cnt = 1
    while x>0:
        p = bin(x).count('1')
        x %= p
        cnt += 1
    return cnt
for i in range(n-1, -1, -1):
    if x[n-i-1]=='1':
        init = (mods[0] - pow(2, i, ones-1))%(ones-1)
    else:
        init = (mods[1] + pow(2, i, ones+1))%(ones+1)
    if x[n-i-1]=='1' and ones==1:
        print(0)
    else:
        print(f(init))

### FIXED CODE ###

n = int(input())
x = input()
ones = 0
for i in x:
    if i=='1':
        ones += 1
mods = [0, 0]
for i in range(n):
    if x[n-i-1]=='1':
        if ones>1:
            mods[0] += pow(2, i, ones-1)
        mods[1] += pow(2, i, ones+1)
if ones>1:
    mods[0] %= ones-1
mods[1] %= ones+1
def f(x):
    if x==0:
        return 1
    cnt = 1
    while x>0:
        p = bin(x).count('1')
        x %= p
        cnt += 1
    return cnt
for i in range(n-1, -1, -1):
    if x[n-i-1]=='1' and ones==1:
        print(0)
        continue
    if x[n-i-1]=='1':
        init = (mods[0] - pow(2, i, ones-1))%(ones-1)
    else:
        init = (mods[1] + pow(2, i, ones+1))%(ones+1)
    print(f(init))
n = int(input())
k = int(input())
num = 2**n
list = [format(i,"b").zfill(n) for i in range(num)]
result = []
for i in list:
    a = 1
    for j in range(len(i)):
        if i[j] == "0":
            a *= 2
        else:
            a += k
    result.append(a)
print(min(result))

### FIXED CODE ###

n = int(input())
k = int(input())
a = 1
for i in range(n):
    if 2*a>=a+k:
        a = a+k
    else:
        a = 2*a
print(a)
if a == "22":
    print("Christmas Eve Eve Eve")
elif a == "23":
    print("Christmas Eve Eve")
elif a == "24":
    print("Christmas Eve")
elif a == "25":
    print("Christmas")

### FIXED CODE ###

D = int(input())
if D == 22:
    print("Christmas Eve Eve Eve")
elif D == 23:
    print("Christmas Eve Eve")
elif D == 24:
    print("Christmas Eve")
elif D == 25:
    print("Christmas")
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
#import numpy as np
#import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = input().split(" ")
	A = [int(s) for s in A]
	
	DP = [100000000000000000000000000000000 for _ in range(N)]
	DP[0] = 0
	
	for i, val in enumerate(A):
		if i == 0:
			continue
		tmp = 100000000000000000000000000000000
		
		for j in range(K):
			index = j+1
			if i >= index:
				tmp1 = DP[i-index] + abs(A[i-index] - val)
				tmp = min(tmp, tmp1)
			else:
				break
		DP[i] = min(DP[i], tmp)
		
	#print(DP)
	print(DP[N-1])
	
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	N, K = map(int, input().split(" "))
	H = input().split(" ")
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i in range(1, len(H)):
		paths = [DP[j] + abs(H[j] - H[i]) for j in range(max(0, i-K), i)]
		DP[i] = min(paths)
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
N = int(input())
A = input()
b = A.split(" ")
c = []
for i in range(0,N):
    c.append(abs(int(b[i])))

c.sort

print(int(c[-1])-int(c[0]))

### FIXED CODE ###

N = int(input())
if N%2 == 0:
    print(N)
else:
    print(N*2)
k,x= int(input()), int(input())

k = k * 500 

if k >= x:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

k,x = [int(x) for x in input().split()]

k = k * 500 

if k >= x:
  print("Yes")
else:
	print("No")
n, m = map(int, input().split())

tsuro = [list(map(int, input().split())) for _ in range(m)]

ikeru = [set() for _ in range(n+1)]

for i,j in tsuro:
    ikeru[i].add(j)
    ikeru[j].add(i)

ans = [n+5]*(n+1)
visited = [0]*(n+1)

def dfs(heya,kaiso):
    if visited[heya] != 0 and ans[heya] <= kaiso:
        return True
    else:
        visited[heya] = 1
        ans[heya] = kaiso
        for j in ikeru[heya]:
            dfs(j, kaiso+1)
        return True

hantei = True
if dfs(1,0):
    for i in range(1, n+1):
        if visited[i] == 0:
            hantei = False
    if hantei:
        print('Yes')
        for j in range(2,n+1):
            print(ans[j])
    else:
        print('No')


### FIXED CODE ###

from collections import deque

n, m = map(int,input().split())
graph =[[] for _ in range(n+1)]
for _ in range(m):
    a,b =map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
queue = deque([1])
visited = [False] * (n+1)
visited[0] = True
ans = [0] * (n+1)
while queue:
    node = queue.popleft()
    for xnode in graph[node]:
        if visited[xnode]:
            continue
        ans[xnode]=node
        visited[xnode]=True
        queue.append(xnode)
print("Yes")
for a in ans[2:]:
    print(a)
import sys
from collections import deque
def input():
    return list(map(int, sys.stdin.readline().strip().split()))

n, m = input()
mem = [0 for _ in range(n + 1)] # n -> 1 거리
adj = [set() for _ in range(n + 1)]
q = []

for i in range(m):
    a, b = input()
    adj[b].append(a)
    adj[a].append(b)
    if b == 1: 
        q.append(a)
        mem[a] = 1
    if a == 1: 
        q.append(b)
        mem[b] = 1

visited = []
while q:
    v = q.pop(0)
    if v not in visited:
        visited.append(v)
        for node in adj[v]:
            if node not in visited:
                mem[node] = mem[v] + 1
                q.append(n)

if 0 in mem: print('No')
else: print('Yes', *mem[2:], sep='\n')



### FIXED CODE ###

import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
q=collections.deque()
q.append(1)
check=[0]*(n+1)
check[1]=1
ans=[0]*(n+1)
while len(q)!=0:
 v=q.popleft()
 for u in g[v]:
   if check[u]==0:
     check[u]=1
     ans[u]=v
     q.append(u)
print('Yes')
for i in range(2,n+1):
 print(ans[i])
import math

a = int(input())

print(2 * a // math.gcd(2, a))

### FIXED CODE ###

a = int(input())

if a % 2 == 0:
    print(a)
else:
    print(2*a)
A = list(map(str, input().split()))
B = list(map(str, input().split()))

REA = (A[0] + A[1] + A[2])
REB = (A[2] + A[1] +A[0])

if REA == REB:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

A = input()
B = input()

REA = (A[0] + A[1] + A[2])
REB = (B[2] + B[1] +B[0])

if REA == REB:
    print("YES")
else:
    print("NO")
y,m,d=map(int,input().solit("/"))
if m<5:
  print("Heisei")
else:
  print("TBD")

### FIXED CODE ###

y,m,d=map(int,input().split("/"))
if m<5:
  print("Heisei")
else:
  print("TBD")
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=a.sort(reverse=True)
d=b.sort(reverse=True)
totl=0
for i in range(n):
  totl+=min(c[i],d[i])
print(totl)
  


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  if b[i]-a[i]>0:
    cnt+=a[i]
    cnt+=min(b[i]-a[i],a[i+1])
    a[i+1]=max(a[i+1]-b[i]+a[i],0)
  else:
    cnt+=b[i]
print(cnt)
s = input()
k = int(input())

N = len(s)
word = []
for i in range(N-k+1):
    j = i+1
    for _ in range(k):
        word.append(s[i:j])
        j += 1
word.sort()

from collections import Counter
c = Counter(word)
keys, values = zip(*c.most_common())
ans = []
for i in range(len(keys)):
    ans.append(keys[i])
ans.sort()
print(ans[k-1])


### FIXED CODE ###

s = input()
k = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
n = len(s)
lis = set()
for i in range(26):
    for j in range(len(s)):
        if s[j] == alpha[i]:
            for l in range(j, j+k+1):
                if l < n:
                    lis.add(s[j:l+1])
lis = list(lis)
lis.sort()
#print(lis)
#print(k)
print(lis[k-1])
a = int(input())
if a == 22:
  print('Christmas Eve Eve Eve')
elif a == 23:
  print('Christmas Eve Eve')
elif a == 24:
  print('Christmas Eve')
else a == 25:
  print('Christmas')


### FIXED CODE ###

a = int(input())
if a == 22:
  print('Christmas Eve Eve Eve')
elif a == 23:
  print('Christmas Eve Eve')
elif a == 24:
  print('Christmas Eve')
elif a == 25:
  print('Christmas')
from math import factorial
def P(n, r):
     mod = 10**9+7
     return (factorial(n)//factorial(n-r))%mod

def ncr(n, r):
     mod = 10**9+7
     return (P(n, r)//factorial(r))%mod

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    tmp = ncr(k-1,i-1)*ncr(blueplace,i)%mod
    print(tmp%mod)
solve()

### FIXED CODE ###

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  fact = [1]*(n+5)
  inv = [1]*(n+5)
  finv = [1]*(n+5)
  fact[0] = fact[1] = 1
  finv[0] = finv[1] = 1
  inv[1]  = 1
  for i in range(2,n+4):
   fact[i] = (fact[i-1]*i)%mod
   inv[i] = mod-inv[mod%i]*(mod//i)%mod
   finv[i]= finv[i-1]*inv[i]%mod

  
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    if (n-k+1)>= i:
     tmp = fact[n-k+1]*(finv[i]*finv[n-k+1-i]%mod)%mod
     tmp *= fact[k-1]*(finv[i-1]*finv[k-i]%mod)%mod
     print(tmp%mod)
    else:
      print(0)
solve()
N = int(input())
S = input().split()
count = 1
for i in range(N-1):
    j = i+1
    if S[i] != S[j]:
        count += 1
print(count)

### FIXED CODE ###

N = int(input())
S = input()

checklist = []

for i in range(N-1):
    j = i+1
    if S[i] != S[j]:
        checklist.append(S[i])
print(len(checklist)+1)
N, C = map(int, input().split())
dic = []
L = 0
for i in range(N):
  s, t, c = map(int, input().split())
  dic += [(c-1,s,t)]
  if t+1>L:
    L = t+1

sm = [0]*L
for c in range(C):
  tt = [0]*(L)
  for i in range(N):
    if dic[i][0]==c:
      tt[dic[i][1]*2-1] += 1
      tt[dic[i][2]*2] -= 1
  for i in range(1,L):
    tt[i] += tt[i-1]
  for i in range(L):
    if tt[i]>0:
      sm[i] += 1
print(max(sm))

### FIXED CODE ###

N, C = map(int, input().split())
dic = []
for i in range(N):
  s, t, c = map(int, input().split())
  dic += [(c-1,s,t)]

L = 2*100000+1
sm = [0]*L
for c in range(C):
  tt = [0]*(L)
  for i in range(N):
    if dic[i][0]==c:
      tt[dic[i][1]*2-1] += 1
      tt[dic[i][2]*2] -= 1
  for i in range(1,L):
    tt[i] += tt[i-1]
  for i in range(L):
    if tt[i]>0:
      sm[i] += 1
print(max(sm))
from functions import gcd
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = functions.gcd(ans,new[j])
print(ans)

### FIXED CODE ###

from fractions import gcd
n,x = map(int,input().split())
ls = list(map(int,input().split()))
new = [0]*n
for i in range(n):
    new[i] = abs(ls[i]-x)
ans = new[0]
for j in range(1,n):
    ans = gcd(ans,new[j])
print(ans)
h,n = map(int,input().split())

x = []
y = []

for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)

def knapsack(N,W,weight,value):
  inf=float("inf")
  dp=[[inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=inf

  for i in range(N):
    for w in range(W+1):
        m = dp[i][w]
        p = value[i]
        q = weight[i]
        while w >= q:
            if w - q >= 0:
                m=min(dp[i][w-q]+p,m)
            p += value[i]
            q += weight[i]
        m=min(dp[i][w-q]+p,m,p)
        dp[i+1][w] = m
  return dp[N][W]

k = knapsack(n,h,x,y)
print(k)

### FIXED CODE ###

h = int(input())

count = 1
ans = 0

while h != 0:
    ans += count
    h = h//2
    count *=2

print(ans)
A, B = map(int, input())

_sum = A + B
_sub = A - B
_mul = A * B

_list = [_sum,_sub,_mul]

print(max(_list))


### FIXED CODE ###

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

_sum = A + B
_sub = A - B
_mul = A * B

_list = [_sum,_sub,_mul]

print(max(_list))
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
vis={}
def count(n):
    if n in vis:
        return vis[n]
    if n<2:
        return 0
    if n==2:
        vis[n]=abs(arr[n-1]-arr[n-2])+count(n-1)
    if n>=3:
        vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
from collections import defaultdict
MOD = 10**9+7
N, K = map(int, input().split())
es = defaultdict(list)

for i in range(N-1):
  a, b = map(int, input().split())
  es[a-1] += [b-1]
  es[b-1] += [a-1]
  
def dfs(now, par):
  if par==-1:
    can_use = K-1
  else:
    can_use = K-2
  if K<len(es[now]):
    return 0
  else:
    case_num = 1
    for e in es[now]:
      if e==par:
        continue
      case_num *= can_use
      can_use -= 1
      case_num %= MOD
    for e in es[now]:
      if e==par:
        continue
      case_num *= dfs(e, now)
      case_num %= MOD
    return case_num

ans = K*dfs(0,-1)
ans %= MOD
print(ans)


### FIXED CODE ###

from collections import defaultdict, deque
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
dic = defaultdict(list)
for i in range(N-1):
  a, b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]

log = [float('inf')]*N
log[0] = 0
q = deque([0])
ans = K
while q:
  p = q.popleft()
  if log[p]<1:
    ans *= cmb(K-1,K-1-len(dic[p]),mod)
  else:
    ans *= cmb(K-2,K-1-len(dic[p]),mod)
  ans %= mod
  for e in dic[p]:
    if log[e]>log[p]+1:
      q += [e]
      log[e] = log[p]+1
print(ans)
def sum_triangle(x):
    if x > 0:
        return x + sum_triangle(x - 1)
    else:
        return 0
    

s = input().replace("><", "> <")
new_s = s.split(" ")

a = [0] * len(new_s)

for i in range(len(new_s)):
    if new_s[i].count("<") >= new_s[i].count(">"):
        a[i] = sum_triangle(new_s[i].count("<"))
        a[i] += sum_triangle(new_s[i].count(">") - 1)
    else:
        a[i] = sum_triangle(new_s[i].count(">"))
        a[i] += sum_triangle(new_s[i].count("<") - 1)

print(sum(a))

### FIXED CODE ###

def gauss(n):
    ans = int (n * (n + 1) / 2)
    return(ans) 

s = input().replace("><", "> <")
new_s = s.split(" ")

a = [0] * len(new_s)

for i in range(len(new_s)):
    if new_s[i].count("<") >= new_s[i].count(">"):
        a[i] = gauss(new_s[i].count("<"))
        a[i] += gauss(new_s[i].count(">") - 1)
    else:
        a[i] = gauss(new_s[i].count(">"))
        a[i] += gauss(new_s[i].count("<") - 1)

print(sum(a))
from collections import deque
h,w=map(int,input().split())
S=[input() for _ range(h)]
inf=float("inf")
ans=0
for i in range(h):
   for j in range(w):
      if S[i][j]=="#":
         continue
      else:
         DP=[[inf for _ in range(w)]for _ in range(h)]
         D[i][j]=0
         que=deque([(i,j)])
         while que:
            si,sj=que.popleft()
            for ni,nj in [(si+1,sj)(si-1,sj)(si,sj+1)(si,sj-1)]:
               if 0<=ni<h and 0<=nj<w and S[ni][nj]!="#":
                  if D[ni][nj]>D[si][sj]+1:
                     D[ni][nj]=D[si][sj]+1
                     que.append((ni,nj))
                     ans=max(ans,D[si][sj]+1)
print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
from collections import deque
 
H,W = map(int,readline().split())
H += 2; W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + readline().rstrip().decode() + '#'
grid += '#' * W
 
def bfs(start):
    INF = 10 ** 9
    dist = [INF] * (H*W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1,1,W,-W):
            w = v + move
            if grid[w] == '#':
                continue
            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)
    return max(x for x in dist if x < INF)
 
answer = max(bfs(v) for v in range(H*W) if grid[v] != '#')
print(answer)