Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h, w  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print(f'{"#" * (w + 2)}')
for _ in range(h):
    print(f'#{input()}#')
print(f'{"#" * (w + 2)}')


### FIXED CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h, w  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()
 
print('{}'.format('#' * (w + 2)))
for _ in range(h):
    print('#{}#'.format(input()))
print('{}'.format('#' * (w + 2)))
x = int(input()) % 10
if x == 6, 1, 8:
	print('pon')
if x == 3:
	print('bon')
else:
	print('hon')

### FIXED CODE ###

x = int(input()) % 10
if x == 6 or x == 1 or x== 8 or x == 0:
	print('pon')
elif x == 3:
	print('bon')
else:
	print('hon')
N = int(input().strip())

X = {}
Y = {}
G = (X, Y)

for _ in range(N):
  x, y = map(int, input().strip().split())
  if x not in X: X[x] = []
  if y not in Y: Y[y] = []
  X[x].append(y)
  Y[y].append(x)


def dfs_visit(visited, u, i):
  if u in visited[i]: return
  visited[i].add(u)
  for v in G[i][u]:
    dfs_visit(visited, v, (i + 1) % 2)


count = 0
while len(X) > 0:
  visited = (set(), set())
  x = X.__iter__().__next__()
  dfs_visit(visited, x, 0)

  for x in visited[0]:
    count += len(visited[1]) - len(X.pop(x))
  for y in visited[1]:
    del Y[y]

print(count)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N = int(input().strip())

X = {}
Y = {}
G = (X, Y)

for _ in range(N):
  x, y = map(int, input().strip().split())
  if x not in X: X[x] = []
  if y not in Y: Y[y] = []
  X[x].append(y)
  Y[y].append(x)


def dfs_visit(visited, u, i):
  if u in visited[i]: return
  visited[i].add(u)
  for v in G[i][u]:
    dfs_visit(visited, v, (i + 1) % 2)


count = 0
i = 0
while len(X) > 0:
  visited = (set(), set())
  x = X.__iter__().__next__()
  dfs_visit(visited, x, 0)

  for x in visited[0]:
    count += len(visited[1]) - len(X.pop(x))

print(count)
import math
N=int(input())
number=list(map(int,input().split()))
SUM=[]
sum=0
p=10**9 +7
#Nの階乗
x=math.factorial(N)%p
#0からにすると1/0でエラーになる
for i in range(1,N+1):
  #kは逆元
  k=pow(i,p-2,p)
  sum+= (x*k)%p
  sum= sum%p
  SUM.append(sum)
#SUMのi番目は1/1から1/iまで足した和になっている。
#k=i-1となる
#1/1を二回足してしまったので引く
for i in range(N):
  ans+= (number[i]*(SUM[i]+SUM[N-i-1]-x))%p
  ans= ans%p
#答え
print(ans)

### FIXED CODE ###

import math
n=int(input())
number=list(map(int,input().split()))
SUM=[]
sum=0
p=10**9 +7
x=math.factorial(n)%(10**9 +7)
for i in range(1,n+1):
  k=pow(i,p-2,p)
  sum+= (x*k)%p
  sum= sum%(p)
  SUM.append(sum)
ans=0
for i in range(n):
  ans+= number[i]*(SUM[n-1-i]+SUM[i]-x)
  ans=ans%(p)
print(ans)
N,K,*A=map(int,open(0))
print(sum([min(a,K-a)*2 for a in A]))

### FIXED CODE ###

N = int(input())
K = int(input())
*A, = map(int, input().split())
print(sum([min(a,K-a)*2 for a in A]))
n=map(int, raw_input().split())
print n[0]*n[1] " " n[0]*2+n[1]*2

### FIXED CODE ###

l = map(int, raw_input().split())
print l[0]*l[1], l[0]*2+l[1]*2
A,B=map(int,input().split())
S1,S2=input().split("-")
if len(S1)==A and len(S2)==B:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A,B=map(int,input().split())
S=input()
if S.count("-")==1 and S.index("-")==A:
    print("Yes")
else:
    print("No")
x = int(input())
a = int(x/500)
b = x - 500*a
c = int(b/5)

print(1000*a + 5*c)



### FIXED CODE ###

x = list(input())
if (x[2] ==x[3]) and (x[4]==x[5]):
  print("Yes")
else: print("No")
a, b = list(map(int, input().split()))
lis = list(range(a, b+1))
lis2 = list(map(lambda x: x%2019, lis))
lis2.sort()
#print(lis2)
min1 = lis2.pop(0)
min2 = lis2.pop(0)
#print(min1)
#print(min2)
print((min1*min2)%2019)

### FIXED CODE ###

a, b = list(map(int, input().split()))
if b-a >= 2019:
  print(0)
  quit()

lis = list(range(a, b+1))
  
ans = 2019

for i in range(b-a+1):
  for j in range(i+1, b-a+1):
    #print("i: " + str(lis[i]) + "  j: "+ str(lis[j]))
    temp = ((lis[i]%2019)*(lis[j]%2019))%2019
    #print(temp)
    if temp < ans:
      ans = temp
print(ans)
N, A = map(int, input().split())

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

tmp_max = max(x)
tmp_max = max(tmp_max, A)

dp = [[[0 for _ in range(tmp_max * N + 1)] for _ in range(N + 1)] for _ i range(N + 1)]
dp[0][0][0] = 0

for j in range(N + 1):
  for k in range(j + 1):
    for s in range(tmp_max * K + 1):
      if j >= 1 and s < x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
        
        
ans = 0
for k in range(1, N + 1):
  ans += dp[N][k][k * A]
  
print(ans)

### FIXED CODE ###

N, A = map(int, input().split())
x = list(map(int, input().split()))

max_num = max(x)
max_num = max(A, max_num)
# x_jまでからk枚選んで合計がｓになる選び方の総数。ｓはk*Aにすれば平均がAになる
dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
#何も選ばないで平均が０
dp[0][0][0] = 1

for j in range(N+1):
  for k in range(j+1):
    for s in range(max_num * k + 1):
      if j >= 1 and s < x[j - 1]:
        # j番目を選んでk+1個を選んだ際に平均がAにならない場合
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        # j番目をえらんでk+1個選んで平均がAになるものがあるなら、j-1番までの合計はs-x_j-1なので、その数を足している
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
 

ans = 0
# 合計がkAになるものを加算
for k in range(1, N + 1):
  ans += dp[N][k][k*A]
print(ans)
input = int(row_input())
hour = input / 3600
minute = hour / 60
second = minute / 60
print("%1:%2:%3") % (hour,minute,second)

### FIXED CODE ###

input = int(input())
if 0 <= input < 86400:
    hour = input / 3600
    minute = (input / 60) % 60
    second = input % 60
    print("%d:%d:%d" % (hour,minute,second))
A, B, C D = map(int, input())
ans = 0
for i in range(A, B):
  if i % C == 0 and i % D == 0:
    ans = ans + 1
print(ans)

### FIXED CODE ###

def bbb(x, y):
    return (x * y) // aaa(x, y)
 
 
def aaa(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return aaa(y, x % y)
 
 
a, b, c, d = map(int, input().split())
bc = b // c
bd = b // d
ac = (a-1) // c
ad = (a-1) // d
aw = (a-1) // bbb(c, d)
bw = b // bbb(c, d)
print((b - a + 1) - (bc - ac) - (bd - ad) + (bw - aw))
N, M = map(int, input().split())
if N == 1:
    print(1)
    exit()

a = [int(input()) for i in range(M+100)]
ans = [0] * (N+1)
ans[0] = 1
if a[0] != 1:   ans[1] = 1
else:   pass
for i in range(2, N+1):
    if i in a:
        ans[i] = 0
    else:
        ans[i] = (ans[i-1] + ans[i-2]) % (10**9+7)
print(ans[N])

### FIXED CODE ###

import bisect
N, M = map(int, input().split())
if N == 1:
    print(1)
    exit()

a = [int(input()) for i in range(M)]
broken = [0]*(N+1)
for i in range(M):
    broken[a[i]] = 1
if M == 0:  a.append(0)
ans = [0] * (N+1)
ans[0] = 1
if a[0] != 1:   ans[1] = 1
else:   pass
for i in range(2, N+1):
    if broken[i] == 1:
        ans[i] = 0
    else:
        ans[i] = (ans[i-1] + ans[i-2]) % (10**9+7)
print(ans[N])
N = int(input())
a = list(map(int, input().split()))

a.sort()
xy = [[] for i in range(N-1)]
cnt = 0
while len(a) > 2:
    if a[len(a)-1] > 0 and a[len(a)-2] > 0:
        n = a[0] - a[len(a)-1]
        xy[cnt] = [a[0], a[len(a)-1]]
        a = [n].extend(a[1:len(a) - 1])
    else:
        n = a[len(a)-1] - a[0]
        xy[cnt] = [a[len(a)-1], a[0]]
        a = a[1:len(a) - 1].extend([n])
    cnt += 1

m = a[1] - a[0]
xy[cnt] = [a[1], a[0]]
print(m)
for _xy in xy:
    print(str(_xy[0]) + " " + str(_xy[1]))

### FIXED CODE ###

from collections import deque

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

a.sort()

if a[0] >= 0:
    m = sum(a[1:]) - a[0]
    print(m)
    p = a.pop(0)
    while len(a) > 1:
        b = a.pop(0)
        print(*[p, b])
        p -= b
    b = a.pop()
    print(*[b, p])
elif a[-1] <= 0:
    m = -sum(a[:-1])+a[-1]
    print(m)
    p = a.pop(-1)
    while len(a) > 0:
        b = a.pop(0)
        print(*[p, b])
        p -= b
else:
    mi = list(filter(lambda x: x < 0, a))
    pl = list(filter(lambda x: x >= 0, a))
    m = -sum(mi) + sum(pl)
    print(m)
    lp = pl.pop(0)
    mi = deque(mi)
    while len(pl) > 0:
        b = pl.pop()
        c = mi.pop()
        print(*[c, b])
        c -= b
        mi.append(c)
    while len(mi) > 0:
        b = mi.pop()
        print(*[lp, b])
        lp -= b
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [0]*M
y = [0]*M
z = [0]*M
for i in range(M):
  x[i],y[i],z[i] = map(int,input().split())
zsort = sorted(z)
mi = zsort[-1]
ind = z.index(mi)
am = min(a)
bm = min(b)
mae = am + bm
indxy = a[ind-1] + b[ind-1] - mi


if mae < indxy:
  print(mae)
else:
  print(indxy)

### FIXED CODE ###

A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [0]*M
y = [0]*M
c = [0]*M
for i in range(M):
  x[i],y[i],c[i] = map(int,input().split())
ans = 10**10
ma = max(c)
#ind = c.index(ma)
am = min(a)
bm = min(b)
mae = am + bm #ここまで
#indxy = a[x[ind]-1] + b[y[ind]-1] - ma

for i in range(M):
  mai = a[x[i]-1] + b[y[i] -1] - c[i]
  if mai < ans:
    ans = mai
if mae < ans:
  print(mae)
else:
  print(ans)
x = int(raw_input())
print 2*(x//11) + (2 if x%11>6 else 1)

### FIXED CODE ###

s = raw_input()
print s.rfind("Z")-s.find("A")+1
W, H, N = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(N)]

X = [0, W]
Y = [0, H]

for l in lst:
    if l[2] == 1 and X[0] < l[0]:
        X[0] = l[0]
    elif l[2] == 2 and l[0] < X[1]:
        X[1] = l[0]
    elif l[2] == 3 and Y[0] < l[1]:
        Y[0] = l[1]
    elif lst[2] == 4 and l[1] < Y[1]:
        Y[1] = l[1]

width = X[1] - X[0]
height = Y[1] - Y[0]

if width >= 0 and height >= 0:
    print(width * height)
else:
    print(0)

### FIXED CODE ###

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

W_ = [0, W] 
H_ = [0, H]

for l in lst:
    if l[2] == 1 and W_[0] < l[0]:
        W_[0] = l[0]
    elif l[2] == 2 and l[0] < W_[1]:
        W_[1] = l[0]
    elif l[2] == 3 and H_[0] < l[1]:
        H_[0] = l[1]
    elif l[2] == 4 and l[1] < H_[1]:
        H_[1] = l[1]
        
width = W_[1] - W_[0] if W_[1] - W_[0] > 0 else 0
height = H_[1] - H_[0] if H_[1] - H_[0] > 0 else 0

print(width * height)
input()
x=map(int,input().split())
print(x[-1]-x[0])


### FIXED CODE ###

input()
x=sorted(map(int,input().split()))
print(x[-1]-x[0])
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
# for i in range(n + 1):
#     if str(i) in a:
#         total *= total_act
#         total_act = 0
#         total_act2 = 1
#     else:
#         total_act3 = total_act2 + total_act
#         total_act2 = total_act
#         total_act = total_act3
# total *= total_act
# print(total % 1000000007)
b.append(int(a[0]))
for i in range(len(a) - 1):
    b.append(int(a[i + 1]) - int(a[i]) - 1)
b.append(n - int(a[-1]))

for i in range(max(b)):
    total_act3 = total_act2 + total_act
    total_act2 = total_act
    total_act = total_act3
    c.append(total_act)

for i in b:
    total *= c[i - 1]
    if i - 1 == -1:
        total = 0

print(total % 1000000007)


### FIXED CODE ###

n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
if m == 0:
    for i in range(n + 1):
        if str(i) in a:
            total *= total_act
            total_act = 0
            total_act2 = 1
        else:
            total_act3 = total_act2 + total_act
            total_act2 = total_act
            total_act = total_act3
    total *= total_act
    print(total % 1000000007)
else:
    b.append(int(a[0]))
    for i in range(len(a) - 1):
        b.append(int(a[i + 1]) - int(a[i]) - 1)
        if int(a[i + 1]) - int(a[i]) - 1 == 0:
            print(0)
            exit()
    b.append(n - int(a[-1]))

    for i in range(max(b)):
        total_act3 = total_act2 + total_act
        total_act2 = total_act
        total_act = total_act3
        c.append(total_act)

    for i in b:
        total *= c[i - 1]
    print(total % 1000000007)
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
import itertools
J=(list(itertools.permutations(range(n))))

for i, j in enumerate(J):
    if j == p:
        a=i
    if j==q:
        b=i
print(abs(a-b))

### FIXED CODE ###

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
import itertools
J=(list(itertools.permutations(range(1,n+1))))
#print(J)
for i, j in enumerate(J):
    #print(j,p,q)
    if j == p:
        a=i
    if j==q:
        b=i
print(abs(a-b))
import sys
n = int (input())
words = []
for i in range (n) :
    words.append(input())
for x in range(len(words)):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        print("No")
        sys.exit()
    else:
        "Yes"

### FIXED CODE ###

import sys
n = int (input())
words = []
No=" "
for i in range (n) :
    words.append(input())
for x in range(len(words)-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        No="No"
        print (No)
        sys.exit() 
if No != "No":
     print ("Yes")
s=input()
t=input()

dp=[[-1]*(3001) for x in range(3001)]
arr = ""
def func(i,j):
    if i>=len(s) or j>=len(t):
        return 0
    if dp[i][j]!=-1:
        return dp[i][j]
    if s[i]==t[j]:
        dp[i][j] = func(i+1,j+1)+1
        return dp[i][j]
    if s[i]!=t[j]:
        dp[i][j] = max(func(i+1,j),func(i,j+1))
        return dp[i][j]
l=func(0,0)
i,j=0,0
while len(arr)<l:
    if s[i] == t[j]:
        arr=arr+s[i]
        i+=1
        j+=1
    else:
        if dp[i+1][j]>dp[i][j+1]:
            i+=1
        else:
            j+=1

print(arr)

### FIXED CODE ###

s=input()
t=input()

dp=[[-1]*(len(t)+1) for x in range(len(s)+1)]
arr = ""
for i in range(len(s),-1,-1):
    for j in range(len(t),-1,-1):
        if i>=(len(s)) or j>=(len(t)):
            dp[i][j] = 0
        else:
            if s[i] == t[j]:
                dp[i][j] = dp[i+1][j+1] + 1
            else:
                dp[i][j] = max(dp[i+1][j],dp[i][j+1])

l=dp[0][0]
i,j=0,0
while len(arr)!=l:
    if s[i] == t[j]:
        arr=arr+s[i]
        i+=1
        j+=1
    else:
        if dp[i+1][j]>=dp[i][j+1]:
            i+=1
        else:
            j+=1

print(arr)



# def func(i,j):
    # if i>=(len(s)) or j>=(len(t)):
    #     return 0
    # if dp[i][j]!=-1:
    #     return dp[i][j]
    # if s[i]==t[j]:
    #     dp[i][j] = func(i+1,j+1)+1
    #     return dp[i][j]
    # if s[i]!=t[j]:
    #     dp[i][j] = max(func(i+1,j),func(i,j+1))
    #     return dp[i][j]
# l=func(0,0)
S = input()
T = input()
print(T+S)
#
#
#################################

### FIXED CODE ###

str1 , str2 = input().split(" ")
str3 = str2+str1
print(str3)
s = input()
s[3] = '8'
print(s)

### FIXED CODE ###

s = input()
s = s.replace('7','8',1)
print(s)
N,M = map(int,input().split())
if M == 0:
  if N == 1:
    print(0)
    exit()
  elif N == 2:
    print(10)
    exit()
  else:
    print(100)
    exit()
dic = {} 
for _ in range(M):
  s,c = map(int,input().split())
  if s in dic and dic[s] != c:
    print(-1)
    exit()
  else:
    dic[s] = c
if N != 1 and dic[1] == 0:
  print(-1)
  exit()
ans = ''
for i in range(N):
  if i+1 in dic:
    ans += str(dic[i+1])
  elif i+1 == 1:
    ans += '1'
  else:
    ans += '0'
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
ret = ['a']*N
for _ in range(M):
  s,c = map(int,input().split())
  if ret[s-1] not in ['a', c]:
    print(-1)
    exit()
  ret[s-1] = c
if ret[0] == 0:
  if N != 1:
    print(-1)
    exit()
ans = ''
for i in range(N):
  if ret[i] != 'a':
    ans += str(ret[i])
  else:
    if i == 0 and N > 1:
      ans += '1'
    else:
      ans += '0'
print(int(ans))
ab = list(input().split())

a = int(ab[0])
b = float(ab[1]*100)

print(a*b//100)

### FIXED CODE ###

from decimal import Decimal 
a,b = input().split()
c = Decimal(b)
print(int(int(a)*c))
a,b,c,d=map(int,input().split())
l=[a+c,a+d,b+c,b+d]
print(min(l))

### FIXED CODE ###

a,b,c,d=[int(input()) for i in range(4)]
print(min(a,b)+min(c,d))
H, W = map(int, input().split(" "))
 
result = True
masu = [["0" for i in range(H+2)] for j in range(W+2)]
for h in range(1, H+1):
    s = "0"+input()+"0"
    masu[h] = list(s)
 
# print(masu)    
 
for h in range(1, H+1):
    for w in range(1, W+1):
        # print(h, w, masu[h][w])
        if masu[h][w] == "#" and masu[h+1][w] != "#" and masu[h][w+1] != "#" and masu[h-1][w] != "#" and masu[h][w-1] != "#":
            result = False
            break
if result:
    print("Yes")
else:
    print("No")

### FIXED CODE ###


H, W = map(int, input().split(" "))

# result = True
masu = [['.' for i in range(W+2)] for j in range(H+2)]
for h in range(H):
    s = "."+input()+"."
    masu[h+1] = s

# print(masu)

for h in range(1,H+1):
    for w in range(1,W+1):
        if masu[h][w] == "#":
            if "#" == masu[h+1][w] or "#" == masu[h][w+1] or "#" == masu[h-1][w] or "#" == masu[h][w-1]:
                pass
            else:
                # result = False
                print("No")
                exit()

print("Yes")
o = input()
e = input()

o_length = len(o)
e_length = len(e)

for letter in range(len(o)):
    print(o[letter], end="")
    print(e[letter], end="")

if len(o) == len(e):
    print(o[len(o)], end="")
    print(e[len(e)])
else:
    print(o[len(o)])

### FIXED CODE ###

o = input()
e = input()

for letter in range(len(o)-1):
    print(o[letter], end="")
    print(e[letter], end="")

if len(o) == len(e):
    print(o[len(o)-1], end="")
    print(e[len(e)-1])
else:
    print(o[len(o)-1])
a,b,c,d=map(int,input().split());m=998244353;x=range(c+d);D=[[0]*3011for _ in[0]*3011];D[a][b]=1
for i in x:
 for j in x:D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%m
print(D[c][d])

### FIXED CODE ###

A,B,C,D=map(int,input().split())
m=998244353
d=[[0]*(D+1) for _ in range(C+1)]
d[A][B]=1
for i in range(A,C+1):
 for j in range(B,D+1):
        d[i][j]+=(d[i][j-1]*i+d[i-1][j]*j-d[i-1][j-1]*(i-1)*(j-1))%m
print(d[C][D])
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for i in range(N)]
temp = 0

for i in range(N):
	if A[i] != max(A):
		print(max(A))
	else
		temp = A[i]
		del A[i]
		print(max(A))
		A.insert(i,temp)
		temp = 0

### FIXED CODE ###

# -*- coding:utf-8 -*-

r = int(input())
A = 3 * r**2

print(int(A))
import collections
import sys
sys.setrecursionlimit(10000)
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    global dp
    if dp[node]>=0:
        return dp[node] 
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i)+1)
    dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


### FIXED CODE ###

import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)
S = str(input())

count = 0
result = []

for i in range(len(S)):
  if (S[i] == "A") or (S[i] == "C") or (S[i] == "G") or (S[i] == "T"):
    count += 1
  elif (i == len(S)):
    result.append(count)
  else:
    result.append(count)
    count = 0

maxi = result[0]
    
for j in range(len(result)):
  if maxi < result[j]:
    maxi = result[j]

print(maxi)


### FIXED CODE ###

S = str(input())

count = 0
result = []

for i in range(len(S)):
  if (S[i] == "A") or (S[i] == "C") or (S[i] == "G") or (S[i] == "T"):
    count += 1
    if i == len(S) - 1:
      result.append(count)
  else:
    result.append(count)
    count = 0
    if i == len(S) - 1:
      result.append(count)

maxi = result[0]
    
for j in range(len(result)):
  if maxi < result[j]:
    maxi = result[j]

print(maxi)
d={}
N,K=map(int,raw_input().split())

for i in xrange(N):
    a,b=map(int,raw_input().split())
#    print a,b
    if a in d:
        d[a] = d[a] + b
    else:
        d[a]=b
#    td={}
#    cnt=0
#    print d
#    for key in sorted(d):
#        print key
#        if cnt<=K:
#            td[key]=d[key]
#        else:
#            break
#    d=td

aa=None
cnt=0
#print d
for k in sorted(d):
    aa=k
    cnt+=d[k]
#    print cnt
    if cnt>=K:
        break
print aa

    


### FIXED CODE ###

A,B,C = map(int, raw_input().split())

if A <= C and B >= C:
    print("Yes")
else:
    print("No")
n = int(input())
a = list(map(int, input().split()))

from collections import Counter

c = Counter(a)

from scipy.special import comb

s = set(c.values())

dic = {}
for ss in s:
    if ss not in dic.keys():
        dic[ss] = comb(ss, 2)
for ss in s:
    ss -= 1
    if ss not in dic.keys():
        dic[ss] = comb(ss, 2)

base = 0
for k in c.keys():
    base += dic[c[k]]

for k in range(len(a)):
    print(int(base - dic[c[a[k]]] + dic[c[a[k]] - 1]))

### FIXED CODE ###

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

from collections import Counter

c = Counter(a)

def comb(x):
    return x * (x - 1) // 2

base = 0
for aa in c.keys():
    x = c[aa]
    base += comb(x)

for aa in a:
    ans = base - comb(c[aa]) + comb(c[aa] - 1)
    print(ans)
n=int(input())
    print((n-n//2)/n)

### FIXED CODE ###

n=int(input())
print((n-n//2)/n)
a = input()
if len(a)==5:
    b = int(a)
    c = b - 9999 + 9 + 900
elif len(a)==4:
    b = int(a)
    c = 9 + 900
elif len(a)==3:
    b = int(a)
    c = b - 99 + 9
elif len(a)==2:
    b = int(a)
    c = 9
elif len(a)==1:
    b = int(a)
    c = b
print(c)

### FIXED CODE ###

a = input()
if len(a)==5:
    b = int(a)
    c = b - 9999 + 9 + 900
elif len(a)==4:
    b = int(a)
    c = 9 + 900
elif len(a)==3:
    b = int(a)
    c = b - 99 + 9
elif len(a)==2:
    b = int(a)
    c = 9
elif len(a)==1:
    b = int(a)
    c = b
elif len(a)==6:
    c = 90000 + 900 +9
print(c)
import math
a,b,c,d = map(int,input().split())
cd = c*d//math.gcd(c,d)
e = a-1
f = (b//c + b//d - b//(cd)) - (e//c + e//d - e//(cd))
print(b-e-f)

### FIXED CODE ###

import fractions
a,b,c,d = map(int,input().split())
cd = c*d//fractions.gcd(c,d)
e = a-1
f = (b//c + b//d - b//(cd)) - (e//c + e//d - e//(cd))
print(b-e-f)
x = raw_input()
print(str(int(x) ** 3))

### FIXED CODE ###

x = input()
print(int(x) ** 3)
N, K = map(int, input().split())N, K = map(int, input().split())

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

visitcount = dict()
n_point = list()

x = 1
count = 0
while(x not in set(visitcount)):
  visitcount[x] = count
  n_point.append(x)
  x = A[x-1]
  count += 1
  
period = count - visitcount[x]

if (K < visitcount[x]):
  print(n_point[K])
else:
  y = (K-visitcount[x]) % period
  print(n_point[visitcount[x] + y])
 



### FIXED CODE ###

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

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

visitset = set()
visitcount = dict()
n_point = dict()

x = 1
count = 0
while(x not in visitset):
  visitset.add(x)
  visitcount[x] = count
  n_point[count] = x
  x = A[x-1]
  count += 1


period = count - visitcount[x]

if (K < visitcount[x]):
  print(n_point[K])
else:
  y = (K-visitcount[x]) % period
  print(n_point[visitcount[x] + y])