Harryxun/stf_run huggingface dataset:
a,b = int(input().split())
if a*b % 2 = 0:
  print(a*b//2)
else:
  print(a*b//2+1)

### FIXED CODE ###

h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
else:
  print((h*w+1)//2)
A, B = map(int, input().split())
     
    if A*B%2==0:
      print("No")
    else:
      print("Yes")

### FIXED CODE ###

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

if A*B%2==0:
  print("No")
else:
  print("Yes")
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, Q = map(int, input().split())
S = [0] * N
T = [0] * N
X = [0] * N
D = [0] * Q
event = []
working = []
for i in range(N):
	S[i], T[i], X[i] = map(int, input().split())
	event.append((S[i] - X[i], 1, X[i]))
	event.append((T[i] - X[i], -1, X[i]))
	
for i in range(Q):
	D[i] = int(input())
	
event.sort()
j = 0
for i in range(len(event)):		
	while event[i][0] > D[j] and j < Q:
		if len(working) > 0:
			print(working[0])
		else:
			print(-1)
		j += 1
	
	if event[i][1] == 1:
		working.append(event[i][2])
	else:
		working.remove(event[i][2])

while j < Q:
	print(-1)
	j += 1

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, Q = map(int, input().split())
S, T, X = [0] * N, [0] * N, [0] * N
work = []

for i in range(N):
	S[i], T[i], X[i] = map(int, input().split())
	work.append((X[i], S[i] - X[i], T[i] - X[i]))

D = [int(input()) for _ in range(Q)]

work.sort()
ans = [-1] * Q
skip = [-1] * Q

for i in range(N):
	left = bisect.bisect_left(D, work[i][1])
	right = bisect.bisect_left(D, work[i][2])
	
	while left < right:
		if skip[left] == -1:
			skip[left] = right
			ans[left] = work[i][0]
			left += 1
		else:
			left = skip[left]					
		
for i in ans:
	print(i)
s, t = input().split()
a, b = map(int, input())
u = input()

if s == u:
  print(a-1, b)
else:
  print(a, b-1)

### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = input()
 
if s == u:
  print(a-1, b)
else:
  print(a, b-1)
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    for i in range(len(T)-1):
        if T[i] == "?":
            if result[i-1] == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    bef = ""
    for i in range(len(T)-1):
        if T[i] == "?":
            if bef == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
        bef = result[-1]
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

if __name__ == '__main__':
    main()
#from collections import deque

num_r,num_c = map(int,input().split())
field = [input() for i in range(num_r)]
q = []
seen = [0]*(num_c*num_r)
count = 0

for i in range(num_r):
  for j in range(num_c):
    if field[i][j] == "#":
      seen[i*num_c+j] = 1
      q.append(i*num_c+j)

while q:
  tank = []
  for i in q:
    if (0<=i-num_c) and (seen[i-num_c] == 0):
      tank.append(i-num_c)
      seen[i-num_c] = 1
    if (i+num_c<num_c*num_r) and (seen[i+num_c] == 0):
      tank.append(i+num_c)
      seen[i+num_c] = 1
    if (0<=i%num_c-1) and (seen[i-1] == 0):
      tank.append(i-1)
      seen[i-1] = 1
    if (i%num_c+1<num_r) and (seen[i+1] == 0):
      tank.append(i+1)
      seen[i+1] = 1
   
  count = count + 1
  q = tank

print(count-1)

### FIXED CODE ###

def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())

    used = [True]*(h*w)

    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False


    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)

if __name__ == '__main__':
    main()
n, m = map(int, input().split())
ary = []
a = []
b = []
d = []
for i in range(m):
	s,c = map(int, input().split())
	if s == 1:
		a.append(c)
	elif s == 2:
		b.append(c)
	else:
		d.append(c)
if m == 0:
	print (-1)
	exit()
if n == 1:
	print (min(d))
	exit()
ans = 1000
if len(a) == 0:
	a.append(0)
if len(b) == 0:
	b.append(0)
if len(d) == 0:
	d.append(0)
for i in a:
	for j in b:
		for k in d:
			wk = str(i) + str(j) + str(k)
			if len(str(int(wk))) != n:
				continue
			else:
				ans = min(ans, int(wk))
if ans >= 1000:
	print (-1)
else:
	print (ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = []
for i in range(m):
	s,c = map(int, input().split())
	a.append([s,c])

for i in range(10**(n-1)-1,10**n):
	if len(str(i)) != n:
		continue
	if all(str(i)[s-1] == str(c) for s,c in a):
		print (i)
		exit()
print (-1)
a,b,c = map(int, input().split())

print(int(a*B/2))

### FIXED CODE ###

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

print(int(a*b/2))
a,b= map(input().split())
print((a-1)*(b-1))

### FIXED CODE ###

a,b= map(int,input().split())
print((a-1)*(b-1))
Tmp = []
Tmp = input().rstrip().split(',')
 
sA = (Tmp[0])
sB = (Tmp[1])

if sA == 'H' and sB == 'H':
  print('H')
elif sA == 'H' and sB == 'D':
  print('D')
elif sA == 'D' and sB == 'D':
  print('H')
elif sA == 'D' and sB == 'H':
  print('D')


### FIXED CODE ###

Tmp = []
Tmp = input().rstrip().split(' ')
 
sA = (Tmp[0])
sB = (Tmp[1])
 
if sA == 'H' and sB == 'H':
  print('H')
elif sA == 'H' and sB == 'D':
  print('D')
elif sA == 'D' and sB == 'D':
  print('H')
elif sA == 'D' and sB == 'H':
  print('D')
n,m=map(int,input().split())
  count=n*(n-1)//2
  countt=m*(m-1)//2
print(count+countt)


### FIXED CODE ###

n,m=map(int,input().split())
if n==2:
  count=1
else:
  count=n*(n-1)//2
  
if m==2:
  countt=1
else:
  countt=m*(m-1)//2

print(count+countt)
import numpy as np


def get_primes(a=10 ** 6):
    table = np.ones(a + 1)
    table[:2] = False
    for i in range(2, a):
        table[i + i::i] = False
    primes = np.where(table == True)[0]
    return primes


def main():
    n = int(input())
    A = np.array(input().split(), dtype=np.int64)
    primes = get_primes(A.max())

    if A.max() == 1:
        print("pairwise coprime")

    fact_counts = A.reshape([-1, 1]) % primes.reshape([1, -1]) == 0
    count = fact_counts.sum(axis=0).max()

    if count == 1:
        print("pairwise coprime")
    elif count != n:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


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

    counts = [0] * (10**6 + 1)
    for a in A:
        counts[a] += 1

    ans = 1
    for i in range(2, 10**6+1):
        co_primes = 0
        for j in range(i, 10**6+1, i):
            co_primes += counts[j]
        if ans < co_primes:
            ans = co_primes

    if ans == 1:
        print("pairwise coprime")
    elif ans < n:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == "__main__":
    main()
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()

ans = 0
middles = [n // 2 - 1, n // 2, n // 2 + 1]
if middles.count(0):
    middles.remove(0)
if middles.count(n-1):
    middles.remove(n-1)
for mid in middles:
    l = 0; r = n-1
    val = abs(a[mid] - a[l])
    state = True 
    while l != r:
        val += abs(a[r] - a[l])
        if state:
            l += 1
            if l == mid:
                l += 1
            state = False
        else:
            r -= 1
            if r == mid:
                r -= 1
            state = True
    ans = max(ans, val)
for mid in middles:
    l = 0; r = n-1
    val = abs(a[mid] - a[r])
    state = True 
    while l != r:
        val += abs(a[r] - a[l])
        if state:
            r -= 1
            if r == mid:
                r -= 1
            state = False
        else:
            l += 1
            if l == mid:
                l += 1
            state = True
    ans = max(ans, val)
print(ans)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()

if n == 2:
    print(a[1] - a[0])
    exit()

ans = 0
middles = [n // 2 - 1, n // 2, n // 2 + 1]
if middles.count(0):
    middles.remove(0)
if middles.count(n-1):
    middles.remove(n-1)
for mid in middles:
    l = 0; r = n-1
    val = abs(a[mid] - a[l])
    state = True 
    while l != r:
        val += abs(a[r] - a[l])
        if state:
            l += 1
            if l == mid:
                l += 1
            state = False
        else:
            r -= 1
            if r == mid:
                r -= 1
            state = True
    ans = max(ans, val)
for mid in middles:
    l = 0; r = n-1
    val = abs(a[mid] - a[r])
    state = True 
    while l != r:
        val += abs(a[r] - a[l])
        if state:
            r -= 1
            if r == mid:
                r -= 1
            state = False
        else:
            l += 1
            if l == mid:
                l += 1
            state = True
    ans = max(ans, val)
print(ans)
x = input()

print(x*x*x)

### FIXED CODE ###

x = int(input())
print(x**3)
while True:
    n,x = map(int,input().split())

    if n==0 and x==0: 
        break

    print( sum( len( range(max(i+1,x-i-n),min(n,(x-i+1)//2)) ) ) for i in range(1,min(n-1,x//3)) )

### FIXED CODE ###

import math

def factorize(p):
    l = []
    while p % 2 == 0:
        p //= 2
        l.append(2)

    r = 3
    while r < int(math.sqrt(p)+1):
        if p % r == 0:
            p //= r
            l.append(r)
        else:
            r += 2

    if p != 1:
        l.append(p)

    return l

n = int(input())
l = factorize(n)

print(str(n)+":",*l)
N = int(input())
H = list(map(int, input().split()))
 
ans = 1
if (N==1):
    continue

elif (N == 2):
    if (H[0] - H[1] >= 2):
        print('No')
        ans = -1
else:
    for i in range(1, N-1, 1):
        #print((H[i] - H[i+1]))
        if ((H[i-1] - H[i]) >= 1) & ((H[i] - H[i+1]) >= 1):
            print('No')
            ans = -1
            break
        elif ((H[i-1] - H[i]) == 0) & ((H[i] - H[i+1]) == 1):
            print('No')
            ans = -1
            break
        elif ((H[i-1] - H[i]) >= 2) or ((H[i] - H[i+1]) >= 2):
            print('No')
            ans = -1
            break
        else:
            continue

 
if (ans == 1): print('Yes')

### FIXED CODE ###

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

ans = 1
for i in reversed(range(1, N, 1)):
    if (H[i-1] - H[i]) == 1:
        H[i-1] -= 1
    if (H[i-1] - H[i]) > 1:
        print('No')
        ans = -1
        break
if ans == 1: print('Yes')
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
for j in range(1,105):
for k in range(1,105):
v = i*i+j*j+k*k+i*j+j*k+k*i;
if v<10050:
ans[v]+=1
for i in range(n):
print(ans[i+1])

### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1
for i in range(n):
	print(ans[i+1])
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])

cm = np.prod(A)
max_gcd = 0
# for i in range(len(A)):
#     Am = A.copy()
#     Am[i] = cm
#     gcd = np.gcd.reduce(Am)
#     if gcd > max_gcd:
#         max_gcd = gcd
print(max_gcd)

### FIXED CODE ###

A, B, T = [int(i) for i in input().split()]
b = ((T+0.5) // A) * B
print(int(b))
import string
alp=string.ascii_lowercase

s=input()
for i in range(28):
  temp=alp[i]
  if temp not in s:
    print(temp)
    exit()
print("None")

### FIXED CODE ###

import string
alp=string.ascii_lowercase

s=input()
for i in range(26):
  temp=alp[i]
  if temp not in s:
    print(temp)
    exit()
print("None")
N,M=[int(x) for x in input().split()]
I=[[] for n in range(N)]
G=[n for n in range(N)]
W=[1 for n in range(N)]
E=[]

result=[]
ans = int(N * (N-1) / 2)

def union(i,g):
    if(G[i]!=g):
        G[i]=g
        for n in I[i]:
            union(n,g)

for m in range(M):
    A,B=[int(x) for x in input().split()]
    E.append((A-1,B-1))

for m in range(M):
    result.append(ans)
#    print(E)
    if(ans>0):
        A,B=E.pop()
        Ga,Gb=G[A],G[B]
        if (Ga!=Gb):
            Wa,Wb=W[Ga],W[Gb]
#        print("%i=%i-(%i*%i)" % (ans-(Wa*Wb),ans,Wa,Wb))
            ans=ans-(Wa*Wb)
        I[A].append(B)
        I[B].append(A)
        if (Wb>Wa):
            union(Ga,Gb)
            W[Gb]=Wa+Wb
        else:
            union(Gb,Ga)
            W[Ga]=Wa+Wb
#    print(I)
#    print(G)
#    print(W)
#    print("----")

for r in reversed(result):
    print(r)


### FIXED CODE ###

N,M=[int(x) for x in input().split()]
G=[-1] * N
W=[0] * N
E=[]

result=[]
ans = int(N * (N-1) / 2)

def union(i,j):
    gi=find(i)
    gj=find(j)

    if(gi!=gj):
        if W[gi] > W[gj]:
            G[gi]+=G[gj]
            G[gj]=gi
        else:
            G[gj]+=G[gi]
            G[gi]=gj
            if W[gi]==W[gj]:
                W[gj]+=1

def find(i):
    if G[i]<0:
        return i;
    else:
        G[i]=find(G[i])
        return G[i]

for m in range(M):
    A,B=[int(x) for x in input().split()]
    E.append((A-1,B-1))

for m in range(M):
    result.append(ans)
    if(ans>0):
        A,B=E.pop()
        ga,gb=find(A),find(B)
        if (ga!=gb):
            ans=ans-(G[ga]*G[gb])
            union(A,B)

for r in reversed(result):
    print(r)
numbers = input()
number_list = numbers.splist(" ")
N = int(number_list[0])
K = int(number_list[1])
if N%K == 0:
  print 0
else:
  print 1
  

### FIXED CODE ###

numbers = input()
number_list = numbers.split(" ")
N = int(number_list[0])
K = int(number_list[1])
if N%K == 0:
  print(0)
else:
  print(1)
n, a, b = map(int,input().split())

sum = ""
for i in range(10**18):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    print(ans)
    exit()
    

print(sum.count("b"))

### FIXED CODE ###

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

ans = a*(n//(a+b))+ min(a,n%(a+b))
print(ans)
a,b,c = input().split()
print(a.upper()[0]+b.upper()[0].c.upper()[0])

### FIXED CODE ###

a,b,c = input().split()
print(a.upper()[0]+b.upper()[0]+c.upper()[0])
S = input()

weather = ["Sunny", "Cloudy", "Rainly"]
print(weather[(weather.index(S)+1)%3 ])


### FIXED CODE ###


S = input()

weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[(weather.index(S)+1)%3])
n,m = map(int,input().split())

li = [True] * n

count = 0
for sub1 in range(1,m+1):
    while True:
        if li[count]:
            print(count+1, count + sub1 + 1)
            li[count] = False
            li[count+sub1] = False
            break
        else:
            count += 1


### FIXED CODE ###

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

li = [True] * n

a = 1 + m
if m % 2 == 0:
    for i in range(m//2):
        print(1+i, a-i)
    for i in range(m//2):
        print(a+1+i, a+m-i)

else:
    for i in range((m+1)//2):
        print(1+i, a-i)
    for i in range(m//2):
        print(a+1+i, a+m-i)
n=int(input())
if n%2==:
  print(n/2)
else:
	print(n//2+1)  

### FIXED CODE ###

n=int(input())
if n%2==0:
  print(int(n/2))
else:
  print(int((n+1)/2))
from scipy.sparse.csgraph import bellman_ford

n,m=map(int,input().split())
g=[[float('inf')]*(n+1) for _ in range(n+1)]
for _ in range(m):
  a,b,c=map(int,input().split())
  g[a][b]=-c
try:
  score=int(bellman_ford(g)[1][n])
except:
  print('inf')
else:
  print(-score)

### FIXED CODE ###

#https://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e
def BF(p,n,s):
    inf=float("inf")
    d=[inf for i in range(n)]
    d[s-1]=0
    for i in range(n+1):
        for e in p:
            if e[0]!=inf and d[e[1]-1]>d[e[0]-1]+e[2]:
                d[e[1]-1] = d[e[0]-1] + e[2]
        if i==n-1:t=d[-1]
        if i==n and t!=d[-1]:
            return [0,'inf']
    return list(map(lambda x:-x, d))

n,m=map(int,input().split())
g=[]
for _ in range(m):
  a,b,c=map(int,input().split())
  g.append([a,b,-c])
print(BF(g,n,1)[-1])
k,n = map(int,input(),split())
a = list(map(int,input().split()))
a += [a[0]]
m = 11414114514

for i in range(n):
  m = min(m,a[i]-a[i+1])
  
print(k-m)

### FIXED CODE ###

k,n = map(int,input().split())
a = list(map(int,input().split()))
tm = a[0]
a.append(tm)
m = -9878789894545656
 
for i in range(n-1):
  m = max(m,a[i+1]-a[i])
  
m = max(m,a[0]+k-a[n-1])
  
print(k-m)
N = int(input())
from functools import reduce
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
A = factorize(N)
for i in range(1,len(A)):
    x = 1
    y = 1
    for a in A[0:i]:
        x *= a
    for a in A[i:]:
        y *= a
ans = x+y-2

ans = N-1 if len(A) == 1else ans
print(ans)

### FIXED CODE ###

from math import ceil, sqrt
N = int(input())
for i in range(ceil(sqrt(N)),0,-1):
    if N%i == 0:
        print(i + N//i -2)
        break
import sys

if __name__ == '__main__':
    i = 1
    for line in sys.stdin.read().splitlines():
        if line == '0':
            break
        print "Case %d: %s" % (i, line)
        i += 


### FIXED CODE ###

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

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

if __name__ == '__main__':
    i = 1
    while 1:
        line = raw_input()
        if line == '0':
            break
        print "Case %d: %s" % (i, line)
        i += 1
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if not m == 0:
    lis = [int(input()) for x in range(m)]
else:
    lis = []
stairs = [0 for x in range(n)]
stairs[0] = 1
if 1 in lis:
    stairs[1] = 0
else:
    stairs[1] = 1
#print(stairs)
f = 0
for x in range(2,n):
    if x in lis:
        stairs[x] = 0
    else:
        stairs[x] = (stairs[x-1] + stairs[x-2]) % mod
    
#print(stairs)
print((stairs[n-1] + stairs[n-2]) % mod)
    


### FIXED CODE ###

import sys
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if n in [0,1]:
    print(1)
    sys.exit()
    
if not m == 0: lis = [int(input()) for x in range(m)]
else: lis = [-1]
val1 = 1
if 1 in lis: val2 = 0
else: val2 = 1

if lis[0] == 1 and len(lis) >= 2:
    flg = lis[1]
    nex = 1
else:
    flg = lis[0]
    nex = 0
#print(lis)
for x in range(2,n):
    if x == flg: #x in lis
        #print(flg)
        nex += 1
        try: flg = lis[nex]
        except:flg = 0
        now = 0
    else:
        now = (val1 + val2) % mod
    val1,val2 = val2,now
    
print((val1 + val2) % mod)
if "__name__"=="__main__":
  r = (int) raw_input()
  g = (int) raw_input()
  k = 2*g - r
  print k

### FIXED CODE ###

r = int(raw_input())
g = int(raw_input())
k = 2*g - r
print k
n = int(input())
w = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  c = min(c, abs(w[:i+1] - w[i+1:n]))
print(c)

### FIXED CODE ###

n = int(input())
W = list(map(int, input().split()))
c = float("inf")
for i in range(n-1):
  d = abs(sum(W[:i+1]) - sum(W[i+1:]))
  c = min(c, d)
print(c)
def f(i,ans,l,t):
  if (i+1) == (len(l)-1):
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return t+ans
    else:
      return t
  else:
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return f(i+1,ans,l,t+ans)
    else:
      return f(i+1,0,l,t)
n = input("")
an = input("").split(" ")
ani = [int(a) for a in an]
if len(ani) == 1:
  print("0")
else:
  print(f(0,0,ani,0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000)
def f(i,ans,l,t):
  if (i+1) == (len(l)-1):
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return t+ans
    else:
      return t
  else:
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return f(i+1,ans,l,t+ans)
    else:
      return f(i+1,0,l,t)
n = input("")
an = input("").split(" ")
ani = [int(a) for a in an]
if len(ani) == 1:
  print("0")
else:
  print(str(f(0,0,ani,0)))
N = int(input())
K = int(input())

L = list(map(int, list(str(N))))
if L < N:
  x = 1 / 0
M = len(L)
DP = [[[0] * 2 for _ in range(K + 1)] for _ in range(M)]

DP[0][1] = [L[0] - 1, 1]
DP[0][0][0] = 1

for i in range(1, M):
  DP[i][0][0] = DP[i - 1][0][0]
  for j in range(1, K + 1):
    DP[i][j][0] = DP[i - 1][j][0]
    DP[i][j][0] += DP[i - 1][j - 1][0] * 9
    DP[i][j][0] += DP[i - 1][j - 1][1] * (L[i] - 1)
    DP[i][j][0] += DP[i - 1][j][1] 
    DP[i][j][1] = DP[i - 1][j - 1][1]

ans = DP[-1][-1][0] + DP[-1][-1][1]
ans = max(0, ans)
print(ans)


### FIXED CODE ###

N = int(input())
K = int(input())

L = list(map(int, list(str(N))))
M = len(L)
DP = [[[0] * 2 for _ in range(K + 1)] for _ in range(M)]

DP[0][1] = [L[0] - 1, 1]
DP[0][0][0] = 1

for i in range(1, M):
  DP[i][0][0] = DP[i - 1][0][0]
  for j in range(1, K + 1):
    if L[i] != 0:
      DP[i][j][0] = DP[i - 1][j][0]
      DP[i][j][0] += DP[i - 1][j][1]
      DP[i][j][0] += DP[i - 1][j - 1][0] * 9
      DP[i][j][0] += DP[i - 1][j - 1][1] * (L[i] - 1)
      DP[i][j][1] = DP[i - 1][j - 1][1]
    else:
      DP[i][j][0] = DP[i - 1][j][0]
      DP[i][j][0] += DP[i - 1][j - 1][0] * 9
      DP[i][j][1] = DP[i - 1][j][1]

ans = DP[-1][-1][0] + DP[-1][-1][1]
ans = max(0, ans)
print(ans)
import sys
import math

getNum = int(sys.argv[1])
print(int(math.pow(argNum,3)))

### FIXED CODE ###

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

import math

def main():
  N = float(input())
  print(int(math.pow(N,3)))

if __name__ == '__main__':
  main()
N = int(input())
D = list(map(int,input().split()))
D.sort(reverse = True)
A = []
B = []
for i in range(N):
    if i%2==0:
        A.append(D[i])
    else:
        B.append(D[i])
 
print(sum(A)-sum(B))

### FIXED CODE ###

N = int(input())
A = int(input())
sample = N%500
if A >= sample:
  print("Yes")
else:
  print("No")
import heapq
N = int(input())
node = [[] for _ in range(N)]
for _ in range(N-1):
  a,b,c = map(int,input().split())
  node[a-1].append([c,b-1])
  node[b-1].append([c,a-1])
Q,K = map(int,input().split())

flag = [True]*N
ques = [[0,K-1]]
D = [0]*N
while ques:
  d1,l1 = heapq.heappop(ques)
  if flag[l1]:
    flag[l1]=False
    D[l1] = d1
    for d2,l2 in node[l1]:
      if flag[l2]:
        heapq.heappush([d1+d2,l2])
for _ in range(Q):
  x,y = map(int,input().split())
  print(D[x-1]+D[y-1])
        

### FIXED CODE ###

import heapq
N = int(input())
node = [[] for _ in range(N)]
for _ in range(N-1):
  a,b,c = map(int,input().split())
  node[a-1].append([c,b-1])
  node[b-1].append([c,a-1])
Q,K = map(int,input().split())

flag = [True]*N
ques = [[0,K-1]]
D = [0]*N
while ques:
  d1,l1 = heapq.heappop(ques)
  if flag[l1]:
    flag[l1]=False
    D[l1] = d1
    for d2,l2 in node[l1]:
      if flag[l2]:
        heapq.heappush(ques,[d1+d2,l2])
for _ in range(Q):
  x,y = map(int,input().split())
  print(D[x-1]+D[y-1])