peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import re
s = input()
pattern={
    '.*keyence'
    ,'k.*eyence'
    ,'ke.*yence'
    ,'key.*ence'
    ,'keye.*nce'
    ,'keyen.*ce'
    ,'keyenc.*e'
    ,'keyence.*'
    }

for p in pattern:
    if re.fullmatch(p, s):
        print('YES')
        break
else:
    print('NO')
# Judge status: Accepted
X = input()
N = len(X)

tcnt_l = 0
scnt_l = 0
for i in range(N):
    if X[i] == "T" and scnt_l == 0:
        tcnt_l += 1
    elif X[i] == "S":
        scnt_l += 1
    else:
        scnt_l -= 1

tcnt_r = 0
scnt_r = 0
for i in range(N-1,-1,-1):
    if X[i] == "S" and tcnt_r == 0:
        scnt_r += 1
    elif X[i] == "T":
        tcnt_r += 1
    else:
        tcnt_r -= 1

print(tcnt_l+scnt_r)
# Judge status: Accepted
#!/usr/bin/env python3
_, c, k, *t = map(int, open(0).read().split())
t.sort()
n = 0
f = t.pop(0)
p = 1
for i in t:
    if i > f + k or p >= c:
        n += 1
        p = 1
        f = i
    else:
        p += 1
print(n + (c > 0))
# Judge status: Accepted
N=int(input())
S=input()
a=0
b=0
cnt=0
for i in range(N):
  if S[i]==')':
    b+=1
  else:
    a+=1
  cnt=max(cnt,b-a)
A='('*cnt+S
d=A.count(')')
e=A.count('(')
f=e-d
print(A+')'*f)
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
num = sorted([list(map(int, input().split())) for i in range(n)], key = lambda x: x[0])

s = []
j = 0
count = 0
heapq.heapify(s)

for i in range(1, m + 1):
  while (j < n and num[j][0] <= i):
    heapq.heappush(s, num[j][1] * (-1))
    j += 1
  if(len(s)):
    count += heapq.heappop(s) * (-1)

print(count)
# Judge status: Accepted
y, m, d = map(lambda x: int(x), input().split('/'))
if m <= 4:
  print('Heisei')
else:
  print('TBD')
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
odd = 0
mul2 = 0
mul4 = 0
for i in a:
    if i % 2 == 1:
       odd += 1
    elif i % 4 == 0:
        mul4 += 1
    else:
        mul2 += 1

if mul2:
    if odd <= mul4:
        print("Yes")
    else:
        print("No")
else:
    if odd <= mul4 + 1:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def permitation(x):
    res = 1
    for i in range(1, x + 1):
        res = res * i % mod
    return res


pn = permitation(n)
pm = permitation(m)

if n == m:
    res = pn * pm * 2 % mod
    print(res)
elif n == m - 1 or n == m + 1:
    res = pn * pm % mod
    print(res)
else:
    print(-1)
# Judge status: Accepted
from collections import defaultdict
n = int(input())
s = [input() for _ in range(n)]
table = defaultdict(int)
for i in s:
    table[i] += 1
for j in ["AC", "WA", "TLE", "RE"]:
    print(j+" "+"x"+" "+str(table[j]))
# Judge status: Accepted
N= int(input())

p=list(map(int,input().split()))
q=sorted(p)

count=0
for i in range(len(p)):
  if p[i]!=q[i]:
    count += 1
#print(N,p,q,count, sep="\n")

#zipを使う
count=0
for a,b in zip(p,q):
  if a!=b:
    count += 1
#print(N,p,q,count, sep="\n")

print('YES' if count<=2 else 'NO')
# Judge status: Accepted
import sys
a,b,c=map(int,input().split())
for i in range(1,b+1):
  if a*i%b==c:
    print("YES")
    sys.exit()
  else:
    continue
print("NO")
# Judge status: Accepted
def solve():
    x, a, b = map(int, input().split())
    if b <= a:
        print('delicious')
    elif a < b <= a + x:
        print('safe')
    else:
        print('dangerous')


if __name__ == "__main__":
    solve()
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())

ans = 0
if a + b > c * 2:
    d = min(x, y)
    ans += c * d * 2
    x -= d
    y -= d

if x > 0:
    if a > c * 2:
        ans += x * c * 2
    else:
        ans += x * a

if y > 0:
    if b > c * 2:
        ans += y * c * 2
    else:
        ans += y * b

print(ans)
# Judge status: Accepted
from itertools import count
# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n


from collections import Counter

c = Counter(prime_factors(int(input())))
res = 0
for cnt in c.values():
    for i in count(1):
        if cnt < 0:
            break
        cnt -= i
        res += 1
    res -= 1

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

dist = [x[i] - x[i - 1] for i in range(1, n)]
dist.append(x[0] + k - x[n - 1])

# print(len(dist))
ans = k - max(dist)

print(ans)
# Judge status: Accepted
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""

"""
#solution:
#潜 影 蛇 手 ! !
N=int(input())
T,A=pin()
H=[i for i in pin()]
c=(T-A)/0.006
HH=[abs(h-c) for h in H]
#print(c,HH)
print(HH.index(min(HH))+1)
# Judge status: Accepted
n, k = map(int, input().split())
s = list(str(input()))
unhappy = 0
for i in range(n - 1):
    if s[i] != s[i + 1]:
        unhappy += 1
print(n - unhappy - 1 + min(2 * k, unhappy))
# Judge status: Accepted
a,b,c = map(int,input().split())
ans = min(b+c,c+b,a+c,c+a,a+b,b+a)
print(ans)
# Judge status: Accepted
import sys
def main():
    input = sys.stdin.readline
    N,K=map(int, input().split())
    H=[int(input()) for _ in range(N)]

    H.sort()
    ans=10**12
    for i in range(N):
        if i+K-1 >= N: break
        ans = min(ans, H[i+K-1]-H[i])
    print(ans)

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

l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]
for i in range(1, n+1):
  l[i] = l[i-1] + a[i-1]
  r[-(i+1)] = r[-i] + a[-i]

ans = 10e+12
for i in range(1, n):
  ans = min(ans, abs(l[i] - r[i]))
print(ans)
# Judge status: Accepted
from collections import deque

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

graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
ans = [-1] * (n - 1)
used = [0]*n
used[0] = 1
que = deque([0])
while que:
    posi = que.popleft()
    for p in graph[posi]:
        if not used[p]:
            que.append(p)
            ans[p-1] = posi+1
            used[p] = 1
print('Yes')
print(*ans, sep='\n')
# Judge status: Wrong Answer
s = list(input())
data = [0] * (len(s) + 1)
for i in range(len(s)):
    if s[i] == "<":
        data[i + 1] = data[i] + 1

for i in range(len(s) - 1, -1, -1):
    if s[i] == ">":
        data[i] = max(data[i], data[i + 1] + 1) 
print(data)
print(sum(data))
# Judge status: Accepted
h = int(input())
 

def cal(h):
  if h == 1:
    return 1
  
  return 2*cal(int(h/2)) + 1
 
print(cal(h))
# Judge status: Accepted
from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    inf=10**10
    n,k=map(int,readline().split())
    h=np.array(list(map(int,readline().split())),dtype=np.int64)

    dp=np.full(n,inf,dtype=np.int64)
    dp[0]=0
    for i in range(n-1):
        end=min(n,i+k+1)
        sa=np.abs(h[i]-h[i+1:end])
        dp[i+1:end]=np.minimum(dp[i+1:end],dp[i]+sa)

    print(dp[n-1])

if __name__=="__main__":
    main()
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))
print(-(-(N-1)//(K-1)))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print((b-a+1)//c)
# Judge status: Accepted
import numpy as np

def main():
    N = np.array([str(i) for i in range(1,int(input())+1)])
    C = np.zeros((10,10), dtype=np.int)
    ans = 0

    # C[i][j](0 <= i,j <= 9)のテーブルを構築する: O(N)
    for n in N:
        C[int(n[0])][int(n[-1])] += 1

    for i in range(1,9+1):
        for j in range(1,9+1):
            ans += C[i][j] * C[j][i]

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
s=list(input())
if s[0]=="A" and s[2:len(s)-1].count("C")==1:
    s[0]="a"
    s[s.index("C")]="c"
    if "".join(s).islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")
# Judge status: Accepted
#!/usr/bin/env python3


def main():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort(reverse=True)

    alice = l[0::2]
    bob = l[1::2]
    print(sum(alice)-sum(bob))

if __name__ == '__main__':
    main()
# Judge status: Accepted
L, R, d = map(int, input().split())

ret = 0
for i in range(L, R + 1) :
  if i % d == 0 :
    ret += 1
    
print(ret)
# Judge status: Wrong Answer
import io
import sys

_INPUT = """\
999983
"""
sys.stdin = io.StringIO(_INPUT)

K = int(input())

x = 7 % K
s = set()
count = 0
while(True):
    count += 1
    if x in s:
        print(-1)
        break
    else:
        s.add(x)
        if x == 0:
            print(count)
            break
        x = (10*x+7) % K
# Judge status: Accepted
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
kingaku = 0
for i in range(k):
    kingaku += p[i]    
print(kingaku)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
x = sorted(list(map(int, input().split())))
t = 1
for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

if (t > 10 ** 18): 
    print(-1)
else:
    print(t)
# Judge status: Accepted
n,k = map(int,input().split())
h = [int(input()) for _ in range(n)]
h.sort()
ans = 10**10
for i in range(n-k+1):
    ans = min(ans, h[k+i-1]-h[i])
print(ans)
# Judge status: Accepted
# https://atcoder.jp/contests/abc044/tasks/abc044_b
w = list(input())

for token in w:
    if w.count(token) % 2 != 0:
        print("No")
        exit()

print("Yes")
# Judge status: Wrong Answer
N, M = map(int, input().split(' '))
l_val, r_val = map(int, input().split(' '))
for i in range(M-1):
    l, r = map(int, input().split(' '))
    l_val = max(l_val, l)
    r_val = min(r_val, r)

print(r_val - l_val + 1)
# Judge status: Accepted
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()

print(A[0], A[1])

if A[0] == max(A):
    print(A[0])
else:
    a = A[0]
    b = 0
    for i in range(N):
        if a != A[i]:
            b = A[i]
            break

    def gcd(x, y):
        if y == 0: return x
        return gcd(y, x%y)

    print(gcd(a, b))
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

print((N+K-3)//(K-1))
# Judge status: Accepted
import math
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = int(input())
print(round(math.pi*t*2,2))
# Judge status: Accepted
import numpy as np
 
N = int(input())
A = np.array(list(map(int, input().split())))
i = np.arange(1, N + 1)
 
b = int(np.median(sorted(A - i)))
 
print(np.sum(np.abs(A - (i + b))))
# Judge status: Accepted
S, T = map(str,input().split())
A, B = map(int,input().split())
U = str(input())

if(S == U):
    A -= 1
elif(T == U):
    B -= 1
else:
    A
    B
    
print("{} {}".format(A, B))
# Judge status: Accepted
num, back = map(int, input().split(' '))
r_point, s_point, p_point = map(int, input().split(' '))
t = input()
j_dict = {'r': 'p', 's': 'r', 'p': 's'}
score = {'r': r_point, 's': s_point, 'p': p_point, 'e': 0}
result = [j_dict[i] for i in t]
for i in range(back, num):
    if result[i] == result[i - back]:
        result[i] = 'e'
print(sum(score[i] for i in result))
# Judge status: Accepted
s=input()
if s[0]=='A' and s[2:-1].count('C')==1 and s[1:].replace('C','').islower():
    print('AC')
else:
    print('WA')
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())
c = 0
for i in range(a, b + 1):
    if i % k == 0:
        c = 1
        break
if c == 1:
    print("OK")
else:
    print("NG")
# Judge status: Wrong Answer
a,b,t = map(int,input().split())
print(((t+0.5)//a)*b)
# Judge status: Accepted
import sys
import fractions
input = sys.stdin.readline
N = int(input())
list_A = list(map(int, input().split()))
ans = list_A[0]
sum = 0
for i in range(1, N):
  ans = ans * list_A[i] // fractions.gcd(ans, list_A[i])
for a in list_A:
  sum += ans//a
print(sum%(7+10**9))
# Judge status: Wrong Answer
# -*- coding : utf-8 -*-

n, k = map(int, input().split())
D = input().split()
D = list(map(int, D))
E = [0,1,2,3,4,5,6,7,8,9]
for i in range(len(D)):
  E.remove(D[i])
  
for i in range(n, 10 * n+1):
  a = i //1000
  m = i - a*1000
  b = m //100
  l = m - b*100
  c = l // 10
  d = l - c*10
  if a in E and b in E and c in E and d in E:
    print (i)
# Judge status: Accepted
n, m, k = map(int, input().split())

ans = set()

for i in range(m+1):
    cnt = i * n
    rev = m - i
    for j in range(n+1):
        ans.add(cnt + (rev - i) * j)

if k in ans:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s=list(input())

for i in range(len(s)):
    if(s[i]=='A'):
        a=i
        break

for i in range(len(s)-1,-1,-1):
    if(s[i]=='Z'):
        z=i
        break

print(z-a+1)
# Judge status: Accepted
s = input()
t = s[::-1]
n = len(s) // 2
ans = False
if s[0:n] == t[0:n]:
	if s[0:n] == s[n+1:n*2+2]:
		ans = True

if ans:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
s=input()
for i in range(int(input())):
  if s[i]!='1': print(s[i]);break
else:
  print(1)
# Judge status: Accepted
import sys
s = input()

l = len(s)
if s[0] != "A":
    print("WA")
    sys.exit()
ss =  s[2:l-1]
if ss.count("C") != 1:
    print("WA")
    sys.exit()

cidx = ss.find("C")+2
sss = s[1:cidx]+s[cidx+1:]
if sss.islower():
    print("AC")
    sys.exit()

print("WA")
# Judge status: Accepted
a,b = map(int,input().split())
if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Accepted
X = int(input())
a = X // 500
b = X % 500
c = b // 5
print(a * 1000  + c * 5)
# Judge status: Wrong Answer
mod = 1000000007
n = int(input())
a = list(map(lambda x: format(int(x), 'b'), input().split()))

cnt = [0] * 65

for i in range(n):
  for j in range(len(a[i])):
    if a[i][j]  == '1':
      cnt[len(a[i])-j-1] += 1
      
ans = 0
for i in range(len(cnt)-1, -1, -1):
  ans *= 2
  ans %= mod
  ans += cnt[i] * (n-cnt[i])
    
print(ans)
# Judge status: Accepted
import collections
s=list(input())
l=collections.Counter(s)
a=all(v%2==0 for v in l.values())
print("Yes" if a==True else "No")
# Judge status: Accepted
h, n = map(int, input().split())
A = list(map(int, input().split()))
print("Yes" if h <= sum(A) else "No")
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))

sum = b[0] + b[-1]
for i in range(1, n-1):
    sum += min(b[i-1], b[i])

print(sum)
# Judge status: Accepted
N=int(input())
A=list(int(i)%4 for i in input().split())
b1=A.count(1)+A.count(3)
b2=A.count(2)
b4=A.count(0)
print('Yes' if ( (b2==0 and (b1<=b4+1)) or b1<=b4) else 'No')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from fractions import gcd
def lcm(x,y):
  return x * y // gcd(x,y)
def list_gcd(list):
    c=list[0]
    for i in list:
        c=gcd(c,i)
    return c
def list_lcm(list):
  c=1
  for i in list:
    c=lcm(c,i)
  return c
a = [i//list_gcd(a) for i in a]
a = [list_lcm(a) // i for i in a]
print(sum(a))
# Judge status: Accepted
a = int(input())
ar = list(map(int,input().split(" ")))
if len(set(ar)) == a:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from sys import stdin

n, x = [int(x) for x in stdin.readline().split()]
a_lst = sorted([int(x) for x in stdin.readline().split()])
s = 0

for i, a in enumerate(a_lst):
  s += a
  if s > x:
    print(i)
    exit()
    
if s == x: print(i+1)
else: print(i)
# Judge status: Accepted
l, r = list(map(int,input().split()))

if r - l >= 2019:
  print(0)
  
else:
  ll = l % 2019
  rr = r % 2019
  if rr < ll:
    print(0)
    
  else:
    keep = 2020
    for i in range(ll, rr+1):
      for j in range(i+1, rr+1):
        keep = min((i*j)%2019, keep)
    print(keep)
# Judge status: Wrong Answer
import numpy as np
N,K = map(int,input().split())
an = list(map(int,input().split()))

min_an_index = np.argmin(an)

a = min_an_index
b = N - min_an_index - 1

if K > a:
    b -= K - a - 1
if K > b:
    a -= K - b - 1
    
a1 = a // (K-1)
if a % (K-1) != 0:
    a1 += 1
    
b1 = b // (K-1)
if b % (K-1) != 0:
    b1 += 1

count = a1 + b1
print(count)
# Judge status: Accepted
N = int(input())

t = []
x = []
y = []

for i in range(N):
    tadd, xadd, yadd = map(int, input().split())
    t.append(tadd)
    x.append(xadd)
    y.append(yadd)

ans = 'Yes'

for j in range(N):
    if t[j] % 2 != (x[j] + y[j]) % 2 or t[j] < abs(x[j]) + abs(y[j]):
        ans = 'No'
        break

print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A[0],B[0])
B[0]-=ans
for i in range(N-1):
    score=min(A[i+1],B[i]+B[i+1])
    ans+=score
    B[i+1]-=min(0,score-B[i])
print(ans+min(B[N-1],A[N]))
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(2147483647)

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

for k in range(n):
    c = a[k]
    del a[k]
    for v in range(1,n+1):
        co = a.count(v)
        co2 = co - 1
        if co >= 2:
            ans += co*co2/2
    ans = 0
    print(int(ans))
    a.append(c)
# Judge status: Wrong Answer
S = input()

s = list(S)
ss = list(reversed(S))

ans = 0
for i in range(len(S)):
    if s[i] == ss[i]:
        ans += 1

print(ans)
# Judge status: Wrong Answer
s=input()
q=int(input())
que=[list(map(str,input().split())) for i in range(q)]
count=0
for i in que:
  if i[0]=="1":
    count+=1
ans=[[],[]]
    
for i in que:
  if i[0]=="1":
    count-=1
  else:
    if i[1]=="1":
      ans[count%2].append(i[2])
    else:
      ans[(count+1)%2].append(i[2])
print("".join(ans[0])+s+"".join(ans[1]))
# Judge status: Accepted
N=int(input())
h=list(map(int,input().split()))

dp=[0]*N
dp[1]=abs(h[1]-h[0])

for i in range(2,N):
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])

print(dp[N-1])
# Judge status: Wrong Answer
N =int(input())
A = list(map(int,input().split()))
leaf = sum(A)
if A[0] != 0:
    print(-1)
    exit()
v = [[0,a] for a in A]
v[0][0] = 1
MAX = 2
for i in range(1,N+1):
    v[i][0] = min((v[i-1][0]-v[i-1][1])*2,leaf)
    leaf -= v[i][1]
    MAX *= 2

if v[N][0] != v[N][1]:
    print(-1)
    exit()

ans = 0
for a,b in v:
    if a <= 0:
        print(-1)
        exit()
    ans += a

print(ans)
# Judge status: Accepted
a,b,c,d=input()
print("Yes" if a==b==c or b==c==d else "No")
# Judge status: Wrong Answer
w,h,n=map(int,input().split())
minx=0
maxx=w
miny=0
maxy=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        minx=max(minx,x)
    elif a==2:
        maxx=min(maxx,x)
    elif a==3:
        miny=max(miny,y)
    elif a==4:
        maxy=min(maxy,y)
print((maxx-minx)*(maxy-miny))
# Judge status: Accepted
N = int(input())
S = input()
lb = 0
rw = S.count('.')
ans = rw
for s in S:
    if s == '.':
        rw -= 1
    else:
        lb += 1
    ans = min(ans, lb + rw)
print(ans)
# Judge status: Accepted
# A
N =  int(input())

if N in [7,5,3]:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
S = input()
T = input()

print(T[:-1])
if S == T[:-1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
X = int(input())
print((X//500*1000)+(X % 500)//5*5)
# Judge status: Accepted
n=int(input())
s=input()
ans=0
for i in range(1,n-1):
    ans=max(ans,len(set(list(s[:i]) )&set(list(s[i:])) ))
print(ans)
# Judge status: Wrong Answer
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
A = combinations_with_replacement(range(1, m), n)
L = []

for _ in range(q):
    L.append(list(map(int, input().split())))

r = 0
for a in A:
    t = 0
    for l in L:
        if a[l[1] - 1] - a[l[0] - 1] == l[2]:
            t += l[3]
    if t > r:
        r = t
print(r)
# Judge status: Accepted
#!/usr/bin/env pytHon3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort()

    for a, b in AB:
        K -= b
        if K <= 0:
            break

    print(a)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
l,r=map(int,input().split())
x=[]
if r-l>=2018:
    print(0)
else:
    for i in range(l,r+1):
        x.append(i%2019)
    x.sort()
    print(x[0]*x[1])
# Judge status: Wrong Answer
a = input().split()
b = int(a[0])*int(a[1])
if b / 2 == 0:
  print('Even')
else:
  print('Odd')
# Judge status: Wrong Answer
s = input()

n = list(s)

if n == ["h", "i"]:
    print("Yes")

else:
    print("No")
# Judge status: Accepted
N = int(input())
mod = 10**9 + 7
ans = pow(10, N, mod)
ans -= 2 * pow(9, N, mod)
ans += pow(8, N, mod)
ans %= mod
print(ans)
# Judge status: Accepted
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
for s in set(S+T):
  ans = max(ans, S.count(s) - T.count(s))
print(ans)
# Judge status: Wrong Answer
import bisect
N,X = map(int, input().split())
x = sorted(map(int, input().split()))
bisect.insort(x,X)
ans = [x[i+1]-x[i] for i in range(N-1)] 
if N ==1:
    print(x[1]-x[0])
else:
    print(min(ans))
# Judge status: Accepted
from math import log2

def main():
    N = int(input())
    if N == 0:
        print(0)
        return
    Ans = []
    while N !=  0:
        r = N%2
        Ans.append(r)
        N = -1*( N // 2)
    print(*Ans[::-1],sep="")
    return

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
if __name__ == '__main__':
    n = int(input())
    robots = []
    for i in range(n):
        x, l = map(int, input().split())
        robots.append((x, l, x - l, x + l))
    robots = sorted(robots, key=lambda x: x[2])
    ans = []
    for i in range(n):
        if i == 0:
            ans.append(robots[i][3])
        else:
            if robots[i][2] >= ans[-1]:
                ans.append(robots[i][3])
    print(len(ans))
# Judge status: Wrong Answer
import sys

N = int(input())
CSF = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N - 1)]

for i in range(N - 1):
    res = 0
    for c, s, f in CSF[i:]:
        if res < s:
            res = s + c
        elif (res - s) % f == 0:
            res += c
        else:
            res += (res - s) % f + c
    print(res)
print(0)
# Judge status: Accepted
if __name__ == '__main__':
  line=input().split()
  print(line[1],end="")
  print(line[0],end="")
# Judge status: Accepted
X,A,B=map(int,input().split())
if((B-A) <= 0):
    print("delicious")
elif(X >= (B-A)):
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
a = list(input().split())
print(len(set(a)))
# Judge status: Accepted
import collections

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

i_s = [i + 1 + Heights[i] for i in range(N)]
j_s = [j + 1 - Heights[j] for j in range(N)]

CTR_i = collections.Counter(i_s)
CTR_j = collections.Counter(j_s)

i_value = CTR_i.keys()
total = 0

for v in i_value:
    N_i = CTR_i[v]
    N_j = CTR_j[v]
    
    total += N_i * N_j

print(total)
# Judge status: Accepted
a, b = map(int, input().split())
if a<0 and b<0:
    if (b-a)%2 ==0:
        print("Negative")
    else:
        print("Positive")
elif a>0 and b>0:
    print("Positive")
else:
    print("Zero")
# Judge status: Accepted
n = int(input())

h = n // 100
x = h * 100 + h * 10 + h
print(x) if n <= x else print(x + 111)
# Judge status: Accepted
X, Y = map(int, input().split())
now = X
count = 0
while now <= Y:
    now = now * 2
    count += 1
print(count)
# Judge status: Wrong Answer
H,W = map(int, input().split())

ans = int((W // 2) * H)

if W % 2 != 0:
    if H % 2 == 0:
        ans += H / 2
    else:
        ans += (H + 1) / 2

print(int(ans))
# Judge status: Accepted
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[]
for i in range(m-1):
    b.append(a[i+1]-a[i])
b_sort=sorted(b,reverse=1)
print(sum(b_sort[n-1:]))
# Judge status: Accepted
a,b,c=map(int,input().split())
if c-(a-b)<0:
    print(0)
else:
    print(b+c-a)