Harryxun/stf_run huggingface dataset:
N = int(input())
adj_list = [[] for _ in range(N)]
depth = [float('inf')] * 100010


def dfs(v, p, d):
    depth[v] = d
    for adj in adj_list[v]:
        if adj[0] == p:
            continue
        dfs(adj[0], v, d + adj[1])


for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj_list[a].append((b, c))
    adj_list[b].append((a, c))

Q, K = map(int, input().split())
dfs(K - 1, -1, 0)

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(depth[x] + depth[y])


### FIXED CODE ###

import heapq


def dijkstra(K):
    c_l = [float('inf')] * N
    c_l[K] = 0
    hq = [(0, K)]
    while hq:
        u = heapq.heappop(hq)[1]
        for nv, c in adj_list[u]:
            if c_l[nv] > c_l[u] + c:
                c_l[nv] = c_l[u] + c
                heapq.heappush(hq, (c_l[u] + c, nv))
    return c_l


N = int(input())
adj_list = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj_list[a].append((b, c))
    adj_list[b].append((a, c))

Q, K = map(int, input().split())
c_l = dijkstra(K - 1)

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(c_l[x] + c_l[y])
N, M = [int(nm) for nm in input().split()]
A = []
for m in range(M):
  A.append(int(input()))

for n in range(N, -1, -1):
  if n == N:
    i2 = 1
  elif n == N-1:
    i1 = 1
    if n in A:
      i1 = 0
  else:
    i = i1 + i2
    if n in A:
      i = 0
    i1, i2 = i, i1

ans = i % (10**9 + 7)
print(ans)

### FIXED CODE ###

N, M = [int(nm) for nm in input().split()]
if M != 0:
  a = int(input())

C = [1, 0] # [-2段目, -1段目]
C += [0]*(N+10) # C = [-2段目, -1段目, 0段目, 1段目, 2段目, ...]
for n in range(0, N+1):
  if M == 0:
    C[n+2] = (C[n] + C[n+1]) % 1000000007
  else: # M > 0:
    if n != a:
      C[n+2] = (C[n] + C[n+1]) % 1000000007
    else: # n == a:
      C[n+2] = 0
      M -= 1
      if M > 0:
        a = int(input())

ans = C[N+2]  % 1000000007
print(ans)
n,m=map(int,input().split())
a=[list(map(int,input().split()))
b=[int(input())for i in range(m)]
[print(sum([j*k for j,k in zip(a[i],b])) for i in range(n)]


### FIXED CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[int(input())for _ in range(m)]
[print(sum([j*k for j,k in zip(a[i],b)]))for i in range(n)]
import math
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0

n_ = (A-1) // C
n = math.ceil(A / C) - 1
m = B // C
if m >= n:
  count_div += m - n

l_ = (A-1) // D
l = math.ceil(A / D) - 1
k = B // D
if k >= l:
  count_div += k - l

j_ = (A-1) // E
j = math.ceil(A / E) - 1
i = B // E
if i >= j:
  count_div -= i - j

if (n_ != n) or (l_ != l) or (j_ != j):
  sleep(2)
else:
  print(B - A + 1 - count_div)

### FIXED CODE ###

import math
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0
 
n = (A-1) // C
m = B // C
count_div += m - n

l = (A-1) // D
k = B // D
count_div += k - l

j = (A-1) // E
i = B // E
count_div -= i - j

print(B - A + 1 - count_div)
n,k=map(int,input().split())
h=list(map(int,input().split()))
res=[-1]*n
res[0]=0
for i in range(1,k):
    
    res[i]=abs(h[i-1]-h[i])
for i in range(k,n):
    mini=999999999
    for j in range(1,k+1):
        mini=min(abs(h[i-j]-h[i])+res[i-j],mini)
    res[i]=mini

print(res[-1])


### FIXED CODE ###

import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[sys.maxsize]*n
dp[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]))
print(dp[n-1])
n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
s.sort()
print(s)
cnt=0
for i in range(n-1):
    if s[i]==s[i+1]
    cnt +=1
print(cnt-n)


### FIXED CODE ###

n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
s.sort()
ans=0
pairs=1
for i in range(n-1):

    if s[i]==s[i+1]:
        pairs += 1
    else:      
        ans += pairs*(pairs-1)/2
        pairs =1
if pairs != 1:
    ans += pairs*(pairs-1)/2
    pairs =1
print(int(ans))
import math
N = int(input())
monsterlist = list(map(int,input().split()))
monsterlist.sort()
minnum = monsterlist[0]
count = 0
for i in range(1,N):
    if monsterlist[i] % minnum != 0:
        count += 1
        comparenum = monsterlist[i]
        break
if count == 0:
    print(minnum)
else:
    print(math.gcd(minnum,comparenum))

### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
 
# 最大公約数を求める関数
def gcd(a,b):
    rem = a % b
    while rem != 0:
        a = b
        b = rem
        rem = a % b
    return b
 
cand = A[0]
 
for i in range(1,N):
    cand = gcd(cand, A[i])
 
    if cand == 1:
        break
 
print(cand)
#  --*-coding:utf-8-*--



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

    M = 2*10**5
    X = [0]*(M+1)

    for a in A:
        X[a] += 1

    c = 0

    for i in range(17, -1, -1):
        r1 = 1<<i
        r2 = r1*2

        c2 = X[r1]//2
        c += c2
        X[r1] -= c2*2        

        for j in range(r1+1, min(r2-1, M)+1):
            j2 = r2-j

            c2 = min(X[j], X[j2])
            c += c2
            
            X[j] -= c2
            X[j2] -= c2

    print(c)



if __name__ == '__main__':
    main()


### FIXED CODE ###

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



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

    M = int(10**9)
    bitOfM = M.bit_length()

    X = {}
    Y = [set() for _ in range(bitOfM+1)]

    for a in A:
        if not a in X:
            X[a] = 1
            Y[a.bit_length()].add(a)
        else:
            X[a] += 1

    c = 0

    for i in range(bitOfM, 0, -1):
        P = 1<<(i-1)
        
        if P in X:
            c += X[P]//2

        for a in Y[i]:
            if a == P:
                continue

            a2 = 2*P - a
            if a2 in X:
                c2 = min(X[a], X[a2])
                c += c2
                X[a2] -= c2


    print(c)



if __name__ == '__main__':
    main()
def main():
  N, K, C=map(int, input().split())
  S = input()
  
  S=S[::-1]
  R=set()
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      R.add(N-n)
      k+=1
      n += C
    n+=1
  #print(R)
  
  S=S[::-1]
  n, k=0, 0
  while k < K:
    if S[n]=='o':
      if n+1 in R:
        print(n+1)
      k+=1
      n += C
    n+=1
  #print(L)
  

  
if __name__=='__main__':
  main()


### FIXED CODE ###

from collections import deque

def main():
  N=int(input())
  for n in range(N):
    x=ans.popleft()
    if x%10!=0:
      ans.append(10*x+(x%10)-1) # x equal y-1
    ans.append(10*x+(x%10)) # x equal y
    if x%10!=9:
      ans.append(10*x+(x%10)+1) # x equal y+1
  print(x)
  
if __name__=='__main__':
  ans=deque([1,2,3,4,5,6,7,8,9])
  main()
A, B, C = map(int, input().split()))

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)

### FIXED CODE ###

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

if A == B:
    print(C)
elif B == C:
    print(A)
else:
    print(B)
n = int(input())
S = input()

R = []
G = []
B = []

for i in range(n):
    if S[i] == 'R':
        R.append(i)
    elif S[i] == 'G':
        G.append(i)
    else:
        B.append(i)

#print(R, G, B)

cnt = 0
r = R[0]
g = G[0]
b = B[0]

iR = 0
iG = 0
iB = 0

def ccc(ia, ib, ic, BB, CC):
    cnt = 0
    #for aa in BB[:ib:-1]:
    for aa in BB[ib:]:
        if aa > ia:
            for aaa in CC[ic:]:
                if aaa > aa:
                    if (aa - ia) != (aaa - aa):
                        #print(ia, aa, aaa)
                        cnt += 1


    return cnt

for i in range(n):
    if S[i] == 'R':
        if iR < len(R) - 1:
            iR += 1

        cnt += ccc(i, iG, iB, G, B)
        cnt += ccc(i, iB, iG, B, G)

    elif S[i] == 'G':
        if iG < len(G) - 1:
            iG += 1

        cnt += ccc(i, iR, iB, R, B)
        cnt += ccc(i, iB, iR, B, R)

    else:
        if iB < len(B) - 1:
            iB += 1

        cnt += ccc(i, iG, iR, G, R)
        cnt += ccc(i, iR, iG, R, G)

    
print(cnt)


### FIXED CODE ###

n = int(input())
S = input()

R = {}
G = {}
B = {}

for i in range(n):
    if S[i] == 'R':
        R[i] = None
    elif S[i] == 'G':
        G[i] = None
    else:
        B[i] = None

#print(R, G, B)

cnt = 0

cnt = len(R) * len(G) * len(B)

for b in B:
    for g in G:
        if (b + g) / 2 in R:
            cnt -= 1

for r in R:
    for b in B:
        if (r + b) / 2 in G:
            cnt -= 1

for r in R:
    for g in G:
        if (r + g) / 2 in B:
            cnt -= 1
            
print(cnt)
import sys;
lines = sys.stdin.readlines();

#配列の宣言
alfabet = {};

#値の格納
alfabet['A'] = 1;
alfabet['B'] = 2;
alfabet['C'] = 3;
alfabet['D'] = 4;

for i, line in enumerate(lines):
    #値を受け取り格納
    first,second = line.split();

if(alfabet[first]<alfabet[second]):
    print ("<");
elif(alfabet[first]>alfabet[second]):
    print (">");
else:
    print("=");


### FIXED CODE ###

import sys;
lines = sys.stdin.readlines();

#配列の宣言
alfabet = {};

#値の格納
alfabet['A'] = 1;
alfabet['B'] = 2;
alfabet['C'] = 3;
alfabet['D'] = 4;
alfabet['E'] = 5;
alfabet['F'] = 6;

for i, line in enumerate(lines):
    #値を受け取り格納
    first,second = line.split();

if(alfabet[first]<alfabet[second]):
    print ("<");
elif(alfabet[first]>alfabet[second]):
    print (">");
else:
    print("=");
S=str(input())
for i in range(len(S)):
  s = S[0:len(S)-i]
  if len(s)%2 == 0:
    if s[0:len(s)/2] == s[len(s)/2:len(s)]:
      break
print(len(s))

### FIXED CODE ###

S=str(input())
for i in range(1,len(S)):
  s = S[0:len(S)-i]
  if len(s)%2 == 0:
    if s[0:round(len(s)/2)] == s[round(len(s)/2):len(s)]:
      break
print(len(s))
import math
N = input()
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(2, N))

### FIXED CODE ###

import fractions
N = int(input())
def lcm(x, y):
    return (x * y) / fractions.gcd(x, y)

print(int(lcm(2, N)))
a=input()
b=input()
if (int(a)*int(b))%2==0:
  print("even")
else:
  print("odd")

### FIXED CODE ###

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

if a >=1 and a <=10000 and b >=1 and b <=10000:
  if (a*b)%2==0:
    print("Even")
  else:
    print("Odd")
import sys
import string
from collections import Counter

f = sys.stdin

while True:    
    n = int(f.readline())
    if n == 0:
        break
    counters = {c:Counter() for c in string.ascii_lowercase}
    for i in range(n):
        for word in f.readline().strip().split():
            counters[word[0]].update([word])
    c = f.readline().strip()

    candidate = counters[c].most_common()
    candidate.sort(key=operator.itemgetter(0))
    candidate.sort(key=operator.itemgetter(1), reverse=True)
    candidate = [word for word, count in candidate[:5]]
    if len(candidate) == 0:
        print('NA')
    else:
        print(*candidate)

### FIXED CODE ###

import sys
import string
import operator
from collections import Counter

f = sys.stdin

while True:    
    n = int(f.readline())
    if n == 0:
        break
    counters = {c:Counter() for c in string.ascii_lowercase}
    for i in range(n):
        for word in f.readline().strip().split():
            counters[word[0]].update([word])
    c = f.readline().strip()

    candidate = counters[c].most_common()
    candidate.sort(key=operator.itemgetter(0))
    candidate.sort(key=operator.itemgetter(1), reverse=True)
    candidate = [word for word, count in candidate[:5]]
    if len(candidate) == 0:
        print('NA')
    else:
        print(*candidate)
A,P=map(int(input().split()))
print(((A*3)+P)//2)

### FIXED CODE ###

A,P=map(int,input().split())
print(((A*3)+P)//2)
)import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
 
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(l,l[i] + l[j]) - j - 1
print(ans)

### FIXED CODE ###

import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
 
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(l,l[i] + l[j]) - j - 1
print(ans)
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = [0]+readInts()
c = [0]+readInts()

ans = -1*float("inf")
for i in range(1,n+1):
	j = p[i]
	past[j] = True
	t = [0]
	al = set()
	while j not in al:
		t.append(t[-1]+c[j])
		al.add(j)
		j = p[j]
	if t[-1]<0:
		ans = max(ans, max(t[1:k+1]))
	else:
		kuri = k//(len(t)-1)
		s = kuri*t[-1]
		ans = max(ans, max(s,s+max(t[:k-kuri*(len(t)-1)+1])))

print(ans)


### FIXED CODE ###

from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = [0]+readInts()
c = [0]+readInts()

ans = -1*float("inf")
for i in range(1,n+1):
	j = p[i]
	t = [0]
	al = set()
	while j not in al:
		t.append(t[-1]+c[j])
		al.add(j)
		j = p[j]
	if t[-1]<=0:
		ans = max(ans, max(t[1:k+1]))
	else:
		kuri =(k-1)//(len(t)-1)
		s = kuri*t[-1]
		re = k -kuri*(len(t)-1)
		ans = max(ans, max(s,s+max(t[:re+1])))

print(ans)
n,q=map(int,input().split())
tree = [set() for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].add(b)
ans=[0]*n
def add_l(x):    
    for i in list(tree[x-1]):
        add_l(i)
        tree[x-1] |= tree[i-1]

add_l(1)
#print(tree)

for i in range(q):
    
    p,x=map(int,input().split())
    ans[p-1]+=x
    if tree[p-1]:

        for j in list(tree[p-1]):
            ans[j-1]+=x
print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
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(list(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")


### 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")
l = [x+' '+y for x in ['S','H','C','D'] for y in [str(i) for i in range(1,14)]]
n = int(input())
while n > 0:
  l.remove(input())
  n += 1
for i in l:
  print(i)

### FIXED CODE ###

l = [x+' '+y for x in ['S','H','C','D'] for y in [str(i) for i in range(1,14)]]
n = int(input())
while n > 0:
  l.remove(input())
  n -= 1
for i in l:
  print(i)
s = input()
s = s.remove('/').remove('/')
if int(s) <= 20190430:
	print('Heisei')
else:
	print('TBD') 

### FIXED CODE ###

s = input()
s = s.replace('/','')
if int(s) <= 20190430:
	print('Heisei')
else:
	print('TBD')
A,B,T=int().split()
print((T//A)*B)


### FIXED CODE ###

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

print(t//a*b)
a, b=(int(i) for i in input().split())

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))


### FIXED CODE ###

a, b=(int(i) for i in input().split())

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))
N=int(input())
abc=list("abcdefghi")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)

### FIXED CODE ###

#=============================================================================
# パナソニックコンテスト D
#=============================================================================
import sys
sys.setrecursionlimit(10**8)
N=int(input())
abc=list("abcdefghij")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    a,b,c,d = map(int, input().split())
    rooms[a-1][b-1][c-1] += d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(rooms[i][j][k], end = "")
            if k != 9:
                print(" ", end="")
        print()
    if i != 3
        print("####################")


### FIXED CODE ###

rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    a,b,c,d = map(int, input().split())
    rooms[a-1][b-1][c-1] += d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(rooms[i][j][k]), end = "")
        print()
    if i != 3:
        print("####################")
t = list(input())
l = len(t)

for i in range(l):
    if t[i] == "?":
        if i == 0:
            if t[i+1] == "P":
                t[i] = "D"
                print(t[i],end="")
            else:
                t[i] = "P"
                print(t[i],end="") 
        if i == l-1:
            t[i] = "D"
            print(t[i],end="")
        elif t[i+1] == "P":
            t[i] = "D"
            print(t[i],end="")
        elif t[i+1] == "D" and t[i-1] == "P":
            t[i] = "D"
            print(t[i],end="")
        else:
            t[i] = "P"
            print(t[i],end="")
    else:
        print(t[i],end="")

### FIXED CODE ###

t = list(input())
l = len(t)

for i in range(l):
    if t[i] == "?":
        t[i] = "D"
        print(t[i],end="")
    else:
        print(t[i],end="")
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

vector<ll> a,p;
ll f(ll n,ll x){
	if(n==0){
		if(x<=0){
			return 0;
		}else{
			return 1;
		}
	}else if(x<=1+a[n-1]){
		return f(n-1,x-1);
	}else{
		return p[n-1]+1+f(n-1,x-2-a[n-1]);
	}
}

int main(){
	//source
	ll n,x;
	cin >> n >> x;
	a.push_back(1);
	p.push_back(1);
	rep(i,n){
		a.push_back(a[i]*2+3);
		p.push_back(p[i]*2+1);
	}

	cout << f(n,x) << endl;
	return 0;
}


### FIXED CODE ###

import numpy as np

n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n):
	a.append(a[i]*2+3)
	p.append(p[i]*2+1)

def f(N,X):
	if N==0:
		return 0 if X<=0 else 1
	elif X <=1+a[N-1]:
		return f(N-1,X-1)
	else:
		return p[N-1]+1+f(N-1,X-2-a[N-1])
	
print (f(n,x))


def inputList():
	a=list(map(int,input().split()))
	return a

def multisort(li,index):
	return sorted(li,key=lambda x: x[index])
N = int(input())
flag = False
for i in range(1,N):
    if i * (i+1) == 2 * N:
        flag = True
        print('Yes')
        break
if not flag:
    print('No')
else:
    print(i+1)
    S = [[] for k in range(i+1)]
    now = 0
    for k in range(1, N+1):
        l = now % (i+1)
        m = (now + 1) % (i+1)
        S[l].append(k)
        S[m].append(k)
        now = m
    for j in range(i+1):
        print(i, end = ' ')
        for n in range(i):
            if n < i-1:
                print(S[j][n], end = ' ')
            else:
                print(S[j][n])


### FIXED CODE ###

import numpy
N = int(input())
i = int(numpy.sqrt(2*N))

if i * (i+1) == 2 * N:
    print('Yes')
    print(i+1)
    S = [[] for k in range(i+1)]
    k = 1
    for now in range(0, i+1):
        for now2 in range(now+1, i+1):
            S[now].append(k)
            S[now2].append(k)
            k += 1
    for j in range(i+1):
        print(i, end = ' ')
        values = map(str, S[j])
        print(' '.join(values))
else:
    print('No')
N = int(input())
S = str(input())

res = list()

strings = [chr(ord('a').upper() + i) for i in range(26)]
for s in S:
  ind = strings.index(s) + N
  res.append(strings[ind % len(strings)])
  
print(''.join(map(str, res)))

### FIXED CODE ###

N = int(input())
S = str(input())
 
res = list()
 
strings = [chr(i) for i in range(65, 65+26)]
for s in S:
  ind = strings.index(s) + N
  res.append(strings[ind % len(strings)])
  
print(''.join(map(str, res)))
N = int(input())
X = list(map(int, input().split()))
X = [x//400 for x in X]
min_X = len(set([x for x in X if x < 8]))
max_X = min_X + len([x for x in X if x >= 8])
# この max は気づかないなあ
print(max([min_X, 1], max_X)


### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
X = [x//400 for x in X]
min_X = len(set([x for x in X if x < 8]))
max_X = min_X + len([x for x in X if x >= 8])
# この max は気づかないなあ
print(max([min_X, 1]), max_X)
h, n = map(int, input().split())

abKeys = set([])
result = [10**9] * (h+1)
for _ in range(n):
    a, b = map(int, input().split())
    result[a] = min(result[a],b)

for i in range(1,h+1):
    j = 1
    while j <= i // 2:
        result[i] = min(result[i], result[j] + result[i - j])

        j += 1


print(result[-1])


### FIXED CODE ###

h,n=map(int,input().split())

ab=[]
dp=[10**9]*(10**5)

maxA=0
for _ in range(n):
    a,b=map(int,input().split())
    dp[a]=min(dp[a],b)
    maxA=max(maxA,a)
#print(dp)
#dp[a]は、相手にaダメージを与えるときの、消耗する自分の最小HP
result=10**9
for i in range(1,h+maxA):
    #print(i,"##########")
    for k in range(1,i//2+2):
        dp[i]=min(dp[i],dp[k]+dp[i-k])
    if i>=h:
        result=min(result,dp[i])
    #print(dp)
print(result)