Harryxun/stf_run huggingface dataset:
#D
#https://tech-kyopro.com/atcoder-abc126-d
n = int(input())
edges = [list(map(int,input().split())) for _ in range(n-1)]
#頂点iと隣接する頂点とその距離を格納[["隣接する頂点","その距離"]]
a = [[] for _ in range(n+1)]

for i in edges:
    a[i[0]].append([i[1],i[2]])
    a[i[1]].append([i[0],i[2]])
    
#頂点1からの距離をdepth
depth = [-1 for _ in range(n+1)]
depth[0] = 0

def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])
            
dfs(a,1)

for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1)


### FIXED CODE ###

#D
#https://tech-kyopro.com/atcoder-abc126-d

import sys
sys.setrecursionlimit(500*500)
n = int(input())
edges = [list(map(int,input().split())) for _ in range(n-1)]
#頂点iと隣接する頂点とその距離を格納[["隣接する頂点","その距離"]]
a = [[] for _ in range(n+1)]

for i in edges:
    a[i[0]].append([i[1],i[2]])
    a[i[1]].append([i[0],i[2]])
    
#頂点1からの距離をdepth
depth = [-1 for _ in range(n+1)]
depth[0] = 0

def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])
            
dfs(a,1)

for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1)
import math

s = input().split()

a = int(s[0])
b = int(s[1])
c = int(s[2])

if math.sqrt(a) + math.sqrt(b) < math.sqrt(c) :
  print('Yes')
else:
  print('No')

### FIXED CODE ###

d = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
str_n = input()
n = int(str_n)
print(d[n-1])
n, k = map(int, input().split())
s = input()

def count_diff(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

s2 = s[1:]
cnt = count_diff(s[:-1], s2)
init = n - cnt - 1

if (s[0] == "L" and s[1] == "L") or (s[-1] == "R" and s[-2] == "R"):
        init -= 1

print(init + (2 * k))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()

def count_diff(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

s2 = s[1:]
cnt = count_diff(s[:-1], s2)
init = n - cnt - 1

ans = min(n-1, init + (2 * k))

print(ans)
from collections import deque

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
  a, b = list(map(int, input().split()))
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  
ans = 0
v = 0
s = 1
l = 1
q = deque()
q.append((v, s, l))

while q:
  v, s, l = q.popleft()
  if l == N:
    ans += 1
    continue
  for nv in G[v]:
    if s&(1<<n) == 0:
      q.append((nv, s|(1<<n), l+1))
print(ans)

### FIXED CODE ###

from collections import deque

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
  a, b = list(map(int, input().split()))
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  
ans = 0
v = 0
s = 1
l = 1
q = deque()
q.append((v, s, l))

while q:
  v, s, l = q.popleft()
  if l == N:
    ans += 1
    continue
  for nv in G[v]:
    if s&(1<<nv) == 0:
      q.append((nv, s|(1<<nv), l+1))
print(ans)
param = sys.argv

print( int(param[1]) ** 3 )

### FIXED CODE ###

import sys
p = sys.stdin.readline()
p = int(p)
o = p ** 3
print o
# -*- coding: utf-8 -*-
import sys 
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W, M= map(int,readline().split())
h_cnt = [0]*(H+1)
w_cnt = [0]*(W+1)
data = [[False]*(W+1) for i in range(H+1)]
 
for i in range(M):
    h,w = map(int,readline().split())
    data[h][w] = True
    h_cnt[h] += 1 
    w_cnt[w] += 1
    
max_h = max(h_cnt)
max_w = max(w_cnt)
 
max_h_ind = []
max_w_ind = []
max_h_cnt = 0
max_w_cnt = 0
 
for i in range(H+1):
    if max_h == h_cnt[i]:
        max_h_cnt += 1
        max_h_ind.append(i)
        
for i in range(W+1):
    if max_w == w_cnt[i]:
        max_w_cnt += 1
        max_w_ind.append(i)
max_h_ind = set(max_h_ind)
max_w_ind = set(max_w_ind)
 
if max_w_cnt * max_h_cnt > M:
    print(max_h+max_w)
else:
    t = list(itertools.product(max_h_ind, max_w_ind))
    for h,w in t:
        if data[h][w] == False:
            print(max_h+max_w)
            sys.exit()
    print(max_h+max_w-1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys 
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W, M = map(int,readline().split())
h_cnt = [0]*(H+1)
w_cnt = [0]*(W+1)
bomb = []
 
for i in range(M):
    h,w = map(int,readline().split())
    bomb.append((h,w))
    h_cnt[h] += 1 
    w_cnt[w] += 1
    
maxh = max(h_cnt)
maxw = max(w_cnt)
maxhCnt = h_cnt.count(maxh)
maxwCnt = w_cnt.count(maxw)

total = maxhCnt*maxwCnt
ans = maxh+maxw
cnt = 0
for h,w in bomb:
    if h_cnt[h] == maxh and w_cnt[w] == maxw:
       cnt += 1

print(ans-1 if cnt == total else ans)
#数列に対しy/nの判定をする
def solve(balls):

  #B, Cの一番上の数(ただし常にB <= Cを保つ)
  last_b = last_c = 0

  while balls:
    new = balls.pop(0)
    
    #new <= last_b <= last_c  --> 不可能
    if new <= last_b:
      print("NO")
      break
    
    #last_b < new <= last_c   --> Bを更新
    elif new <= last_c:
      last_b = new
    
    #last_b < last_c < new    --> Cを更新
    else:
      last_c = new
  
  else:
    print("YES")

      


while True:
  try:
    n = int(input())

    for i in range(n):
      balls = list(map(int, input().split()))
      solve(balls)

  except EOFError:
    break


### FIXED CODE ###

#数列に対しy/nの判定をする
def solve(balls):

  #B, Cの一番上の数(ただし常にB <= Cを保つ)
  last_b = last_c = 0

  while balls:
    new = balls.pop(0)
    
    #new <= last_b <= last_c  --> 不可能
    if new <= last_b:
      print("NO")
      return
    
    #last_b < new <= last_c   --> Bを更新
    elif new <= last_c:
      last_b = new
    
    #last_b < last_c < new    --> Cを更新
    else:
      last_c = new
  
  print("YES")
  return

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

  for _ in range(n):
    balls = list(map(int, input().split()))
    solve(balls)

main()
import numpy as np
import pandas as pd

R, G, B, N = map(int, input().split())
r = np.arange(0, int(N/R)+1)
g = np.arange(0, int(N/G)+1)
rg = r[:, np.newaxis]*R+g[np.newaxis, :]*G
mask = (rg<=N) & ((N-rg)%B==0)
print(np.sum(mask))

### FIXED CODE ###

import numpy as np
R, G, B, N = map(int, input().split())
r = np.arange(0, int(N/R)+1)
g = np.arange(0, int(N/G)+1)
rg = r[:, np.newaxis]*R+g[np.newaxis, :]*G
mask = (rg<=N) & ((N-rg)%B==0)
print(np.sum(mask))
N, K = map(int, input().split())
Hs = map(int,input().split())
print(sum(sorted(Hs, reverse=True)[K::])

### FIXED CODE ###

N, K = map(int, input().split())
Hs = map(int,input().split())
print(sum(sorted(Hs, reverse=True)[K::]))
N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

out = set(L) & set(R)
out.sort()
for a in out:
    print(a+1)

### FIXED CODE ###

N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

L.sort()
R.sort()
for i in range(min(len(L),len(R))):
    if L[i]==R[i]:
        print(L[i]+1)
def out(m, n):
  a = m*(m-1)%2 + n*(n-1)%2
  return a

m, n = int(input())
a = out(m,n)

print(a)

### FIXED CODE ###

n, m = map(int, input().split())
a = n*(n-1)/2 + m*(m-1)/2
print(int(a))
try:
    while True:
except EOFError:

### FIXED CODE ###

a=[int(input()) for i in range(10)]
a.sort(reverse=True)
for i, iv in enumerate(a):
	print(iv)
	if i >= 2:
		break
from bisect import bisect_left
N,K=map(int, input().split())
A=list(map(int, input().split()))
p=10**9+7
A=sorted(A)
thresh=bisect_left(A,0)
minus=A[:thresh]
plus=A[thresh:][::-1]

#print(plus, minus)
if len(plus)==0:
    ans=1
    if K%2!=0:
        minus=minus[::-1]
        for i in range(K):
            ans*=minus[i]
            ans%=p
    else:
        for i in range(K):
            ans*=minus[i]
            ans%=p
    print(ans)
    exit()

if len(minus)==0:
    ans=1
    for i in range(K):
        ans*=plus[i]
        ans%=p
    print(ans)
    exit()

midx=0
pidx=0
ans=1
while K>0 and (0<=midx<len(minus) or 0<=pidx<len(plus)):
    if midx!=len(minus)-1:
        nexmin=minus[midx]*minus[midx+1]
    elif midx<len(minus):
        nexmin=minus[midx]
    else:
        nexmin=-1


    if pidx!=len(plus)-1:
        nexplus=plus[pidx]*plus[pidx+1]
    elif pidx<len(plus):
        nexplus=plus[pidx]
    else:
        nexplus=-float("INF")

    if nexmin>nexplus and K>=2:
        ans*=nexmin
        ans%=p
        midx+=2
        K-=2
    else:
        ans*=plus[pidx]
        ans%=p
        pidx+=1
        K-=1

print(ans)



### FIXED CODE ###

from bisect import bisect_left
N,K=map(int, input().split())
A=list(map(int, input().split()))
p=10**9+7
A=sorted(A)
thresh=bisect_left(A,0)
minus=A[:thresh]
plus=A[thresh:][::-1]

#print(plus, minus)
if len(plus)==0:
    ans=1
    if K%2!=0:
        minus=minus[::-1]
        for i in range(K):
            ans*=minus[i]
            ans%=p
    else:
        for i in range(K):
            ans*=minus[i]
            ans%=p
    print(ans)
    exit()

if len(minus)==0:
    ans=1
    for i in range(K):
        ans*=plus[i]
        ans%=p
    print(ans)
    exit()

midx=0
pidx=0
ans=1

while K>0 and (0<=midx<len(minus) or 0<=pidx<len(plus)):
    if midx==len(minus)-1:
        nexmin=minus[midx]
    elif midx>=len(minus):
        nexmin=-1
    else:
        if K>=2:
            nexmin=minus[midx]*minus[midx+1]
        else:
            nexmin=minus[midx]

    if pidx==len(plus)-1:
        nexplus=plus[pidx]
        fact=nexplus
    elif pidx>=len(plus):
        nexplus=-float("INF")
        fact=nexplus
    else:
        #if plus[pidx+1]!=0:
        #    nexplus=plus[pidx]*plus[pidx+1]
        #else:
        #    nexplus=plus[pidx]
        if K>=2:
            nexplus=plus[pidx]*plus[pidx+1]
        else:
            nexplus=plus[pidx]
        fact=plus[pidx]

    if nexmin>=nexplus:
        ans*=nexmin
        ans%=p
        midx+=2
        K-=2
    else:
        ans*=fact
        ans%=p
        pidx+=1
        K-=1


print(ans)
N, K = input().split()
l = list(int(i) for i int input().split())
count = 0

for i in l:
  if(i > K):
    count = count + 1

print(count)

### FIXED CODE ###

N, K = input().split()
l = list(int(i) for i in input().split())
count = 0
 
for i in l:
  if(i >= int(K)):
    count = count + 1

print(count)
import math
def div(n, m):
  if n > m:
    n = m
  d = []
  for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0 and m % i == 0:
        d.append(i)
  if m % n == 0:
    d.append(i)
  return d

a, b = map(int, input().split())
lc = div(a,b)
print(len(lc) + 1)


### FIXED CODE ###

import math
def gcd(a, b):
  while b > 0:
    a, b = b, a % b
  return a
def div(a):
  r = []
  i = 2
  k = int(math.sqrt(a))
  while i <= k:
    if a % i == 0:
      r.append(i)
      while a % i == 0:
        a //= i
      k = math.sqrt(a)
    i += 1
  if a > 1:
    r.append(a)
  return r

a, b = map(int, input().split())
if a > b:
  a, b = b, a
c = gcd(a,b)
print(len(div(c))+1)
a,b=input().split()

if len(a)>=2 or len(b)>=2:
  print(-1)
else:
  print(a*b)

### FIXED CODE ###

a,b=input().split()

if len(a)>=2 or len(b)>=2:
  print(-1)
else:
  a=int(a)
  b=int(b)
  print(a*b)
#D                 more faster method than above               see it ..........
l = lambda : list(map(int,input().split().strip()))
n = int(input())
a = l
t = [0]*(10**5+1)
s = 0
for i in a:
    s += i
    t[i] += 1
q = int(input())
for _ in range(q):
    b,c = l
    s += (c-b)*t[b]
    t[c] += t[b]
    t[b] = 0
    print(s)


### FIXED CODE ###

#D                 more faster method than above               see it ..........
l = lambda : list(map(int,input().strip().split()))
n = int(input())
a = l()
t = [0]*(10**5+1)
s = 0
for i in a:
    s += i
    t[i] += 1
q = int(input())
for _ in range(q):
    b,c = l()
    s += (c-b)*t[b]
    t[c] += t[b]
    t[b] = 0
    print(s)
S = input()
l = re.findall(r'[ACGT]+', S)
if l:
  print(max(map(len, l)))
else:
  print(0)


### FIXED CODE ###

S = input()
count, max_count = 0, 0
for s in S:
  if s in 'ACGT':
    count += 1
    if count > max_count:
      max_count = count
  else:
    count = 0
print(max_count)
N,K = map(int,input().split())
P = list(map(int,input().split()))

ls = P[0:K]
summ = sum(ls)
ans = [0]*K

for i in range(N-K+1):
    if summ < sum(P[i:i+K]):
        ls = P[i:i+K]
        summ = sum(ls)
for j in range(K):
    ans[j]=(ls[j]+1)*ls[j]/(2*ls[j])
print(sum(ans))

### FIXED CODE ###

S,T = input().split()
A,B = map(int,input().split())
U = input()

if U == S:
    print(A-1,B)
else:
    print(A,B-1)
import math
tan, tyou, hour, minute = input()
tan_rad = 30 * hour + 0.5 * minute
tyou_rad = 6 * minute
if tan_rad == tyon_rad:
  answer = abs(tyou - tan)
else:
  rad = abs(tan_rad - tyou_rad)
if rad:
  answer = math.sqrt((tan ** 2) + (tyou ** 2) - 2 * tan * tyou * math.cos(rad))
print(answer)

### FIXED CODE ###

import math
ji, hun, H, M = input().split()
ji = int(ji)
hun = int(hun)
H = int(H)
M = int(M)
ji_rad = 30 * H + 0.5 * M
hun_rad = 6 * M
diff = abs(ji_rad - hun_rad)
if diff == 0:
  answer = abs(ji - hun)
elif diff == 180:
  answer = ji + hun
else:
  if diff > 180:
      diff = abs(360 - diff)
  answer = math.sqrt((ji ** 2) + (hun ** 2) - 2 * ji * hun * math.cos(math.radians(diff)))
print(answer)
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		for j in range(10) :
			if s[i-k][j] != s[i][j] :
				ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);

### FIXED CODE ###

import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);
sucl =[]
for i in range(0,int(N)):
  T=True
  for j in range(0,int(N)):
    if T== False:
      break
    if A[i]<A[j]:
      break
    if A[i] % A[j]==0:
      if i==j:
        pass
      else:
        T=False
        
  if T==True:
    sucl.append(i)
print(len(sucl))
    

### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
N = int(N)
MA = max(A)
s=0
LS = [0 for i in range(0,MA)]
for i in range(0,N):
  k=1
  while A[i]*k<=MA:
    LS[A[i]*k-1] +=1
    k +=1
for j in range(0,N):
  if LS[A[j]-1]==1:
    s+=1
print(s)
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
for i in range(n-2):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")
    
      
  

### FIXED CODE ###

n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
  A.append([a,b,c])
if n==1:
  print("Yes")
  exit()
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")
t = input()
if(t[0] == '?'):
    if  (t[1] == 'D'): t = "".join(['P' , t[1:]])
    elif(t[1] == '?'): t = "".join(['PD', t[2:]])
    else:              t = "".join(['D' , t[1:]])
if(t[-1] == '?'):
    t = "".join([t[:-1], 'D'])
for i in range(len(t)-1):
    if(t[i] == '?'):
        if(t[i-1] == 'P'):    t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == 'D'):  t = "".join([t[:i], 'P' , t[i+1:]])
        elif(t[i+1] == 'P'):  t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == '?'):  t = "".join([t[:i], 'PD', t[i+2:]])
print(t)

### FIXED CODE ###

t = input()
if(len(t) == 1):
    if (t[0] == '?'): t = "D"
if(t[0] == '?'):
    if  (t[1] == 'D'): t = "".join(['P' , t[1:]])
    elif(t[1] == '?'): t = "".join(['PD', t[2:]])
    else:              t = "".join(['D' , t[1:]])
if(t[-1] == '?'):
    t = "".join([t[:-1], 'D'])
for i in range(len(t)-1):
    if(t[i] == '?'):
        if(t[i-1] == 'P'):    t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == 'D'):  t = "".join([t[:i], 'P' , t[i+1:]])
        elif(t[i+1] == 'P'):  t = "".join([t[:i], 'D' , t[i+1:]])
        elif(t[i+1] == '?'):  t = "".join([t[:i], 'PD', t[i+2:]])
print(t)
N=int(input())
A=[0]*N
A=list(map(int,input().split()))
money=1000
money_temp=1000
kazu=0
for i in range(N-1):
    if(A[i]<A[i+1]):
        money=money+kazu*ma
        kazu=money//A[i]
        money_temp=max(money_temp,money-A[i]*kazu)
        money=money-A[i]*kazu
        #print('ue')
        #print(A[i])
        #print(A[i+1])
    elif(A[i]==A[i+1]):
        pass
    elif(A[i+1]<A[i]):
        stop=1
        ma=max(A[i],ma)

money=money+kazu*A[N-1]

print(max(money,money_temp))


### FIXED CODE ###

N=int(input())
A=[0]*N
A=list(map(int,input().split()))
money=1000
money_temp=1000
kazu=0
ma=0
mi=float('inf')
stop=0
for i in range(0,N-1):
    money=money+A[i]*kazu
    kazu=0
    if(A[i]<A[i+1]):
        kazu=money//A[i]
        money=money-A[i]*kazu

    elif(A[i+1]<=A[i]):
        pass

money=money+A[N-1]*kazu
print(money)
s = input()
t = input()
LENs = len(s)
LENt = len(t)
dp = [[0 for i in range(LENt+1)] for j in range(LENs+1)]
for i in range(LENs+1):
    for j in range(LENt+1):
        if i+1 <= LENs:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= LENt:
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])
        if i+1 <= LENs and j+1<=LENt:
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1

ans = ''
x = LENs
y = LENt
while True:
    if len(ans)==dp[-1][-1]:
        break
    if dp[x-1][y] == dp[x][y-1]:
        if dp[x-1][y-1] < dp[x][y]:
            ans.append(s[x-1])
            x = x-1
            y = y-1
            continue
        else:
            x = x-1
            continue
    elif dp[x-1][y] < dp[x][y-1]:
        y = y-1
    elif dp[x-1][y] < dp[x][y-1]:
        x = x-1

print(ans[::-1])

### FIXED CODE ###

s = input()
t = input()
LENs = len(s)
LENt = len(t)
dp = [[0 for i in range(LENt+1)] for j in range(LENs+1)]
for i in range(LENs+1):
    for j in range(LENt+1):
        if i+1 <= LENs:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= LENt:
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])
        if i+1 <= LENs and j+1<=LENt:
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1

ans = ''
x = LENs
y = LENt
while True:
    if len(ans)==dp[-1][-1]:
        break
    if dp[x-1][y] ==dp[x][y]:
        x = x-1
    elif dp[x][y] == dp[x][y-1]:
        y = y-1
    elif dp[x-1][y-1]+1== dp[x][y]:
        ans =s[x-1] + ans
        x = x-1
        y = y-1
        continue
#     elif dp[x-1][y] == dp[x][y-1]:
#         x = x-1

print(ans)
a = int(input())
b = int(input())
  
print(str(a*b), str(a*2 + b*2))

### FIXED CODE ###

z = input()
m,l = z.split()
s = int(m) * int(l)
n = int(m)*2 + int(l)*2

print("{} {}".format(str(s),str(n)))
a = int(input())
if a >= 3200:
    print(s)
else:
    print("red")


### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
#include <iostream>
#include <vector>
using namespace std;

uint64_t gcd(uint64_t a, uint64_t b)
{
    uint64_t r;
    while ((r = a % b) != 0) {
        a = b;
        b = r;
    }

    return b;
}

uint64_t binomial(uint64_t n, uint64_t r)
{
    r = (r > n / 2) ? n - r : r;
    uint64_t result = 1;

    for (uint64_t i = 1; i <= r; i++, n--) {
        int d = gcd(result, i);

        result /= d;
        result *= n / (i / d);
    }

    return result;
}

int main(){
    int N, K;
    cin >> N >> K;
    int ans;
    
    for(int i=1; i<=K; i++){
        ans = binomial(N-K+1, i) * binomial(K-1, i-1);
        ans = ans % int(1E9 + 7);
        cout << ans << endl;
    }
}

### FIXED CODE ###

n, k = list(map(int, input().split()))
lim = 10**9 + 7
C = [[1], [1,1]]

for i in range(2, n+10):
    C.append([1] + [(C[i-1][j-1] + C[i-1][j])%lim for j in range(1, i)] + [1])

for i in range(1, k+1):
    if n-k+1 < i  or k < i:
        #赤ボールが操作回数よりも少ない時、青ボールが操作回数よりも少ない時
        print(0)
    else:
        #青ボールを入れる箇所の組み合わせ×各箇所に入れる青ボール個数の組み合わせ
        print((C[n-k+1][i]*C[k-1][i-1])%lim)
n, k = [int(x) for x in input().split()]
a = [int(x)-1 for x in input().split()]

visited = []
x=0
for i in range(n):
  x = a[x]
  if x in visited:
    for j in range(i):
      if visited[j] == x:
        first = j
        break
    T = i - j
  break
  else:
    visited.append(a[i])
mod = (k-first) % T
print(a[first+mod]+1)


### FIXED CODE ###

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

visited = [-1 for i in range(n+1)] # 訪れていたら訪れたときの添字を格納する。
points = []
p = 1
while visited[p] == -1:
  visited[p] = len(points)
  points.append(p)
  p = a[p-1] #添字に直す

T = len(points) - visited[p]
s = visited[p]

if k < s:
  print(points[k])
else:
  mod = (k - s) % T
  print(points[s+mod])
n=input()
print((10**n-(2*9**n-8**n))%(10**9+7))

### FIXED CODE ###

n=int(input())
print((10**n-(2*9**n-8**n))%(10**9+7))
def remain(pos,length):
  p=pos
  for c,d in moves:
    if s[p]==c:
      if d=='L':
        p-=1
      if d=='R':
        p+=1
    if p<0 or p>=length:
      return False
  return True

n,q=map(int,input().split())
s=input()
moves=[list(map(str,input().split())) for _ in range(q)]
l=-1
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    r=mid
  else:
    l=mid
remain_left=r
l=remain_left
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    l=mid
  else:
    r=mid
remain_right=l
print(remain_right-remain_left+1)

### FIXED CODE ###

def remain(pos,length):
  p=pos
  for c,d in moves:
    if s[p]==c:
      if d=='L':
        p-=1
      if d=='R':
        p+=1
    if p<0 or p>=length:
      return False
  return True

n,q=map(int,input().split())
s=input()
moves=[list(map(str,input().split())) for _ in range(q)]
l=-1
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    r=mid
  else:
    l=mid
remain_left=r
if remain_left==n:
  print(0)
  exit()
l=remain_left
r=n
while r-l!=1:
  mid=(l+r)//2
  if remain(mid,n)==True:
    l=mid
  else:
    r=mid
remain_right=l
print(remain_right-remain_left+1)
import sys

if __name__ == '__main__':
	a,b,c=map(int,sys.stdin.read().split())
	print len(i for i in range(a,b+1) if c%i==0)


### FIXED CODE ###

#!/usr/bin/env python
#-*- coding: utf-8 -*-

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D

if __name__ == '__main__':
    a, b, c = map(int, raw_input().split())
    cnt = 0
    for i in range(a, b + 1):
        if c % i == 0:
            cnt += 1
    print cnt
X, Y = map(int, input().split())

result = "No"
for i in range(X + 1):
    if 2 * i + (X - i) * 4 == Y:
        result = "Yes"

print(result)

### FIXED CODE ###

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

result = 1
if 0 in A:
    print("0")
else:
    for a in A:
        result *= a
        if result > 10**18:
            result = -1
            break
    print(result)
N = input()
sum = 0
for n in N:
  sum += int(n)
res = int(N) % sum
if res == 0:
  print("yes")
else
  print("no")


### FIXED CODE ###

N = input()
s = 0
for n in N:
  s += int(n)
res = int(N) % s
if res == 0:
  print("Yes")
else:
  print("No")