Harryxun/stf_run huggingface dataset:
import collections as c
 
d=c.defaultdict(list)
n=int(input())
for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
 
def DFS(point,d,cost,TFlist): #入力と同じindex系
    for s in d[point]:
        try:
            p=s[0]
            c=s[1]+cost[point]
            if TFlist[p-1]:
                continue
            cost[p]+=c
            TFlist[p-1]=1
            DFS(p,d,cost,TFlist)
        except KeyError:
            continue
 
cost=[None]+[0 for i in range(n)]
q,k=map(int,input().split())
TFlist=[0 for i in range(n)]
TFlist[k-1]=1
DFS(k,d,cost,TFlist)
 
for t in range(q):
    a,b=map(int,input().split())
    print(cost[a]+cost[b])

### FIXED CODE ###

from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()

d=defaultdict(list)
n=int(input())

for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})

def DIJKSTRA(point,d):
    cost      = {node:float("inf") for node in d.keys()}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

q,k=map(int,input().split())
y=DIJKSTRA(k,d)

for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])
from sys import stdin, exit

input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()


def dfs(node):
    if len(graph[node]) == 0:
        dp[node] = 0
        return 0
    if dp[node] != -1: return dp[node]
    ans = 0
    for i in graph[node]:
        ans = max(ans, dfs(i)+1)
    dp[node] = ans
    return ans


n, m = mi()
graph= [[] for i in range(n+1)]
for i in range(m):
    a, b = mi()
    graph[a].append(b)
dp = [-1]*(n+1)
for i in range(1, n+1):
    if dp[i] == -1:
        dfs(i)
print(max(dp))

### FIXED CODE ###

from sys import stdin, exit, setrecursionlimit
setrecursionlimit(100000000)

input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()


def dfs(node):
    if len(graph[node]) == 0:
        dp[node] = 0
        return 0
    if dp[node] != -1: return dp[node]
    ans = 0
    for i in graph[node]:
        ans = max(ans, dfs(i)+1)
    dp[node] = ans
    return ans


n, m = mi()
graph= [[] for i in range(n+1)]
for i in range(m):
    a, b = mi()
    graph[a].append(b)
dp = [-1]*(n+1)
for i in range(1, n+1):
    if dp[i] == -1:
        dfs(i)
print(max(dp))
s = list(str(input()))
t = list(str(input()))



def judge(S,T):
    start = [-1 for i in range(26) ] 
    goal = [-1 for i in range(26)]
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')
        if start[a] != -1 or goal[b] != -1:
            if start[a]!= b or goal[b] !=a:
                print("No")
                break
        else:
            start[a] = b
            goal[b] =a
        if i==len(S)-1:
            print("Yes")
            
            
 judge(s,t)           

### FIXED CODE ###

s = list(str(input()))
t = list(str(input()))

def judge(S,T):
    start = [-1 for i in range(26) ] 
    goal = [-1 for i in range(26)]
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')
        if start[a] != -1 or goal[b] != -1:
            if start[a]!= b or goal[b] !=a:
                print("No")
                break
        else:
            start[a] = b
            goal[b] =a
        if i==len(S)-1:
            print("Yes")
            
judge(s,t)
def e_flatten_prime_factorization(MOD=10**9 + 7):
    from collections import defaultdict
    N = int(input())
    A = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    lcm_prime = defaultdict(int)
    for a in A:
        for base, exp in prime_factorization_dict(a).items():
            lcm_prime[base] = max(lcm_prime[base], exp)
    lcm = 1
    for base, exp in lcm_prime.items():
        lcm *= pow(base, exp, MOD)
        lcm %= MOD
    coefficient = sum(pow(a, MOD - 2, MOD) for a in A)
    return (lcm * coefficient) % MOD

print(e_flatten())

### FIXED CODE ###

def e_flatten(MOD=10**9 + 7):
    from fractions import gcd
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    def lcm(a, b):
        return a * b // gcd(a, b)

    def inv(n, mod=MOD):
        return pow(n, mod - 2, mod)

    l = reduce(lcm, A) % MOD
    ans = [(l * inv(a)) % MOD for a in A]
    return sum(ans) % MOD

print(e_flatten())
while True:
    try:
        num = int(input())
        lst = list(map(int, input().split()))
        point = lst[-1]
        ans = 0
        for n in lst[-1::-1]:
            point = min(point, n)
            ans += point
        ans lst[0]
        print(ans)
    except:
        break

### FIXED CODE ###

while True:
    try:
        num = int(input())
        lst = list(map(int, input().split()))
        ans = 0
        ans += lst[-1] + lst[0]
        if num == 2:
            print(ans)
            continue
        for i in range(1, num-1):
            ans += min(lst[i], lst[i-1])
        print(ans)
    except:
        break
k=int(input())
s=input()

a=len(s)

if k>=a:
print(s)

else :
print(s[:k]+"...")


### FIXED CODE ###


k= int(input())
s= input()

a=len(s)

if k >= a:
  print(s)

else :
  print(s[:k]+"...")
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import numpy as np
N,S = map(int,input().split())
MOD = 998244353
A = list(map(int,input().split()))
dp = np.zeros(S+1,dtype = np.int64)
dp[0] = 2
if A[0] <= S:
    dp[A[0]] = 1
for i in range(1,N):
    a = A[i]
    p = (dp*2) %= MOD
    if a > S:
        continue
    else:
        p[a:] += dp[:-a]
    dp = p % MOD
print(dp[-1])

    





### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]

N,S = map(int,input().split())
MOD = 998244353
A = list(map(int,input().split()))
dp = [[0]*(S+1) for _ in range(N)]
if A[0] <= S:
    dp[0][A[0]] = 1
dp[0][0] = 2
for i in range(1,N):
    a = A[i]
    for j in range(S+1):
        dp[i][j] += 2*dp[i-1][j] % MOD
        if j - a < 0:
            continue
        else:
            dp[i][j] += dp[i-1][j-a]
        dp[i][j] %= MOD
print(dp[N-1][S])
n,k = map(int, input().split())
s = input()
ans = [s[:k],s[k].lower(),s[k+1:]]
print(''.join(ans))




### FIXED CODE ###

n,k = map(int, input().split())
s = input()
ans = [s[:k-1],s[k-1].lower(),s[k:]]
print(''.join(ans))
c = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = [0]*(n1+1)
    R = [0]*(n2+1)
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = float("inf")
    R[n2] = float("inf")
    i = 0
    j = 0
    for k in range(left,right): 
        if L[i] <= R[j]:
            c = c+1
            A[k] = L[i]
            i = i + 1
        else:
            c = c+1
            A[k] = R[j]
            j = j + 1

def mergeSort(A, left, right):
  if left+1 < right:
    mid = (left + right)//2;
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)
    
### Main Function
n = int(input())
S = list(map(int,input().split()))


mergeSort(S, 0, n)

print(S)
print(c)



### FIXED CODE ###

def merge(A,left,mid,right):
    n1=mid-left
    n2=right-mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    """
    L=[0]*(n1+1)
    R=[0]*(n2+1)
    for i in range(n1):
        L[i]=A[left+i]
    for i in range(n2):
        R[i]=A[mid+i]
    L[n1]=float("inf")
    R[n2]=float("inf")
    """
    i=0
    j=0
    for k in range(left,right):
        global cnt
        cnt+=1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(input().split())
for i in range(n):
    S[i]=int(S[i])
cnt=0
mergeSort(S,0,n)
for i in range(n):
    if i==n-1:
        print(S[i])
    else:
        print(S[i],end=" ")
print(cnt)
n = int(input())
a = [int(input()) for i in range(n)]
print(-(-n // min(a)) + 4)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(5)]
print(-(-n // min(a)) + 4)
import numpy as np
X=int(input())
Y=int(np.sqrt(X))+1
max=1
for j in range(2,Y+1):
    for i in range(1,Y+1):
        if i**j<=X and i**j>max:
            max=i**j
print(max)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
ans="No"
ab=a-b
if ab<0:
    ab=-ab
bc=b-c
if bc<0:
    bc=-bc
ac=a-c
if ac<0:
    ac=-ac
if (ab<=d and bc<=d)or (ac<=d):
    ans="Yes"
print(ans)
v = []
v = str(input()).split()
dif_max = -200000

for i in range(len(v)):
    v[i] = int(v[i])

l = v[0]

for i in range(2, l + 1, 1):
    for j in range(i + 1, l + 1, 1):
        dif = v[j] - v[i]
        dif_max = dif if dif_max < dif else dif_max

print("{}".format(dif_max))

### FIXED CODE ###

cnt = int(input())
dif_max = -1000000000
v_min = 1000000000

for i in range(cnt):
    buf = int(input())
    if i > 0:
        dif_max = dif_max if buf - v_min < dif_max else buf - v_min
    v_min = buf if buf < v_min else v_min
print(dif_max)
def suuji(a,b):

print a * b ,
print a * 2 + b * 2

### FIXED CODE ###


l = map(int, raw_input().split())
 
print "%d %d" % (l[0]*l[1], (l[0]+l[1])*2)
import numpy as np

n = int(input())
a = input().split()

c1 = a.count('1')
c2 = a.count('2')
c3 = a.count('3')

# dp =[ [[-1] * (n+1) for _ in range(n+1)] for __ in range(c3+1)]
# dp = np.full((c3+1, c2+c3+1, n+1), -1.0)
# dp[0][0][0] = 0

from functools import lru_cache
@lru_cache(maxsize=None)
def calc_dp(t3,t2,t1):
    # global dp
    # if(dp[t3][t2][t1] > -1):
    #     return dp[t3][t2][t1]
    if(t3+t2+t1==0):
        return 0

    temp = 0
    if(t3 > 0):
        temp += calc_dp(t3-1,t2+1,t1) * t3/(t1+t2+t3)
    if(t2 > 0):
        temp += calc_dp(t3,t2-1,t1+1) * t2/(t1+t2+t3)
    if(t1 > 0):
        temp += calc_dp(t3,t2,t1-1) * t1/(t1+t2+t3)
    temp = temp + n/(t1+t2+t3)

    # dp[t3][t2][t1] = temp
    return temp

print(calc_dp(c3,c2,c1))

### FIXED CODE ###

n = int(input())
a = input().split()

c1 = a.count('1')
c2 = a.count('2')
c3 = a.count('3')

dp =[ [[0] * (n+1) for _ in range(c3+c2+1)] for __ in range(c3+1)]
# dp[0][0][0] = 0

for i in range(c3+1):
    for j in range(c3+c2+1-i):
        for k in range(n+1-i-j):
            if(i+j+k == 0):
                dp[i][j][k]=0
            else:
                temp = 0
                if(i > 0):
                    temp += dp[i-1][j+1][k] * i/(k+j+i)
                if(j > 0):
                    temp += dp[i][j-1][k+1] * j/(k+j+i)
                if(k > 0):
                    temp += dp[i][j][k-1] * k/(k+j+i)
                dp[i][j][k] = temp + n/(k+j+i)

print(dp[c3][c2][c1])
ans = 0
first_b = 0
last_a = 0
same = 0

N = int(input())

for i in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B" and s[-1] == "A":
        same +=1

ans += min(first_b, last_a)
if same > 0 and first_b ==  last_a and first_b = same:
    ans -=1
 print(ans)

### FIXED CODE ###

ans = 0
first_b = 0
last_a = 0
same = 0

N = int(input())

for i in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B" and s[-1] == "A":
        same +=1

ans += min(first_b, last_a)
if same > 0 and first_b ==  last_a and first_b == same:
    ans -=1
print(ans)
#n = a の本:m = b の本
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = 0
z = 0
i = 0
j = 0

while p < k:
    if a[i] <= b[j]:
        p += a[i]
        z += 1
        i += 1
    else:
        p += b[j]
        z += 1
        j += 1
    if p > k:
        z -= 1

print(z)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [0]*(n+1)
d = [0]*(m+1)
for i in range(n):
    c[i+1] = a[i]+c[i]
for i in range(m):
    d[i+1] = b[i]+d[i]
for i in range(m+1)[::-1]:
    if d[i] <= k:
        x = i
        break
ans = x
for i in range(1,n+1):
    while c[i] + d[x] > k:
        if x >= 1:
            x -= 1
        else:
            break
    if c[i] + d[x] <= k:
        ans = max(ans,i+x)
print(ans)
import sys

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

# 1st. get Num

Num = int(raw_input())

p_dbg('Num : ' + str(Num))

square_max = 1

for i in range(1, Num):
    tmp = i * i
    p_dbg(str(i) + str(square_max))
    if(tmp <= Num):
        square_max = tmp
    else:
        break

print square_max


### FIXED CODE ###

import sys

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

# 1st. get Num

Num = int(raw_input())

p_dbg('Num : ' + str(Num))

square_max = 1

# MEMORY OVER
# for i in range(1, Num):
#     tmp = i * i
#     p_dbg(str(i) + str(square_max))
#     if(tmp <= Num):
#         square_max = tmp
#     else:
#         break

i = 1
tmp = 1
while tmp <= Num:
    p_dbg(str(i) + ':' + str(square_max))
    square_max = tmp
    tmp = i*i
    i = i+1

print square_max
A, B, K = map(int, input().split())
if B - A < 2 * K:
    print(*range(A, B + 1))
else:
    print(*range(A, A + K), *range(B - K + 1, B + 1))


### FIXED CODE ###

A, B, K = map(int, input().split())
if B - A < 2 * K:
    # ans = [*range(A, B + 1)]
    ans = list(range(A, B + 1))
else:
    # ans = [*range(A, A + K), *range(B - K + 1, B + 1)]
    ans = list(range(A, A + K)) + list(range(B - K + 1, B + 1))
for v in ans:
    print(v)
import re
s = input()
pa = s.replace('x', '')
if pa != pa[::-1]:
    print(-1)
else:
    ans = 0
    sp = s.split(pa[len(pa) // 2])
    for r, l in zip(re.split(r'[a-wyz]', sp[0]),
                    re.split(r'[a-wyz]', sp[-1])[::-1]):
        ans += abs(len(r) - len(l))
    print(ans)

### FIXED CODE ###

import re
s = input()
pa = s.replace('x', '')
if pa != pa[::-1]:
    print(-1)
else:
    ans = 0
    sp = re.split(r'[a-wyz]', s)
    for r, l in zip(sp, sp[::-1]):
        ans += abs(len(r) - len(l))
    print(ans // 2)
n = input()

for "9" in n:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
  
if "9" in n:
  print("Yes")
else:
  print("No")
import numpy as np
n,s = map(int, input().split( ))

a = np.array(list(map(int, input().split( ))))

dp = np.array([[0]*(s+1) for i in range(n)])
dp[0][0] = 1
dp[0][a[0]] = 1

ans = 0

for i in range(1,n):
    dp[i] += dp[i-1]
    dp[i][a[i]:] += dp[i-1][:-a[i]]
    dp[i][0] +=1
    dp[i][a[i]] += 1
    ans += dp[i][s]
print(ans)

### FIXED CODE ###

import numpy as np
n,s = map(int, input().split( ))

a = np.array(list(map(int, input().split( ))))

dp = np.array([[0]*3001 for i in range(n)])
dp[0][0] = 1
dp[0][a[0]] = 1

ans = 0
mod = 998244353
for i in range(1,n):
    dp[i] += dp[i-1]
    dp[i][a[i]:] += dp[i-1][:-a[i]]
    dp[i][0] +=1
    dp[i][a[i]] += 1
    dp[i]%=mod
    ans += dp[i][s]
print(ans%mod)
def check_max_coin(a,b):
  max_coin = 0
  for i in range(1:3):
    if a < b :
      max_coin += b 
    else:
      max_coin += a      
  print(max_coin)
  
a, b = map(int, input().split())
check_max_coin(a,b)

### FIXED CODE ###

def check_max_coin(a,b):
  max_coin = 0
  for i in range(1,3):
    if a < b :
      max_coin += b 
      b-=1 
    else:
      max_coin += a  
      a-=1    
  print(max_coin)
  
a, b = map(int, input().split())
check_max_coin(a,b)
from statistics import mean, median,variance,stdev
import sys
import math

#a = input().split()
#y = input().split()
a = input()

x = int(input())
y = int(input())

x=-1
y=-1

print(x*y)


### FIXED CODE ###

from statistics import mean, median,variance,stdev
import sys
import math

a = input().split()
#y = input().split()

x = int(a[0])
y = int(a[1])
x-=1
y-=1
print(x*y)
import sys

X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

comp = 101

for i in range(1, 101):
    x = abs(X - i)
    if x == comp:
        break
    if comp > x and i not in p and:
        comp = x
        result = i

print(result)

### FIXED CODE ###

import sys

X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)
    sys.exit()

comp = 101
for i in range(102):
    x = abs(X - i)
    if comp > x and i not in p:
        comp = x
        result = i

print(result)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
k = int(input())
#3つとも違う数字
s3=0
for a in range(3,k+1):
    for b in range(2,k):
        for c in range(1,k-1):
            if c<b<a:
                s3+=gcd(gcd(b,c),a)
#2種類
s2 = 0
for a in range(2,k+1):
    for b in range(1,k):
        if b<a:
            s2+=gcd(a,b)
s = s3*6 + s2*6 +k*(k+1)/2
print(int(s)

### FIXED CODE ###

k = int(input())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

s3=0
for a in range(3,k+1):
    for b in range(2,k):
        for c in range(1,k-1):
            if c<b<a:
                s3+=gcd(gcd(b,c),a)
s2 = 0
for a in range(2,k+1):
    for b in range(1,k):
        if b<a:
            s2+=gcd(a,b)
s = s3*6 + s2*6 +k*(k+1)/2
print(int(s))
n = int(input())
_a = input().split()

a = []

x = []

for i in range(n):
  a.append(2*int(_a[i]))
  x.append(0)
  
for i in range(1, n):
  a[i] -= a[i-1]

x[n-1] = a[n-1] // 2

for i in range(n-2, -1, -1):
  if i%2==0:
    x[i] = a[i] - x[n-1]
  else:
    x[i] = a[i] + x[n-1]
    
ans = str(x[n-1]) + ' '
for i in range(n-1):
  ans += str(x[i]) + ' '
  

print(ans[:-1])


### FIXED CODE ###

nab = input().split()

n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

print(min(a*n, b))
usrInput = {}
for n in range(6):
  append.usrInput = input()

for l in range(5):
  for m in range(5):
    if abs(int(usrInput[l])-int(usrInput[m])) > usrInput[6]:
      flag = True

if flag:
  print(":(")
else:
  print("Yay!")

### FIXED CODE ###

usrInput = []
flag = False
for n in range(6):
    usrInput.append(int(input()))

for l in range(5):
    for m in range(5):
        if abs(int(usrInput[l]) - int(usrInput[m])) > usrInput[5]:
            flag = True

if flag:
    print(":(")
else:
    print("Yay!")
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    j =0
    if i < k:
        while i *(2**j) < k:
            j += 1
        ans +=(1/n)*/(2**j)
    else:
        ans += (1/n)
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    j = 0
    if i < k:
        while i*(2**j) < k:
            j +=1
        ans += (1/n) *1/(2**j)
    else:
        ans += (1/n)
print(ans)
N, M = map(int, input().split())
acc = [False] * N
pen = 0
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S[0] == 'A':
        acc[p] = True
    else:
        if not acc[p]:
            pen += 1
print('{} {}'.format(sum(acc), pen))

### FIXED CODE ###

import numpy as np

def main():
    C = input()
    print('{}'.format(chr(ord(C) + 1)))


if __name__ == '__main__':
    main()
S=input()
Sn=0
for i in range(1, 10):
	if i > len(S):break
	Sn+=int(S[-i])
ans = "No"
if int(S) % Sn == 0:ans = "Yes"

print(ans)

### FIXED CODE ###

S=input()
Sn=0
for i in range(1, 10):
	if i > len(S):break
	Sn+=int(S[-i])
ans = "No"
if Sn == 0 or int(S) % Sn == 0:ans = "Yes"

print(ans)
def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for row in r:
				row[:ix] = [False]*ix
		elif a == 2:
			for row in r:
				row[ix:] = [False]*ix
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()

### FIXED CODE ###

def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for i in range(h):
				for j in range(ix):
					r[i][j] = False
		elif a == 2:
			for i in range(h):
				for j in range(ix, w):
					r[i][j] = False
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()
n = int(input())
lens = list(map(int,input().split()))
items = set[lens]
items = list(items).sort(reverse = True)
cnt = 0
for j in items:
  if j >= 4 and cnt == 0:
    print(j**2)
    break
  elif j >= 2 and cnt == 0:
    cnt = j
  elif j >= 2 and cnt != 0:
    print(cnt * j)
    break
else:
  print(0)

### FIXED CODE ###

import collections
 
n = int(input())
lens = list(map(int,input().split()))
lens = collections.Counter(lens)
lens = sorted(lens.items(), key=lambda x:x[0], reverse = True)
cnt = 0
for j in lens:
  if j[1] >= 4 and cnt == 0:
    print(j[0]**2)
    break
  elif j[1] >= 2 and cnt == 0:
    cnt = j[0]
  elif j[1] >= 2 and cnt != 0:
    print(cnt * j[0])
    break
else:
    print(0)
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
c.append(0)
max=0

for i in range(1,N+1):
    max=max+b[a[i]]+c[a[i-1]]
print(max)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
max=sum(b)

for i in range(N-1):
    if a[i]==a[i+1]-1:
            max+=c[a[i]-1]
print(max)