Harryxun/stf_run huggingface dataset:
for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue


### FIXED CODE ###

N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue
import sys


def main():
    N, K = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split())) * K

    count = 0

    for i, n in enumerate(A):
        for j, m in enumerate(A):
            if i <= j:
                break
            elif m > n:
                count = count + 1

    ans = count % (10 ** 9 + 7)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys


def main():
    N, K = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split()))

    count1 = 0
    count2 = 0

    for i in range(N - 1):
        for j in range(i + 1, N):
            if A[i] > A[j]:
                count1 = count1 + 1
            if A[i] != A[j]:
                count2 = count2 + 1
    count1 = count1 * K
    count2 = count2 * (K * (K - 1) // 2)

    ans = (count1 + count2) % 1000000007
    print(ans)


if __name__ == "__main__":
    main()
from collections import defaultdict, deque


def main():
    N, Q = map(int, input().split())

    tree = defaultdict(list)
    f = defaultdict(int)
    ans = defaultdict(int)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        f[p] += x

    # dfs
    visited = {1}
    def dfs(i, s):
        ans[i] = s
        for j in tree[i]:
            if j in visited:
                continue
            visited.add(j)
            s += f[j]
            dfs(j, s)
            s -= f[j]

    dfs(1, f[1])

    counts = [ans[i] for i in range(1, N+1)]
    ans = " ".join(map(str, counts))
    print(ans)



if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict, deque


def main():
    N, Q = map(int, input().split())

    tree = defaultdict(list)
    counter = defaultdict(int)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p, x = map(int, input().split())
        counter[p] += x

    # bfs
    q = deque([1])
    visited = {1}

    while q:
        i = q.popleft()

        for j in tree[i]:
            if j not in visited:
                q.append(j)
                counter[j] += counter[i]
                visited.add(j)

    counts = [counter[i] for i in range(1, N+1)]
    ans = " ".join(map(str, counts))
    print(ans)



if __name__ == '__main__':
    main()
n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

num_max_10k = total // 10000
num_max_5k = total // 5000
num_max_1k = total // 1000

for num_10k in range (num_max_10k + 1):
    for num_5k in range(num_max_5k + 1):
        if (num_10k + num_5k >= n):
            num_1k = 0
        else:
            num_1k = n - (num_10k + num_5k)

        #print(num_10k, num_5k, num_1k, sep=" ")
        if (total == (sum_10k * 10000 + sum_5k * 5000 + sum_1k * 1000)
            and n == (num_10k + num_5k + num_1k)):
            x, y, z = num_10k, num_5k, num_1k

print(x, y, z, sep=" ")


### FIXED CODE ###

n, total = map(int, input().split(" "))

x = -1
y = -1
z = -1

for x_tmp in range(0, n + 1):
    for y_tmp in range(0, (n - x_tmp) + 1):
        z_tmp = n - (x_tmp + y_tmp) if n >= (x_tmp + y_tmp) else 0
        if total == (x_tmp * 10000 + y_tmp * 5000 + z_tmp * 1000):
            x, y, z = x_tmp, y_tmp, z_tmp

print(x, y, z, sep = " ")
a,b=map(int,input.split())

if a*b%2==1:
    print("Odd")
else:
    print("Even")

### FIXED CODE ###

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


if (a*b)%2==0:
    print("Even")
else:
    print("Odd")
N, M = map(int,input().split())
L = list(map(int,input().split()))
K = [0,2,5,5,4,5,6,3,7,6]
A = sorted([[L[k],K[L[k]]] for k in range(M)])[::-1]
dp = [0 for k in range(N+1)]

for k in range(1,N+1):
    t = -float("inf")
    for j in range(M):
        if k-A[j][1]>=0:
            t = max(t, dp[k-A[j][1]]+1)
    dp[k] = t

ans = ""
keta = dp[N]
match = N
while keta > 0:
    for k in range(M):
        if dp[match-A[k][1]] == keta-1:
            ans += str(A[k][0])
            match -= A[k][1]
            keta -= 1
            break
print(ans)


### FIXED CODE ###

N, M = map(int,input().split())
L = list(map(int,input().split()))
K = [0,2,5,5,4,5,6,3,7,6]
A = sorted([[L[k],K[L[k]]] for k in range(M)])[::-1]
dp = [0 for k in range(N+1)]

for k in range(1,N+1):
    t = -float("inf")
    for j in range(M):
        if k-A[j][1]>=0:
            t = max(t, dp[k-A[j][1]]+1)
    dp[k] = t

ans = ""
keta = dp[N]
match = N
while keta > 0:
    for k in range(M):
        if match-A[k][1] >= 0:
            if dp[match-A[k][1]] == keta-1:
                ans += str(A[k][0])
                match -= A[k][1]
                keta -= 1
                break
print(ans)
n,l = map(int,input().split())
s=[]
for i in range(n):
	i=input()
	s.append(i)
s.sort()
result=''.join(s)
print(reault)


### FIXED CODE ###

n,l=map(int,input().split())
s=list(input() for _ in range(n))
s.sort()
result=''.join(s)
print(result)
import copy
import fractions

n = int(input())
l = list(map(int, input().split()))
sum = 0
if len(l) == 2:
    print(max(l[0], l[1]))
    exit()
else:
    for i in range(n):
        ll = copy.deepcopy(l)
        ll.pop(i)
        ans = ll[0]
        for j in range(1, len(ll)):
            ans = fractions.gcd(ans, ll[j])
            if sum < ans:
                sum = ans
print(sum)

### FIXED CODE ###

a, b, t = map(int, input().split())
print(t // a * b)
LIM=200002
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
  	if N==0:
      return 0
    count=1
    N=N%b
    while N!=0:
        b=L[N]
        N=N%b
        count+=1
    return count
X=int(input())
Y=input()
d=bin_sum2(Y)+1
c=bin_sum2(Y)-1
for i in range(X):
    Y_i=Y[:i]+str(abs(int(Y[i])-1))+Y[i+1:]
    if Y_i[i]=="1":
        b=d
    else:
        b=c
    print(pop_num(int(Y_i,2),b,L))

### FIXED CODE ###

from collections import deque
LIM=200004
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
M=[0]*200005
for i in range(1,200004):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)
e=int(Y,2)%(d+1)
f=int(Y,2)%max(1,(d-1))
O=[1]*(X+2)
P=[1]*(X+2)
q=max(d-1,1)
for i in range(1,X+1):
    O[i]=O[i-1]*2%q
    P[i]=P[i-1]*2%(d+1)
for i in range(X):
    
    if int(Y[i])==1:
        b=max(d-1,1)
        flag=max(0,d-1)
        g=(f-O[X-1-i]+b)%b
    else:
        b=d+1
        flag=1
        g=(e+P[X-1-i])%b

    if flag==0:
        print(0)
    elif g==0:
        print(1)
    else:
        print(M[g]+1)
print('NYoe s'[[*'000']in[eval(eval(t.replace(*' -')))for t in open(0)]::2])

### FIXED CODE ###

_,*d=[{*t.split()}for t in open(0)]
print('YNeos'[all(max(map(len,d[i:i+3]))>1for i in range(len(d)-2))::2])
def main(length_num,num_list):
    count_num = 0
    for i in range(0,length_num):
        flag_tag = True
        for j in range(0 , i ):
          if int(num_list[i]) >= int(num_list[j]):
              print(num_list[i],num_list[j])
              flag_tag = False
              break
        if flag_tag != False:
            count_num += 1
    return count_num


    
if __name__ == "__main__":
    input_length_num = int(input())
    input_num2 = input()
    input_num_list = input_num2.split()
    print(main(length_num,num_list))

### FIXED CODE ###

def main(length_num,num_list):
    count_num = 0
    min_num = int(num_list[0])
    for i in num_list:
        if int(min_num) >= int(i):
            min_num = i
            count_num += 1           
    return count_num
    
if __name__ == "__main__":
    input_length_num = int(input())
    input_num2 = input()
    input_num_list = input_num2.split()
    print(main(input_length_num,input_num_list))
a,b=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
z=gcd(a,b)
j=0
ans=[]
for i in range(0,z):
  if z%i==0:
    z/=i
    ans.append(i)
  else:
    j+=1
print(len(set(ans)))    
    

### FIXED CODE ###

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

def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
  
  
n=gcd(a,b)  
i=2
ans=[1]

while i * i <= n:
  if n % i == 0:
    n /= i
    ans.append(i)
  else:
    i += 1

ans.append(n)    
  
print(len(set(ans)))
N, X = map(int, input().split())
X = list(map(int, input().split()))

min_dist = abs(X - min(L))

ans = 1

for d in range(min_dist, 0, -1):
    b = all((x - X) % d == 0 for x in L)
    if b:
        print(d)
        break


### FIXED CODE ###

import math
from functools import reduce

def gcd(ns):
    return reduce(math.gcd, ns)

N, X = map(int, input().split())
L = list(map(int, input().split()))

diff = [abs(x - X) for x in L]

if len(diff) == 1:
    print(diff[0])
else:
    print(gcd(diff))
int(input()) = N
for a in range(1,10):
  for b in range(1,10):
  if N==a*b:
    break
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")
import bisect
import sys
input = sys.stdin.readline
def main():
    N,M = map(int,input().split())
    A= list(map(int,input().split()))
    A = sorted(A)

    BC=[list(map(int,input().split())) for i in range(M)]
    BC = sorted(BC, key=lambda x: x[1],reverse=True)
    index=0
    max_index=len(A)
    
    for B,C in BC:
        temp = [C]*B
        for t in temp:
            if t>A[index] or max_index>index:
                A[index] = t
            else:
                return A
            index+=1
    
if __name__ == '__main__':
    A=main()
    print(sum(A))


### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N,M = map(int,input().split())
    A= list(map(int,input().split()))
    A = sorted(A)

    BC=[list(map(int,input().split())) for i in range(M)]
    BC = sorted(BC, key=lambda x: x[1],reverse=True)
    index=0
    max_index=len(A)
    
    for B,C in BC:
        temp = [C]*B
        for t in temp:
            if max_index>index and  t>A[index]:
                A[index] = t
            else:
                return A
            index+=1
    return A
    
if __name__ == '__main__':
    A=main()
    print(sum(A))
N = int(input())
A = map(int,input().split())
B = map(int,input().split())
C = map(int,input().split())

ans = 0
for i in range(N):
    ans+= B[i]

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

print(ans)

### FIXED CODE ###

N = int(input())
A = input().split()
B = input().split()
C = input().split()

ans = 0
for i in range(N):
    ans+= int(B[i])

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

print(ans)
n,m=map(int,input().split())
day_pay=[[0] for _ in range(m)]
for _ in range(n):
    a,b=map(int,input().split())
    day_pay[a-1].append(b)
    day_pay[a-1].sort()

ans=0
for d in range(0, m):
    best=0
    idx=m+2
    for i in range(d+1):
        if day_pay[i][-1]>best:
            best=day_pay[i][-1]
            idx=i
    if idx<len(day_pay):
        day_pay[i].pop()
    ans+=best
print(ans)

### FIXED CODE ###

import heapq
N, M = map(int, input().split())

fee = [[] for _ in range(10**5+10)]  # i日後に収入がもらえるバイトの価値
for _ in range(N):
    a, b = map(int, input().split())
    fee[a].append(-b)

task = []
ans = 0

# 締め切り日からさかのぼっていって、できるバイトで最大の収入をもらえるやつを実行する感じ
for i in range(1, M + 1):
    for f in fee[i]:
        heapq.heappush(task, f)

    if task:
        ans -= heapq.heappop(task)

print(ans)
n, k, q = map(int, input().split())
inl = [int(x) for x in range(q)]
chl = [0] * n
for z in inl:
  chl[z-1] += 1
for y in chl:
  if y > (q-k):
    print('Yes')
  else:
    print('No')


### FIXED CODE ###

n, k, q = map(int, input().split())
inl = [int(input()) for x in range(q)]
chl = [0] * n
for z in inl:
  chl[z-1] += 1
for y in range(n):
  if chl[y] > (q-k):
    print('Yes')
  else:
    print('No')
MOD = 10 ** 9 + 7
inv = [None, 1]
for i in range(2, 10 ** 5 + 1):
    inv.append((MOD - MOD // i * inv[MOD % i]) % MOD)

fact = [1]
ifact = [1]
for i in range(1, 10 ** 5 + 1):
    fact.append((i * fact[-1]) % MOD)
    ifact.append((inv[i] * ifact[-1]) % MOD)


class Node:
    def __init__(self, ind):
        self.ind = ind
        self.val = 1
        self.ndesc = 1
        self.neighs = []

    def calc(self, fro):
        subdescs = []
        for neigh in self.neighs:
            if neigh.ind == fro:
                continue
            neigh.calc(self.ind)
            self.val *= neigh.val
            self.ndesc += neigh.ndesc
            subdescs.append(neigh.ndesc)
        self.val = self.val * fact[self.ndesc - 1] % MOD
        for subdesc in subdescs:
            self.val = self.val * ifact[subdesc] % MOD

    def comp(self, fro, carry):
        self.val = carry * self.ndesc * inv[max(1, N - self.ndesc)] % MOD
        for neigh in self.neighs:
            if neigh.ind == fro:
                continue
            neigh.comp(self.ind, self.val)


N = int(input())
nodes = [Node(i) for i in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].neighs.append(nodes[b - 1])
    nodes[b - 1].neighs.append(nodes[a - 1])
nodes[0].calc(0)
nodes[0].comp(0, (nodes[0].val * inv[N]) % MOD)
for i in range(N):
    print(nodes[i].val)


### FIXED CODE ###

MOD = 10 ** 9 + 7
inv = [None, 1]
for i in range(2, 10 ** 5 * 2 + 1):
    inv.append(MOD - MOD // i * inv[MOD % i] % MOD)

fact = [1]
ifact = [1]
for i in range(1, 10 ** 5 * 2 + 1):
    fact.append((i * fact[-1]) % MOD)
    ifact.append((inv[i] * ifact[-1]) % MOD)


class Node:
    def __init__(self, ind):
        self.ind = ind
        self.val = 1
        self.ndesc = 1
        self.neighs = []


N = int(input())
nodes = [Node(i) for i in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].neighs.append(nodes[b - 1])
    nodes[b - 1].neighs.append(nodes[a - 1])

stack = [(-1, nodes[0])]
for i in range(N):
    fro, node = stack[i]
    for neigh in node.neighs:
        if neigh.ind == fro:
            continue
        stack.append((node.ind, neigh))

for i in range(N - 1, -1, -1):
    fro, node = stack[i]
    node.val = node.val * fact[node.ndesc - 1] % MOD
    if fro == -1:
        continue
    nodes[fro].ndesc += node.ndesc
    nodes[fro].val = nodes[fro].val * node.val * ifact[node.ndesc] % MOD

stack = [(-1, node, nodes[0].val * inv[N] % MOD)]
for i in range(N):
    fro, node, val = stack[i]
    node.val = val * node.ndesc * inv[max(1, N - node.ndesc)] % MOD
    for neigh in node.neighs:
        if neigh.ind == fro:
            continue
        stack.append((node.ind, neigh, node.val))

for i in range(N):
    print(nodes[i].val)
N = int(input())
V = list(map(int, input().split()))
alist = []
tmp = 0

def cook(N, V, alist, tmp):
    if N = 1:
        print(V[0])
    
    else:
        V.sort()
        for i in range(0, N, 2):
            if i + 1 > N - 1:
                alist.append(V[i])
                
            else:
                tmp = (V[i] + V[i +1]) / 2
                alist.append(tmp)
            
        N = len(alist)
        V = alist
        alist = []
        tmp = 0
        cook(N, V, alist, tmp)
        
cook(N, V, alist, tmp)

### FIXED CODE ###

N = int(input())
v = list(map(float, input().split()))

v.sort()

r = v[0]

for i in v[1::]:
    r = (r + i) / 2

print(r)
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(a,b):
    if b == 0:
        return a
    return gcd (b, a%b)

#2数の積/最大公約数=最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

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

### FIXED CODE ###

n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(a,b):
    if b == 0:
        return a
    return gcd (b, a%b)

#2数の積/最大公約数=最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

if n == 1:
    print(t[0])
    exit(0)
ans = lcm(t[0], t[1])
for i in range(1, n-1):
    ans = lcm(ans, t[i+1])
print(ans)
n, m = map(int, input().split())
num = ['x'] * n
flag = 0

if n == 1:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        print(num[s-1])

else:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
            if s == 1 and c == 0:
                print(-1)
                flag = 1
                break
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        for j in range(n):
            if num[0] == 'x':
                num[0] = 1
            else:
                if num[j] == 'x':
                    num[j] = 0
        str_num = map(str, num)
        print(''.join(str_num))

### FIXED CODE ###

n, m = map(int, input().split())
num = ['x'] * n
flag = 0

if n == 1:
    if m == 0:
        print(0)
    else:
        for i in range(m):
            s, c = map(int, input().split())
            if num[s-1] == 'x':
                num[s-1] = c
            else:
                if num[s-1] != c:
                    print(-1)
                    flag = 1
                    break
        if flag == 0:
            print(num[s-1])

else:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s-1] == 'x':
            num[s-1] = c
            if s == 1 and c == 0:
                print(-1)
                flag = 1
                break
                
        else:
            if num[s-1] != c:
                print(-1)
                flag = 1
                break
    if flag == 0:
        if num[0] == 'x':
            num[0] = 1
        for j in range(1, n):
            if num[j] == 'x':
                num[j] = 0 
        str_num = map(str, num)
        print(''.join(str_num))
input()
A=list(map(int,input().split())
count=0

while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    count +=1
print(count)


### FIXED CODE ###

input()
A=list(map(int,input().split()))
count=0

while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    count +=1
print(count)
str = input()
N = int(str.split()[0])
d = []
for i in range(N) :
	s = str = input()
	dict = {}
	for j in range(26):
		dict[j] = 0
	for j in range(10) :
		k = ord(s[j]) - ord("a")
		dict[k] = dict[k] + 1
	d.append(dict)
	
E = 0
while(len(d) != 0) :
	deli = []
	for i in range(1, len(d)) :
		f = 0
		for j in range(26):
			if (d[0][j] != d[i][j]) :
				f = 1
				break
		if (f != 1) :
			deli.append(i)
	a = 0
	while(len(deli) != 0) :
		d.pop(deli[0] - a)
		deli.pop(0)
		a = a + 1
	if (len(d) != 0) :
		if (a != 0) :
			E = E + a * (a - 1) / 2
		d.pop(0)
print(E)


### FIXED CODE ###

str = input()

A = (int(str.split()[0]))
B = (int(str.split()[1]))

X = A + B
Y = A - B
Z = A * B
E = 0
if (X < Y) :
	if (Y < Z) :
		E = Z
	else :
		E = Y
else :
	if (X < Z) :
		E = Z
	else :
		E = X
print("{}".format(E))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=1
check=0
for i in a:
    if i-check==1 and i!=1:
        print(0)
        exit()
    if i-check==1 and i==1:
        check=2
    else:
      ans*= fib(i-check-1)
      check=i+1
ans*=fib(n-a[-1]-1)
print(ans%((10**9)+7))


### FIXED CODE ###

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

    
dp=[0]*(n+1)
dp[0]=1

a=set(int(input()) for i in range(m))

for i in range(1,n+1):
    if i in a:
        continue
    x=dp[i-1]
    if i>1:
        x+=dp[i-2]
    dp[i]=x%mod
print(dp[-1])
import sys

N = int(sys.argv[1])
K = int(sys.argv[2])

if int((N+1) / 2) >= K:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys

arglist = [int(i) for i in raw_input().split()]
N = arglist[0]
K = arglist[1]

if int((N+1) / 2) >= K:
    print('YES')
else:
    print('NO')
print(int(input)/3)

### FIXED CODE ###

a = int(input())/3
print(a*a*a)
import numpy as np

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
data = np.unique(data)
length = R - L

min_mod = 2018
for t in range(length):
    i = length - t
    for j in range(i):
        mod = data[i] * data[j] % 2019
        min_mod = mod if min_mod > mod else min_mod
        if min_mod == 0:
            break
        
print(min_mod)

### FIXED CODE ###

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)
n, k = map(int, input().split())
a = list(map(int, input().split())) 

ll = [a[0]]

for i in range(1, n):
    cnt = ll[i-1]
    if a[cnt-1] == a[0]:
        break
    else:
        ll.append(a[cnt-1])

print(ll[k%3-1])

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

done = [-1]*N
done[0] = 0

tmp = 0
done[0] = 0
for k in range(1, K + 1):
    tmp = A[tmp]
    if done[tmp] >= 0:
        for _ in range((K - done[tmp]) % (k - done[tmp])):
            tmp = A[tmp]
        print(tmp + 1)
        exit()
    else:
        done[tmp] = k
print(tmp + 1)
s = input()

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)


### FIXED CODE ###

s = input()

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a is None:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)
n, k=mat(int, input().split())

ans=(k-1)**(n-1)

print(ans*k)

### FIXED CODE ###


def penki(a, b, c):
  if a==b and b==c:
    return 1
  elif a!=b and b!=c and c!=a:
    return 3
  else:
    return 2

a,b,c=map(int, input().split())
print(penki(a, b, c))
n = int(input())
k = int(nput())
price = []
cost = 0
for p in range(n):
        p = int(input())
        price.append(p)

price.sort()
for  p in price:
        cost += p

print(price)

### FIXED CODE ###

n, k,  =map(int, input().split())
cost = 0
price = list(map(int, input().split()))
        
price.sort()
del price[k:]
for p in price:
        cost += p

print(cost)
import sys

stdin = sys.stdin

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

def main():
  n = ni()

  odd = 1 if i%2 == 1 else 0
  for i in range(1, n+1):
    if i%2 == 0:
      odd += 1
  print(odd/n)

main()

### FIXED CODE ###

import sys

stdin = sys.stdin

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

def main():
  n = ni()

  odd = 1 if n%2 == 1 else 0
  for i in range(1, n+1):
    if i%2 == 0:
      odd += 1
  print(odd/n)

main()
x = int(input())

d = 2

while d < 1+x//2:
  if x%d == 0:
    x += 1
    d = 2
  else:
    if d == 1+x//2:
      ans = x
      break
    else:
      d += 1
print(ans)

### FIXED CODE ###

x = int(input())

d = 2

ans = 2

if x != 2:
  while d <= 1+x//2:
    if x%d == 0:
      x += 1
      d = 2
    else:
      if d == 1+x//2:
        ans = x
        break
      else:
        d += 1
  print(ans)
else:
  print(ans)