Harryxun/stf_run huggingface dataset:
n = int(input())
l0 = 2
l1 = 1
if n == 1:
  print(l1)
else:
  for i in range(2, n+1):
  if i == 2:
    li = l0
    lj = l1
  l = li + lj
  li = lj
  lj = l
  print(l)


### FIXED CODE ###

n = int(input())
l0 = 2
l1 = 1
if n == 1:
  print(l1)
else:
  for i in range(2, n+1):
    if i == 2:
      li = l0
      lj = l1
    l = li + lj
    li = lj
    lj = l
  print(l)
def lcm(a, b): #lcm(int, int)
    if a<b:
        a,b = b,a
    x = a*b
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return x//b
n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
ans = lcm(t[0],t[1])
for i in range(2,n):
    ans = lcm(ans,t[i])
print(ans)

### FIXED CODE ###

def lcm(a, b): #lcm(int, int)
    if a<b:
        a,b = b,a
    x = a*b
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return x//b
n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
ans = t[0]
for i in range(1,n):
    ans = lcm(ans,t[i])
print(ans)
N=int(input())
S,T=input().split("")
P=""
for i in range(N):
  P=P+S[i]+T[i]
print(P)

### FIXED CODE ###

n=int(input())
s,t=input().split(" ")
u=""
for i in range(n):
  u = u + s[i] + t[i]
print(u)
6 2
1 2
1 3
2 4
3 6
2 5
1 10
1 10

### FIXED CODE ###

N,Q=map(int,input().split())
tree={}
for i in range(N-1):
  a,b=map(int,input().split())
  if (a-1) in tree:
    tree[a-1].append(b-1)
  else:
    tree[a-1]=[b-1]
  if (b-1) in tree:
    tree[b-1].append(a-1)
  else:
    tree[b-1]=[a-1]

point=[0]*N

for i in range(Q):
  p,x=map(int,input().split())
  point[p-1]+=x

ans=[0]*N
stack=[]
stack.append([0,0,-1])
while len(stack)>0:
  nodes=stack.pop()
  node=nodes[0]
  sump=nodes[1]
  parent=nodes[2]
  sump=sump+point[node]
  ans[node]=sump
  if node in tree:
      childs=tree[node]
      for child in childs:
        if child!=parent:
          stack.append([child,sump,node])

print(*ans)
# -*- coding: utf-8 -*-

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

color = [0,0,0,0,0,0,0,0,0]

for i in range(n):
    if 1 <= a[i] <= 399:
        color[0] += 1
    elif 400 <= a[i] <= 799:
        color[1] += 1
    elif 800 <= a[i] <= 1199:
        color[2] += 1
    elif 1200 <= a[i] <= 1599:
        color[3] += 1
    elif 1600 <= a[i] <= 1999:
        color[4] += 1
    elif 2000 <= a[i] <= 2399:
        color[5] += 1
    elif 2400 <= a[i] <= 2799:
        color[6] += 1
    elif 2800 <= a[i] <= 3199:
        color[7] += 1
    elif 3200 <= a[i]:
        color[8] += 1


min_col = color[:]
min_cnt = 0
del min_col[-1]
for i in range(len(min_col)):
    if min_col[i] != 0:
        min_cnt += 1

max_cnt = min(min_cnt + color[8])
min_cnt = max(1,min_cnt)

print(min_cnt, max_cnt)

### FIXED CODE ###

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

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

color = [0,0,0,0,0,0,0,0,0]

for i in range(n):
    if 1 <= a[i] <= 399:
        color[0] += 1
    elif 400 <= a[i] <= 799:
        color[1] += 1
    elif 800 <= a[i] <= 1199:
        color[2] += 1
    elif 1200 <= a[i] <= 1599:
        color[3] += 1
    elif 1600 <= a[i] <= 1999:
        color[4] += 1
    elif 2000 <= a[i] <= 2399:
        color[5] += 1
    elif 2400 <= a[i] <= 2799:
        color[6] += 1
    elif 2800 <= a[i] <= 3199:
        color[7] += 1
    elif 3200 <= a[i]:
        color[8] += 1


min_col = color[:]
min_cnt = 0
del min_col[-1]
for i in range(len(min_col)):
    if min_col[i] != 0:
        min_cnt += 1

max_cnt = min_cnt + color[8]
min_cnt = max(1,min_cnt)

print(min_cnt, max_cnt)
n,a,b = map(int, input().split())
MOD = 10**9 + 7
allpair = pow(2,n,MOD)

def combo(n,k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= MOD

    d = 1
    for i in range(1, k+1):
        d *= i
        d %= MOD

    return (c * pow(d, mod-2, MOD)) % MOD

print((allpair - combo(n, a) - combo(n, b) - 1) % MOD)


### FIXED CODE ###

n,a,b = map(int, input().split())
MOD = 10**9 + 7
allpair = pow(2,n,MOD)

def combo(n,k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= MOD

    d = 1
    for i in range(1, k+1):
        d *= i
        d %= MOD

    return (c * pow(d, MOD-2, MOD)) % MOD

print((allpair - combo(n, a) - combo(n, b) - 1) % MOD)
A1, A2, A3 = map(int, split(input()))
total = A1 + A2 + A3
if total >= 22:
    print("bust")
else:
    print("win")

### FIXED CODE ###

A1, A2, A3 = map(int, input().split())
total = A1 + A2 + A3
if total >= 22:
    print("bust")
else:
    print("win")
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
a, b = tuple(li())
div, mod = divmod(b, a)
if mod == 0:
	return a + b
else:
	return b - a


### FIXED CODE ###

import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
a, b = tuple(li())
div, mod = divmod(b, a)
if mod == 0:
    print(a + b)
else:
    print(b - a)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
n = 10**4
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,M = list(map(int,input().split()))
a = list(map(int,input().split()))

data = {}

tmp = 0
for i in range(N):
  tmp += a[i]
  if tmp%M not in data:
    data[tmp%M] = 1
  else:
    data[tmp%M] += 1
else:
  data[0] += 1

cnt = list(data.values())
ans = 0
for i in cnt:
  if i == 0:
    continue
  else:
    ans += cmb(i,2,mod)
print(ans)

### FIXED CODE ###

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

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

S = {0 : 1}
t = 0
for i in range(N):
  t = (t + D[i]) % M
  if t in S:
    S[t] += 1
  else:
    S[t] = 1

r = 0

for i in S.values():
  r += i * (i - 1) // 2
  
print(r)
a1,a2,a3=int(input(),split())
if a1+a2+a3>=22 :
    print('bust')
elif a1+a2+a3<=21 :
    print('win')


### FIXED CODE ###

a1,a2,a3=map(int,input().split())
if a1+a2+a3>=22 :
    print('bust')
elif a1+a2+a3<22 :
    print('win')
N = int(input())
A_list = [int(item) for item in input().split()]

all_sum = sum(A_list)

F_sum_list = []

for j in range(1,N):
    F = A_list[:j]
    F_sum = sum(F)
    F_sum_list.append(F_sum)
    if F_sum >= all_sum // 2:
        break

mini = min(all_sum - 2 * F_sum_list[-2], -1*(all_sum - 2 * F_sum_list[-1]))
print(mini)

### FIXED CODE ###

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

res = 0

if x == 1:
    res += 300000
elif x == 2:
    res += 200000
elif x == 3:
    res += 100000

if y == 1:
    res += 300000
elif y == 2:
    res += 200000
elif y == 3:
    res += 100000

if x == 1 and y == 1:
    res += 400000

print(res)
from itertools import product
from collections import defaultdict


def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    m_list = defaultdict(list)

    for i in range(1,m+1):
        m_list[i].append(0)

    for data in abcd:
        for i in range(1, m+1):
            for j in range(i+1, m+1):
                if j - i == data[2]:
                    m_list[data[0]].append(i)
                    m_list[data[1]].append(j)

    ll = list(product(*m_list.values()))

    ans = 0
    for l in ll:
        tmp = 0
        for data in abcd:
            if l[data[1]-1] - l[data[0]-1] == data[2]:
                tmp += data[3]
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from itertools import combinations_with_replacement
from collections import defaultdict


def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    ll = list(combinations_with_replacement(range(1, m+1), n))

    ans = 0
    for l in ll:
        tmp = 0
        for data in abcd:
            if l[data[1]-1] - l[data[0]-1] == data[2]:
                tmp += data[3]
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()
strargs = input()

n, a, b = map(lambda x: int(x), strargs)

if (b - a) % 2 == 0:
  print(int((b - a)/2))
  
elif n - a < b - 1:
  print(n - a)

else:
  print(b - 1)

### FIXED CODE ###

strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  newB = b - a
  mid = (newB - 1)//2 + 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)
i = list(map(int, input().split()))
a=i[0]
b=i[1]
c=i[2]
import math

if a**0.5+b**0.5>c**0.5:
    print('No')
elif(math.isclose(a**0.5+b**0.5,c**0.5)):
    print('No')
else:
    print('Yes')
    

### FIXED CODE ###

i = list(map(int, input().split()))
a=i[0]
b=i[1]
c=i[2]
if a+b>c:
    print('No')
elif a**2+b**2+c**2<=2*(a*c+a*b+b*c):
    print('No')
else:
    print('Yes')
N = int(input())
l = i for i in range(1, int(input()) + 1) if i % 3 != 0 and i % 5 != 0
s = sum(l)
print(s)

### FIXED CODE ###

N = int(input())
sum=0
for i in range(1, N+1):
    if i%3!=0 and i%5!=0:
        sum += i
print(sum)
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



### FIXED CODE ###

N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = list(input())
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += member[i]*member[j]*member[k]

print(ans)
T=input()

if S==T[:len(T)-1]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S=input()
T=input()

if S==T[:len(T)-1]:
  print('Yes')
else:
  print('No')
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
info = []
for _ in range(m):
    b, c = map(int, input().split())
    info.append([b, c])
info.sort(key=lambda x: x[1], reverse=True)
# print(info, A)
index = 0
for i in range(m):
    for j in range(info[i][0]):
        if A[index] < info[i][1]:
            A[index] = info[i][1]
            index += 1
            if index == n-1:
                break
        else:
            break

ans = sum(A)
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
A = sorted(map(int, input().split()))
info = []
for _ in range(m):
    b, c = map(int, input().split())
    info.append([b, c])
info.sort(key=lambda x: x[1], reverse=True)
# print(info, A)
index = 0
for i in range(m):
    if index == n:
        break
    for j in range(info[i][0]):
        if index == n:
            break
        if A[index] < info[i][1]:
            A[index] = info[i][1]
            index += 1
        else:
            break

ans = sum(A)
print(ans)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N,M=map(int,input().split())
primes0=prime_factorize(M)
keys=list(set(primes0))
primes={}
for i in range(len(keys)):
  k=keys[i]
  primes[k]=0
  for j in range(len(primes0)):
    if primes0[j]==k:
      primes[k]+=1

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    if n < k or n < 0 or k < 0:
        return 0
    else: 
        k = min(k, n-k)
        return fac[n] * ifac[k] * ifac[n-k] % mod
 
def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

mod=10**9+7
fac,ifac = make_tables(mod,N*2)
ans=1
for i in range(len(keys)):
  ans*=cmb(N+primes[keys[i]]-1, primes[keys[i]], mod, fac, ifac)
  ans%=mod
print(ans)

### FIXED CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
 
N,M=map(int,input().split())
primes0=prime_factorize(M)
keys=list(set(primes0))
primes={}
for i in range(len(keys)):
  k=keys[i]
  primes[k]=0
  for j in range(len(primes0)):
    if primes0[j]==k:
      primes[k]+=1
 
def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    if n < k or n < 0 or k < 0:
        return 0
    else: 
        k = min(k, n-k)
        return fac[n] * ifac[k] * ifac[n-k] % mod
 
def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
 
mod=10**9+7
fac,ifac=make_tables(mod,N*10)
ans=1
for i in range(len(keys)):
  ans*=cmb(N+primes[keys[i]]-1, primes[keys[i]], mod, fac, ifac)
  ans%=mod
print(ans)
def shortie (L):
 R= L/3
 return (R**3)

L=int(input())
Shortie (L)

### FIXED CODE ###

#maximum volume problem
J = int(input()) #to take input from the user, input function is used
K = J /3   
M= K
print(M ** 3) #to print the solution of the problem
N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
for i in range(N):
	ret = ret * T[i] // gcd(ret, T[i]])
	
print(ans)

### FIXED CODE ###

N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
for i in range(N):
	ans = ans * T[i] // gcd(ans, T[i])
	
print(ans)
n, k = map(int,input().split())
def replace(n,k):
    n = min(n,abs(n - k))
    if n <= abs(n - k):
        return n,k
    else:
        return replace(n, k)
if k == 1:
    print(0)
else:
    n1, k1 = replace(n,k)
    print(n1)

### FIXED CODE ###

n, k = map(int,input().split())
nk = n % k
print(min(nk,abs(nk - k)))
num = input()
if num < 1000:
  print('ABC')
else:
  print('ABD')

### FIXED CODE ###

num = int(input())
if num < 1000:
   print('ABC')
else:
   print('ABD')
x,m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:-(n-1)]))

### FIXED CODE ###

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

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:m-n]))
s=input()
k=int(input())
chain_hajime=0
chian_owa=0
for i in range(len(s)):
    if s[0]==s[i]:
        chain_hajime+=1
    else: break
for i in range(len(s)):
    if s[-1]==s[-(i+1)]:
        chian_owa+=1
    else: break
print(chain_hajime)
print(chain_owa)
import re
def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """

    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]
a=list(nchars(s, 2))
b=0
for i in a:
    b+=len(i)//2


if len(set(s))==1:
    print(len(s)*k//2)
elif s[0]!=s[-1]:
    print(b*k)
else:
    print(b*k-(chain_hajime//2+chain_owa//2-(chain_hajime+chain_owa)//2)*(k-1))

### FIXED CODE ###

s=input()
k=int(input())
chain_hajime=0
chain_owa=0
for i in range(len(s)):
    if s[0]==s[i]:
        chain_hajime+=1
    else: break
for i in range(len(s)):
    if s[-1]==s[-(i+1)]:
        chain_owa+=1
    else: break
#print(chain_hajime)
#print(chain_owa)
import re
def nchars(s, n):
    """文字列 s に、同じ文字が n 個以上連続している部分文字列を見つける
    """

    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))  # カンマを取ると n 個ちょうどになる
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]
a=list(nchars(s, 2))
b=0
for i in a:
    b+=len(i)//2


if len(set(s))==1:
    print(len(s)*k//2)
elif s[0]!=s[-1]:
    print(b*k)
else:
    print(b*k-(chain_hajime//2+chain_owa//2-(chain_hajime+chain_owa)//2)*(k-1))
a, b = int(input())

if (a*b) % 2:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

a, b = map(int, input().split())
 
if (a*b) % 2 :
  print('Odd')
else:
  print('Even')
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(i+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



### FIXED CODE ###

N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = list(input())
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += member[i]*member[j]*member[k]

print(ans)
a,b=[int(i) for i in inpput().split()]
a,b=min(a,b),max(a,b)
c=b-a
if c%2==0:
  print(c//2)
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

a,b=[int(i) for i in input().split()]
a,b=min(a,b),max(a,b)
c=b+a
if c%2==0:
  print(c//2)
else:
  print("IMPOSSIBLE")
s=input()

i=0
flug=0
for x in range(1,len(s)+1):
    if(x%2==1):
        if(s[x] =='L'):
            flug=1
            break
    else:
        if(s[x] =='R'):
            flug=1
            break

if(flug==1):
    print("No")
else:
    print("Yes")

### FIXED CODE ###

s=input()

i=0
flug=0
for x in range(1,len(s)+1):
    if(x%2==1):
        if(s[x-1] =='L'):
            flug=1
            break
    else:
        if(s[x-1] =='R'):
            flug=1
            break

if(flug==1):
    print("No")
else:
    print("Yes")
N = int(input())
n = N
fN = 0
while n > 9:
  fN += n%10
  n //= 10
if N % fN == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = int(input())
n = N
fN = 0
while n >= 10:
  fN += n%10
  n //= 10
fN += n
  
if N % fN == 0:
  print('Yes')
else:
  print('No')
s1,s2,s3=map(str,input().split().capitalize()) #文字列
print(s1[0]+s2[0]+s3[0])

### FIXED CODE ###

s1,s2,s3=map(str,input().upper().split()) #文字列
print(s1[0]+s2[0]+s3[0])
A, B, C, D, E, F = map(int, input().split())
density = 0
for i in range(F//(100*A) +1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*A*i + 100*B*j
        if water == 0:
            continue
        for k in range((F-water)//C+1):
            for l in range((F-water-C*k)//D+1):
                sugar = C*k + D*l
                if density < sugar/(sugar + water) and sugar <= (E/100)*water:
                    density = sugar/(sugar + water)
                    ans = [sugar+water, sugar]
print(ans[0], ans[1])

### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
density = 0
for i in range(F//(100*A) +1):
    for j in range((F-100*A*i)//(100*B)+1):
        water = 100*A*i + 100*B*j
        if water == 0:
            continue
        for k in range((F-water)//C+1):
            for l in range((F-water-C*k)//D+1):
                sugar = C*k + D*l
                if density <= sugar/(sugar + water) and sugar <= (E/100)*water:
                    density = sugar/(sugar + water)
                    ans = [sugar+water, sugar]
print(ans[0], ans[1])
n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[float('inf')]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy]!=float('inf'):
            continue
        else:
            set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])


### FIXED CODE ###

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


n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[None]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy] is not None:
            continue
        set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])
N,A=map(int,input().split())
x=input().split()
for i in range(N):
    x[i]=int(x[i])
ans=0
y=[0 for i in range(N)]
def check(ans,y):
    ave=0
    for i in range(N):
        ave+=x[i]*y[i]
    if sum(y)!=0:
        ave=ave/sum(y)
    if sum(y)==0:
        ave=0
    if ave==A:ans+=1
    return ans

def branch(ans,now,pre,y):
    if now==0 and pre==-1:
        if y[now]==0:
            y[now]=1
            now+=1
            pre=1
            ans,now,pre=branch(ans,now,pre,y)
        elif y[now]==1:
            return ans,now,pre

    elif now==N-1:
        ans,now,pre=last(ans,now,pre,y)
        ans,now,pre=branch(ans,now,pre,y)
    
    elif now!=0 and pre==-1:
        if y[now]==0:
            y[now]=1
            pre=1
            now+=1
            ans,now,pre=branch(ans,now,pre,y)
        elif y[now]==1:
            y[now]=0
            now-=1
            ans,now,pre=branch(ans,now,pre,y)
    elif pre==1 and now!=N-1:
        now+=1
        ans,now,pre=branch(ans,now,pre,y)
    return ans,now,pre

def last(ans,now,pre,y):
    y[-1]=0
    ans = check(ans,y)
    y[-1]=1
    ans = check(ans,y)
    y[-1]=0
    pre=-1
    now-=1
    return ans,now,pre
now=0
pre=1
ans,now,pre=branch(ans,now,pre,y)
print(ans)

### FIXED CODE ###

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

for i in range(N):
    x[i]=int(x[i])
X=max(max(x),A)
for i in range(N):
    x[i]=x[i]-A
dp=[[0 for t in range(2*N*X+1)] for j in range(N+1)]

for j in range(N+1):
    for t in range(2*N*X+1):
        if j==0 and t==N*X:dp[j][t]=1
        elif j>=1:
            if t-x[j-1]<0 or t-x[j-1]>2*N*X:
                dp[j][t]=dp[j-1][t]
            elif t-x[j-1]>=0 and t-x[j-1]<=2*N*X:
                dp[j][t]=dp[j-1][t]+dp[j-1][t-x[j-1]]
print(dp[N][N*X]-1)
#http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
s = input().split()
a = int(s[0])
b = int(s[1])
c = (a*b)/2
if c =! int(c):
  print('Odd')
else:
  print('Even')

### FIXED CODE ###

s = input().split()
a = int(s[0])
b = int(s[1])
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')
s = input()
k = int(input())
cnt = 0
flag = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    cnt += 1
    if i-1 >=0 and s[i-1] == s[i] and flag == 0:
      cnt -= 1
      flag = 1
    else:
      flag = 0
  else:
    flag = 0
tmp = 0
if len(s)%2 and (s[0] == s[1] == s[-1] or s[0] == s[-2] == s[-1]):
  tmp = k//2
print(cnt*k + tmp)

### FIXED CODE ###

from itertools import groupby

s = input()
k = int(input())
a = [sum(1 for _ in g) for _, g in groupby(s)]
if len(a) == 1:
  print(len(s) * k // 2)
else:
  ans = sum(x // 2 for x in a) * k
  if s[0] == s[-1] and a[0] & a[-1] & 1:
    ans += k - 1
  print(ans)