Harryxun/stf_run huggingface dataset:
def hoge(K, A, B):
    K = int(input())
    A, B = map(int, input().split())
    
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

if hoge(K, A, B):
    print('OK')
else:
    print('NG')

### FIXED CODE ###

def hoge(K, A, B):
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

K = int(input())
A, B = map(int, input().split())
if hoge(K, A, B):
    print('OK')
else:
    print('NG')
s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s[a:b+1] = s[b+1:a]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])


### FIXED CODE ###

s = input()
n = int(input())

for i in range(n):
    command = input().split()
    if command[0] == 'replace':
        a,b = map(int,command[1:3])
        s = s[:a]+ command[3] + s[b+1:]
    elif command[0] == 'reverse':
        a,b = map(int,command[1:3])
        s = s[0:a] + s[a:b+1][::-1] + s[b+1:]
    elif command[0] == 'print':  
        a,b = map(int,command[1:3])
        print(s[a:b+1])
H, N = map(int, input().split())
A = list(map(int, input().split()))

if sum(A) >= H:
  print('Yes')
else:

### FIXED CODE ###

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

if sum(A) >= H:
  print('Yes')
else:
  print('No')
import heapq
from collections import namedtuple

Data = namedtuple("Data", ("time", "number"))

all_player = []

for _ in range(3):
    player = [input().split(" ") for lp in range(8)]
    player = [Data(float(time), number) for number, time in player]

    heapq.heapify(player)
    data = heapq.heappop(player)
    print(data.number, data.time)
    data = heapq.heappop(player)
    print(data.number, data.time)

    all_player.extend(player)

heapq.heapify(all_player)
data = heapq.heappop(all_player)
print(data.number, data.time)
data = heapq.heappop(all_player)
print(data.number, data.time)



### FIXED CODE ###

import heapq
from collections import namedtuple

Data = namedtuple("Data", "time number")

all_player = []

for _ in range(3):
    player = [input().split(" ") for lp in range(8)]
    player = [Data(float(time), number) for number, time in player]

    heapq.heapify(player)
    data = heapq.heappop(player)
    print(data.number, data.time)
    data = heapq.heappop(player)
    print(data.number, data.time)

    all_player.extend(player)

heapq.heapify(all_player)
data = heapq.heappop(all_player)
print(data.number, data.time)
data = heapq.heappop(all_player)
print(data.number, data.time)
N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
n = 1
for _ in range(N+1):
    n = A[n-1]
    c += 1
    if n == 1:
        ok = False
        break
    if n == 2:
        ok = True
        break
if ok:
    print(c)
else:
    print(-1)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
n = 1
checked = [False for _ in range(N)]
checked[0] = True
for _ in range(N+1):
    n = A[n-1]
    c += 1
    if n == 2:
        ok = True
        break
    if checked[n-1]:
        ok = False
        break
    checked[n-1] = True
if ok:
    print(c)
else:
    print(-1)
n, m, k = map(int, input().split())

f_adj_list = [[] for i in range(n)]
b_adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  f_adj_list[_].append(__)
  f_adj_list[__].append(_)
  
for j in range(k):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  b_adj_list[_].append(__)
  b_adj_list[__].append(_)
  
  
group_id = [None for i in range(n)]
for i in range(n):
  # i から DFS
  newly_visited = [i]
  group_id[i] = i
  while len(newly_visited) > 0:
    now = newly_visited.pop()
    for j in f_adj_list[now]:
      if group_id[j] is not None: continue
      newly_visited.append(j)
      group_id[j] = i

# group_id
# print(group_id)

# 連結成分のサイズ
from collections import Counter
cnt = Counter(group_id)
# cnt[5] = 7

ans_list = []
for i in range(n):
  ans = cnt[group_id[i]]
  ans -= 1 # 自分自身
  ans -= len(f_adj_list[i]) # 直接の友達
  for j in b_adj_list[i]:
    if group_id[i] == group_id[j]:
      ans -= 1
  ans_list.append(ans)

print(" ".join(ans_list))


### FIXED CODE ###

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

f_adj_list = [[] for i in range(n)]
b_adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  f_adj_list[_].append(__)
  f_adj_list[__].append(_)
  
for j in range(k):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  b_adj_list[_].append(__)
  b_adj_list[__].append(_)
  
  
group_id = [None for i in range(n)]
for i in range(n):
  if group_id[i] is not None: continue
  # i から DFS
  newly_visited = [i]
  group_id[i] = i
  while len(newly_visited) > 0:
    now = newly_visited.pop()
    for j in f_adj_list[now]:
      if group_id[j] is not None: continue
      newly_visited.append(j)
      group_id[j] = i

# group_id
# print(group_id)

# 連結成分のサイズ
from collections import Counter
cnt = Counter(group_id)
# cnt[5] = 7

ans_list = []
for i in range(n):
  ans = cnt[group_id[i]]
  ans -= 1 # 自分自身
  ans -= len(f_adj_list[i]) # 直接の友達
  for j in b_adj_list[i]:
    if group_id[i] == group_id[j]:
      ans -= 1
  ans_list.append(ans)

print(" ".join(map(str, ans_list)))
r = int(input())
x = 3.14159265358979323846
print(r * r * x, 2 * r * x)



### FIXED CODE ###

r = float(input())
x = 3.141592653589793238462643383279
print('{:.7f}'.format(r * r * x), '{:.7f}'.format(2 * r * x))
N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    tree[a-1].append((b-1,c))
    tree[b-1].append((a-1,c))

Q,K = map(int,(input().split()))

dis = [-1]*N
dis[K-1] = 0
def dfs(v,d):
    for i in tree[v]:
        d = dis[v]
        next,c = i
        if dis[next] == -1:
            d += c
            dis[next] = d
            dfs(next,d)
dfs(K-1,0)

for i in range(Q):
    x,y = map(int,(input().split()))
    print(dis[x-1]+dis[y-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

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

Q,K = map(int,(input().split()))

dis = [-1]*N
dis[K-1] = 0
def dfs(v,d):
    for i in tree[v]:
        d = dis[v]
        next,c = i
        if dis[next] == -1:
            d += c
            dis[next] = d
            dfs(next,d)
dfs(K-1,0)

for i in range(Q):
    x,y = map(int,(input().split()))
    print(dis[x-1]+dis[y-1])
n = input()
n = n.replace("1","a")
n = n.replace("9","1")
n = n.replace("a,"9")
print(n)

### FIXED CODE ###

n = input()
n = n.replace("1","a")
n = n.replace("9","1")
n = n.replace("a","9")
print(n)
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
for i in range(H):
  ans=[0]*W
  for i in range(W):
    if s[i][j]=="#":
      ans[j]=="#"
      continue
    count=0
    if i > 0:
      if s[i-1][j]=="#":
        count+=1
      if j > 0:
        if s[i-1][j-1]=="#":
          count+=1
      if j < W-1:
        if s[i-1][j+1]=5"#":
          count+=1
    if i<H-1:
      if s[i+1][j]=="#":
        count+=1
      if j >0:
        if s[i+1][j-1]=="#":
          count+=1
      if j<W-1:
        if s[i+1][j+1]=="#":
          count+=1
    if j>0:
      if s[i][j-1]==”#”:
        count+=1
    if j<W-1:
      if s[i][j+1]=="#":
        count+=1
    ans[j]=count
  print("".join(map(str,ans)))
        
        

### FIXED CODE ###

H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
for i in range(H):
  ans=["0"]*W
  for j in range(W):
    if s[i][j]=="#":
      ans[j]="#"
      continue
    count=0
    if i > 0:
      if s[i-1][j]=="#":
        count+=1
      if j > 0:
        if s[i-1][j-1]=="#":
          count+=1
      if j < W-1:
        if s[i-1][j+1]=="#":
          count+=1
    if i<H-1:
      if s[i+1][j]=="#":
        count+=1
      if j >0:
        if s[i+1][j-1]=="#":
          count+=1
      if j<W-1:
        if s[i+1][j+1]=="#":
          count+=1
    if j>0:
      if s[i][j-1]=="#":
        count+=1
    if j<W-1:
      if s[i][j+1]=="#":
        count+=1
    ans[j]=str(count)
  print("".join(ans))
# coding: utf-8
 
def main():
	H, W = (int(x) for x in input().split())
	S = [[] for x in range(H)]
 
	for i in range(H):
		S[i] = [x for x in input()]
 
	# 隣接行列の作成
	inf = 1000000
 
	nodes = []
	for i in range(H):
		for j in range(W):
			if S[i][j] == ".":
				nodes.append([i, j])
	
	g = [[inf for j in range(len(nodes))] for i in range(len(nodes))]
	for i in range(len(nodes)):
		for j in range(len(nodes)):
			if   nodes[i][0] == nodes[j][0] and nodes[i][1] == nodes[j][1]:
				g[i][j] = 0
			elif abs(nodes[i][0]-nodes[j][0]) + abs(nodes[i][1]-nodes[j][1]) == 1:
				g[i][j] = 1
 
	max = 0
	for k in range(len(g[0])):
		for i in range(len(g[0])):
			for j in range(len(g[0])):
				g[i][j] = min(g[i][j], g[i][k] + g[k][j])
                if max < g[i][j]:
					max = g[i][j]

	print(max)
 
if __name__ == "__main__":
	main()

### FIXED CODE ###

# coding: utf-8

import queue

def main():
	H, W = (int(x) for x in input().split())
	S = [[] for x in range(H)]

	for i in range(H):
		S[i] = [x for x in input()]

	max_d = [[-1 for x in range(W)] for y in range(H)]
	for i in range(H):
		for j in range(W):
			if S[i][j] == "#":
				continue
			d = [[-1 for x in range(W)] for y in range(H)]
			q = queue.Queue()
			q.put([i, j])
			d[i][j] = 0
			while not q.empty():
				n = q.get()
				for y, x in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
					if (n[0] == 0   and y == -1) or\
					   (n[0] == H-1 and y ==  1) or\
					   (n[1] == 0   and x == -1) or\
					   (n[1] == W-1 and x ==  1) or\
					   S[n[0]+y][n[1]+x] == "#"  or\
					   d[n[0]+y][n[1]+x] != -1:
						continue
					d[n[0]+y][n[1]+x] = d[n[0]][n[1]] + 1
					q.put([n[0]+y, n[1]+x])
			for y in range(H):
				for x in range(W):
					if max_d[i][j] < d[y][x]:
						max_d[i][j] = d[y][x]

	max = 0
	for i in range(H):
		for j in range(W):
			if max < max_d[i][j]:
				max = max_d[i][j]

	print(str(max))

if __name__ == "__main__":
	main()
from collections import deque
# N < 10^5, A, B, C < 10^9
# s = ('AB', 'AC', 'BC')
# A >= 0, B >= 0, C >= 0
# N回操作できるか？できるなら道筋を
# 各ステップで2通りのどちらかしか選択できない。
# DPだと思う
# (A, B, C, i, '')

def f(x, dic):
    if x[4] == '':
        return 1
    else:
        if f(dic[x], dic):
            print(x[4])
            return 1

N, A, B, C = [int(i) for i in input().split()]
S = [input() for _ in range(N)]
i = 0
dic = {}
que = deque([(A, B, C, i, '')])
while len(que) != 0:
    x = que.pop()
    i = x[3]
    if x[3] == N:
        print('Yes')
        f(x, dic)
        exit()
    if S[i] == 'AB':
        if x[1] > 0:
            newx = (x[0]+1, x[1]-1, x[2], x[3]+1, 'A')
            dic[newx] = x
            que.append(newx)
        if x[0] > 0:
            newx = (x[0]-1, x[1]+1, x[2], x[3]+1, 'B')
            dic[newx] = x
            que.append(newx)
    elif S[i] == 'BC':
        if x[2] > 0:
            newx = (x[0], x[1]+1, x[2]-1, x[3]+1, 'B')
            dic[newx] = x
            que.append(newx)
        if x[1] > 0:
            newx = (x[0], x[1]-1, x[2]+1, x[3]+1, 'C')
            dic[newx] = x
            que.append(newx)
    elif S[i] == 'AC':
        if x[2] > 0:
            newx = (x[0]+1, x[1], x[2]-1, x[3]+1, 'A')
            dic[newx] = x
            que.append(newx)
        if x[0] > 0:
            newx = (x[0]-1, x[1], x[2]+1, x[3]+1, 'C')
            dic[newx] = x
            que.append(newx)
    else:
        print('error')
print('No')


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(500000)
# N < 10^5, A, B, C < 10^9
# s = ('AB', 'AC', 'BC')
# A >= 0, B >= 0, C >= 0
# N回操作できるか？できるなら道筋を
# 各ステップで2通りのどちらかしか選択できない。
# DPだと思う
# (A, B, C, i, '')

def f(x, dic):
    if x[4] == '':
        return 1
    else:
        if f(dic[x], dic):
            print(x[4])
            return 1

N, A, B, C = [int(i) for i in input().split()]
S = [input() for _ in range(N)]
i = 0
dic = {}
que = deque([(A, B, C, i, '')])
while len(que) != 0:
    x = que.pop()
    i = x[3]
    if x[3] == N:
        print('Yes')
        f(x, dic)
        exit()
    if S[i] == 'AB':
        if x[1] > 0:
            newx = (x[0]+1, x[1]-1, x[2], x[3]+1, 'A')
            dic[newx] = x
            que.append(newx)
        if x[0] > 0:
            newx = (x[0]-1, x[1]+1, x[2], x[3]+1, 'B')
            dic[newx] = x
            que.append(newx)
    elif S[i] == 'BC':
        if x[2] > 0:
            newx = (x[0], x[1]+1, x[2]-1, x[3]+1, 'B')
            dic[newx] = x
            que.append(newx)
        if x[1] > 0:
            newx = (x[0], x[1]-1, x[2]+1, x[3]+1, 'C')
            dic[newx] = x
            que.append(newx)
    elif S[i] == 'AC':
        if x[2] > 0:
            newx = (x[0]+1, x[1], x[2]-1, x[3]+1, 'A')
            dic[newx] = x
            que.append(newx)
        if x[0] > 0:
            newx = (x[0]-1, x[1], x[2]+1, x[3]+1, 'C')
            dic[newx] = x
            que.append(newx)
    else:
        print('error')
print('No')
N = int(input())

if N <= 599:
    pirint(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

### FIXED CODE ###

N = int(input())

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)
n = int(raw_input())

x = lambda: map(int, raw_input().strip().split())

A = x()
B = x()
C = x()

points = 0
for i in xrange(n):
  points += B[A[i]-1]
  if i > 0 and A[i] == A[i-1] + 1:
    points += C[A[i]-1]

print points

### FIXED CODE ###

n = int(raw_input())

x = lambda: map(int, raw_input().strip().split())

A = x()
B = x()
C = x()

points = 0
for i in xrange(n):
  points += B[A[i]-1]
  if i > 0 and A[i] == A[i-1] + 1:
    points += C[A[i]-2]

print points
s = raw_input()
w = int(raw_input())

result = ""
for i in xrange((len(s) / w)):
  result += s[i * w]
  
if w != 1:
  result += s[i * w + w]
print result

### FIXED CODE ###

s = raw_input()
w = int(raw_input())

result = ""
for i in xrange((len(s) / w)):
  result += s[i * w]
  
if len(s) % w != 0:
  result += s[-(len(s) % w)]
print result
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import defaultdict
import numpy


def main():
  n, m = map(int, input().strip().split())
  memo = numpy.full(n+1, -1)
  graph = defaultdict(list)

  for _ in range(m):
    x, y = map(int, input().strip().split())
    graph[y].append(x)

  def rec(v):
    if memo[v] != -1:
      return memo[v]

    memo[v] = numpy.max([0] + [rec(t)+1 for t in graph[v]])
    return memo[v]

  print(numpy.max([rec(v) for v in range(1, n+1)]))

if __name__=='__main__':
  main()

### FIXED CODE ###

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

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)

def main():
  n, m = map(int, input().strip().split())
  memo = [-1] * (n+1)
  graph = defaultdict(list)

  for _ in range(m):
    x, y = map(int, input().strip().split())
    graph[y].append(x)

  def rec(v):
    if memo[v] != -1:
      return memo[v]

    lp = 0
    for t in graph[v]:
      lp = max(lp, rec(t)+1)
    memo[v] = lp
    return memo[v]

  lp = 0
  for v in range(1, n+1):
    lp = max(lp, rec(v))
  print(lp)


if __name__=='__main__':
  main()
from math import sqrt
x1,y1,x2,y2= map(int,raw_input().split())
print sqrt((y2-y1)**2+(x2-x1)**2)

### FIXED CODE ###

from math import sqrt
x1,y1,x2,y2= map(float,raw_input().split())
print '%.8f' % sqrt((y2-y1)**2+(x2-x1)**2)
import math

N, K = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


w = 10**9+7
for i in range(1, K+1):
    if N-K+1-i > 0:
        ans1 = combinations_count(N-K+1, i)
        ans2 = combinations_count(K-1, i-1)
        ans = ans1 % w * ans2 % w
        print(ans)
        cnt += ans
    else:
        print(combinations_count(N, K) % w-cnt)


### FIXED CODE ###

import math

N, K = list(map(int, input().split()))
mod = 10**9+7


def combination(a, b):
    ans = (math.factorial(a) // math.factorial(a-b)) // math.factorial(b)
    return ans


for i in range(1, K+1):
    if (N-K+1-i) >= 0:
        ans1 = combination(N-K+1, i)
        ans2 = combination(K-1, i-1)
        print(ans1 % mod*ans2 % mod)
    else:
        print(0)
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
n,m = map(int, input().split())
a=[]
b=[]
for i in range(m):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

graph=np.zeros((n,n))

for i in range(m):
    graph[a[i]-1][b[i]-1] = 1
    graph[b[i]-1][a[i]-1] += 1

d,p=shortest_path(graph,return_predecessors=True)
print(d)
print(p)

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])
    
def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]

for i in range(1,m):
    for j in range(i,m):
        if graph[i][j] == np.inf:
            print('No')
            break
        if i == m - 1 and j == m -1:
            print('Yes')
            for i in range(1,n):
                michi= get_path(0,i,p)
                print(michi[-2]+1)

### FIXED CODE ###

n,m=map(int,input().split())
g=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)
l,r = map(int,input().split())
if r - l >= 2019:
    print(0)
else:
    ans_o = (l*(l+1))%2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = (i*j)%2019
            ans_o = min(ans,ans_o)
print(ans_o)

### FIXED CODE ###

l,r = map(int,input().split())
if r - l >= 2019:
    print(0)
else:
    ans_o = (l*(l+1))%2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = (i*j)%2019
            ans_o = min(ans,ans_o)
    print(ans_o)
import math
n = int(input())
ans = 1
for _ in range(n):
    x = int(input())
    ans *=  x//math.gcd(ans,x)
print(ans) 

### FIXED CODE ###

n = int(input())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a
  
ans = 1
for _ in range(n):
    x = int(input())
    ans *=  x//gcd(ans,x)
print(ans)
from math import gcd
from functools import reduce

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

#a = [746130, 1385670, 4849845, 881790, 3233230, 1939938, 570570, 510510]
#a = [7,6,8]
#n = len(a)
max_value = 0
for i in range(n):
    b = a.copy()
    b.pop(i)
    x = reduce(gcd, b)
    if x > max_value:
        max_value = x
        max_pos = i
print(max_value)


### FIXED CODE ###

from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
l = [0]
r = [0]
ans = 0
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
for i in range(n-1):
    r.append(gcd(r[i],a[n-1-i]))
for i in range(n):
    ans = max(ans,gcd(l[i],r[-i-1]))
print(ans)
n=int(input())
x=input()
memo={}

def func(m,i):
  if m in memo:
    return memo[m]
  elif m%i==0:
    memo[m]=1
    return 1
  else:
    ret=0
    mm=m%i
    ii=bin(mm).count('1')
    ret+=func(mm,ii)+1
    memo[m]=ret
    return ret

c=x.count('1')
xx=0
for i in range(n):
  xx+=pow(2,i)*int(x[-1-i])
for i in range(n):
  if x[i]=='0':
    xxx=xx+pow(2,n-1-i)
    cc=c+1
  else:
    xxx=xx-pow(2,n-1-i)
    cc=c-1
  print(func(xxx,cc))
#print(memo)

### FIXED CODE ###

n=int(input())
x=input()
import sys
sys.setrecursionlimit(10**7)
if n==1:
  print(0 if x=='1' else 1)
  exit()
def pc(x):
  a=bin(x)[2:]
  return a.count('1')
def func(x):
  if x==0:
    return 0
  else:
    return func(x%pc(x))+1
pcx=x.count('1')
if pcx==0:
  for _ in range(n):
    print(1)
else:
  x0,x1=0,0
  for i in range(n):
    if x[i]=='1':
      if pcx!=1:
        x0+=pow(2,n-1-i,pcx-1)
        x0%=pcx-1
      x1+=pow(2,n-1-i,pcx+1)
      x1%=pcx+1
  for i in range(n):
    ans=0
    if x[i]=='1':
      if pcx==1:
        print(0)
      else:
        xx=x0-pow(2,n-1-i,pcx-1)
        xx%=pcx-1
        print(func(xx)+1)
    else:
      xx=x1+pow(2,n-1-i,pcx+1)
      xx%=pcx+1
      print(func(xx)+1)
import numpy as np 
n , m = map(int, input().split())
l = np.array([list(map(int, input().split())) for _ in range(m)])
l2 = np.zeros(m)

l2 = l[:,0]*(10**6) + l[:,1]
l2 = np.sort(l2)

j = 1000000
k = 1
for i in range(m):
    if j+1000000 > l2[i]:
        l2[i] = j + k
        k += 1
    else :
        j += 1000000
        l2[i] = j + 1
        k = 2

for i in l2 :
    print('{0:012d}'.format(i))


    

### FIXED CODE ###

x , y = map(int, input().split())
print(int(x+y/2))
import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = np.max(a)+1
dp = np.array([True]*(max_num))

if np.all(a==a[0]):
    print(0)
else:
    for i in range(1,max_num):
        if dp[i] and i in a:
            for j in np.arange(i*2, max_num, i):
                dp[j] = False
        if np.count_nonzero(a==i) >1:
            dp[i] = False
    print(np.count_nonzero(dp[np.a] == True))

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([0]*(max_num))

if n == 1:
    print(1)
elif np.all(a==a[0]):
    print(0)
elif np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in a:
        for j in np.arange(i, max_num, i):
            dp[j] += 1
    print(np.count_nonzero(dp[a] == 1))
print('No' if !(input().replace('hi','')) else 'Yes')

### FIXED CODE ###

s=input()
answer='Yes'
for i in range(len(s)):
    if len(s)%2==1:
        answer='No'
        break
    elif i%2==0:
        if s[i]!='h' or s[i+1]!='i':
            answer='No'
print(answer)
n = int(input())

ans = 0
for i in range(1, n+1, 2):
    tmp = 0
    for j in range(1, n/2):
        if i % j == 0:
            tmp += 1

    if tmp == 8:
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)
X, N = map(int, input().split())
if N = 0:
    print(X)
    exit()
p = list(map(int, input().split()))

ans = -1

for i in range(0,102):
    if i not in p:
        if abs(i-X) < abs(ans-X):
            ans = i
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 10**12
    a = -1
    for i in range(0,102):
        if i not in p and abs(X-i) < ans:
            ans = abs(X-i)
            a = i
    print(a)


if __name__ == "__main__":
    main()