peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, m = [int(i) for i in input().split()]
n_list = [10] * n
for _ in range(m):
  si, ci = [int(i) for i in input().split()]
  if n_list[si - 1] == 10:
    n_list[si - 1] = ci
  elif n_list[si - 1] != ci:
    print(-1)
    exit()
if n != 1:
  ans = n_list[0] if n_list[0] != 10 else 1
else:
  ans = n_list[0] if n_list[0] != 10 else 0
if ans == 0 and n != 1:
  print(-1)
  exit()
for ai in n_list[1:]:
  if ai != 10:
    ans = ans * 10 + ai
  else:
    ans = ans * 10
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int, input().split())
print(b + c -a)
# Judge status: Accepted
a = input()
b = input()

arr = []
la = len(a)
lb = len(b)

for i in range(la-lb+1):
    c = a[i:i+lb] 
    cu = 0
    for j in range(lb):
        if c[j] != b[j]:
            cu += 1
    arr.append(cu)
    
print(min(arr))
# Judge status: Accepted
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]

d = defaultdict(lambda: 50+1)

for i in range(N):
    for c in range(ord("a"), ord("z")+1):
        d[chr(c)] = min(d[chr(c)], S[i].count(chr(c)))

ans = ""
for key, value in d.items():
    ans += key * value

print(ans)
# Judge status: Accepted
N = int(input())
S = input()
a = S.count("E")
c = a 

for s in S:
  if s=="E":
    c-=1
  else:
    c+=1
  a=min(a,c)

print(a)
# Judge status: Wrong Answer
from math import *

def nHr(n, r):
   if 0 <= r:
      return factorial(n+r-1) / (factorial(r) * factorial(n-1))
   else:
      return 0

lst = input().split()
K = int(lst[0])
S = int(lst[1])

a = nHr(3, S)
b = (3 * nHr(3, S - K)) - (3 * nHr(3, S - (2*K)))

print(int(a - b))
# Judge status: Wrong Answer
x=int(input())

if 0<=x%11<=5:
    ans=(x//11)*2+1

if x%11>5:
    ans=(x//11)*2+2

print(ans)
# Judge status: Accepted
O,E=input(),input()
ans=''
for i in range(len(O+E)):
    if i%2==0: ans=ans+O[i//2]
    else: ans=ans=ans+E[i//2]
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=[]
cnt=0
for i in range(n):
    while a[i]%2==0:
       a[i] /= 2
       cnt += 1
    b.append(cnt)
cnt = 0
if min(b)!=0:
    print(min(b)-1)
else:
    print('0')
# Judge status: Accepted
x=int(input())
y=1  # y個購入すると題意をみたす時、1<=y<=x//100、実際に支払い可能な金額は100＊y〜105＊y
if x<100:
  print(0)
else:
  while y<=x//100+1:
    if y*100<=x<=y*105:
      print(1)
      break
    elif y>x//100:
      print(0)
      break
    else:
      y+=1
# Judge status: Wrong Answer
Q, H, S, D = map(int, input().split())
N = int(input())
q, h, s, d = Q * 4, H * 2, S, D / 2
if N % 2 == 0:
    ans = N * min(q, h, s, d)
else:
    if N == 1:
        ans = min(q, h, s)
    else:
        ans = (N - 1) * min(q, h, s, d) + min(q, h, s)
print(int(ans))
# Judge status: Wrong Answer
n = int(input())
cs = []
ss = []
fs = []

for _ in range(n-1):
    c, s, f = map(int, input().split())
    cs.append(c)
    ss.append(s)
    fs.append(f)

for i in range(n):
    t = 0
    for j in range(i, n-1):
        if t < ss[j]:
            t = ss[j] + cs[j]
        elif t % fs[j] == 0:
            t += cs[j]
        else:
            t = t + t % fs[j] + cs[j]
    print(t)
print(0)
# Judge status: Wrong Answer
A = [1,3,5,7,10,12]
B = [4,6,9,11]
a,b = map(int, input().split())
if ((a in A)and(b in A)) or ((a in B) and (b in B)) or a == b == 2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = int(input())
ans = 0

ans = x//11*2
x %= 11

# 0 <= x < 11 になっている
if x == 0:
  pass
elif x < 6:
  ans += 1
else:
  ans += 2

print(ans)
# Judge status: Wrong Answer
print('NYoe s'[len(set(input()))<3::2])
# Judge status: Accepted
a, b, c = map(int, input().split())
if max(a, b, c) == a + b + c - max(a, b, c):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
if '7' in str(input()):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,b=list(map(int,input().split()))

a=[input() for i in range(n)]

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

m=n//2

print(a[m]-a[m-1])
# Judge status: Accepted
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

N,X=map(int,input().split())
W=list(map(int,input().split()))
ans=[]
for i in W:
    ans.append(abs(i-X))

print(gcd_list(ans))
# Judge status: Accepted
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

a = [x[0] for x in ab]
a.sort()
b = [y[1] for y in ab]
b.sort()

if n % 2 == 0:
    print((b[n // 2 - 1] + b[n // 2]) - (a[n // 2 - 1] + a[n // 2]) + 1)
else:
    print(b[(n - 1) // 2] - a[(n - 1) // 2] + 1)
# Judge status: Accepted
s = input()
ans = 0
n = len(s)
prev = ""
now = 0
while now<n:
    if prev != s[now]:
        prev = s[now]
        now += 1
    else:
        if now != n-1:
            now += 2
            prev = ""
        else:
            break
    ans += 1
print(ans)
# Judge status: Wrong Answer
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[0]==a[1]==a[2]:
  print(0)
  exit()
if a[0]==[1]:
  print(a[2]-a[1])
  exit()
if a[1]==a[2]:
  if (a[2]-a[0])%2==0:
    print(a[2]-a[0])
    exit()
  else:
    print(a[2]-a[0]+1)
    exit()
cnt+=a[2]-a[1]
a[0]+=cnt
if a[0]%2==0:
  cnt+=a[2]-a[0]
else:
  cnt+=a[2]-a[0]+1
print(cnt)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
# print(A)
ans = sum(A[N:2*N])
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3

print((int(input())+int(input()))*int(input())//2)
# Judge status: Wrong Answer
n , k = map(int, input().split())
H = list(map(int, input().split()))

DP = [100000 for i in range(n)]
DP[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            tmp = DP[i - j] + abs(H[i - j] - H[i])
            DP[i] = min(DP[i], tmp)
        else:
            pass

print(DP[n - 1])
# Judge status: Wrong Answer
M = 10**9 + 7
n, a, b = map(int, input().split())
r = (pow(2, n, M) - 1) % M
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    r = (r - c * pow(f, M - 2, M)) % M
print((r - c * pow(f, M - 2, M) % M))
# Judge status: Accepted
A, B, C = map(int, input().split())

if (C >= A) and (C <= B):
    print( "Yes" )
else :
    print( "No" )
# Judge status: Wrong Answer
n = int(input())
s = input()
 
if n%2 == 1:
  print("No")
 
slise = (n/2)+1
a = s[:int(slise)]
b = s[int(slise):]
 
if a==b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from math import floor
a, b, n = map(int, input().split())

if b > n:
    print(floor(a*n/b))
else:
    print(floor(a*(b-1)/b))
# Judge status: Wrong Answer
N = int(input())
if N % 2 ==1:
    print(N//2 +1)
else:
    print(N/2)
# Judge status: Wrong Answer
n, k = map(int, input().split())
ans = []
for i in range(1, n+1):
    if i < k:
        cnt = 0
        while i < k:
            i *= 2
            cnt += 1
        tmp = 1/n * ((1/2) ** cnt)
        ans.append(tmp)
print(sum(ans))
# Judge status: Accepted
X, Y = map(int, input().split())

f = 0

for a in range(100):
    for b in range(100):
        x = a + b
        y = 2 * a + 4 * b
        if x == X and y == Y:
            f = 1
            break

    if f == 1:
        break

print(['No', 'Yes'][f])
# Judge status: Accepted
N=input()
*A, = map(int,input().split())
ans = 0
h = A[0]
for a in A:
    ans += max(0,h-a)
    h = max(h,a)

print(ans)
# Judge status: Accepted
n, m   = map(int, input().split())
a =list(map(int, input().split()))
b = [i  for i in a if i >= sum(a)*(1/(4*m))]

if len(b) >= m:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
l, r = map(int, input().split())
m = 2019
if r - l < 673:
    print(0)
else:
    ans = 2018
    l = l%m
    r = r%m
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
    print(ans)
# Judge status: Wrong Answer
"""
a,b,c=map(int,input().split())
s=[a,b,c]
s.sort()
print(s[0]+s[1])
"""
n = int(input())
count=0
temp=0
xtemp=0
ytemp=0
for i in range(0,n):
    t,x,y = map(int, input().split())
    if (t-temp)>=x-xtemp+y-ytemp and (x-xtemp+y-ytemp-(t-temp))%2==0:
        count=count+1
    temp=t
    xtemp=x
    ytemp=y
if count==n:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
H = int(input())

def func(h):
    if h == 1:
        return 1
    else:
        return func(h // 2) * 2 + 1

r = func(H)
print(r)
# Judge status: Wrong Answer
import numpy as np
 
N = int(input())
AList = np.array(input().split(" "), dtype=np.int64)
result = AList.prod()
 
if result > 10 ** 18:
    print("-1")
else:
    print(result)
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a>=b: print(a-1)
else: print(a)
# Judge status: Wrong Answer
import math

A, B, C, D = map(int, input().split())
CD = int(C * D // math.gcd(C, D))

B_in_C = int(B/C)
B_in_D = int(B/D)
B_in_CD = int(B/(CD))
B_con = B - (B_in_C + B_in_D - B_in_CD)

A = A-1 if A > 1 else A
A_in_C = int(A/C)
A_in_D = int(A/D)
A_in_CD = int(A/(CD))
A_con = A - (A_in_C + A_in_D - A_in_CD)

print(B_con - A_con)
# Judge status: Wrong Answer
N = int(input())
ls = []
for i in range(N):
    a,b = map(int,input().split())
    ls.append([a,b])
ls.reverse()
#貪欲法 (aをbの倍数にする)
ans = 0
for i in range(N):
    A = ls[i][0]
    B = ls[i][1]
    if i != 0:
        A += ans
    if B == 1:
        continue
    else:
        ans += B - A % B
print(ans)
# Judge status: Accepted
l=[i*111 for i in range(1,10)]
N=int(input())
for i in l:
    if N>i:
        continue
    else:
        print(i)
        break
# Judge status: Accepted
import fractions

a,b,c,d = map(int, input().split())
x = (b//c - (a - 1)//c)
y = (b//d - (a - 1)//d)
z = (b//((c * d)//fractions.gcd(c,d)) - (a - 1)//((c * d)//fractions.gcd(c,d)))

print(int((b - a + 1) - (x + y - z)))
# Judge status: Accepted
n = int(input())
lst = [list(map(int, input().split())) for i in range(n)]
ans = [[0]*3 for i in range(n)]
ans[0] = lst[0]
for i in range(1, n):
  ans[i][0] = lst[i][0] + max(ans[i-1][1], ans[i-1][2])
  ans[i][1] = lst[i][1] + max(ans[i-1][0], ans[i-1][2])
  ans[i][2] = lst[i][2] + max(ans[i-1][0], ans[i-1][1])

res = max(ans[n-1][0], max(ans[n-1][1], ans[n-1][2]))
print(res)
# Judge status: Wrong Answer
N, M = map(int, input().split())
mat = [[0 for _ in range(N)] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    mat[a][b] = 1
    mat[b][a] = 1
for i in range(N):
    cnt = 0
    for j in range(N):
        if mat[i][j] != 0:
            cnt += 1
    print(cnt)
# Judge status: Accepted
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range((n-3)//2+1):
    for j in range(n-3-i*2+1):
        j1 = j+i+1
        j2 = j+i*2+2
        if s[j] != s[j1] and s[j1] != s[j2] and s[j2] != s[j]:
            ans -= 1
print(ans)
# Judge status: Wrong Answer
import numpy as np
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort
j=0
if K >= N:
    print(N)
else:
    for i in range (N-K):
        j+=H[i]
    print(j+K)
# Judge status: Accepted
m,n=map(int,input().split())
l=[]
for i in range(1,12500):
    if i*2//25==m and i//10==n:
        l.append(i)
if len(l)==0:
    print(-1)
else:
    print(min(l))
# Judge status: Accepted
a=list(input())
b=set(a)
count=0
for i in range(4):
  if a[0]==a[i]:
    count+=1
if len(b)==2 and (count==2):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n=int(input())
s=input()
r=input()
t=s+r
f=0
for i in range(n):
    if(s[i:]==r[:n-i]):
        t=s[:i]+r
        f=1
        break
if(f==1):
    print(len(t))
else:
    print(2*n)
# Judge status: Wrong Answer
import sys
import numpy as np
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, K = readnums()
    h = np.sort(np.array([readint() for _ in range(N)]))
    print(min(h[K - 1] - h[0], h[-1] - h[-K]))


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, L = map(int, input().split())
taste_list = list(range(L, N + L, 1))
print(sum(taste_list) - min(taste_list, key=lambda x: -x if x < 0 else x))
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
cont = 0
cont_list =[]

for a in A:
    if a % 2 != 0:
      cont_list.append(cont)
      break
    else:
        while a % 2==0:
            a //= 2
            cont += 1
        cont_list.append(cont)
        cont=0

print(min(cont_list))
# Judge status: Accepted
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = []

X.sort()
for i in range(1, M):
    Y.append(X[i] - X[i-1])

Y.sort()
if N >= M:
    print(0)
else:
    print(sum(Y[:M-N]))
# Judge status: Accepted
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())

    a = int(input())
    s = input()

    if a >= 3200:
        print(s)
    else:
        print("red")


if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b = map(int,input().split())
print(a*b if a<=9 and b<=9 else -1)
# Judge status: Wrong Answer
d,n = map(int,input().split())
print(n*100**d)
# Judge status: Accepted
G1 = [1,3,5,7,8,10,12]
G2 = [4,6,9,11]
x,y = map(int, input().split())

if x in G1 and y in G1:
  print('Yes')
elif x in G2 and y in G2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
W = list(map(int,input().split()))

ans = float("inf")
for T in range(N):
    ans = min(ans, abs(sum(W[:T]) - sum(W[T:])))

print(ans)
# Judge status: Accepted
N = int(input())
L_a = [int(s) for s in input().rstrip().split(' ')]
l_a = set(L_a)
if len(l_a) == len(L_a):
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
a, b = (int(x) for x in input().split())
x = (a+b) / 2
if (a+b) % 2 == 0:
  print(x)
else:
  print(x + 0.5)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
if n%2 == 1:
    a.append(0)
    n += 1
ans = 0
for i in range(n//2):
    ans += a[2*i]
    ans -= a[2*i+1]
print(ans)
# Judge status: Accepted
import math
import collections
def main():
    n = int(input())
    s = []
    dd = collections.defaultdict(int)
    for i in range(n):
        a  = int(input())
        dd[a]+=1
        s.append(a)
    k = max(dd.keys())
    lis = sorted(list(dd.keys()),reverse = True)

    for i in range(n):
        if(s[i]==k and dd[s[i]]==1):
            print(lis[1])
        else:
            print(k)






if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a=list(map(int,input().split()))

ans = [-1]*n
for i,b in enumerate(a):
    ans[b-1]=i+1
print(*ans)
# Judge status: Accepted
a=input()
b=input()
if(a[2]==b[0] and a[1]==b[1] and a[0]==b[2]):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
from math import sqrt


def eratosthenes(x):
    prime = []
    for i in range(2, int(sqrt(x)) + 1):
        if x % i == 0:
            prime.append(i)
            while x % i == 0:
                x //= i
    
    return prime


N = int(input())
prime = eratosthenes(N)
ans = 0
for x in prime:
    i = 1
    while N % x**i == 0:
        ans += 1
        N /= x**i
        i += 1

print(ans)
# Judge status: Wrong Answer
A,B = map(int,input().split())

print(max(2*A-1, A+B, 2*B+1))
# Judge status: Wrong Answer
a,b = map(int,input().split())
l = [i*(i+1)//2 for i in range(1,101)]
ans = 0

for i in range(100):
  a += 1
  b += 1
  ans += 1
  if a in l and b in l:
    print(ans)
    break
# Judge status: Wrong Answer
A,B = map(int,input().split())
t=0
for i in range(A):
    X,Y = map(int,input().split())
    if (X^2+Y^2)>=B^2:
        t=t+1
    else:
        t=t
print(t)
# Judge status: Accepted
S={suit:list(input()) for suit in 'abc'}
s='a'
while S[s]:s=S[s].pop(0)
print(s.upper())
# Judge status: Accepted
N = int(input())
S = input()

for i in range(len(S)):
    print(chr(ord("A") + (ord(S[i]) - ord("A") + N) % 26), end="")
# Judge status: Accepted
S=input()
N=len(S)
ans=""
for i in range(2,N,2):
    T=S[:i]
    T1=T[:i//2]
    T2=T[i//2:]
    if T1==T2:
        ans=T
print(len(ans))
# Judge status: Accepted
import math

s = input().split()

a = int(s[0])
b = int(s[1])
c = int(s[2])

if a + b >= c :
  print('No')
else:
  if 4*a*b < ( c - a - b ) ** 2 :
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))


for a in A:
    if a%2 == 0:
        if a%3 != 0 and a%5 != 0:
            print("DENIED")
            exit()

print("APPROVED")
# Judge status: Accepted
S=str(input())
n=[]
for i in range(3):
    n.append(S[i])
print(''.join(n))
# Judge status: Accepted
from itertools import combinations

def main():
    _ = int(input())
    A = list(map(int, input().split()))
    if len(set(A)) < 3:
        print(0)
        return
    C = combinations(A, 3)
    ans = 0
    for c in C:
        c = sorted(c)
        if c[0] != c[1] and c[0] != c[1] and c[1] != c[2]:
            if c[2] < c[1] + c[0]:
                ans += 1
    print(ans)
    
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
li = list(map(int,input().split()))
ans_li=[10 ** 5 + 1] * n

ans_li[0] = li[0]
for i in range(len(li)-1):
    ans_li[i] = min(li[i], ans_li[i])
    ans_li[i+1] = min(li[i], li[i+1])
ans_li[-1] = li[-1]

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

import collections
c = collections.Counter(a)
_max = 0
for i in range(max(a)+1):
  _sum = c[i-1] + c[i] + c[i+1]
  if _max < _sum:
    _max = _sum
print(_max)
# Judge status: Accepted
n,m=map(int,input().split())
h=list(map(int,input().split()))
flag=[1]*n
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if h[a] == h[b]:
        flag[a] =0
        flag[b] =0
    elif h[a] > h[b]:
        flag[b] = 0
    else:
        flag[a] = 0
print(sum(flag))
# Judge status: Wrong Answer
import functools
import operator
import time

N = int(input())
start = time.time()
power_list = [x+1 for x in range(N)]
result = functools.reduce(operator.mul, power_list)
print(result % (10**9+7))
elapsed_time = time.time() - start
print(elapsed_time)
# Judge status: Accepted
import sys
ri = lambda: int(sys.stdin.readline())
s = ri()
print(['Christmas Eve Eve Eve', 'Christmas Eve Eve', 'Christmas Eve', 'Christmas'][s-22])
# Judge status: Wrong Answer
S= list(map(str, input().split()))
T= list(map(str, input().split()))

STand = set(S) & set(T)
STlist = list(STand )
print(len(STlist))
# Judge status: Wrong Answer
N=input()
if N.isupper()=="TRUE":
    print("A")
else:
    print("a")
# Judge status: Wrong Answer
n=int(input())
ans=''
while n:
  ans+=str(n%2)
  n-=n%2
  n//=-2
print([''.join(ans[::-1]),0][n==0])
# Judge status: Wrong Answer
H=int(input())
ans=1
num=1
while H>0:
  ans+=num
  num*=2
  H//=2
print(ans)
# Judge status: Accepted
s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')
# Judge status: Accepted
S0,S1,S2=input().split("/")
if int(S1)<5:
  print("Heisei")
else:
  print("TBD")
# Judge status: Accepted
N = int(input())
S = input()

Wlist = [0]*(N+1) 
Elist = [0]*(N+1) 

for i in range(1,N+1):
    if S[i-1] == 'W':
        Wlist[i] = Wlist[i-1] + 1
    else:
        Wlist[i] = Wlist[i-1]
        
    if S[i-1] == 'E':
        Elist[i] = Elist[i-1] + 1
    else:
        Elist[i] = Elist[i-1]

ans = []

for i in range(1,N+1):
    ans.append((Elist[-1] - Elist[i]) + (Wlist[i-1]))
    
print(min(ans))
# Judge status: Accepted
n = int(input())
ans = ''
l = []
while n>0:
    w = chr(96+n%26)
    if not n%26:
        w = 'z'
        n-=26
    l.append(w)
    n = int(n//26)
l.reverse()
ans = ''.join(l)
print(ans)
# Judge status: Accepted

import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b = input_int_list()
    if b < a or (n == 1 and a != b):
        print(0)
        sys.exit()
    n -= 2
    if n == 0:
        print(1)
    else:
        ans = (b * n) - (a * n) + 1
        print(ans)

    return


if __name__ == "__main__":
    main()
# Judge status: Accepted
import math

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        tmp = math.gcd(i, j)
        for k in range(1, K+1):
            ans += math.gcd(tmp, k)

print(ans)
# Judge status: Wrong Answer
H,N=map(int,input().split())
As=[int(i) for i in input().split()]
if sum(As)>H:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,k = map(int, input().split())
l = [0]+list(map(int, input().split()))

journey = [1]

for i in range(2*n):
    next = l[journey[-1]]
    journey.append(next)
if k <= n+1:
    print(journey[k])
    exit()

end = n
start = n-1

while journey[start] != journey[end]:
    start -= 1

period = end - start
k %= period

while k < n:
    k += period

print(journey[k])
# Judge status: Accepted
from itertools import count


def count_div_by_100(n: int) -> int:
    for idx in range(4):
        q, r = divmod(n, 100)
        if r != 0:
            return idx
        n //= 100
    return -1


D, N = map(int, input().split())
current = 0
current_idx = 0
for n in count(start=1):
    if count_div_by_100(n) == D:
        current = n
        current_idx += 1
    if current_idx == N:
        print(current)
        break
# Judge status: Accepted
d, n = map(int, input().split())
ans = 100**d*n
if ans % 100**(d+1) == 0:
    ans += 100**d
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
load = {}
for i in range(N):
  load[i] = 0
for i in range(M):
  a, b = map(int, input().split())
  load[a-1] += 1
  load[b-1] += 1
for i in range(N):
  print(load[i])
# Judge status: Wrong Answer
a = int(input())
input_s = input()



if 3200 <= a <5000:
    output_s = ("pink")
elif 2800 <= a <3200:
    output_s = ("red")

print(output_s)
# Judge status: Wrong Answer
if sum(list(map(int,str(input()))))==9:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
K=int(input())
S=input()

if K>=len(S):
  print(S)
else:
  print(S[0:K]+str("..."))
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int,input().split())))
ans1 = a[-1]
ans2 = a[0]
for i in range(1,n-1):
    if abs(ans2-ans1/2)>abs(a[i]-ans1/2):
        ans2 = a[i]
print(ans1,ans2)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
mod = 10**9+7
def inv(x):
  return pow(x, mod-2, mod)
def fact(x):
  f = 1
  for i in range(1, x + 1):
    f *= i
    f %= mod
  return f
def comb(n, r):
  return (fact(n) * inv(fact(n-r)) * inv(fact(r))) % mod
print((pow(2, n) - comb(n, a) - comb(n, b)) % mod)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = [set(list(map(int, input().split()))[1:]) for i in range(n)]
s = 0
for i in a:
  if a.index(i) == 0:
    s = i
  else:
    s = s & i
print(len(s))
# Judge status: Accepted
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)
# Judge status: Accepted
def coun(n,r):
    return n*r+1+r-r**2

def sigma(func,frm,too):
    result=0
    for i in range(frm,too+2):
        #print(i)
        result=result+func(too,i)
        #print(result)
    print(result%mod)

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

sigma(coun,k,n)
# Judge status: Accepted
X = int(input())
ans = 0
for i in range(X+1):
    ans += i
    if ans >= X:
        print(i)
        exit()
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(N):
    l.extend([a[i]-1,a[i],a[i]+1])

import collections
c=collections.Counter(l)

print(c.most_common()[0][1])
# Judge status: Accepted
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        
        tmp = 1
        while tmp*tmp <= n:
            if n % tmp == 0:
                b[tmp-1] ^= 1
                if tmp != n//tmp:
                    b[n//tmp-1] ^= 1
            tmp += 1

M = len(ans)
print(M)
if ans:
    print(*ans)