peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
#D - Teleporter
N,K = map(int, input().split())
A = list(map(int, input().split()))
DP = []
DP.append(A[0])
for i in range(N):
    DP.append(A[DP[i]-1])

print(DP[K%len(DP)-1])
# Judge status: Wrong Answer
data = list(map(int, input().split()))
if len(set(data)) == 1:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
from fractions import gcd
from functools import reduce

def lcm(n1, n2):
    return n1 * n2 // gcd(n1, n2)

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] //= 2

lcmA = reduce(lcm, A)
if lcmA % 2 == 1:
    all_num = M // lcmA
    if all_num % 2 == 0:
        print(all_num // 2)
    else:
        print(all_num // 2 + 1)
else:
    print(M // lcmA)
# Judge status: Accepted
N, K = map(int ,input().split())
A = [int(x) for x in input().split()]
checked = [False] * N
root=[0]

idx = 0
checked[0]=True

for k in range(K):
  root.append(A[idx]-1)
  idx = A[idx]-1
  if (checked[idx]):
    break
  checked[idx]=True
else:
  print(idx+1)
  exit(0)

for i, r in enumerate(root):
  if r == root[-1]:
    break

root2=root[i:]
l = len(root2)-1
idx = root2[(K-i)%(l)]
print(idx+1)
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)
k = X // D
print(abs(X - D * (k + (1 if (K - k) % 2 == 1 else 0))) if k <= K else X - D * K)
# Judge status: Accepted
x, y = map(int, input().split())

a = 0
b = 0
det = 2
a = (4 * x - y) / det
b = (-2 * x + y) / det


if a < 0 or b < 0 or y % 2 == 1:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
X=int(input())

ans=0
for i in range(1,40):
    for j in range(2,100):
        n=pow(i,j)
        if n>X:
            break
        ans=max(ans,n)
        
print(ans)
# Judge status: Accepted
n = int(input())
ans = 0
out = 1
for i in range(1, n + 1):
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    if cnt > ans:
        ans = cnt
        out = i * 2 ** ans
print(out)
# Judge status: Accepted
x,n=list(map(int,input().split()))
import sys
if n==0:
  print(x)
  sys.exit()

p=list(map(int,input().split()))
for i in range(x,110):
  if 2*x-i not in p:
    print(2*x-i)
    sys.exit()
  if i not in p:
    print(i)
    sys.exit()
# Judge status: Accepted
n,m = map(int,input().split())
ans = 1
for i in range(1,int(m**0.5)+1):
    if m%i!=0:continue
    if m//i>=n:
        ans = max(i,ans)
    if i>=n:
        ans = max(m//i,ans)

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

ans = 0
t = k**(ans)
while n >= t:
  ans += 1
  t=k**(ans)
if n == 0:
  print(1)
else:
  print(ans)
# Judge status: Accepted
x,a,b = map(int,input().split())
if abs(x-a)>abs(x-b):
    print('B')
else:
    print('A')
# Judge status: Accepted
print('YNeos'[(int(input())%500)>int(input())::2])
# Judge status: Wrong Answer
x = int(input())
print(1000*(x//500) + 5*((x%500)%5))
# Judge status: Wrong Answer
n,a,b = map(int,input().split())

if a == 0:
  print(0)
elif b == 0:
  print(n)
elif a >= n:
  print(n)
elif a+b >= n:
  print(a)
else:
  c = a*n//(a+b) + min(n%(a+b),a)
  print(c)
# Judge status: Accepted
K = int(input())
r = [[] for _ in range(10)]
r[0] = list(range(1,10))

for i in range(9):
  for a in r[i]:
    s = str(a)
    d = a%10
    for j in range(d-1, d+2):
      if not 0 <= j <= 9: continue
      r[i+1].append(int(s+str(j)))

for i in range(10):
  if K >= len(r[i]):
    K -= len(r[i])
  else:
    print(r[i][K-1])
    break
# Judge status: Accepted
import math
a, b = [int(i) for i in input().split()]
 
a_min = math.ceil(a * 12.5)
a_max = int((a+1) * 12.5 - 10e-10)
 
b_min = math.ceil(b * 10 )
b_max = int((b+1)*10 - 10e-10)

  
if a_max < b_min:
  print(-1)
  exit()
  
if b_max < a_min:
  print(-1)
  exit()
  
if a_min <= b_min:
  print(b_min)
  exit()
print(a_min)
# Judge status: Wrong Answer
s=input()
word='keyence'
flag=0
if s[:6]==word:
    flag=1
if s[-7:]==word:
    flag=1
for i in range(7):
    if s[:i]+s[-(6-i):]==word:
        flag=1
print('YES' if flag else 'NO')
# Judge status: Accepted
lst=[2,1]
n=int(input())
for i in range(n-1):
    lst.append(lst[-1]+lst[-2])

print(lst[-1])
# Judge status: Accepted
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, k = ns()
    p = na()

    p.sort()
    ans = sum(p[:k])

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():

    k = int(input())
    a = [0] * (10 ** 6 + 1)
    a[0] = 7 % k
    if a[0] == 0:
        print(1)
        exit()
    for i in range(1, k + 1):
        a[i] = (a[i - 1] * 10 + 7) % k
        if a[i] == 0:
            print(i + 1)
            exit()
    print(-1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, d = list(map(int ,input().split()))
ans = 0
for i in range(a, b+1):
    if(i%d ==0):
        ans+=1
print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(1, n + 1):
    if p[i - 1] == i:
        cnt += 1
    if p[i - 1] != i or i == n:
        ans += (cnt + 1) // 2
        cnt = 0
print(ans)
# Judge status: Wrong Answer
N = int(input())
if N % 9 == 0:
  print('Yes')
else:
  print('Mo')
# Judge status: Wrong Answer
S = sorted(input())
print('Yes') if S[0] == S[1] and S[0] != S[2] and S[0] != S[3] else print('No')
# Judge status: Accepted
N = input()
listed = input().split()
mul = 1
for num in listed:
  num = int(num)
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10**18:
      mul = -1
print(mul)
# Judge status: Accepted
n = int(input().replace(" ",""))
if n%4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import os

def main():
    a=[int(x) for x in input().split()]
    if a[0] >= 10:
        print(a[1])
    else:
        num = 100*(10-a[0])
        print(num + a[1])

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s = input()
if s == 'RRR':
    print(3)
elif s == 'RRS' or 'SRR':
    print(2)
elif s == 'SSS':
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
s = str(input())
if(s[2] == s[3] and  s[4] == s[5]):
    print("yes")

else:
    print("no")
# Judge status: Accepted
n, a, b = map(int, input().split())
print((n // (a + b)) * a + min(n % (a + b), a))
# Judge status: Accepted
import math

N = int(input())

li = []

for i in range(N):
    x, l = map(int, input().split())
    li.append([x-l,x+l])

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

ans = 0
t = 0 - 10**9 + 99
for i in range(N):
    if t <= li[i][0]:
        ans += 1
        t = li[i][1]

print(ans)
# Judge status: Accepted
x, y = map(int, input().split())
if x * y > 0:
    if x < y:
        ans = abs(x - y)
    else:
        ans = abs(x - y) + 2
elif x * y < 0:
    ans = abs(abs(x) - abs(y)) + 1
else:
    if x < y:
        ans = abs(x - y)
    else:
        ans = abs(x - y) + 1
print(ans)
# Judge status: Accepted
import collections
N = int(input())
D = list(map(int,input().split()))

if D[0] != 0 or 0 in D[1:]:
    print(0)
    exit()

A = collections.Counter(D)
A = list(A.items())
A.sort()

if len(A) != max(D) + 1:
    print(0)
    exit()

ans = 1
for i in range(max(D)):
    ans *= A[i][1]**A[i+1][1]
    if ans >= 998244353:
        ans %= 998244353
print(ans)
# Judge status: Wrong Answer
from itertools import combinations_with_replacement
N,M,Q = map(int,input().split())
A = []
for i in range(Q):
    b = list(map(int,input().split()))
    A.append(b)
K = list(combinations_with_replacement([1,2,3,4,5,6,7,8,9],N))

ans = 0
for line in K:
    total = 0
    for combi in A:
        if line[combi[1]-1] - line[combi[0]-1] == combi[2]:
            total += combi[3]
    ans = max(total,ans)

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

ans = 0
for i in range(1, len(A)):
    height = max(0, A[i-1] - A[i])
    A[i] += height
    ans += height

print(ans)
# Judge status: Accepted
n = int(input())
ac_cnt = 0
wa_cnt = 0
tle_cnt = 0
re_cnt = 0
for i in  range(n):
    s = input()
    if s == 'AC':
        ac_cnt += 1
    elif s == 'WA':
        wa_cnt += 1
    elif s == 'TLE':
        tle_cnt += 1
    elif s == 'RE':
        re_cnt += 1
print('AC x ' + str(ac_cnt))
print('WA x ' + str(wa_cnt))
print('TLE x ' + str(tle_cnt))
print('RE x ' + str(re_cnt))
# Judge status: Wrong Answer
def main():
    S = list(input())
    K = int(input())
    N = len(S)
    k = K
    for i,c in enumerate(S):
        distance = ord('z') + 1 - ord(c)
        if distance <= k:
            k -= distance
            S[i] = 'a'
    
    S[-1] = chr((ord(S[-1]) - ord('a') + k) % 26 + ord('a'))
    print(''.join(S))

main()
# Judge status: Wrong Answer
x=int(input())
a=list(map(int, input().split()))
suma=sum(a)
ans=0
for i in range(len(a)):
  ans+=a[i]
  if ans>=suma/2:
    chuou=i
    break
print(abs(2*sum(a[:chuou+1])-suma))
# Judge status: Wrong Answer
import math

def count_index(list, k):
    count = 0
    for i in range(k):
        if (list[i] < list[k]):
            count = count + 1
    return list[k]-count-1

n = int(input())-1
p = list(map(int,input().split()))
q = list(map(int,input().split()))

a = (p[0]-1) * math.factorial(n)+1
b = (q[0]-1) * math.factorial(n)+1
print(a)
print(b)

for i in range(1,n):
    a = a + count_index(p, i) * math.factorial(n-i)
    b = b + count_index(q, i) * math.factorial(n-i)

ans = a-b
print(abs(ans))
# Judge status: Accepted
S=input()
cnt=0
for i in range(len(S)//2):
  if S[i]!=S[-i-1]:
    cnt+=1
print(cnt)
# Judge status: Accepted
# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLE思想

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

ans = M // N
for a in range(ans, 0, -1):
    if M % a == 0:
        print(a)
        exit()
# Judge status: Wrong Answer
n=int(input())
a=iter(map(int,input().split()))
p=1
i,j=next(a),next(a,0)
while j!=0:
    k=next(a,0)
    #print(j,k)
    if 0 not in (i,j,k) and (i<j>k or i>j<k):
        p+=1
        i,j=j,k
        k=next(a,0)
    i,j=j,k
print(p)
# Judge status: Accepted
import heapq

N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

BC.sort(key=lambda x: x[1], reverse=True)
heapq.heapify(A)
for (b, c) in BC:
    for _ in range(b):
        min_val = A[0]
        if min_val < c:
            heapq.heappop(A)
            heapq.heappush(A, c)
        else:
            break
print(sum(A))
# Judge status: Wrong Answer
d = int(input())
if d == 25:
    print('Christmas')
elif d == 24:
    print('Christmas Eve')
elif d == 23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
for i in range(n):
  if i == 0:
    memo=a[0]
    d=abs(s-memo)
  else:
    memo += a[i]
    d_ = abs(s-memo)
    d=min(d,d_)
print(d)
# Judge status: Accepted
# w/o decimal module

a, b = map(str, input().split())
b = b[:-3] + b[-2:]
# print(int(int(a)*int(b) / 100)) # WA
print(int(a)*int(b) // 100)
# Judge status: Accepted
li = []

for i in range(5):
    li.append(int(input()))

k = int(input())

if li[-1] - li[0] <= k:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
n = int(input())
arr = list(map(int,input().split()))
ans = 0
tmp = 0

for i in range(n-1):
    tmp += arr[i]%1000000007
    ans += tmp*arr[i+1] % 1000000007

print(ans%1000000007)
# Judge status: Accepted
a,b,c=[int(x) for x in input().split(" ")]
if (a+b)==c or (a+c)==b or (b+c)==a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input());

dict = {}

for i in range(n):
    s = input();
    if not s in dict:
        dict[s] = 1

sum = 0
for i in dict:
    sum += 1

print(sum)
# Judge status: Accepted
a,b=map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

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

a.sort()

maxa=max(a)
ans=0
ch=0

for i in range(n-1):
  b=maxa-a[i]
  c=min(b,a[i])
  if c>=ch:
    ans=a[i]
    ch=c
    
print(str(maxa)+' '+str(ans))
# Judge status: Accepted
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if m == 0:
    if n == 1:
        print(0)
    else:
        print(10 ** (n - 1))
    exit()

if n == 1:
    left = 0
else:
    left = 10 ** (n - 1)
right = 10 ** n

ans = -1
for i in range(left, right):
    i = str(i)
    for s, c in sc:
        if int(i[s - 1]) != c:
            break
    else:
        ans = i
        break

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

if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(int(B/2))
else:
    print(0)
# Judge status: Accepted
N=int(input())
ans=0
reject=0
A=[]
for i in range(1,N+1):
    ans+=i
    if ans>=N:
        reject=ans-N
        for j in range(1,i+1):
            if j!=reject:
                print(j)
        break
# Judge status: Accepted
def main():
  s = list(input())
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 753         
  count = 0
  lis = []
  
  for i in range(len(s)-2):
    a = abs(753 - (int(s[i])*100+int(s[i+1])*10+int(s[i+2])))
    ans = min(a,ans)
  print(ans)
  
if __name__ == '__main__':
  main()
# Judge status: Accepted
a, b, c, d = map(int, input().split())
while True:
    c -= b
    if c <= 0:
        print('Yes')
        break
    a -= d
    if a <= 0:
        print('No')
        break
# Judge status: Accepted
import math
a,b,x=map(float,input().split())
volume=a**2*b
if volume<x*2:
    sub=volume-x
    sub=sub/a*2/a
    ans=math.degrees(math.atan(sub/a))
else:
    x=x/a*2/b
    ans=90.0-math.degrees((math.atan(x/b)))
print(ans)
# Judge status: Accepted
import collections

N = int(input())

words=[]

for i in range(N):
    words.append(input())

c = collections.Counter(words)

l=c.most_common()

max_num = l[0][1]

max_words =[]
    
for i in l:
    if i[1] == max_num:
        max_words.append(i[0])
    else:
        break
        
max_words.sort()

for word in max_words:
    print(word)
# Judge status: Accepted
#!/usr/bin/env python3
import math

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

if n == k:
    ans = 1 
elif (n-1)%(k-1)==0:
    ans = (n-1)//(k-1)
else:
    ans = (n-1)//(k-1) + 1 
print(ans)
# Judge status: Accepted
n = int(input())
t = [int(input()) for i in range(n)]

#最大公約数
def gcd(a, b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a * b // gcd(a, b)

ans = t[0]
for i in range(1,n):
    ans = lcm(ans, t[i])

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

if A == 1:
    A += 13
elif B == 1:
    B += 13

if A > B :
    print("Alice")
elif A < B:
    print("Bob")
else:
    print("Draw")
# Judge status: Accepted
# ABC121C - Energy Drink Collector
def main():
    N, M, *AB = map(int, open(0).read().split())
    AB = list(zip(*[iter(AB)] * 2))
    AB.sort()
    ans = 0
    for a, b in AB:
        while b > 0 and M > 0:
            ans += a
            b -= 1
            M -= 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n, *a = map(int, open(0).read().split())
f = 0
t = 0
o = 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
    else:
        o += 1
if f >= o - 1 and t == 0:
    print('Yes')
elif f >= o:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math

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

ans = 0
for i in range(n):
    cnt = 0
    for j in reversed(range(n)):
        if i != j:
            if a[i] % a[j] != 0:
                cnt += 1
                if cnt == n-1:
                    ans += 1
            else:
                break
print(ans)
# Judge status: Accepted
n = int(input())

print("0.5" if n%2==0 else ((n//2)+1)/n)
# Judge status: Wrong Answer
n = int(input())
keep=[]
ans=[0]*n
for i in range(n):
    lis = list(input().split())
    keep.append(lis)
for j in range(len(keep)):
    num=1
    for k in (keep[0:j]+keep[j+1:n]):
        if keep[j][0]>k[0]:
            num+=1
        elif keep[j][0]==k[0] and keep[j][1]<k[1]:
            num+=1
    ans[j]=num
for l in range(n):
    print(ans.index(l+1)+1)
# Judge status: Accepted
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K, S = lr()
INF = 10 ** 9
if S < INF:
    answer = [S] * K + [S+1] * (N-K)
else:
    answer = [S] * K + [1] * (N-K)    

print(*answer)
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)

k = X // D
if abs(X - k * D) <= abs(X - (k + 1) * D):
    best_k = k
else:
    best_k = k + 1

if K < best_k:
    print(abs(X - K * D))
elif (K - best_k) % 2 == 0:
    print(abs(X - best_k * D))
else:
    print(min(abs(X - best_k * D + D), abs(X - best_k * D - D)))
# Judge status: Accepted
n=int(input())
x=int(input())
d=n%500
if(d<=x):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = list(map(str, input()[0:3]))
res = 0
for i in S:
    if i == "R":
        res += 1
print(res)
# Judge status: Wrong Answer
N = int(input())
S = []

for i in range(N):
  S.append(int(input()))
  
S.sort()
ans = sum(S)

if ans % 10 != 0:
  print(ans)
  
for i in range(N):
  if S[i] % 10 != 0:
    ans -= S[i]
    print(ans)
    exit()

print(0)
# Judge status: Wrong Answer
li = list(input())
for i in li:
    if i != 'b' or i != 'a' or i != 'c':
        print('No')
        exit()

print('Yes')
# Judge status: Accepted
count = 0
S = [int(i) for i in list(input())]

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        if S[i] == 0:
            S[i+1] = 1
        elif S[i] == 1:
            S[i+1] = 0
        count += 1 
print(count)
# Judge status: Accepted
n,k=map(int,input().split())
ps=list(map(int,input().split()))
ps.sort()

print(sum(ps[:k]))
# Judge status: Accepted
n, c, k = list(map(int, input().split()))
t = [int(input()) for i in range(n)]
t.sort()

limit = t[0] + k
num = 1
cnt = 1
for i in range(1, n):
  if limit < t[i] or num == c:
    num = 1
    limit = t[i] + k
    cnt += 1
  
  else:
    num += 1
print(cnt)
# Judge status: Wrong Answer
n  = int(input())
a = list(map(int, input().split()))

wallet = 1000
stock = 0

for i in range(len(a)-1):
  if a[i+1] > a[i]:
    stock = wallet // a[i]
    wallet -= stock * a[i]
  elif a[i+1] <= a[i]:
    wallet += stock * a[i]
    stock = 0

wallet += stock * a[-1]

print(wallet)
# Judge status: Wrong Answer
l, r = map(int, input().split())
res = 2018

if r-l > 2019:
    print(0)
else:
    for i in range(l, r):
        for j in range(i+1, r+1):
            res = min(res, (i*j)%2019)
print(res)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

from bisect import bisect
from math import factorial
def rank(l):
  r = 0
  nums = [_ for _ in range(1,n+1)]
  for i in range(n):
    r += bisect(nums, l[i]) * factorial(len(nums)-1)
    nums.remove(l[i])
  return r
print(abs(rank(p)-rank(q)))
# Judge status: Wrong Answer
a,b,k = map(int,input().split())
ans = 0
for i in range(1,min(a,b)):
  if(a%i==0)and(b%i==0):
    ans += 1
  if(ans==k):
    print(i)
    break
# Judge status: Accepted
import math
k=int(input())
l=[]
s=0
for x in range(1,k+1):
  for y in range(1,k+1):
    l.append(math.gcd(x,y))

for x in range(len(l)):
  for y in range(1,k+1):
    s+=math.gcd(l[x],y)
print(s)
# Judge status: Accepted
import math
N=int(input())
c=int(math.sqrt(N))
print(c**2)
# Judge status: Accepted
S,T = input().split()
A,B = map(int,input().split())
U = input()
if S ==U:
  print(A-1,B)
else:
  print(A,B-1)
# Judge status: Accepted
n = int(input())
ai = [int(i) for i in input().split()]

ans = ai[0]

for i in range(n-1):
    ans = ans ^ ai[i+1]
    
ans_li = []

for i in range(n):
    ans_li.append(ans^ai[i])
    
print(*ans_li)
# Judge status: Accepted
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,a,b = map(int,ipt().split())
    if a > b:
        print(0)
    else:
        print(max(0,(n-2)*b-(n-2)*a+1))

    return

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
import math
import bisect

def main():
    a, b = map(int, input().split())
    if a <= 5:
        ans = 0
    elif a <= 12:
        ans = b // 2
    else:
        ans = b
    print(ans)
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
def main():
    W, H, x, y = map(int, input().split())
    if x * 2 == W and y * 2 == H:
        print(W * H / 2, 1)
    else:
        print(W * H / 2, 0)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
mod = 10**9+7

for i in range(1, N+1):
    N *= i
    N %= mod

print(N % mod)
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
for i in range(1,3200,400):
    flag = False
    for j in range(i - 1, i + 398 + 1):
        if j in A:
            flag = True

    if flag:
        ans += 1

ans1 = ans
ans2 = ans + len([a for a in A if a >= 3200])
print(ans1,ans2)
# Judge status: Accepted
s = list(input().split())
print(s[0][0],s[1][0],s[2][0],sep='')
# Judge status: Wrong Answer
import collections

N = int(input())

S_list = set(list(map(str,input().split())))
print(len(S_list))
# Judge status: Wrong Answer
N,Q = map(int,input().split())
S = input()
AC = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    AC.append(i+1.5)

print(AC)

for j in range(Q):
  l,r = map(int,input().split())
  cnt = 0
  for k in AC:
    if l < k < r:
      cnt += 1
    if r < k:
      break
  print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
bmax = a[0]
st = 0
for i in range(1,n):
	if a[i] < bmax:
		st += bmax - a[i]
	else:
		bmax = a[i]
print(st)
# Judge status: Accepted
s=input()
k=int(input())
l=0
for i in s:
    if i=="1":
        l+=1
    else:
        break
print("1" if k<=l else s[l])
# Judge status: Accepted
r, g, b = map(int, input().split())
op = int(input())
while op > 0 and g <= r:
    g *= 2
    op -= 1
while op > 0 and b <= g:
    b *= 2
    op -=1
if r < g and g < b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
s=input()
x=0
Mx=x
for i in range(n):
  if s[i]=='I':
    x+=1
  else:
    x-=1
  Mx=max(Mx, x)
print(Mx)
# Judge status: Wrong Answer
n,m = map(int,input().split())
dic = {}
ls = [1]*(n+1)
ls[0] = 0
cnt = 0
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ls[a] -= 1
    ls[b] += 1
    if dic.get(b,0) == 0:
        cnt += 1
        dic[b] = 1
print(sum([1 for e in range(1,n+1) if ls[e] > 0 and dic.get(e,0)!= 0]))
# Judge status: Accepted
A, B = map(int,input().split())
r = B - A +1
ans = 0
for i in range(r):
  n = str(A + i)
  l = len(n)//2
  count = 0
  for j in range(l):
    if n[j] == n[-(j+1)]:
      count +=1
  if count == l:
    ans += 1
    
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n = int(input())
ll = []
for i in range(n):
  x, l = map(int, input().split())
  ll.append([x-l, x+l])
ll.sort(key=lambda x:x[1])

ans = 0
tmp = -10**9

for s, t in ll:
  if s >= tmp:
    ans += 1
    tmp = t

print(ans)