peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=set([1,2,3])
for i in range(2):
    l=l-set([int(input())])
print(int(list(l)[0]))
# Judge status: Accepted
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in a[1:]:
  ans=gcd(ans,i)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    x,y=MI()
    if x%y==0:
        print(-1)
    else:
        print(x*(y+1))

main()
# Judge status: Accepted
N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))
# Judge status: Accepted
from typing import List


def answer(n: int, m: int, x: int, y: int, xs: List[int], ys: List[int]) -> str:
    xs.append(x)
    ys.append(y)
    if min(ys) <= max(xs):
        return 'War'
    return 'No War'


def main():
    n, m, x, y = map(int, input().split())
    xs = list(map(int, input().split()))
    ys = list(map(int, input().split()))
    print(answer(n, m, x, y, xs, ys))


if __name__ == '__main__':
    main()
# Judge status: Accepted
input();a,b1,b2,b4=list(map(int,input().split())),0,0,0
for i in a:
  if i%2!=0: b1+=1
  elif i%4==0: b4+=1
  else: b2+=1
print('Yes'if b1<=b4 else'No'if b2 else'Yes'if b1<=b4+1 else'No')
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                cnt += 1
print(cnt)
# Judge status: Accepted
def main(n,k,s):
  l=[0]
  for i in range(1,n):
    if s[i]==s[i-1]:
      l[-1]+=1
    else:
      l.append(0)
  print(min(n-1,sum(l)+k*2))
    
if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n,k=map(int,input().split())
  s=input()
  main(n,k,s)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(0, n, 2):
    if a[i] % 2 != 0:
        res += 1

print(res)
# Judge status: Accepted
from math import ceil
n = int(input())
arr = list(map(int, input().split()))
B = []
for i in range(n):
    B.append(arr[i] - (i+1))
B.sort()
b1 = B[n//2]
b2 = B[n//2]
if n > 1:
	b2 = B[int(ceil(n/2))]
ans1, ans2 = 0, 0
for i in range(n):
    ans1 += abs(arr[i]-(b1+i+1))
    ans2 += abs(arr[i]-(b2+i+1))
print (min(ans1, ans2))
# Judge status: Accepted
X = int(input())

N, r = divmod(X, 100)

if r <= 5*N:
  print(1)
else:
  print(0)
# Judge status: Accepted
n = int(input())
p = input().split(" ")

ans = 0

for i in range(1,n-1):
    if (int(p[i-1]) < int(p[i]) and int(p[i]) < int(p[i+1])) or(int(p[i-1]) > int(p[i]) and int(p[i]) > int(p[i+1])):
        ans += 1
    else:
        ans += 0

print(ans)
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
dist = abs(A - B)
velocity = V - W
if velocity * T >= dist:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
d = int(input())
ans = ["Christmas", "Eve", "Eve", "Eve"]

print(" ".join(ans[:26-d]))
# Judge status: Wrong Answer

N,M = map(int,input().split())
adj = [[0]*N for _ in range(N)]
intx = lambda x: int(x)-1
for i in range(M):
    a,b = map(intx,input().split())
    #print(a,b)
    adj[a][b] = 1
    adj[b][a] = 1
for i in range(N): 
    print(sum(adj[i]))
# Judge status: Accepted
from collections import deque
K=int(input())
Q=deque(list(range(1,10)))
for _ in range(K):
  x=Q.popleft()
  if x%10 != 0:
    Q.append(10*x+x%10-1)
  Q.append(10*x+x%10)
  if x%10 != 9:
    Q.append(10*x+x%10+1)
print(x)
# Judge status: Accepted
N, M = map(int, input().split())

C = []
for i in range(M):
    p, y = map(int, input().split())
    C.append([i, p, y])
C.sort(key=lambda x: (x[1], x[2]))

ans = []
k = C[0][1]
n = 1
for i in range(M):
    city = C[i][1]
    if k != city:
        k = city
        n = 1
    number = f'{city:06}{n:06}'
    ans.append([C[i][0], number])
    n += 1
ans.sort(key=lambda x: x[0])
for i in range(M):
    print(ans[i][1])
# Judge status: Accepted
n,m=map(int,input().split())
ab=[[int(x) for x in input().split()] for _ in range(n)]
cd=[[int(x) for x in input().split()] for _ in range(m)]

for a,b in ab:
  ans=list()
  for c,d in cd:
    ans.append(abs(a-c)+abs(b-d))
  print(ans.index(min(ans))+1)
# Judge status: Accepted
a, b, c = map(int, input().split())
if 4*a*b < (c-a-b)**2 and c > a+b:
    print('Yes')
else :
    print('No')
# Judge status: Accepted
s = input()
pattern1 = 0
pattern2 = 0
for i in range(len(s)):
  if i %2 == 0:
    if s[i] == "0":
      pattern1 += 1
    else:
      pattern2 += 1
  else:
    if s[i] == "0":
      pattern2 += 1
    else:
      pattern1 += 1
print(min(pattern1,pattern2))
# Judge status: Accepted
n, m = [int(i) for i in input().split()]
if n > m:
    n, m = m, n
if n == m == 1:
    print(1)
elif n == 1 and m > 1:
    print(m - 2)
else:
    print((n - 2) * (m - 2))
# Judge status: Wrong Answer
n,p=map(int,input().split())
a=[i%2 for i in map(int,input().split())]

print(2**(n-1))
# Judge status: Wrong Answer
from collections import deque

N,K = map(int,input().split())
telpo = [int(x) for x in input().split()]
now = 1
loop = deque([now])
count = 0

for i in range(K):
    now = telpo[now-1]
    if now in loop:
        while now != loop[0]:
            loop.popleft()
            count += 1
        break
    else:
        loop.append(now)

remain = (K-count)%len(loop)

for i in range(remain):
    now = telpo[now-1]

print(now)
# Judge status: Accepted
S = input()
for i in range(0, len(S), 2):
    if S[i:i+2] != "hi":
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

x = K - A
if 0 <= x:
    A = 0
    B = B - x
else:
    A = A + x

print(A, B)
# Judge status: Wrong Answer

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

A_, B_ = A, B
common = 1
n_max = int(min(A,B)**0.5+1)

for n in range(2, n_max+1):
    while True:
        if (A_ % n == 0) and (B_ % n == 0):
            common *= n
            A_ = A_ // n
            B_ = B_ // n
        else:
            break

print(A*B//common)
# Judge status: Accepted
a = input()
if a.isupper()== True :
    print('A')
else :
    print('a')
# Judge status: Accepted
N, K = map(int, input().split())
h = [int(x) for x in input().split()]

INF = float('inf')
dp = [INF] * N
dp[0] = 0

for i in range(1, N):
    if i < K:
        k = i
    else:
        k = K
    for j in range(i-k, i):
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))

print(dp[-1])
# Judge status: Wrong Answer
n = int(input())
ans = 1
for i in range(n):
    if i**2 <= n:
        ans = i**2
    else:
        break
print(ans)
# Judge status: Accepted
import math
a,b=input().split()
n=a+b
n=int(n)
if int(math.sqrt(n))**2==n:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
import math
X = math.ceil(N/1.08)
if math.floor(X * 1.08) == N:
    print(X)
else:
    print(":(")
# Judge status: Accepted
n=int(input())
if n % 2 == 0:
  temp = int(n/2)
  print(temp ** 2)
else:
  temp = n//2
  print(temp*(temp+1))
# Judge status: Accepted
def main():
    n = int(input())
    x = [int(xn) for xn in input().split()]
    x_sorted = sorted(x)
    idx_median = n // 2
    median_low = x_sorted[idx_median - 1]
    median_high = x_sorted[idx_median]
    for xn in x:
        print(median_high if xn <= median_low else median_low)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import numpy as np

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

if 0 not in A_1n:
	out = np.cumprod(A_1n)[-1]
	print(out) if out < 10 ** 18 else print(-1)
else:
    print(0)
# Judge status: Wrong Answer
a,b = map(int,input().split())

o = 0.08
t = 0.1

x = a / o
y = b / t

if x > y:
	lst = [i for i in range(int(y),int(x+1))]
else:
	lst = [i for i in range(int(x),int(y+1))]

for i in lst:
	if int(i * o) == a and int(i*t)==b:
		print(i)
		exit()

print(-1)
# Judge status: Wrong Answer
s=input()
n=len(s)
set=set(s)
t=len(set)
m=n//t
res=0
for i in set:
  if m<=s.count(i)<m+1:
    res+=1
  elif s.count(i)==m+1:
    continue
  else:
    print('NO')
    exit()
if m<=res:
  print('NO')
else:
  print('YES')
# Judge status: Accepted
N,A,B = map(int, input().split())

count = 0
sum1 = 0

for i in range(1, N+1):
    i_str = str(i)
    tmp = 0
    for j in range(len(i_str)):
        tmp += int((i_str[j]))
    if A <= tmp <= B:
        sum1 += i
print(sum1)
# Judge status: Accepted
N, M = map(int, input().split())

for i in range((M+1)// 2):
    print(1+i, (M+1)//2*2 - i)

for j in range(M//2):
    print((M+1)//2*2+1 + j, 2*M + 1 - j)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans = 0
from collections import defaultdict
dic = defaultdict(int)
for i in range(N):
    dic[A[i]] += 1
    dic[A[i]+1] += 1
    dic[A[i]-1] += 1
for x in range(-1, 10**5+1):
    ans = max(ans, dic[x])
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

ans = [0] * N

for i in range(N):
  ans[A[i] - 1] = i+1

print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline
_ = int(input())
nums = map(int, input().split())
maxnum = 0

for x in nums:
    if maxnum < x:
        maxnum = x
    if maxnum - x > 1:
        print('No')
        sys.exit() 

print('Yes')
# Judge status: Accepted
a, b, c, d = map(int, input().split())
ans = -float('inf')
for x in (a, b):
    for y in (c, d):
        ans = max(ans, x * y)
print(ans)
# Judge status: Accepted
N=int(input())
A=[int(input()) for i in range(N)]
dict = {}
for i in A:
  if i not in dict:
    dict[i] = 1
  else:
    dict[i] += 1
print(len([1 for i in dict.values() if i%2!=0]))
# Judge status: Accepted
nums = list(input())
for i in range(2**3):
    seven = int(nums[0])
    opt = []
    for j in range(3):
        if i >> j & 1:
            seven += int(nums[j+1])
            opt.append("+")
        else:
            seven -= int(nums[j+1])
            opt.append("-")
    if seven == 7:
        print(nums[0]+opt[0]+nums[1]+opt[1]+nums[2]+opt[2]+nums[3]+"=7")
        exit()
# Judge status: Accepted
N = int(input())
c = input()

right = N-1
left = 0
cnt = 0
for i in range(N):
    if right <= left:
        break
        
    if c[right] == "W":
        right -= 1
    else:
        if c[left] == "R":
            left += 1
        # 交換
        else:
            cnt += 1
            left += 1
            right -= 1

print(cnt)
# Judge status: Accepted
n = int(input())
sum=0
for i in range(1,n+1):
    sum+=i
print(sum)
# Judge status: Wrong Answer
a, b = input().split()
l_a = len(a)
l_b = len(b)
if isinstance((int(a)*(10**l_b) + int(b))**0.5, int):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys

n=int(input())
li=[int(x) for x in input().split()]

h=0
k=0

for i in range(n):
  if h<=li[i]:
    h=max(h,li[i])
  else:
    k=k+(h-li[i])
    h=max(h,li[i])
    
print(k)
# Judge status: Accepted
n,m = map(int,input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]
ans = "No"

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if B[k] != A[k+i][j:j+m]:
                break
            if k == m-1 and B[k] == A[k+i][j:j+m]:
                ans = "Yes"
                
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
n,m=map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i] = list(map(int, input().split()))
a.sort()
ans=0
for i in range(n):
    ans+=a[i][0]*min(m,a[i][1])
    m-=a[i][1]
    if m<=0:
        break
print(ans)
# Judge status: Wrong Answer
n,m = map(int, input().split())
if n >= m:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,x=map(int,input().split())
l=list(map(int,input().split()))
cnt=0
d=[0 for _ in range(n+1)]
d[0]=0
for i in range(1,n+1):
    d[i]=d[i-1]+l[i-1]
    if d[i]<=x:
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
if a>k:
    print(a-k,b)
elif a+b>k:
    print(0,a-(k-a))
else:
    print(0,0)
# Judge status: Wrong Answer
a,b = map(int,input().split())

if a in {1,3,5,7,8,10,12} and b in {1,3,5,7,8,10,12}:
    print("Yes")
if a in{2} and b in {2}:
    print("Yes")
if a in {4,6,9,11} and b in {4,6,9,11}:
    print("Yes")   

else:
    print("No")
# Judge status: Accepted
n, a, b = map(int, input().split())

ans = 0
for i in range(1, n+1):
    s = str(i)
    tot = 0
    for c in s:
        tot += ord(c) - ord('0')
    if tot >= a and tot <= b:
        ans += i

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())

res = []

if N % 2 == 0:
    x = 0
    for i in range(N // 2 // 2):
        res.append((x + 1, (x + 2 * i + 1) % N + 1))
        x -= 1
        x %= N
    for i in range((N // 2 - 1) // 2):
        res.append((x + 1, (x - (N // 2 - 1) // 2 * 2 + 2 * i) % N + 1))
        x -= 1
        x %= N

else:
    for i in range(N // 2):
        res.append((i + 1, N - i - 1))

for i in range(M):
    a, b = res[i]
    print(a, b)
# Judge status: Accepted
s = input()
if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
else:
  print(1)
# Judge status: Accepted
N, A, B = map(int, input().split())

if N % (A+B) > A:
    left = A
else:
    left = N % (A+B)
ans = (N // (A+B)) * A + left
print(ans)
# Judge status: Accepted
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    n, k = map(int, input().split())
    cst = list(map(int, input().split()))
    arr = [0] * n
    arr[1] = abs(cst[1] - cst[0])
    for i in range(2, n):
        arr[i] = min(abs(cst[j] - cst[i]) + arr[j] for j in range(max(i - k, 0), i))
    print(arr[n - 1])
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s,t = (i for i in input().split())
print(s+t)
# Judge status: Accepted
a, b = map(int, input().split())
ans = 0
for i in range(a, b + 1):
    if str(i) == str(i)[::-1]:
        ans += 1
print(ans)
# Judge status: Accepted
import math
import bisect
N,K = list(map(int,input().split(" ")))
r,s,p = list(map(int,input().split(" ")))

di = {}
di["r"] = p
di["s"] = r
di["p"] = s
di["@"] = 0
T = input()
T = list(T)
for i in range(K,N):
    if T[i - K] == T[i]:
        T[i] = "@"
ans = 0
for temp in T:
    ans += di[temp]

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

mae = a[0]
ans = 0

for i in a:
    if mae > i:
        ans += mae - i
    else:
        mae = i

print(ans)
# Judge status: Accepted
s, k, t = input(), int(input()), ""
for q in s:
    if (p := (123 - ord(q)) % 26) <= k:
        k -= p
        t += "a"
    else:
        t += q
print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))
# Judge status: Accepted
N = int(input())
print(N*800 - 200*(N//15))
# Judge status: Wrong Answer
n=int(input())
s=[]
s.append(2)
s.append(1)
if n==1:
    print('2')
    exit()
elif n==2:
    print('1')
    exit()
else:
    for i in range(2,87):
        k = s[i-2]+s[i-1]
        s.append(k)
        if i==n:
            print(s[i])
            exit()
# Judge status: Accepted
a=input()
print(int(a[0])+int(a[1])+int(a[2]))
# Judge status: Wrong Answer
N,R=map(int,input().split())
print(R-100*(10-N))
# Judge status: Accepted
a, b, c, d = map(int, input().split())
print(max(min(b,d) - max(a,c), 0))
# Judge status: Wrong Answer
H, N = map(int, input().split())
# mahous = [(a, b) for a, b in list(map(int, input().split()))]

mahous = []
for i in range(N):
    a, b = map(int, input().split())
    mahous.append((a, b))

dp = [float("inf")] * (H + 1)
dp[0] = 0

for h in range(1, H + 1):
    for n in range(N):
        a, b = mahous[n]
        if h - a >= 0:
            dp[h] = min(dp[h], dp[h - a] + b, dp[h - 1] + b)
    # print(dp)

print(dp[H])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

c = [0]*100
for i in a:
    b = format(i,'b')[::-1]
    for x in range(len(b)):
        c[x] += int(b[x])

ans = 0
mod = 10**9+7
for i in range(100):
    ans += c[i]*(n-c[i])*2**i
    ans %= mod

print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
li=[list(map(int,input().split())) for _ in range(m)]
box=[[1,0]]
for i in range(n-1):
    box.append([0,1])
for x,y in li:
    tmp=box[x-1].copy()
    box[x-1][0]-=tmp[0]/(tmp[0]+tmp[1])
    box[x-1][1]-=tmp[1]/(tmp[0]+tmp[1])
    box[y-1][0]+=tmp[0]/(tmp[0]+tmp[1])
    box[y-1][1]+=tmp[1]/(tmp[0]+tmp[1])
ans=0
for i in box:
    if i[0]>0:
        ans+=1
print(ans)
# Judge status: Wrong Answer
S = input()
now = (0, 0)
d = {'S': (0, -1), 'E': (1, 0), 'N': (0, 1), 'W': (-1, 0)}
res = "No"
for i in range(len(S)):
    now = (now[0] + d[S[i]][0], now[1] + d[S[i]][1])
    if now == (0, 0):
        res = "Yes"
        break
print(res)
# Judge status: Accepted
def main():
    _, k = map(int, input().split())
    x = tuple(map(int, input().split()))
    print(min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :])))
 
 
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

a_meter = (12-A)/0.006

ans = -1
diff = 10**6
for i in range(N):
    temp = abs(a_meter - H[i])
    # print("temp:" + str(temp))
    # print("diff:" + str(diff))
    if diff > temp:
        diff = temp
        ans = i+1

print(ans)
# Judge status: Wrong Answer
import math

i = int(input())
print(i*math.pi)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a==b:
  print(2*a)
else:
  print(2*a-1)
# Judge status: Wrong Answer
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        t = L[i] + L[j]
        idx = bisect.bisect_left(L, t)
        ans += max(0, idx-j-1)
        print(i, j, idx, ans)
print(ans)
# Judge status: Wrong Answer
import collections
s = str(input())
l = []
for i in range(0,4):
  l.append(s[i])
  i += 1
c = collections.Counter(l)
if len(c) == 4:
  print('Good')
else:
  print('Bad')
# Judge status: Accepted

a, b, c = map(int, input().split())
res = 0
if a < b+c:
    res = b + c - a
else:
    res = 0
print(res)
# Judge status: Wrong Answer
S = input()
if S[0] != S[1]!= S[2] != S[3]:
  print("Bad")
else:
  print("Good")
# Judge status: Accepted
s = sorted(input())
t = sorted(input(), reverse=True)
print("Yes") if s < t else print("No")
# Judge status: Accepted
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *L = map(int, read().split())

L.sort()
ans = 0

for i in range(1,N-1):
    upper = N-1
    for j in reversed(range(0,i)):
        sum = L[i] + L[j]

        if upper == N :
            upper = N-1

        while upper > i and sum <= L[upper]:
            upper -= 1
        ans += upper-i

print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    ans=0
    rem=N-2
    rem=max(rem,0)
    ans=rem*(B-A)+1
    ans=max(ans,0)
    if A>B or rem==0:
        ans=0
    print(ans)

main()
# Judge status: Accepted
import fractions
 
def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)
 
N=int(input())
T=1
for i in range(N):
  T=lcm(T,int(input()))
print(T)
# Judge status: Accepted
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

l,r,d = MI()





print(r//d-(l-1)//d)
# Judge status: Wrong Answer
a, b = map(int, input().split())
answer = (a * b)% 2
if answer == 0:
    print('even')
else:
    print('odd')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print(str(c),"",str(a),"",str(c))
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
if A>B:
    print(0)
    exit()
ans = (B*(N-1)+A) - (A*(N-1)+B) + 1
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print("Zero")
elif a > 0:
    print("Positive")
elif b < 0:
    tmp = b-a
    if tmp %2 == 1:
        print("Positive")
    else:
        print("Negative")
# Judge status: Accepted
N = int(input())

dp = [0] * (N + 1)
dp[0] = 2
dp[1] = 1

for i in range(2, N + 1):
    dp[i] = dp[i - 2] + dp[i - 1]
    
print(dp[N])
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
S = input()
a = b = 0
for s in S:
  if s == 'a' and a+b < A+B:
    print('Yes')
    a += 1
  elif s == 'b' and b < B:
    print('Yes')
    b += 1
  else:
    print('No')
# Judge status: Accepted
n = list(input())
r = list(map(int,n))[::-1]
ans = 0
k = 0
f = 0
for i in r:
  i += k
  if f==5 and i>4:
    i += 1
  ans += min(i,10-i)
  k = int(i>5)
  f = i
print(ans+k)
# Judge status: Accepted
t=input()
ans=""
for i in range(len(t)):
    if t[i]=="?":
        ans+="D"
    else:
        ans+=t[i]
print(ans)
# Judge status: Accepted
r, g, b = map(int, input().split())
if ((10 * g + b) % 4 == 0):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
s = input()
if n % 2 == 1:
    print('No')
else:
    if s[:n // 2] == s[n // 2:]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
S, T = [i for i in input().split()]
A, B = [int(i) for i in input().split()]
U = input()
if U == S:
    print(A-1, B)
else:
    print(A, B-1)
# Judge status: Accepted
from collections import Counter
# ABC091
N = int(input())
S = Counter([input() for _ in range(N)])
M = int(input())
T = Counter([input() for _ in range(M)])

ans = 0

for word, count in S.items():
    temp = count - T[word]
    ans = max(ans, temp)
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

qual = {"A": 0, "B": 0}

for i in range(N):
    ans = False
    l = S[i]
    if qual["A"] + qual["B"] < A + B:
        if l == "a":
            ans = True
            qual["A"] += 1
        elif l == "b":
            if qual["B"] < B:
                ans = True
                qual["B"] += 1
    if ans:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
li = sorted(list(map(int, input().split())))
# n, m = map(int, input().split())
if li[0] + li[1] == li[2]:
	print("Yes")
else:
	print("No")
# print(chr(ord('A')+ind[1])+str(ind[0]))
# Judge status: Accepted
X, A, B = map(int, input().split())
if A-B >= 0:
    print("delicious")
elif B-A <= X:
    print("safe")
else:
    print("dangerous")
# Judge status: Wrong Answer
ans=-1
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
for k in range(10**(n-1),10**n):
    for i in range(m):
        if str(k)[l[i][0]-1]!=str(l[i][1]):
            break
    else: 
        ans=k
        print(ans) 
        break
if ans==-1: print(-1)
# Judge status: Accepted
s = input()
s = s[-1::-1]
word = ['resare','esare','remaerd','maerd',]
for i in word:
    s = s.replace(i,'')
if s:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
x,y = map(int,input().split())
if x%y != 0:
  print(x)
else:
  print(-1)
# Judge status: Accepted
x,y,z = map(int, input().split())

print(int((x-z)/(y+z)))
# Judge status: Wrong Answer
S = input()
ans = 753
for i in range(len(S)-3):
  ans = min(ans, abs(int(S[i:i+3])-753))

print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
a1=-1
b1=-1
c1=-1
for a in range(0,x+1):
    for b in range(0,x+1-a):
        c=x-a-b
        if 10000*a+5000*b+1000*c==y:
            a1=a
            b1=b
            c1=c
print(a1,b1,c1)