Harryxun/stf_run huggingface dataset:
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    A = il()
    t = [0]*N
    tmp = 1
    cnt = 0
    for n in range(N):
        if t[tmp-1] != 0:
            break
        cnt += 1
        t[n] = tmp
        tmp = A[tmp - 1]
    else:
        print(t[cnt-1])
        exit()

    mod = (K - cnt) % (len(t)-cnt)
    print(t[len(t)-cnt+1:][mod])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    tel = [0] + il()

    # 初期位置
    position = 1

    # 移動回数がN回(町の数)以下の場合
    if K <= N:
        for k in range(K):
            position = tel[position]
        print(position)
        exit()

    # 移動回数がN回(町の数)以上の場合
    for n in range(N):
        position = tel[position]

    # 既にN回移動済みのため、
    # 必要な移動回数(K)から減算
    K -= N
    # ループまでに必要な移動回数を探索
    base = position
    cnt = 1
    while base != tel[position]:
        position = tel[position]
        cnt += 1

    # Kからループ数の余りを求め、
    # 余りの回数だけ移動を行う
    for k in range(K % cnt + 1):
        position = tel[position]
    print(position)


if __name__ == '__main__':
    main()
import sys
import random
import math
#file = open('test.in', 'r') 
file = sys.stdin
n = input()
v = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = (v[i] * lcm) // math.gcd(v[i], lcm)
sm = 0
for i in range(n):
	sm = sm + (lcm // v[i])
print(sm % 1000000007)

### FIXED CODE ###

import sys
import random
import math
#file = open('test.in', 'r') 
file = sys.stdin

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


n = (int)(input())
v = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = (v[i] * lcm) // gcd(v[i], lcm)
sm = 0
for i in range(n):
	sm = sm + (lcm // v[i])
print(sm % 1000000007)
N = int(input())

H = list(list(map(int,input().split())) for _ in range(N))

#sub problem: max cost from 0 to ith day
def rec(i, choice):
  if i == len(H):
    return 0
  m = max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
  print(m)
  return m
print(max(rec(0, j) for j in range(3)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
 
N = int(input())
H = list(list(map(int,input().split())) for _ in range(N))
#sub problem: max cost from 0 to ith day
memo = {}
def rec(i, choice):
  if (i, choice) in memo:
    return memo[(i, choice)]
  if i == len(H):
    return 0
  m = max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
  memo[(i, choice)] = m
  return m
print(max(rec(0, j) for j in range(3)))
N = int(input())
word = []
flag = 1
for i in range(N):
  st = input()
  if i > 0 :
    if final != st[0]:
      flag = 0
    elif st in word:
      flag = 0
    else:
      final = st[-1]
      word += [st]
if flag:
  print("Yes")
else :
  print("No")

### FIXED CODE ###

N = int(input())
word = []
flag = 1
for i in range(N):
  st = input()
  if i > 0 :
    if final != st[0]:
      flag = 0
    elif st in word:
      flag = 0
    else:
      final = st[-1]
      word += [st]
  else:
    final = st[-1]
    word += [st]
if flag:
  print("Yes")
else :
  print("No")
a=list(input())

IN=[int(x) for x in a if x != " "]
N=IN[0]
A=IN[1]
B=IN[2]

Times = N // (A + B)
rest = N - Times * (A + B)

if rest < A:
        ans = A * Times + rest
else:
        ans = A * Times + A

print(ans)

### FIXED CODE ###

N, A, B = [int(x) for x in input().strip().split()]

Times = N // (A + B)
rest = N - Times * (A + B)

if rest < A:
        ans = A * Times + rest
else:
        ans = A * Times + A

print(ans)
def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)
    return


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])
s = 'AKIHABARA'
t = raw_input()
n = len(t)
i = 0
j = 0
while i < n: 
	if t[i] == s[j]:
		i += 1
		j += 1
	elif s[j] == 'A':
		j += 1
	else:
		print 'NO'
		exit()
if i == n:
	print 'YES'
else:
	print 'NO'
	



### FIXED CODE ###

s = 'AKIHABARA'
t = raw_input()
n = len(t)
i = 0
j = 0
while i < n and j < len(s): 
	if t[i] == s[j]:
		i += 1
		j += 1
	elif s[j] == 'A':
		j += 1
	else:
		print 'NO'
		exit()
while j < len(s):
	if s[j] == 'A':
		j += 1
	else:
		break
if i == n and j == len(s):
	print 'YES'
else:
	print 'NO'
def solve(arr,matrix,n,m):
    maxx=0
    if n>0:
        if arr[0][0]=="#":
            matrix[0][0]=1
        maxx=max(maxx,matrix[0][0])
        for col in range(1,m):
            matrix[0][col]=matrix[0][col-1]
            if arr[0][col]=="#":
                matrix[0][col]+=1
            maxx=max(maxx,matrix[0][col])

        for row in range(1,n):    
            matrix[row][0]=matrix[row-1][0]
            if arr[row][0]=="#":
                matrix[row][0]+=1
            maxx=max(maxx,matrix[row][0])

        for row in range(1,n):
            for col in range(1,m):
                matrix[row][col]=min(matrix[row-1][col],matrix[row][col-1])
                if arr[row][col]=="#":
                    matrix[row][col]+=1
                maxx=max(maxx,matrix[row][col])
        return matrix[n-1][m-1]        



n,m=map(int,input().split())
arr=[int(0) for i in range(n)]
matrix=[int(0) for i in range(n)]
for i in range(m):
    arr[i]=list(input())
    matrix[i]=[int(0) for _ in range(m)]



print(solve(arr,matrix,n,m))       


### FIXED CODE ###


def IsvalidStep(arr,row1,col1,row2,col2):
    if arr[row2][col2]=="#" and arr[row1][col1]==".":
        return 1
    return 0    

def solve(arr,matrix,n,m):
    maxx=0
    if n>0:
        if arr[0][0]=="#":
            matrix[0][0]=1
        for col in range(1,m):
            matrix[0][col]=matrix[0][col-1]
            if arr[0][col]=="#" and arr[0][col-1]==".":
                matrix[0][col]+=1

        for row in range(1,n):    
            matrix[row][0]=matrix[row-1][0]
            if arr[row][0]=="#" and arr[row-1][0]==".":
                matrix[row][0]+=1
          
        for row in range(1,n):
            for col in range(1,m):
                matrix[row][col]=min(matrix[row-1][col]+IsvalidStep(arr,row-1,col,row,col),matrix[row][col-1]+IsvalidStep(arr,row,col-1,row,col))
        return matrix[n-1][m-1]        



n,m=map(int,input().split())
arr=[int(0) for i in range(n)]
matrix=[int(0) for i in range(n)]
for i in range(n):
    arr[i]=list(input())
    matrix[i]=[int(0) for _ in range(m)]



print(solve(arr,matrix,n,m))       


"""
def solve(arr,n,m,row,col,count):
    if row>=n or col>=m:
        return 1e9
    elif row==n-1 and col==m-1:
        if arr[row][col]=="#":
            count+=1
        return count
    else:
        if arr[row][col]=="#":
            count+=1
        return min(solve(arr,n,m,row+1,col,count),solve(arr,n,m,row,col+1,count))        
"""
def main():
    H, W, M = map(int, input().split())
    bombs = [list(map(int, input().split())) for i in range(M)]
    
    if M == 1:
        return 1
    
    hw = [[0] * W for i in range(H)]
    
    for i in range(len(bombs)):
        [h, w] = bombs[i]
        hw[h - 1][w - 1] = 1
    
    wh = [list(x) for x in zip(*hw)]
    hw_tuple_list = []
    for i in range(len(hw)):
        hw_tuple_list.append((sum(hw[i]), i+1))
    
    wh_tuple_list = []
    for i in range(len(wh)):
        wh_tuple_list.append((sum(wh[i]), i+1))

    h_list = sorted(hw_tuple_list, reverse = True)
    w_list = sorted(wh_tuple_list, reverse = True)

    h_max = h_list[0][0]
    h_idx_list = []
    for i in range(len(h_list)):
        if h_max > h_list[i][0]:
            break
        h_idx_list.append(h_list[i][1])

    w_max = w_list[0][0]
    w_idx_list = []
    for i in range(len(w_list)):
        if w_max > w_list[i][0]:
            break
        w_idx_list.append(w_list[i][1])
    
    cnt = 1
    for i in range(len(h_idx_list)):
        for j in range(len(w_idx_list)):
        if hw[h_idx_list[i] - 1][w_idx_list[j] - 1] != 1:
            cnt = 0
            break
    return w_max + h_max - cnt

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

def main():
    H, W, M = map(int, input().split())
    bombs = [list(map(int, input().split())) for i in range(M)]
    
    if M == 1:
        return 1
    
    hw = [0] * H
    wh = [0] * W
    
    for i in range(len(bombs)):
        [h, w] = bombs[i]
        hw[h-1] += 1
        wh[w-1] += 1
    
    hw_tuple_list = []
    for i in range(len(hw)):
        hw_tuple_list.append((hw[i], i+1))
    
    wh_tuple_list = []
    for i in range(len(wh)):
        wh_tuple_list.append((wh[i], i+1))

    h_list = sorted(hw_tuple_list, reverse = True)
    w_list = sorted(wh_tuple_list, reverse = True)

    h_max = h_list[0][0]
    h_idx_list = []
    check_h = [0] * H
    for i in range(len(h_list)):
        if h_max > h_list[i][0]:
            break
        h_idx_list.append(h_list[i][1])
        check_h[h_list[i][1]-1] = 1

    w_max = w_list[0][0]
    w_idx_list = []
    check_w = [0] * W
    for i in range(len(w_list)):
        if w_max > w_list[i][0]:
            break
        w_idx_list.append(w_list[i][1])
        check_w[w_list[i][1]-1] = 1
    
    cnt = 0
    for [h, w] in bombs:
        if check_h[h-1] == 1 and check_w[w-1] == 1:
            cnt += 1
    return h_max + w_max if cnt != len(h_idx_list) * len(w_idx_list) else h_max + w_max - 1

if __name__ == '__main__':
    print(main())
a,b,c = map(int,input().split())
if a+b+c<=21:
  print("win")
else:
  prnt("bust")
  

### FIXED CODE ###

a,b,c = map(int,input().split())
if a+b+c<=21:
  print("win")
else:
  print("bust")
N = int(input())
MX = 10**18
a = list(map(int, input.split()))
if 0 in a:
    print(0)
    exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > MX:
        print(0)
        exit(0)
print(ans)

### FIXED CODE ###

A, B = list(map(int, input().split()))
print(A * B)
a=int(input())
for x in range(int(a**0.5),0,-1):
	if a%x==0:
     d=int(a//x)
     s=d+x-2
     break
print(s)

### FIXED CODE ###

a,b=map(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print(-1)
# coding: utf-8
# 整数の入力
#a = int(raw_input())
# スペース区切りの整数の入力
import numpy as np
import itertools

N, W = map(int, raw_input().split())

WeightValueMatrix = np.zeros((W+1, N))
data = []
for i in range(N):
    data.append(map(int, raw_input().split()))

for i in range(N):
    if i == 0:
        for j in range(W+1):
            if j < data[i][0]:
                WeightValueMatrix[j][i] = 0
            else:
                WeightValueMatrix[j][i] = data[i][1]
    else:
        for j in range(W+1):
            if j < data[i][0]:
                WeightValueMatrix[j][i] = WeightValueMatrix[j][i-1]
            else:
                if WeightValueMatrix[j-data[i][0]][i-1] + data[i][1] > WeightValueMatrix[j][i-1]:
                    WeightValueMatrix[j][i] = WeightValueMatrix[j-data[i][0]][i-1] + data[i][1]
                else:
                    WeightValueMatrix[j][i] = WeightValueMatrix[j][i-1]

print int(WeightValueMatrix[W][N-1])
                    

### FIXED CODE ###

N, W = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in range(N)]
 
dp = {}
dp[0] = 0
 
for w, v in X:
    d = dp.copy()
    for k in d:
        if k + w > W:
            continue
        if k + w in dp:
            dp[k + w] = max(dp[k + w], d[k] + v)
        else:
            dp[k + w] = d[k] + v
 
print max(dp.values())
n,m = map(int,input().split())

a = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
    a_tmp = list(map(int,input().split()))
	for j in range(m):
	    a[i][j] = a_tmp[j]

### FIXED CODE ###

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

a = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
    a_tmp = list(map(int,input().split()))
    for j in range(m):
        a[i][j] = a_tmp[j]

b=[]
for i in range(m):
    b.append(int(input()))
    
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j]*b[j]
    print(c)
N,K = list(map(int,input().split()))
Hi = sorted(list(map(int,input().split())))

if N <= K:
    print(0)
else:
    for num in range(K):
        Hi.pop((num+1)*-1)
    print(sum(Hi))

### FIXED CODE ###

N,K = list(map(int,input().split()))
Hi = list(map(int,input().split()))
Hi.sort()
Hi.reverse()

del Hi[:K]
print(sum(Hi))
s=input().split()
n=int(s[0])
m=int(s[1])
k=int(s[2])
import numpy as np
a=np.zeros((n,m))

b=int(n/2)+1
c=int(m/2)+1
x=[]
for i in range(b):
    a[i,:]=1
    x.append(np.count_nonzero(a))
for j in range(c):
    a[:,j]=1-i
    x.append(np.count_nonzero(a))
if k in x:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s=input()
if(len(s)>=4):
    if(s[0]=="Y" and s[1]=="A" and s[2]=="K" and s[3]=="I"):
        print("Yes")
    else:
        print("No")
else:
    print("No")
k = int(input())
s = str(input())

mod = 1000000007
decided_keta = len(s)
all_keta = len(s) + k

kai_list = [1 for i in range(1000010)]
for i in range(2,len(kai_list)):
    kai_list[i] = (kai_list[i-1]*i)%mod

answer = 0
for last_given_character_posi in range(decided_keta-1,all_keta):
    given_posi_pattern = kai_list[last_given_character_posi]*pow(kai_list[decided_keta-1],mod-2,mod)%mod*pow(kai_list[last_given_character_posi-decided_keta+1],mod-2,mod)%mod
    char_pattern = pow(25,last_given_character_posi-(decided_keta-1),mod)
    rest_char_pattern = pow(26,all_keta-(last_given_character_posi+1),mod)
    answer = (answer + given_posi_pattern*char_pattern%mod*rest_char_pattern%mod)%mod
print(answer)

### FIXED CODE ###

k = int(input())
s = str(input())

mod = 1000000007
decided_keta = len(s)
all_keta = len(s) + k

kai_list = [1 for i in range(2000010)]
for i in range(2,len(kai_list)):
    kai_list[i] = (kai_list[i-1]*i)%mod

answer = 0
for last_given_character_posi in range(decided_keta-1,all_keta):
    given_posi_pattern = kai_list[last_given_character_posi]*pow(kai_list[decided_keta-1],mod-2,mod)%mod*pow(kai_list[last_given_character_posi-decided_keta+1],mod-2,mod)%mod
    char_pattern = pow(25,last_given_character_posi-(decided_keta-1),mod)
    rest_char_pattern = pow(26,all_keta-(last_given_character_posi+1),mod)
    answer = (answer + given_posi_pattern*char_pattern%mod*rest_char_pattern%mod)%mod
print(answer)
a,b,c=[int(input()) for _ i in range(3)]
print((a+b)*h//2)

### FIXED CODE ###

a, b, h = [int(input()) for _ in range(3)]
print((a+b)*h//2)
def resolve():
    N = int(input())
    arr = list(map(int, input().split()))
    for num in arr:
        if not num % 2 and not (num % 3 == 0 or num % 5 == 0):
            print('DENIED')
            quit()
    print('APPROVED')

resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    from collections import defaultdict
    cnt = defaultdict(int)
    for _ in range(N):
        cnt[input()] += 1
    items = sorted(cnt.items(), key=lambda x: (-x[1], x[0]))
    max_v = items[0][1]
    for item in items:
        if max_v != item[1]:
            break
        print(item[0])

resolve()
# 作業メモ
# 回答提出済み：ラスト1問で Runtime Error が発生する


#逆ポーランド記法(Reverse Polish Notation, RPN)
class RPN():
    def __init__(self):
        self.top = 0
        self.S = []
        self.MAX = 99

    def isEmpty(self):
        return self.top == 0

    def isFull(self):
        return self.top >= self.MAX - 1

    def push(self,x):
        if self.isFull():
            raise ValueError("オーバーフロー")
        self.top+=1
        self.S.append(x)

    def pop(self):
        if self.isEmpty():
            raise ValueError("アンダーフロー")
        self.top-=1
        #print("self.top:{}".format(self.top))
        #print("S:{}".format(self.S))
        return self.S.pop(self.top)


X = input().split(" ")
rpn = RPN()
for x in X:
    #print(x)
    if x.isnumeric():
        #print("num")
        rpn.push(x)
    else:
        #print("dig")
        num_2 =rpn.pop()
        num_1 =rpn.pop()
        res = eval(str(num_1) + x + str(num_2))
        rpn.push(res)

print(rpn.pop())


### FIXED CODE ###

#逆ポーランド記法(Reverse Polish Notation, RPN)
class RPN():
    def __init__(self):
        self.top = 0
        self.S = []
        self.MAX = 100

    def isEmpty(self):
        return self.top == 0

    def isFull(self):
        #return self.top >= self.MAX - 1
        return self.top >= self.MAX

    def push(self,x):
        if self.isFull():
            raise ValueError("オーバーフロー")
        self.top+=1
        self.S.append(x)

    def pop(self):
        if self.isEmpty():
            raise ValueError("アンダーフロー")
        self.top-=1
        #print("self.top:{}".format(self.top))
        #print("S:{}".format(self.S))
        return self.S.pop(self.top)


X = input().split(" ")
rpn = RPN()
for x in X:
    #print(x)
    if x.isnumeric():
        #print("num")
        rpn.push(x)
    else:
        #print("dig")
        num_2 =rpn.pop()
        num_1 =rpn.pop()
        res = eval(str(num_1) + x + str(num_2))
        rpn.push(res)

print(rpn.pop())
import sys

array=[]
for i in sys.stdin.readlines():
    array.append(int(input()))
array.sort()
num = len(array)
for i in range(num-1,num-4,-1):
    print(array[i]) 

### FIXED CODE ###

array = [int(input()) for i in range(10)]
array.sort()
for i in range(9,6,-1):
    print(array[i])
# -*- coding: utf-8 -*-
import sys

def main():
	n = int(input())

	ins = []
	for _ in range(n):
		t, a = map(int, input().split(" "))
		ins.append((t, a))

	takahashi = 0
	aoki = 0
	takahashi, aoki = ins[0]

	for i, val in enumerate(ins):
		if i == 0: continue
		t, a = val
		m = max(-(-takahashi // t), -(-aoki // a))
		takahashi, aoki = t * m, a * m

	print(int(takahashi + aoki))

if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	a, b, c = map(int, input().split(" "))

	ans = 1
	if a != b:
		ans = ans + 1
	if a != c and b != c:
		ans = ans + 1

	print(ans)

if __name__ == "__main__":
	main()
n, m, x = [*map(int, input().split())]
k = []
ans = 10 ** 6
for i in range(n):
    c, *a = [*map(int, input().split())]
    s += c
    k.append([c, *a])

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 6 else ans)

### FIXED CODE ###

n, m, x = [*map(int, input().split())]
k = [[*map(int, input().split())] for _ in range(n)]
ans = 10 ** 9

for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if ((i >> j) & 1):
            cost += k[j][0]
            for s, t in enumerate(k[j][1:]):
                skills[s] += t
            if all(map(lambda skill: skill >= x, skills)):
                ans = min(ans, cost)
print(-1 if ans == 10 ** 9 else ans)
n = int(input())
h = [int(n) for n in input().split()]

a = 0
b = 1
ans = 1
while h[a]<h[b]:
    ans = ans + 1
    a = a + 1
    b = b + 1
    continue

print(ans)

### FIXED CODE ###

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

max = h[0]
ans = 0

for i in h:
    if max<=i:
        ans += 1
        max = i
print(ans)
L, R = map(int, input().split())
number = list(range(L,R+1))
min = 2100
for i in range(len(number)):
    j = i + 1
    while(j < len(number)):
        if(min > number[i]*number[j] % 2019):
            min = number[i]*number[j] % 2019
        j += 1
print(min)

### FIXED CODE ###

L, R = map(int, input().split())
min = 2100
for i in range(L, R):
    j = i + 1
    while(j < R + 1):
        if(min > i * j % 2019):
            min =  i * j % 2019
        if(min == 0):
            break
        j += 1
    if(min == 0):
        break
print(min)
n = int(input())
h = [int(i) for i in input().split()]
ans = 1
for i in range(n):
    if h[i-1] < h[i]:
        if h[0] == max(h):
            break
        ans += 1

print(ans)

### FIXED CODE ###

import sys
a,b=map(int,input().split())
ans = max(a,b)
if a == b:
    print(a+b)
    sys.exit()

print(ans+(ans-1))
WeatherToady = input()
if WeatherToday == "Sunny":
  return "Cloudy"
elif WeatherToday == "Cloudy":
  return "Rainy"
else:
  return "Sunny"


### FIXED CODE ###

WeatherToday = input()
if WeatherToday == "Sunny":
  print("Cloudy")
elif WeatherToday == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
N, M = map(int, input().split())
print(N * N - M)


### FIXED CODE ###

N = int(input())
M = int(input())
print(N * N - M)
def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
    A = A - 1
  else if A < B:
    ans = B + (B + 1)
  else:
    ans = A + B

### FIXED CODE ###

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

def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B - 1)
  else:
    ans = A + B
  return ans


print(MaxCoinCount(A,B))
s = input()
  print(s.count("1"))

### FIXED CODE ###

s = input()
print(s.count("1"))
s1,s2,s3=map(int,input().split())
print(s1+s2+s3)

### FIXED CODE ###

s=str(input())
print(s.count('1'))
sorted_lst=sorted(list(map(int,input().split())))
if so_lst[0]==5 and so_lst[1] == 5 and so_lst[2]==7:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

lst=list(map(int,input().split()))
so_lst=sorted(lst)
if so_lst[0]==5 and so_lst[1] == 5 and so_lst[2]==7:
    print("YES")
else:
    print("NO")
import math

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

c_min = (a-1) // c
c_max = b // c
c_count = c_max - c_min

d_min = (a-1) // d
d_max = b // d
d_count = d_max - d_min

cd_min = (a-1) // (c * d // math.gcd(c, d))
cd_max = b // (c * d // math.gcd(c, d))
cd_count = cd_max - cd_min

print(b - (a-1) - c_count - d_count + cd_count)


### FIXED CODE ###

import fractions

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

c_min = (a-1) // c
c_max = b // c
c_count = c_max - c_min

d_min = (a-1) // d
d_max = b // d
d_count = d_max - d_min

cd_min = (a-1) // (c * d // fractions.gcd(c, d))
cd_max = b // (c * d // fractions.gcd(c, d))
cd_count = cd_max - cd_min

print(b - (a-1) - c_count - d_count + cd_count)