Harryxun/stf_run huggingface dataset:
k = int(input())
ans = 0
if k % 7 == 0:
    L = (9 * k) / 7
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    if ans == 0:
        print(-1)

### FIXED CODE ###

k = int(input())
ans = 0
if k % 7 == 0:
    L = int((9 * k) / 7)
else:
    L = 9 * k
if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    a = 1 % L
    for i in range(L):
        if (a * 10) % L == 1:
            ans = i + 1
            print(ans)
            break
        a = (a * 10) % L
    if ans == 0:
        print(-1)
N, M = map(int, input().split())
H = list(map(int, input().split()))

AB = [list(map(int, input().split())) for _ in range(M)]

check = [True] * N

for ab in AB:
    # 左みる
    print(ab, "left: ", H[ab[0]-1], "right: ", H[ab[1]-1]) 
    if H[ab[0]-1] < H[ab[1] - 1]:
        check[ab[0]-1] = False
    elif H[ab[0]-1] > H[ab[1] - 1]:
        check[ab[1]-1] = False
    #else:
    #    check[ab[0]-1] = not check[ab[0]-1]
    print(check)
print(sum(check))


### FIXED CODE ###


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

AB = [list(map(int, input().split())) for _ in range(M)]

check = [True] * N

for ab in AB:
    # 左みる
    if H[ab[0]-1] < H[ab[1] - 1]:
        check[ab[0]-1] = False
        
    elif H[ab[1]-1] < H[ab[0] - 1]:
        check[ab[1]-1] = False
    else:
        check[ab[0]-1] = False
        check[ab[1]-1] = False
    
print(sum(check))
a = input()
  b = input()
  if (len(b)>len(a)) and (a==b[:len(a)]):
  	print('Yes')
  else:
  	print('No')

### FIXED CODE ###

a = input()
b = input()
if (len(b)>len(a)) and (a==b[:len(a)]):
  print('Yes')
else:
  print('No')
a,b=input().split()
a=int(a)
b=int(b)
print(int((a*3+b)/2)

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
print(int((a*3+b)/2))
import sys

mod = 10**9 + 7

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().strip().split()))

# 0も入れておく
pos_list = []
neg_list = []
zero_count = 0
for a_i in A:
    if a_i > 0:
        pos_list.append(a_i)
    elif a_i == 0:
        zero_count += 1
    else:
        neg_list.append(a_i)

# 降順
pos_list.sort(reverse = True)
neg_list.sort()


lp = len(pos_list)
ln = len(neg_list)

    
if min(2 * (ln // 2), 2 * (K // 2)) + lp >= K:
    pos_twins = [pos_list[2 * i] * pos_list[2 * i + 1] for i in range(lp // 2)] + [0]
    neg_twins = [neg_list[2 * i] * neg_list[2 * i + 1] for i in range(ln // 2)] + [0]
    pos_twins.sort()
    neg_twins.sort()
 
    ans = 1
    pos_select = 0
    for i in range(K // 2):
        if pos_twins[-1] <= neg_twins[-1]:
            ans *= neg_twins[-1]
            ans %= mod
            neg_twins.pop()
        else:
            ans *= pos_twins[-1]
            ans %= mod
            pos_twins.pop()
            pos_select += 1
 
    if K % 2 == 1:
        if K == 1:
            ans = pos_list[2 * pos_select]
        else:
            ans *= pos_list[2 * pos_select]
    print(ans % mod)    
elif zero_count > 0:
	print(0)
# マイナスになるため、最小化する
else:
    ans = 1
    neg_list.sort(reverse=True)
    for i in range(K):
        ans *= neg_list[i]
        ans %= mod
    print(ans)

### FIXED CODE ###

import sys

mod = 10**9 + 7

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().strip().split()))

# 0も入れておく
pos_list = []
neg_list = []
zero_count = 0
for a_i in A:
    if a_i > 0:
        pos_list.append(a_i)
    elif a_i == 0:
        zero_count += 1
    else:
        neg_list.append(a_i)

lp = len(pos_list)
ln = len(neg_list)

if min(2 * (ln // 2), 2 * (K // 2)) + lp >= K:
    # 降順
    pos_list.sort(reverse = True)
    neg_list.sort()

    pos_twins = [pos_list[2 * i] * pos_list[2 * i + 1] for i in range(lp // 2)] + [0]
    neg_twins = [neg_list[2 * i] * neg_list[2 * i + 1] for i in range(ln // 2)] + [0]
    pos_twins.sort()
    neg_twins.sort()
 
    ans = 1
    pos_select = 0
    for i in range(K // 2):
        if pos_twins[-1] <= neg_twins[-1]:
            ans *= neg_twins[-1]
            ans %= mod
            neg_twins.pop()
        else:
            ans *= pos_twins[-1]
            ans %= mod
            pos_twins.pop()
            pos_select += 1
 
    if K % 2 == 1:
        if K == 1:
            ans = pos_list[2 * pos_select]
        else:
            ans *= pos_list[2 * pos_select]
    print(ans % mod)    
elif zero_count > 0:
	print(0)
# マイナスになるため、最小化する
else:
    ans = 1
    abs_list = sorted([abs(a) for a in A])
    for a in abs_list[:K]:
        ans *= a
        ans %= mod
    print((-1) * ans % mod)
n,m = map(int, input().split())
hs = list(map(int, input().split()))
d = [1]*n

for i in range(m):
    a,b = map(int, input().split())
    if hs[a-1] <= hs[b-1]:
        d[a-1] = 0
    if hs[a-1] >= hs[b-1]:
        d[b-1] = 0
        
    print(hs,d)
    
print(d.count(1))

### FIXED CODE ###

n,m = map(int, input().split())
hs = list(map(int, input().split()))
d = [1]*n

for i in range(m):
    a,b = map(int, input().split())
    if hs[a-1] <= hs[b-1]:
        d[a-1] = 0
    if hs[a-1] >= hs[b-1]:
        d[b-1] = 0
    
print(d.count(1))
A,B,X = map(int,input().split())
#print(A,B,X)
out=0
for i in range(X):
	num = i
	price = A*num+B*len(str(num)) #Nの金額
	if price < X:
		out = num
	else:
		break

print(out)

### FIXED CODE ###

s=input()
if s=='SUN':
	print(7)
if s=='MON':
	print(6)
if s=='TUE':
	print(5)
if s=='WED':
	print(4)
if s=='THU':
	print(3)
if s=='FRI':
	print(2)
if s=='SAT':
	print(1)
N, K, X, Y=[int(input()) for i in range(4)]
if N=<K:
  print(N*X)
else:
print(K*X+Y*(N-K))

### FIXED CODE ###

N, K, X, Y=[int(input()) for i in range(4)]
if N<=K:
  print(N*X)
else:
  print(K*X+Y*(N-K))
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
from collections import deque
from array import array

def input():
    return sys.stdin.readline().rstrip('\n')

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

_C = {}

for i in range(M):
    a,b,c = list(map(int, input().split()))
    a -= 1
    b -= 1
    if c>L:
        continue
    _C[a*300+b] = c
    _C[b*300+a] = c

def C_(i,j):
    return _C.get(i*300+j, sys.maxsize)

Q = int(input())

S = array('q', [0]*Q)
T = array('q', [0]*Q)

for i in range(Q):
    S[i],T[i] = list(map(int, input().split()))

# ワーシャルフロイド法

# distance from i to j
D = [array('q', [0]*N) for i in range(N)]

# initialization
for i in range(N):
    for j in range(N):
        D[i][j] = C_(i,j)
        #print(i,j,D[i][j])

# 本計算
for k in range(N):
    for i in range(N):
        for j in range(N):
            if D[i][j] > D[i][k] + D[k][j]:
                D[i][j] = D[i][k] + D[k][j]


# D[i][j] <= L となる i,j に辺を張る
for i in range(N):
    for j in range(N):
        if D[i][j] <= L:
            _C[i*300+j] = 1
            _C[j*300+i] = 1

# ワーシャルフロイド法 again

# distance from i to j
D = [array('q', [0]*N) for i in range(N)]
STEP = [array('q', [0]*N) for i in range(N)]

# initialization
for i in range(N):
    for j in range(N):
        c = C_(i,j)
        D[i][j] = c
        if c == sys.maxsize:
            STEP[i][j] = sys.maxsize
        else:
            STEP[i][j] = 1
        #print(i,j,D[i][j],STEP[i][j])

# 本計算
for k in range(N):
    for i in range(N):
        for j in range(N):
            if D[i][j] > D[i][k] + D[k][j]:
                D[i][j] = D[i][k] + D[k][j]
                STEP[i][j] = STEP[i][k] + STEP[k][j]


# answer
for q in range(Q):
    i = S[q]-1
    j = T[q]-1
    step = STEP[i][j]
    if step == sys.maxsize:
        #print(i,j,-1)
        print(-1)
    else:
        print(step-1)


### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

# scipy version

import sys
from collections import deque
from array import array

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

def input():
    return sys.stdin.readline().rstrip('\n')

##### main

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

C = [[0]*N for _ in range(N)]

for i in range(M):
    a,b,c = list(map(int, input().split()))
    if c>L:
        continue
    C[a-1][b-1] = c

Q = int(input())

ST = [None]*Q

for i in range(Q):
    s, t = list(map(int, input().split()))
    ST[i] = (s-1,t-1)

dist_matrix, predecessors = floyd_warshall(csgraph=C, directed=False, return_predecessors=True)

# D[i][j] <= L となる i,j に辺を張る
for i in range(N):
    for j in range(i+1,N):
        if dist_matrix[i][j] <= L:
            C[i][j] = 1

dist_matrix, predecessors = floyd_warshall(csgraph=C, directed=False, return_predecessors=True)

# answer
for q in range(Q):
    i,j = ST[q]
    step = dist_matrix[i][j]
    if step > 10**9:
        print(-1)
    else:
        print(int(step-1))
a, b = map(int, input())
if a == b:
  print('Draw')
elif a > b and b!=1:
  print('Alice')
else:
  print('Bob')

### FIXED CODE ###

a, b = map(int, input().split())
if a == b:
  print('Draw')
elif a > b and b!=1:
  print('Alice')
elif a==1:
  print('Alice')
else:
  print('Bob')
import sys
 import math
 K, A, B = list(map(int, input().split()))

 if A >= K:
     print(1)
     sys.exit()
 elif (A - B) <= 0:
     print(-1)
     sys.exit()
 d = A - B

 p = K-A
 q = math.ceil(p/d)
 if p % d != 0:
     q += 1
 print(int(2*q + 1))

### FIXED CODE ###

import sys
import math
K, A, B = list(map(int, input().split()))
 
if (A >= K):
    print('1')
    sys.exit()
elif (A - B) <= 0:
    print('-1')
    sys.exit()
d = A-B
p = K-A
q = int(p//d)
if ((p % d) != 0):
    q += 1
print(str(2*q + 1))
N=int(input())
a = list(map(int, input().split()))

for i in range(N):
  if i%2==1:
    S+=max(a)
    a.remove(max(a))
  else:
    S-=max(a)
    a.remove(max(a))
print(S)

### FIXED CODE ###

N=int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
S=0
for i in range(N):
  if i%2==0:
    S+=a[i]
  else:
    S-=a[i]
print(S)
a=[1,2,4,8,16,32,64,128]
n=int(input())
i=0
while a[i]<=n:
    i+=1
print(a[i-1])

### FIXED CODE ###

print('ABC'+input())
S,W=int(input())
if S < W:
    print("safe")
else:
    print("unsafe")

### FIXED CODE ###

S,W=map(int,input().split())
if S > W:
    print("safe")
else:
    print("unsafe")
import bisect
N=int(input())
D=list(map(int,input().split()))
if D[0]==0:
    D.sort()
    m=max(D)
    counter=[]
    for i in range(1,m+1):
        counter.append(bisect.bisect_right(D,i)-bisect.bisect_left(D,i))
    ans=1
    for i in range(2,m+1):
        if counter[i-1]==0:
            counter[i-1]=1
        ans*=counter[i-1]**counter[i]
    print(ans%998244353)
else:
    print(0)

### FIXED CODE ###

import bisect
N=int(input())
D=list(map(int,input().split()))
if D[0]==0 and D.count(0)==1:
    D.sort()
    m=max(D)
    counter=[]
    for i in range(m+1):
        counter.append(bisect.bisect_right(D,i)-bisect.bisect_left(D,i))
    ans=1
    for i in range(1,m+1):
        ans*=counter[i-1]**counter[i]
    print(ans%998244353)
else:
    print(0)
n,k=map(int,input().split())
mod=10**9+7
f=[1]
for i in range(n):
    f+=[f[-1]*(i+1)%mod]
print(f)
def combination(a,b):
    return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod

a=list(map(int,input().split()))
a.sort()
b=a[::-1]
ans=0
for i in range(k-1,n):
    ans+=((a[i]-b[i])*(comb(i,k-1)))%(10**9+7)
print(ans%(10**9+7))

### FIXED CODE ###

n,k=map(int,input().split())
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

mod=10**9+7
f=[1]
for i in range(n):f+=[f[-1]*(i+1)%mod]
def comb(a,b):
    return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod

a=list(map(int,input().split()))
a.sort()
b=a[::-1]
#print(a,b)
ans=0
for i in range(k-1,n):
    ans+=((a[i]-b[i])*(comb(i,k-1)))%(10**9+7)
print(ans%(10**9+7))
a = int(input().split(" "))

if sum(a) >= 22:
    print("win")
else:
    print("bust")

### FIXED CODE ###

a = input().split(" ")

a = [int(x) for x in a]

if sum(a) >= 22:
    print('bust')
else:
    print('win')
def euclid(a, b):
    r = a % b
    if 0 == r:
        return b
    return euclid(b, r)


def greatest_common_divisor(a, b):
    return int(a * b / euclid(a, b))


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

if 1 == n:
    print(t[0])
elif 2 == n:
    print(greatest_common_divisor(t[0], t[1]))
else:
    d = greatest_common_divisor(t[0], t[1])
    for i in range(2, n):
        d = greatest_common_divisor(d, t[i])
    print(d)


### FIXED CODE ###


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


def lcm(a, b):
    return (a * b) // gcd(a, b)


def lcm_arr(arr):
    ans = arr[0]
    for i in range(1, n):
        ans = lcm(ans, arr[i])
    return ans


n = int(input())
ans = lcm_arr([int(input()) for _ in range(n)])
print(min(ans, 10 ** 18))
N = int(input())
D = [*map(int,input().split())]
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
# for j in range(N):
#     for i in range(j):
        ans += D[i] * D[j]
print(ans)


### FIXED CODE ###

N = int(input())
# D = [*map(int,input().split())]
D = [d for d in map(int,input().split())]
ans = 0
# for i in range(N-1):
#     for j in range(i+1,N):
for j in range(N):
    for i in range(j):
        ans += D[i] * D[j]
print(ans)
A =int( input())
B =int( input())
C =int( input())
D = int(input())
E = int(input())

li = [A,B,C,D,E]
li_nonzero=[]

for x in li:
    if x % 10 != 0:
        li_nonzero.append(x)

z = li_nonzero[0]%10
for y in li_nonzero:
    if y % 10 <= z:
        z = y%10
        last_menu = y
        
li.remove(last_menu)

if len(li) != 4:
    while(len(li)==4):
        li.append(last_menu)
sum_time = 0
for menu in li:
    if menu % 10 != 0:
        sum_time = sum_time +( (menu//10)*10+10)
    else:
        sum_time = sum_time +( (menu//10)*10+0)
        
    
print(sum_time+last_menu)
    

### FIXED CODE ###

A =int( input())
B =int( input())
C =int( input())
D = int(input())
E = int(input())

li = [A,B,C,D,E]
li_nonzero=[]



for x in li:
    if x % 10 != 0:
        li_nonzero.append(x)

if len(li_nonzero) == 0:
    last_menu = li[4]
    li.remove(li[4])
else:
    z = li_nonzero[0]%10
    for y in li_nonzero:
        if y % 10 <= z:
            z = y%10
            last_menu = y
            
    li.remove(last_menu)

if len(li) < 4:
    while(len(li)==4):
        li.append(last_menu)
sum_time = 0
for menu in li:
    if menu % 10 != 0:
        sum_time = sum_time +( (menu//10)*10+10)
    else:
        sum_time = sum_time +( (menu//10)*10+0)
        
    
print(sum_time+last_menu)
a,b,c = map(int, input).split()

ans = 3

if a == b:
  if a == c:
    ans = 1
  else:
    ans = 2
elif a == c:
  ans = 2

print(ans)

### FIXED CODE ###

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

ans = 3

if a == b:
  if a == c:
    ans = 1
  else:
    ans = 2
elif a == c:
  ans = 2
elif b == c:
  ans = 2

print(ans)
N = int(input())
S = str(input())
X = [];Bit = 0;Num = 0
for i in range(N):
  if S[i] == "1":
    Bit += 1
    Num += pow(2,N-1-i)
  X.append(int(S[i]))
#print(X)
#print(Num)
MAX = 2*pow(10,5)+10
small = [-1 for _ in range(MAX)]
small[0] = 0; small[1] = 1; small[2] = 1; small[3] = 2
for i in range(4,MAX):
  ret = 0; target = i*1
  while i > 0:
    cnt = 0
    for j in range(i.bit_length()):
      if (i>>j)&1 == 1:
        cnt += 1
    i = i%cnt
    #print(i,target,cnt)
    ret += 1
    if small[i] != -1:
      ret += small[i]
      break

  small[target] = ret
#print(small)
Numm = Num%(Bit-1)
Nump = Num%(Bit+1)
#print(Num)
ans = []
for i in range(N):
  keta = N-1-i
  if X[i] == 1:
    btemp = Bit -1
    temp = (Numm - pow(2,keta,btemp))%btemp
  else:
    btemp = Bit +1
    temp = (Nump + pow(2,keta,btemp))%btemp
  ret = small[temp] + 1 #最初の一回
  ans.append(ret)
print(*ans,sep="\n")

### FIXED CODE ###

from collections import deque
N = int(input())
X = str(input())
X = list(X)
#motokosu = X.count("1")
motokosu = 0
only = float("inf")
for i in range(N):
  if X[i] == "1":
    motokosu += 1
    only = i
if motokosu != 1:
  only = float("inf")
#print(motosuji,motokosu)
MAX = 2*pow(10,5)+10
base = [0 for _ in range(MAX)] #0から19までの答えを保存
for i in range(MAX):
  now = i
  temp = 0
  while now != 0:
    ones = 0
    tnow = now*1
    for t in range(len(bin(now))-2):
      if (now>>t)&1 == 1:
        ones += 1
    #print(i,ones,now)
    now = now%ones
    #print(now,base[now])
    base[i] = base[now] + 1
    break
    #temp += 1
  #base[i] = temp
#print(base)
A = []
pkosu = motokosu+1
mkosu = motokosu-1
P = deque([])
M = deque([])
ptemp = 1; mtemp = 1
for i in range(N):
  P.appendleft(ptemp%pkosu)
  ptemp = ptemp*2%pkosu
  if mkosu < 1:
    M.appendleft(0)
  else:
    M.appendleft(mtemp%mkosu)
    mtemp = mtemp*2%mkosu

pmotosuji = 0; mmotosuji = 0
for i in range(N):
  if X[i] == "1":
    pmotosuji = (pmotosuji+P[i])%pkosu
    if mkosu >= 1:
      mmotosuji = (mmotosuji+M[i])%mkosu
#print(P,M,pkosu,mkosu,pmotosuji,mmotosuji)

for i in range(N): #i桁目を入れ替える
  if only == i:
    print(0)
    continue
  if X[i] == "0": #その桁が0なら1にする
    kosu = motokosu + 1
    suji = (pmotosuji + P[i])%kosu
  else: #その桁が1なら0にする
    kosu = motokosu - 1
    if kosu == 0:
      suji = -1
    else:
      suji = (mmotosuji - M[i])%kosu
    
  #print(suji,kosu)
  #if suji == 0:
  #  ans = 0
  if suji == -1:
    ans = 1
  else:
    nxt = suji%kosu
    ans = 1+base[nxt]
  #A.append(ans)
  print(ans)

#print(*A,sep="\n")
#print(2**17)
#print(motokosu)
import sys



def enqueue(x):
  x_list_list.append(x)

def dequeue(x_list_list):

  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []

for i in range(a):
  text = raw_input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if int(x_list_list[0][1]) > b:
    x_list_list[0][1] -= int(b)
    for j in range(flag):
      x_list_list[j][2] += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  elif int(x_list[0][1]) <= b:
    for j in range(flag):
      x_list_list[j][2] += x_list_list[0][1]
    x_list_list[0][1] = 0
    flag -= 1
    print x_list_list[0][0],x_list_list[0][2]
    dequeue(x_list_list)

### FIXED CODE ###

import sys

def isEmpty(S):
  if len(S) == 0:
    return True

def isFull(S):
  if len(S) >= 100000:
    return True

def enqueue(x):
  if isFull(x_list_list):
    print 'Error'
  x_list_list.append(x)

def dequeue(x_list_list):
  if isEmpty(x_list_list):
    print 'Error'
  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []
run_time = 0

for i in range(a):
  text = raw_input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if x_list_list[0][1] > b:
    x_list_list[0][1] -= int(b)
    run_time += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  else:
    run_time += x_list_list[0][1]
    x_list_list[0][2] = run_time
    x_list_list[0][1] = 0
    flag -= 1
    print x_list_list[0][0],x_list_list[0][2]
    dequeue(x_list_list)
#!/usr/bin/env python3

lis = [a, e, i, o, u]

if input() in lis:
    print("vowel")
else:
    print("consonant")

### FIXED CODE ###

#!/usr/bin/env python3

lis = ["a", "e", "i", "o", "u"]

if input() in lis:
    print("vowel")
else:
    print("consonant")
n=int(raw_input())
print "ABC"+n

### FIXED CODE ###

n=int(raw_input())
print "ABC"+str(n)
s=list(input())
k=int(input())
ss=[]
t=5*(10**15)
for i in range(len(s)):
               ss.append(int(s[i]))
for i in range(len(s)):
  k-=ss[i]**t
  if k<ss[i+1]:
    print(ss[i+1])
    break
  elif k==0:
    print(ss[i])
    break
    



### FIXED CODE ###

import sys
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        print(s[i])
        sys.exit()
    if s[i]=="1" and i+1==k:
        print(1)
        sys.exit()
X, N = map(int, input().split())
P = [int(p) for p in input().split()]

is_exit = [False] * 101

for p in P:
    is_exit[p] = True

if not is_exit[X]:
    print(X)
else:
    l = X - 1
    r = X + 1
    while True:
        if not is_exit[l]:
            print(l)
            exit()
        if not is_exit[r]:
            print(r)
            exit()
        l -= 1
        r += 1


### FIXED CODE ###

X, N = map(int, input().split())
P = [int(p) for p in input().split()]

is_exit = [False] * 101

for p in P:
    is_exit[p] = True

if not is_exit[X]:
    print(X)
else:
    l = X - 1
    r = X + 1
    while True:
        if 1 <= l:
            if not is_exit[l]:
                print(l)
                exit()
        else:
            print(l)
            exit()
        if r <= 100:
            if not is_exit[r]:
                print(r)
                exit()
        else:
            print(r)
            exit()
        l -= 1
        r += 1
A,B,C,K = map(int, input().split())
card_list = (([1]*A).extend([0]*B)).extend([-1]*C)
 
print(sum(card_list[0:K]))

### FIXED CODE ###

A,B,C,K = map(int, input().split())
ans = 0
if K <= A:
  ans = K
else:
  if K > A and K <= A+B:
    ans = A
  else:
    ans = A-(K-A-B)
print(ans)
# ABC 116 C

N = int(input())

h = list(map(int, input().split()))

def chomp0(arr):
    while len(arr) != 0 and arr[0] == 0:
        del arr[0]

    while len(arr) != 0 and arr[-1] == 0:
        del arr[-1]

    return arr

def solve(arr):
    ans = 0

    num0 = arr.count(0)
    if num0 != 0:
        for _ in range(num0):
            idx = arr.index(0)
            ans += solve(arr[:idx])
            arr = arr[idx+1:]

    minVal = min(arr)
    ans += minVal
    for i in range(len(arr)):
        arr[i] -= minVal

    arr = chomp0(arr)

    if arr.count(0) != len(arr):
        ans += solve(arr)

    return ans

print(solve(h))


### FIXED CODE ###

# ABC 116 C

N = int(input())

h = list(map(int, input().split()))

def chomp0(arr):
    while len(arr) != 0 and arr[0] == 0:
        del arr[0]

    while len(arr) != 0 and arr[-1] == 0:
        del arr[-1]

    return arr

def solve(arr):
    arr = chomp0(arr)

    if len(arr) == 0:
        return 0

    ans = 0

    num0 = arr.count(0)
    if num0 != 0:
        for _ in range(num0):
            idx = arr.index(0)
            ans += solve(arr[:idx])
            arr = arr[idx+1:]

    minVal = min(arr)
    ans += minVal
    for i in range(len(arr)):
        arr[i] -= minVal

    if arr.count(0) != len(arr):
        ans += solve(arr)

    return ans

print(solve(h))
import sys
from bisect import insort_left
from collections import *

N = int(input())
An = list(map(int, input().split()))[0:N]

An_sorted_pos = deque(sorted([ a for a in An if a > 0]))
An_sorted_neg = deque(sorted([ a for a in An if a < 0]))

if len(An_sorted_neg) % 2 == 0:
    print(sum(An_sorted_pos) - sum(An_sorted_neg))
    sys.exit(0)
    pass

min_neg = min(min(An_sorted_pos), -max(An_sorted_neg))

print(sum(An_sorted_pos) - sum(An_sorted_neg) - 2*min_neg)


### FIXED CODE ###

from itertools import chain

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ -a for a in An if a < 0]

ans = sum(An_pos) + sum(An_neg)

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)
H, N = map(int,input().split())
M = [list(map(int,input().split())) for k in range(N)]
dp = [float("inf")]*(H+1)
dp[0] = 0

for e in M:
    a, b = e[0], e[1]
    for k in range(a+1):
        dp[k] = min(dp[k],b)
    for k in range(a+1,H+1):
        dp[k] = min(dp[k],dp[k-a]+b)
print(dp[H])


### FIXED CODE ###

import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    H, N = map(int,input().split())
    M = [list(map(int,input().split())) for k in range(N)]

    dp = [10**9 for k in range(10**4+1)]
    dp[0] = 0
    for e in M:
        A, B = e[0], e[1]
        for k in range(A+1):
            dp[k] = min(dp[k],B)
        for k in range(A+1,H+1):
            dp[k] = min(dp[k],dp[k-A]+B)

    print(dp[H])

if __name__ == '__main__':
    main()
a, b = map(int, input().split())

def Bottuns(x, y):
  if x > y:
    return 2x+1
  elif x < y:
    return 2y+1
  elif x==y:
    return x+y


Buttons(a,b)

### FIXED CODE ###

a, b = map(int, input().split())
 
def Buttons(x, y):
  if x > y:
    return 2*x-1
  elif x < y:
    return 2*y-1
  else:
    return x+y
 
 
print(Buttons(a,b))