Harryxun/stf_run huggingface dataset:
a,b = (int(x) for x in input().split())

if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")


### FIXED CODE ###

a,b = (str(x) for x in input().split())

if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")
x = input()
for i in range(len(x)):
  if x[i] == "7":
    return "Yes"

### FIXED CODE ###

x = input()
if ("7" in x) == True:
    print("Yes")
else:
    print("No")
a, b = int(input().split())

if a >= b:
    k = a-1
    print(a + max(k,b))

else:
    k = b-1
    print(b + max(a,k))

### FIXED CODE ###

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

if a >= b:
    print(a + max(a-1, b))

else:
    print(b + max(a, b-1))
n=int(input())
A=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append([i+1])
for j in range(n):
  a[j].append(A[j])
a.sort(key=lambda x:x[1])
lst=[]
for k in range(n):
  lst.append(a[k][0])
print(''.join(lst))
  


### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append([i+1,A[i]])
b=sorted(a,key=lambda x:x[1])
lst=[]
for k in range(n):
  lst.append(b[k][0])
print(*lst)
import numpy as np

n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]

jobs.sort(key=lambda x:x[1])

flg = True

a = np.array(jobs)[:,0]
b = np.array(jobs)[:,1]

sum = np.add.accumulate(a)
if sum(sum > b):
    print('No')
else:
    print('Yes')

### FIXED CODE ###

from operator import itemgetter

n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]

jobs.sort(key=itemgetter(1))

flg = True
sum = 0
for a, b in jobs:
    sum += a
    if sum > b:
        flg = False
        break

if flg:
    print('Yes')
else:
    print('No')
A,B, K=map(int,input().split())
List_A = list(map(int, input().split()))
List_B = list(map(int, input().split()))
res = 0
inter = 0
n = A+B
for i in range(n):
  if len(List_A)==0:
    inter+=List_B.pop(0)
  elif len(List_B)==0:
    inter+=List_A.pop(0)
  else:
    if List_A[0]>List_B[0]:
      inter+=List_B.pop(0)
    elif List_A[0] < List_B[0]:
      inter+=List_A.pop(0)
    else:
      if List_B[1] > List_A[1]:
        inter+=List_A.pop(0)
      elif List_A[1] > List_B[1]:
        inter+=List_B.pop(0)
      else:
        if len(List_A) > len(List_B):
          inter = inter + List_A.pop(0)
        else:
          inter = inter + List_B.pop(0)
  if K < inter:
    break
  else:
    res +=1
print(res)

### FIXED CODE ###

A,B,K=map(int,input().split())
List_A = list(map(int, input().split()))
List_B = list(map(int, input().split()))
SumListA=[]
SumListA.append(0)
SumListB=[]
SumListB.append(0)
res =0
a=0
for i in range(A):
  SumListA.append(SumListA[i]+List_A[i])
for i in range(B):
  SumListB.append(SumListB[i]+List_B[i])

j=B
for i in range(A+1):
  if SumListA[i] > K:
    break
  while K-SumListA[i] < SumListB[j]:
    j += -1
  res = max(i+j,res)
print(res)
n,m=map(int,input().split())
a=[]
for i in range(m):
  b=int(input())
  a.append(b)

def count(x):
    if x==-1:
        return 0
    elif x==0:
        return 1
    elif x in a:
        return 0
    else:
        return count(x-2)+count(x-1)
    
print(count(n)%1000000007)

### FIXED CODE ###

n,m=map(int,input().split())
mod=10**9+7
a = [int(input()) for i in range(m)]
block=[0,1]
x=[True for i in range(n)]
for j in a:
  x[j-1]=False

for i in range(1,n+1):
  if x[i-1]==False:
    block=block[1:]+[0]
  else:
    block=block[1:]+[sum(block)%mod]
print(block[-1])
N,A = map(int,input().split())
x = [0] + list(map(int,input().split()))
X = max(x)
dp = [[[0]*(N*X+1) for k in range(N+1)] for j in range(N+1)]

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*X+1):
            if j == 0 and k == 0 and s == 0 :
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
            else:
                dp[j][k][s] = 0
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*A]
print(ans)

### FIXED CODE ###

N,A = map(int,input().split())
x = [0] + list(map(int,input().split()))
X = max(x[1:])
y = [0] + list((i-A) for i in x[1:] )
dp = [[0]*(2*N*X+1) for _ 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 and (t-y[j] < 0 or t - y[j] > 2*N*X):
            dp[j][t] = dp[j-1][t]
        elif j >= 1 and (t-y[j] >= 0 and t-y[j] <= 2*N*X):
            dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j]]
        else:
            dp[j][t] = 0
print(dp[N][N*X]-1)
N,K = map(int,input().split())
if K==1:
    ptint("0")
else:
    print(N-K)

### FIXED CODE ###

N,K = map(int,input().split())
if K==1:
    print("0")
else:
    print(N-K)
N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [10**18] * N
DP[0] = 0
for i in range(N - 1):
    for j in range(1, min(K + 1, N - i)):
        DP[i + j] = min(DP[i + j], DP[i] + abs(H[i + j] - H[i]))
print(DP[N - 1])

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
DP = [float('inf')] * N
DP[0] = 0
DP[1] = abs(H[1] - H[0])
for i in range(2, N):
    DP[i] = min(DP[i - 1] + abs(H[i] - H[i - 1]), DP[i - 2] + abs(H[i] - H[i - 2]))
print(DP[N - 1])
from collections import deque

def main():
    N,M = map(int, input().split())
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        r[a-1].append(b-1)
        r[b-1].append(a-1)
    print(r)

    p=[-1]*N
    q=deque([0])
    while q:
        i=q.popleft()
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print('Yes')
    for i in range(1,N):
        print(p[i]+1)

main()

### FIXED CODE ###

n = input()
hon = ['2','4','5','7','9']
pon = ['0','1','6','8']
if n[-1] in hon:
    print('hon')
elif n[-1] in pon:
    print('pon')
else:
    print('bon')
S=int(input())

h=S//3600

m=S%3600//60

s=S%3600%60

print":".join(h,m,s)

### FIXED CODE ###

S=int(input())
 
h=S//3600
 
m=(S%3600)//60
 
s=(S%3600)%60
 
print('{0}:{1}:{2}'.format(h,m,s))
n = int(input())
l = list(map(int,input().split()))
min_num = MAX(l) +1
ans = 0
for i in l:
  if min_num >= i:
    min_num = i
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
min_num = max(l) +1
ans = 0
for i in l:
  if min_num >= i:
    min_num = i
    ans += 1
print(ans)
x, a, b = [int(input() for i in range(3))]
print((x-a) % b)


### FIXED CODE ###

x, a, b = [int(input()) for i in range(3)]
print((x-a) % b)
import numpy as np

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

a_d = []
for i in range(1, n+1):
    a_d.append(a[i-1]-i)

d = (list(np.absolute(a_d)))
d.sort()
m = d[int(n/2)]

print(abs(sum(d-m)))

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
    print(n)
else:
    print(n*2)
s = input()
s2 = s.replace('x', '')
if s2 != s2[::-1]:
    print(-1)
else:
    center = s2[len(s2)//2]
    cnt = s.count(center)//2 + 1
    for i, c in enumerate(s):
        if c == center:
            cnt -= 1
        if cnt == 0:
            center_idx = i
            break

    front = list(s)[:center_idx]
    rear = list(s)[center_idx+1:][::-1]
    if len(front) == 0 or len(rear) == 0:
        print(max(len(front), len(rear)))
    else:
        a, b = front.pop(), rear.pop()
        cnt = 0
        while True:
            if a == b == 'x':
                if 0 < len(front) <= len(rear):
                    a = front.pop()
                    b = rear.pop()
                else:
                    if 0 == len(front) == len(rear):
                        break
                    if 0 < len(front):
                        a = front.pop()
                        cnt += 1
                    if 0 < len(rear):
                        b = rear.pop()
                        cnt += 1
                    continue

            if a == b:
                if 0 < len(front):
                    a = front.pop()
                if 0 < len(rear):
                    b = rear.pop()

            if a == 'x' and b != 'x':
                cnt += 1
                if 0 < len(front):
                    a = front.pop()
            if a != 'x' and b == 'x':
                cnt += 1
                if 0 < len(rear):
                    b = rear.pop()
            if len(front) == 0 and len(rear) == 0:
                break
        print(cnt)


### FIXED CODE ###

from collections import deque

s = input()
s2 = s.replace('x', '')
if s2 != s2[::-1]:
    print(-1)
else:
    d = deque(s)
    a, b = [], []
    cnt = 0
    x = y = ''
    x_skip = y_skip = 0
    while d:
        if not x_skip:
            x = d.popleft()
        if 0 < len(d)and not y_skip:
            y = d.pop()

        if y == '':
            break

        if x == y != 'x':
            cnt += abs(len(a)-len(b))
            x = y = ''
            a, b = [], []
            x_skip = y_skip = 0
            continue

        if x == 'x':
            a.append(x)
        else:
            x_skip = 1

        if y == 'x':
            b.append('x')
        else:
            y_skip = 1
    else:
        cnt += abs(len(a)-len(b))

    print(cnt)
import sys

d = {'A': 1, 'B': 0, 'C': 0}

for line in sys.stdin:
    a, t = line.split().split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

### FIXED CODE ###

d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        a, t = input().split(',')
        d[a], d[t] = d[t], d[a]
    except:
        for k, v in d.items():
            if v:
                print(k)
        break
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    data = []
    for i in range(m):
        p, y = map(int, input().split())
        data.append([p, y, i])
    data_sorted = sorted(data, key=itemgetter(0, 1))

    p, y, i = 0, 0, 0
    p_prev = 0 
    x = 1 # initialize
    codes = []
    for p, y, i in data:
        # initialize if new prefecture, increment if not
        if p != p_prev:
            x = 1
        else:
            x += 1
        code = '{:06d}{:06d}'.format(p, x)
        codes.append([i, codes])
        p_prev = p

    for i, code in sorted(codes, key=itemgetter(0)):
        print code
        
main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe
"""
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    data = []
    for i in range(m):
        p, y = map(int, input().split())
        data.append([p, y, i])
    # print(data)
    data_sorted = sorted(data, key=itemgetter(0, 1))
    # print(data_sorted)

    p, y, i = 0, 0, 0
    p_prev = 0 
    x = 1 # initialize
    codes = []
    for p, y, i in data_sorted:
        # initialize if new prefecture, increment if not
        if p != p_prev:
            x = 1
        else:
            x += 1
        code = '{:06d}{:06d}'.format(p, x)
        codes.append([i, code])
        p_prev = p
    # print(codes)

    codes_sorted = sorted(codes, key=itemgetter(0))
    # print(codes_sorted)

    for i, code in codes_sorted:
        print(code)
        
main()
def solve():
    n = int(input())
    a = []
    b = []
    for _ in range(n):
        A, B = map(int, input().split())
        if B != 1:
            a.append(A)
            b.append(B)

    ans = b[-1] - a[-1]%b[-1]
    for i in range(1, len(a)):
        c = a[-(i+1)]+ans
        if c > b[-(i+1)]:
            dis = b[-(i+1)]-c%b[-(i+1)]
            ans += dis
        else:
            dis = b[-(i+1)] - c
            ans += dis

    return max(0, ans)
    

print(solve())


### FIXED CODE ###

def solve():
    n = int(input())
    a = []
    b = []
    for _ in range(n):
        A, B = map(int, input().split())
        a.append(A)
        b.append(B)

    ans = b[-1] - a[-1]%b[-1]
    if a[-1]%b[-1] == 0: ans = 0

    for i in range(1, n):
        c = a[-(i+1)]+ans
        if c%b[-(i+1)] == 0: continue
        
        if c > b[-(i+1)]:
            dis = b[-(i+1)]-c%b[-(i+1)]
            ans += dis
        else:
            dis = b[-(i+1)] - c
            ans += dis

    return max(0, ans)
    

print(solve())
print(int(input() ** 3))

### FIXED CODE ###

print(int(input()) ** 3)
a=i[nt(input()) i in range(10)]
a.sort
a.reverse
print(a[0:2]) 

### FIXED CODE ###

a=[int(input()) for i in range(10)]
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])
k,x=map(int, input()split())

if 500*k >= x:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

k,x=map(int, input().split())

if 500*k >= x:
    print('Yes')
else:
    print('No')
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

    pos = [a for a in A if a >= 0]
    neg = [a for a in A if a < 0]

    pos.sort()
    neg.sort(reverse=True)

    if N == K:
        vec = A
    elif N == len(neg):
        if K & 1:
            vec = neg[:K]
        else:
            vec = neg[-K:]
    else:
        ans_pos = []
        ans_neg = []
        for _ in range(K):
            if not pos:
                ans_neg.append(neg.pop())
            elif not neg:
                ans_pos.append(pos.pop())
            elif pos[-1] > -neg[-1]:
                ans_pos.append(pos.pop())
            else:
                ans_neg.append(neg.pop())
                
        if len(ans_neg) & 1 and ans_pos[-1] != 0:
            s1 = s2 = 0
            if pos and ans_neg:
                s1 = -pos[-1] / ans_neg[-1]
            if neg and ans_neg:
                s2 = -neg[-1] / ans_pos[-1]

            if s1 > s2:
                ans_pos.append(pos.pop())
                ans_neg.pop()
            else:
                ans_neg.append(neg.pop())
                ans_pos.pop()

        vec = ans_pos + ans_neg

    ans = 1
    for a in vec:
        ans = ans * a % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

    pos = [a for a in A if a >= 0]
    neg = [a for a in A if a < 0]

    pos.sort()
    neg.sort(reverse=True)

    if N == K:
        vec = A
    elif N == len(neg):
        if K & 1:
            vec = neg[:K]
        else:
            vec = neg[-K:]
    else:
        ans_pos = []
        ans_neg = []
        for _ in range(K):
            if not pos:
                ans_neg.append(neg.pop())
            elif not neg:
                ans_pos.append(pos.pop())
            elif pos[-1] > -neg[-1]:
                ans_pos.append(pos.pop())
            else:
                ans_neg.append(neg.pop())

        if (len(ans_neg) & 1) and ((not ans_pos) or (ans_pos[-1] != 0)):
            if not pos or not ans_neg:
                drop_pos = True
            elif not neg or not ans_pos:
                drop_pos = False
            else:
                drop_pos = pos[-1] * ans_pos[-1] < neg[-1] * ans_neg[-1]

            if drop_pos:
                ans_neg.append(neg.pop())
                ans_pos.pop()
            else:
                ans_pos.append(pos.pop())
                ans_neg.pop()

        vec = ans_pos + ans_neg

    ans = 1
    for a in vec:
        ans = ans * a % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()
print((int(input())-1)*(int(input())-1))

### FIXED CODE ###

a = [int(x) for x in input().split()]
print((a[0]-1)*(a[1]-1))
i=int(input())
l=[]
c=True
for k in range(1,i+1):
  l.append(list(input())
if len(l)==len(set(l)):
  for k in range(0,i):
    if l[k][-1]!=l[k+1][0]:
       c=False
       break
else:
  c=False
if c==False:
  print("No")
else:
  print("Yes")
           
  


### FIXED CODE ###

a,s=map(int,input().split())
if a*s%2==0:
  print("No")
else:
  print("Yes")
#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""
input:
3 8

output:
3 -1
"""

import sys


def ext_euclid(a, b):
    if b == 0:
        return 1, 0, a
    else:
        x, y, q = ext_euclid(b, a % b)
        x, y = y, (x - (a // b) * y)
        return x, y


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(*ext_euclid(n1, n2))

### FIXED CODE ###

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


"""
input:
3 8

output:
3 -1
"""

import sys


def ext_euclid(a, b):
    if b == 0:
        return 1, 0
    else:
        x, y = ext_euclid(b, a % b)
        x, y = y, (x - (a // b) * y)
        return x, y


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    print(*ext_euclid(n1, n2))
MOD = 10**9 + 7
list_size = 200001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

h, w, k = map(int, input().split())
ans = k * f_list[h+w] * f_r_list[h+w-k]
ans += (h+w) * k * (k+1) * f_list[h+w-1] * f_r_list[2] * f_r_list[h+w-k]
ans %= MOD
ans += h * w * f_list[h+w-2] * (k-1) * k * (k+1) * pow(3, MOD-2, MOD) * f_r_list[h+w-k]
ans %= MOD
print(ans)

### FIXED CODE ###

MOD = 10**9 + 7
list_size = 20000001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

h, w, k = map(int, input().split())
ans = k * f_list[h+w] * f_r_list[h+w-k]
ans += (h+w) * k * (k+1) * f_list[h+w-1] * f_r_list[2] * f_r_list[h+w-k]
ans %= MOD
ans += h * w * f_list[h+w-2] * (k-1) * k * (k+1) * pow(3, MOD-2, MOD) * f_r_list[h+w-k]
ans %= MOD
print(ans)
s = sum(map(int, raw_input().split())
t = sum(map(int, raw_input().split())
print max(s,t)

### FIXED CODE ###

s = map(int, raw_input().split())
t = map(int, raw_input().split())
print max(sum(s),sum(t))
A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if A11 in b and A12 in b and A13 in b:
    print('Yes')
elif A21 in b and A22 in b and A23 in b:
    print('Yes')
elif A31 in b and A32 in b and A33 in b:
    print('Yes')
elif A11 in b and A21 in b and A31 in b:
    print('Yes')
elif A12 in b and A22 in b and A32 in b:
    print('Yes')
elif A13 in b and A23 in b and A33 in b:
    print('Yes')
elif in b A11 and A22 in b and A33 in b:
    print('Yes')
elif A13 in b and A22 in b and A31 in b:
    print('Yes')
else:
  print('No')

### FIXED CODE ###

A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if A11 in b and A12 in b and A13 in b:
    print('Yes')
elif A21 in b and A22 in b and A23 in b:
    print('Yes')
elif A31 in b and A32 in b and A33 in b:
    print('Yes')
elif A11 in b and A21 in b and A31 in b:
    print('Yes')
elif A12 in b and A22 in b and A32 in b:
    print('Yes')
elif A13 in b and A23 in b and A33 in b:
    print('Yes')
elif A11 in b and A22 in b and A33 in b:
    print('Yes')
elif A13 in b and A22 in b and A31 in b:
    print('Yes')
else:
    print('No')
N,A,B,C=map(int,input().split())
l=[]

for i in range(N):
l.append(int(input()))
INF=100000

def mp(j,a,b,c):
    if j==N:
      return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=mp(j+1,a,b,c)
    ret1=mp(j+1,a+l[j],b,c)+10
    ret2=mp(j+1,a,b+l[j],c)+10
    ret3=mp(j+1,a,b,c+l[j])+10
    return min(ret0,ret1,ret2,ret3)
print(mp(0,0,0,0))

### FIXED CODE ###

N,A,B,C=map(int,input().split())
l=[]
 
for i in range(N):
    l.append(int(input()))
INF=100000
 
def mp(j,a,b,c):
    if j==N:
      return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=mp(j+1,a,b,c)
    ret1=mp(j+1,a+l[j],b,c)+10
    ret2=mp(j+1,a,b+l[j],c)+10
    ret3=mp(j+1,a,b,c+l[j])+10
    return min(ret0,ret1,ret2,ret3)
print(mp(0,0,0,0))
n, a, b = [int(i) for i in input().split()]
hs = [None]*n
kill_b = [None]*n
all_hp = 0
all_killb = 0
for i in range(n):
    hs[i] = int(input())
    # all_hp += hs[i]
    # kill_b[i] = hs[i] // b
    # if((hs[i] % b) != 0):
    #     kill_b[i] += 1
    # all_killb += kill_b[i]
# hs.sort()
max_hp = max(hs)
ret = 0
ab = a - b
right = max_hp // b
if((max_hp % b) != 0):
    right += 1
left = 1
while right != left:
    middle = (right + left) // 2
    # print([left, right, middle])
    all_a = 0
    for x in hs:
        nokori = x - (b * middle)
        if(nokori > 0):
            num_a = nokori // ab
            if(x > num_a * a + (middle - num_a) * b):
                num_a += 1
            all_a += num_a
    if(all_a <= middle):
        right = middle
    else:
        left = middle + 1
ret = right
    # for i in range(hs[-1] // b):
        # flag = False
        # for j in range(n):
        #     ret += 1
        #     base_height = (ret * b) + (i * (a-b))
        #     #print(base_height)
        #     if((j == n-1) or (hs[-(j+2)] <= (base_height))):
        #         break
        # max_height = (ret * b) + ((i + 1) * (a-b))
        # if(max_height >= hs[-1]):
        #     break
print(ret)


### FIXED CODE ###

n = int(input())
s = []
all_ac = 0
for i in range(n):
    s.append(int(input()))
    all_ac += s[-1]
s.sort()
if((all_ac % 10) == 0):
    for x in s:
        if(x % 10 != 0):
            all_ac -= x
            break
if((all_ac % 10) == 0):
    print(0)
else:
    print(all_ac)
c = 1
while True:
    x = input()
    if x == 0 else break
    print("Case ", c, ": ", x) 
    c += 1


### FIXED CODE ###

c = 1
while True:
    x = int(input())
    if x == 0: break
    print("Case {}: {}".format(c, x))
    c += 1
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...
#p(a)

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1, N):
	g = gcd(g,a[i])
	if K%g==0:
		ans=PO
		break
else:
	ans=IM


print(ans)


### FIXED CODE ###

import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1,N):
	g = gcd(g,a[i])

if K%g==0:
	ans=PO
else:
	ans=IM


print(ans)
a,b,c=map(int,input().split("/"))

print(str(a+1)"/"str(b)"/"str(c))

### FIXED CODE ###

a,b,c=input().split("/")

print(int(a)+1,b,c,sep=("/"))
import sys
input = sys.stdin.readline

n=int(input())
l=[list(map(int,input().split())) for _ in [0]*(n-1)]
q,k=map(int,input().split())
L=[list(map(int,input().split())) for _ in [0]*q]

neighbor=[[] for _ in range(n+1)]
for i in range(n-1):
    neighbor[l[i][0]].append([l[i][1],l[i][2]])
    neighbor[l[i][1]].append([l[i][0],l[i][2]])

cost=[-1]*(n+1)
cost[k]=0
c=0

def sol(i,p,d):
    global cost
    cost[i]=d
    for x in neighbor[i]:
        if x[0]!=p:
            sol(x[0],i,d+x[1])
sol(k,-1,0)

for i in range(q):
    print(cost[L[i][0]]+cost[L[i][1]])

### FIXED CODE ###

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

n=int(input())
l=[list(map(int,input().split())) for _ in [0]*(n-1)]
q,k=map(int,input().split())
L=[list(map(int,input().split())) for _ in [0]*q]

neighbor=[[] for _ in range(n+1)]
for i in range(n-1):
    neighbor[l[i][0]].append([l[i][1],l[i][2]])
    neighbor[l[i][1]].append([l[i][0],l[i][2]])

cost=[-1]*(n+1)
cost[k]=0
c=0

def sol(i,p,d):
    global cost
    cost[i]=d
    for x in neighbor[i]:
        if x[0]!=p:
            sol(x[0],i,d+x[1])
sol(k,-1,0)

for i in range(q):
    print(cost[L[i][0]]+cost[L[i][1]])