Harryxun/stf_run huggingface dataset:
from collections import Counter
N, P = map(int, input().split())
S = input()
L = len(str(P))
M = []
for i in range(10 ** (L+1)):
    M.append(i % P)

q = Counter([int(S[i:L-1]) for i in range(L-1)])
q[0] += 1
ans = 0
for i in range(L-1, N):
    nq = Counter()
    n = int(S[i])
    for a, c in q.items():
        s = M[a * 10 + n]
        if s == 0:
            ans += c
        nq[s] += c
    nq[0] += 1
    q = nq
print(ans)

### FIXED CODE ###

from collections import Counter
N, P = map(int, input().split())
S = input()

ans = 0
if P in [2, 5]:
    for i, c in enumerate(S):
        if int(c) % P == 0:
            ans += i + 1
else:
    ct = Counter()
    ct[0] = 1
    prevmod = 0
    mods = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    for i in range(N-1, -1, -1):
        n = int(S[i])
        mod = (mods[n] + prevmod) % P
        ans += ct[mod]
        ct[mod] += 1
        prevmod = mod
        mods = [10 * a % P for a in mods]
print(ans)
a = input()
b = input()
c = input()
if a+b==c or a==b+c or a+c==b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c = map(int, input().split())
if a+b==c or a==b+c or a+c==b:
  print("Yes")
else:
  print("No")
import sys
input = sys.stdin.readline
import numpy as np

N, Q = list(map(int, input().split()))
graph = [[] for i in range(N)]
# 最初にroot pointを定めて:
# graph構造に大して点を与える...
for i in range(N-1):
    a, b = list(map(int, input().split()))
    graph[a-1].append(b-1)

points = np.zeros(N, dtype=int)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    points[p-1] += x

visited = np.zeros(N, dtype=bool)
tot_points = np.zeros(N, dtype=int)
tot_points[0] = points[0]
top_nodes = np.full(N, -1, dtype=int)

nodes = graph[0]
top_nodes[nodes] = 0
old_node = 0
visited[0] = True


def dfs(old_node, node):
    if visited[node]:
        return
    tot_points[node] = tot_points[old_node] + points[node]
    visited[node] = True
    nodes = graph[node]
    while len(nodes):
        dfs(node, nodes.pop())
while len(nodes):
    dfs(0, nodes.pop())
    

for x in tot_points.tolist():
    print(x, end=" ")
    
    

### FIXED CODE ###

import sys
from queue import deque
input = sys.stdin.readline

def main():
    N, Q = list(map(int, input().split()))
    graph = [[] for i in range(N)]
    # 最初にroot pointを定めて:
    # graph構造に大して点を与える...
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    
    points = [0] * N
    for _ in range(Q):
        p, x = list(map(int, input().split()))
        points[p-1] += x
    
    visited = [False] * N
    
    nodes = deque([0])

    while nodes:
        node = nodes.pop()
        visited[node] = True
        for _node in graph[node]:
            if visited[_node]:
                continue
            points[_node] += points[node]
            nodes.append(_node)
    
    print(*points)
    
main()
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(pow(P,(1/N))))):
    tmp=i**4
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)

### FIXED CODE ###

import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)
def solve():
    for i in range(1, W):
        for j in range(1, H):
            if s[i][j] == "#":
                if s[i + 1][j] == "." and s[i][j + 1] == "." and s[i-1][j] == "." and s[i][j-1] == ".":
                    print("No")
                    return;
    else:
        print("Yes")


H, W = [int(i) for i in input().split()]
s = [["."] * (W + 2)]
for _ in range(H):
    sh = ["."] + list(input()) + ["."]
    s.append(sh)
s.append([["."] * (W + 2)])
solve()





### FIXED CODE ###

def solve():
    for i in range(1, H):
        for j in range(1, W):
            if s[i][j] == "#":
                if s[i + 1][j] == "." and s[i][j + 1] == "." and s[i-1][j] == "." and s[i][j-1] == ".":
                    print("No")
                    return;
    else:
        print("Yes")


H, W = [int(i) for i in input().split()]
s = [["."] * (W + 2)]
for _ in range(H):
    sh = ["."] + list(input()) + ["."]
    s.append(sh)
s.append([["."] * (W + 2)])
solve()
import numpy as np
 
a1,a2,a3 = map(int,input().split())
a4,a5,a6 = map(int,input().split())
a7,a8,a9 = map(int,input().split())
 
a = np.array([[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]])
 
n = int(input)
for i in range(n):
  b = int(input())
  np.where(a == b,0,a)

if np.sum(a[1,:]) == 0:
  print("Yes")
elif  np.sum(a[2,:]) == 0:
  print("Yes")
elif  np.sum(a[3,:]) == 0:
  print("Yes")
elif  np.sum(a[:,1]) == 0:
  print("Yes")
elif  np.sum(a[:,2]) == 0:
  print("Yes")
elif  np.sum(a[:,3]) == 0:
  print("Yes")
elif a[1,1] + a[2,2] + a[3,3] == 0:
  print("Yes")
elif a[3,1] + a[2,2] + a[1,3] == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import numpy as np

a1,a2,a3 = map(int,input().split())
a4,a5,a6 = map(int,input().split())
a7,a8,a9 = map(int,input().split())

a = np.array([[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]])

n = int(input())
for i in range(n):
  b = int(input())
  a = np.where(a == b, 0, a)

if a[0,0] + a[0,1] + a[0,2] == 0:
  print("Yes")
elif a[1,0] + a[1,1] + a[1,2] == 0:
  print("Yes")
elif a[2,0] + a[2,1] + a[2,2] == 0:
  print("Yes")
elif a[0,0] + a[1,0] + a[2,0] == 0:
  print("Yes")
elif a[0,1] + a[1,1] + a[2,1] == 0:
  print("Yes")
elif a[0,2] + a[1,2] + a[2,2] == 0:
  print("Yes")
elif a[0,0] + a[1,1] + a[2,2] == 0:
  print("Yes")
elif a[2,0] + a[1,1] + a[0,2] == 0:
  print("Yes")
else:
  print("No")
import sys

for line in sys.stdin
 n =map(int,line.split())
 a = n[0]+n[1]
 print len(str(a))

### FIXED CODE ###

import sys

for line in sys.stdin:
 n =map(int,line.split())
 a = n[0]+n[1]
 print len(str(a))
N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= N and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        break
    else:
        for j in range(M):
            field[i][j] = reverse(field[i][j])
            now = sum(map(sum,field))

print("No")



### FIXED CODE ###

N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if N - 2 * i ==0:
        for j in range(M):
           now += M
    elif (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= M and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        print("No")
        exit(0)
    else:
        now += M
n, k = [int(j) for j in input().split(' ')]
p = input().split(' ')

p.sort()
sum = 0

for i in range(0,k):
  sum+=p[i]
  
print(sum)

### FIXED CODE ###

n, k = [int(j) for j in input().split(' ')]
p = [int(j) for j in input().split(' ')]
 
p.sort()
sum = 0
 
for i in range(0,k):
  sum+=p[i]
  
print(sum)
n,m,q = map(int, raw_input().split(' ')) #2 3 -10
bis = map(int, raw_input().split(' '))
c = 0
for _ in range(m):
	if sum([u*v for u,v in zip(map(int,raw_input().split(' ')),bis)]) + q > 0:
		c+=1
print c


### FIXED CODE ###

n,m,q = map(int, raw_input().split(' ')) #2 3 -10
bis = map(int, raw_input().split(' '))
c = 0
for _ in range(n):
	if sum([u*v for u,v in zip(map(int,raw_input().split(' ')),bis)]) + q > 0:
		c+=1
print c
import math
input = sys.stdin.readline

N = int(input())
lis_all = []
lis_pat = []
lis_num = []

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

count = 0
for i in range(N):
    lis_S = list(str(input()))
    lis_S.sort()
    if lis_S not in lis_all:
        lis_pat.append(lis_S)
    lis_all.append(lis_S)

for i in lis_pat:
    lis_num.append(lis_all.count(i))

ans = 0
for i in lis_num:
    if i != 1:
        ans += comb(i,2)
   
print(ans)
    


### FIXED CODE ###

import sys
input = sys.stdin.readline
 
N=int(input())
dic={}
sum=0
for i in range(N):
    s=list(input())
    s.sort()
    s = "".join(s)
    if s in dic:
        sum+=dic[s]
        dic[s]+=1
    else:
        dic[s]=1
print(sum)
N,K = map(int,input().split(" "))
array = list(map(int,input().split(" ")))

minus = 0
while array[minus] < 0 and minus < N:
    minus += 1

first,last = max(minus-K,0),min(minus,N-K)

ans = 2*(array[N-1]- array[0])

for i in range(first,last+1):
    m_dist, p_dist = array[i], array[K-1+i]
    if m_dist*p_dist <=0:
        dist_i = min(abs(m_dist),abs(p_dist))*2+max(abs(m_dist),p_dist)
    else:
        dist_i = max(abs(m_dist),abs(p_dist))
    ans = min(ans,dist_i)

print(ans)

### FIXED CODE ###

N,K = map(int,input().split(" "))
array = list(map(int,input().split(" ")))

minus = 0
while minus < N and array[minus]<0:
    minus += 1

first,last = max(minus-K,0),min(minus,N-K)

ans = 2*(array[N-1]- array[0])

for i in range(first,last+1):
    m_dist, p_dist = array[i], array[K-1+i]
    if m_dist*p_dist <=0:
        dist_i = min(abs(m_dist),abs(p_dist))*2+max(abs(m_dist),p_dist)
    else:
        dist_i = max(abs(m_dist),abs(p_dist))
    ans = min(ans,dist_i)

print(ans)
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    x = {}
    for _ in range(n):
        k,v = sys.stdin.readline().rstrip().split()
        dic[k] = v
    n = int(sys.stdin.readline().rstrip())
    y = []
    for _ in range(n):
        c = sys.stdin.readline().rstrip()
        if c in x:
            y.append(x[c])
        else:
            y.append(c)
    print(''.join(y))

### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break;
    x = {}
    for i in range(n):
        k,v = input().split()
        x[k] = v
    y = []
    for i in range(int(input())):
        a = input().rstrip()
        if a in x:
            y.append(x[a])
        else:
            y.append(a)
    print(''.join(y))
from math import atan, degrees

a, b, x = map(float, input().split())

if x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))

### FIXED CODE ###

from math import atan, degrees

a, b, x = map(float, input().split())

if a * a * b == x:
    print(0)
elif x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))
import statistics


def calculate_median(lst):
    lst.sort()
    median_right = lst[int(len(lst)/2)]
    median_left = lst[int(len(lst)/2)-1]
    return median_right, median_left


N = int(input())
X = list(map(int, input().split()))
X_copy = X.copy()
median_right, median_left = calculate_median(X)
for i in range(N):
    if X_copy[i] >= median_right:
        print(median_left)
    elif X_copy[i] < median_right:
        print(median_right)

### FIXED CODE ###

from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(ceil((n-1)/(k-1)))
from collections import deque

def bfs(graph, start, goal, connection):
    visited = {start: None}
    unvisited = deque(start)
    while unvisited:
        now = unvisited.popleft()
        if now == goal or (1000000*now + goal) in connection:
            connection[1000000*start + goal] = 1
            connection[1000000*goal + start] = 1
            return "yes"
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return "no"

n, m = map(int, input().split())
g = [[] for i in range(n)]
c = {}

for i in range(m):
    inp = list(map(int, input().split()))
    g[inp[0]].append(inp[1])
    g[inp[1]].append(inp[0])
    c[1000000*inp[0] + inp[1]] = 1
    c[1000000*inp[1] + inp[0]] = 1

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    print(bfs(g, s, t, c))

### FIXED CODE ###

from collections import deque

def bfs(graph, start):
    visited = {start: None}
    unvisited = deque()
    unvisited.append(start)
    while unvisited:
        now = unvisited.popleft()
        for next in graph[now]:
            if not (next in visited):
                unvisited.append(next)
                visited[next] = now
    return visited

n, m = map(int, input().split())
g = [set() for i in range(n)]
group = []

for i in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    for j in range(len(group)):
        if s in group[j] and t in group[j]:
            print("yes")
            break
        elif s in group[j]:
            print("no")
            break
    else:
        group_tmp = set(bfs(g, s).keys())
        if t in group_tmp:
            print("yes")
        else:
            print("no")
        group.append(group_tmp)
S = input()
ans = 99999
for i in range(7):
  n = int(S[i:i + 2])
  ans = min(ans,abs(n - 754))
print(ans)

### FIXED CODE ###

S = input()
ans = 9999
for i in range(0,len(S) - 1):
  n = int(S[i:i + 3])
  ans = min(ans,abs(753 - n))
print(ans)
Z = list(input(""))
N = int(Z[0])
D = int(Z[1])
count = 0

while(N--):
  Z1 = list(input(""))
  X = int(Z[0])
  Y = int(Z[1])
  
  d = (X**2 + Y**2)**0.5
  
  if d<=D:
    count += 1
    
print(count)    

### FIXED CODE ###

Z = input("").split()
N = int(Z[0])
D = int(Z[1])
count = 0
 
while(N):
    Z1 = input("").split()
    X = int(Z1[0])
    Y = int(Z1[1])
  
    d = (X**2 + Y**2)**0.5
  
    if d<=D:
        count += 1
    N = N -1
print(count)
a, b, c, d, e = map(int, input().split())
if a = 0:
	print("1")
elif b = 0:
	print("2")
elif c = 0:
	print("3")
elif d = 0:
	print("4")
else:
	print("5")
    
    

### FIXED CODE ###

x = [int(i) for i in input().split()]
print(x.index(0) + 1)
A = int(input())
B = int(input())

if A < 9 and B < 9:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

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

if A < 9 and B < 9:
    print("Yay!")
else:
    print(":(")
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

X, Y=map(int, input().split())
 
def f(x, y):
  s=max(x, y)
  t=min(x, y)
  st=s+t
  ans=1
  for i in range(1, t+1):
    ans=ans*(st+1-i)//i
    ans=ans%(10**9+6)
    
  return ans
  
      
b=(2*X-Y)//3
btemp=(2*X-Y)%3
a=(Y-a)//2
atemp=(Y-a)%2
if btemp>0 or atemp>0:
  ans=0
else:
  a=(Y-b)//2
  
  #ans=mt.factorial(a+b)//(mt.factorial(a)*mt.factorial(b))
  #ans=tool.permutations(a+b)//(tool.permutations(a)*tool.permutations(b))
  #s=max(a, b)
  #t=min(a, b)
  #ans=comb(s+t, t, 10**9+7)
  m=10**9+7
  ans=1
  for i in range(1, a+b+1):
    ans=ans*i%m
  for i in range(1, a+1):
    ans=ans*mod_inv(i, m)%m
  for i in range(1, b+1):
    ans=ans*mod_inv(i, m)%m
print(ans)


### FIXED CODE ###

p=10**9+7
X, Y=map(int, input().split())

if (X+Y)%3>0:
  print(0)
  exit()
  
a=(2*X-Y)//3
b=(2*Y-X)//3

if a*b<0:
  print(0)
  exit()

ab=a+b
ue=[1]*(ab+1)
for i in range(1, ab+1):
  ue[i]=ue[i-1]*i%p
  
out=ue[-1]*pow(ue[a], p-2, p)%p
out=out*pow(ue[b], p-2, p)%p

print(out)
a = list(map(int,input().split()))
print((a[0] + a[1]) * a[2] // 2)


### FIXED CODE ###

a,b,h = [int(input()) for i in range(3)]
print((a + b) * h // 2)
k,x,y = map(int,input().split())

if (x//k+1)*k <<y :
    print('OK')
else:
    print('NG')


### FIXED CODE ###

k= int(input())
x,y = map(int,input().split())
if 1<=x<=y<=1000 and 1<=k<=1000:
    pass



    if x%k>>0 :
        if x<= (x//k+1)*k <=y :
            print('OK')
        else:
            print('NG')
    else:
        print('OK')

else:
    print('NG')
import sys
n, y = map(int, input().split())
for i in reversed(range(y//10000+1)):
  for j in reversed(range((y-i*10000)//5000+1)):
    if i*10000+j*5000+(n-i-j)*1000 == y:
      print(i, j, n-i-j)
      sys.exit(1)

print('-1 -1 -1')


### FIXED CODE ###

import sys
n, y = map(int, input().split())
for i in range(n+1):
  for j in range(i, n+1):
      if (i*10000+(j-i)*5000+(n-j)*1000 == y):
        print(i, j-i, n-j)
        sys.exit(0)
print('-1 -1 -1')
if X < A:
    print('0')
else:
    print('10')

### FIXED CODE ###

X, A = map(int, input().split())
 
if X < A:
 print(0)
else:
 print(10)
from sys import stdin
import math

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

# 最大公約数
gcd = math.gcd(A, B)

num_list = []

for i in range(1, gcd+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])

### FIXED CODE ###

from sys import stdin

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]


num_list = []

for i in range(1, min([A, B])+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])
N = int(input())
  print("Yes" if N % 9 == 0 else "No")

### FIXED CODE ###

def main():
    N = map(int, input())
    if sum(N) % 9 == 0:
        return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    print(main())
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
ans = pow(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
mod = 10**9 + 7

def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod

ans = powerDX(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)
H,A = (int(x) for x input().split())

if not H <= 10^4 && H >= 1:
  return False
if not A <= 10^4 && H >= 1:
  return False

int count = 0
while H >= 0:
  count=+
  H = H - A

print(count)

### FIXED CODE ###

import math

H,A = map(int,input().split())
f, i = math.modf(H/A)

if not H <= 10^4 and H >= 1:
  False
if not A <= 10^4 and H >= 1:
  False

if f == 0:
  print(int(i))
if f != 0:
  print(int(i+1))
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break

for i in range(H):
    print (('#' * W ) + \n)

### FIXED CODE ###

while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        print (("#" * W ))
    print ()
s, w = map(int, input().sprit())

if(s>w):
    print('safe')
else
    print('unsafe')

### FIXED CODE ###

s, w = map(int, input().split())

if (w>=s):
    print('unsafe')
else:
    print('safe')
a, b = map(int, input().split())
K = (a + b) / 2
if (type(K) is int):
  print(K)
else:
  print(IMPOSSIBLE)

### FIXED CODE ###

a, b = map(int, input().split())
if (a + b) % 2 == 0:
    print(int((a + b)/2))
else:
    print('IMPOSSIBLE')
def main():
    x,y = list(map(int, input().split()))

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = []
    # 右へ進む
    for i in range(x, 101):
        if i not in nums:
           ans.append(i)
           break
    for i in range(x, 0, -1):
        if i not in nums:
           ans.append(i)
           break
    if len(ans) == 1:
        print(ans[0])
        exit()
    if abs(ans[0] - x) == abs(ans[1] - x):
        print(min(ans))
    elif abs(ans[0] - x) > abs(ans[1] - x):
        print(ans[1])
    elif abs(ans[0] - x) < abs(ans[1] - x):
        print(ans[0])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    x,y = list(map(int, input().split()))

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = 0
    for i in range(1, 200):
        if i not in nums:
            ans = ans if abs(ans-x) <= abs(i-x) else i
    print(ans)



if __name__ == '__main__':
    main()
from operator import itemgetter
from heapq import heappush, heappop
from collections import deque
from collections import defaultdict
N = int(input())
l = []
p = [0]*N
lp = [0]*(N-1)
d =defaultdict(list)
for i in range(N-1):
    ta ,tb = map(int,input().split())
    l.append([ta-1,tb-1])    
li = list(map(int,input().split()))



for i,j in l:
    d[i].append([j,li[j]])
    d[j].append([i,li[i]])
q = deque()
q.append(0)
p[0] = 1
c = li[0]
ll = []
while q:
    t = q.pop()
    c = li[t]
    p[t] = 1
    for i ,j in d[t]:
        if p[i] == 0:
            ll.append(min(c,j))
            lp[t] = c
            q.appendleft(i)
print(sum(ll))
print(*li)

### FIXED CODE ###

#実験用の写経
N = int(input())
g = {i: [] for i in range(N)}
for i in range(N - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
c = list(map(int, input().split()))
c.sort()
print(sum(c[:-1]))
nums = [0] * N
stack = [0]
while stack:
    d = stack.pop()
    nums[d] = c.pop()
    for node in g[d]:
        if nums[node] == 0:
            stack.append(node)
print(' '.join(map(str, nums)))
a=int(input())
while a==0:
  c+=a
  a-=1
print(int(c))
  


### FIXED CODE ###

a=int(input())
c=0
while a>=0:
  c+=a
  a=a-1
print(int(c))
n=int(input())
a=list(map(int,input().split()))
b=[]*n
for i in range(n-1):
  b[a[i]-1]+=1
for i in range(n):
  print(b[i])


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1):
  b[a[i]-1]+=1
for i in b:
  print(i)
a, b = map(int, input().split())
if a != 2 and c != 2:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

a, b = map(int, input().split())
if a != 2 and b != 2:
	print("Yes")
else:
	print("No")
import numpy as np
import sys
#input = sys.stdin.readline

def get_adj_tiles(v):
    i, j = v
    res = [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]
    return res

def bfs(point):
    visited = []
    que = deque()
    que.append((point, 1))
    
    while len(que) > 0:
        v, depth = que.popleft()
        visited.append(v)
        adjs = get_adj_tiles(v)
        for a in adjs:
            if field[a[0]][a[1]] == '.' and a not in visited:
                if a == (H, W):
                    return depth + 1
                else:
                    que.append((a, depth+1))

H, W = list(map(int, input().split()))
field = [['#'] * (W + 2) for _ in range(H + 2)]
for i in range(H):
    values = list(input())
    field[i+1][1:-1] = values
    
shortest_path = bfs((1, 1))
print(number_of_whites - shortest_path)

### FIXED CODE ###

H, W = list(map(int, input().split()))
M = [[-1]*(W+2)]
ans = 0
for _ in range(H):
    s = input()
    ans += s.count('.')
    M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])
M += [[-1]*(W+2)]

queue = [(1,1)]
M[1][1] = 1
dr = [(+1,0),(-1,0),(0,+1),(0,-1)]
turn = 1
while len(queue)>0:
    turn += 1
    queue_new = []
    for qx, qy in queue:
        for dx, dy in dr:
            x, y = qx+dx, qy+dy
            if M[y][x]==0:
                M[y][x] = turn
                queue_new.append((x,y))
    queue = queue_new

print(ans-M[H][W] if M[H][W]>0 else -1)
s=input()
a=input()
a=a.split()


c=1
for x in a:
  c=c*int(x)
  
if c > 10**18:
  print("-1")
else:  
  print(c) 


### FIXED CODE ###

a=input()

a=a.split()

A=int(a[0])
B=int(a[1])
C=A*B

print(C)