Harryxun/stf_run huggingface dataset:
from sys import stdin
input = stdin.readline

N, X, M = map(int, input().split())

ls = []
s = set([])

a = X
s.add(a)
ls.append(a)

while True:
    a = pow(a, 2, M)

    if a in s:
        ind = ls.index(a)
        break
    elif len(ls) == N:
        break
    else:
        s.add(a)
        ls.append(a)

new_ls = ls[ind:len(ls)]

ans = sum(new_ls) * (max(0, (N - len(ls))) // len(new_ls)) + sum(ls)

tmp = max(0, (N - len(ls))) % len(new_ls)

if tmp != 0:
    for i in range(tmp):
        ans += new_ls[i % len(new_ls)]

print(ans)


### FIXED CODE ###

from sys import stdin
input = stdin.readline

N, X, M = map(int, input().split())

ls = []
s = set([])

a = X
s.add(a)
ls.append(a)
ind = -1
new_ls = []

while True:
    a = pow(a, 2, M)

    if a in s:
        ind = ls.index(a)
        break
    elif len(ls) == N:
        break
    else:
        s.add(a)
        ls.append(a)

if ind != -1:
    new_ls = ls[ind:len(ls)]

ans = sum(ls)

if len(new_ls) != 0:
    ans += sum(new_ls) * (max(0, (N - len(ls))) // len(new_ls))

    tmp = max(0, (N - len(ls))) % len(new_ls)

    if tmp != 0:
        for i in range(tmp):
            ans += new_ls[i % len(new_ls)]

print(ans)
N,H=map(int,input().split())

a=[0]*N
b=[0]*N
for i in range(N):
  a[i],b[i]=map(int,input().split())

amax=max(a)
n=0
total=0
b.sort(reverse=True)
for i in range(N):
  if b[i] > amax:
    n+=1
    total+=b[i]
  else:
    break

if H <= total:
  for i in range(n):
    H-=b[i]
    if H <＝0:
      print(i+1)
      break
else:
  print(n+int((H-total-1)/amax)+1)

### FIXED CODE ###

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

a=[0]*N
b=[0]*N
for i in range(N):
  a[i],b[i]=map(int,input().split())

amax=max(a)
n=0
total=0
b.sort(reverse=True)
for i in range(N):
  if b[i] > amax:
    n+=1
    total+=b[i]
  else:
    break

if H <= total:
  for i in range(n):
    H-=b[i]
    if H <= 0:
      print(i+1)
      break
else:
  print(n+int((H-total-1)/amax)+1)
x = int(input("はじめ"))
y = int(input("中"))
z = int(input("終わり"))


if x >= 1 and x <= 10:
    if x == 5:
        if y == 5:
            if z == 7:
                print("YES")
            elif z == 5:
                print("NO")
                
        elif y == 7:
            if z == 5:
                print("YES")
            elif z == 7:
                print("NO")
                
    elif x == 7:
        if  y == 5:
            if z == 5:
                print("YES")
            elif z == 5:
                print("NO")
            else:
                print("NO")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")

### FIXED CODE ###

a, b, c = map(int, input().split())
if sorted((a, b, c)) == [5, 5, 7]:
  print('YES')
else:
  print('NO')
L,N=(int(i) for i in input().split())
X = []
for i in range(0,N):
    a = int(input())
    X.append(a)
import math
result=0
if X[math.ceil(N/2)]<L/2:
  for i in range (1,math.ceil(N/2)):
    for j in range (N,math.ceul(N/2),-1):
      result+=abs(X[j]-X[i])
else:
   for i in range (1,math.ceil(N/2)):
    for j in range (N,math.ceil(N/2),-1):
      result+=abs(X[i]-X[j])
print(result)

### FIXED CODE ###

a,b,c=(int(i) for i in input().split())
if b+1>=c:
  print(b+c)
else:
  if a+1>=c-b:
    print(b+c)
  else:
    print(2*b+a+1)
def search(x, num):
    for y in list(edge[x]):
        if y in nodes:
            nodes.remove(y)
            num = search(y, num)
    return num + 1

(n,m),*d  = [list(map(int, s.split())) for s in open(0)]

edge = [set() for _ in range(n+1)]
for x in d:
    edge[x[0]].add(x[1])
    edge[x[1]].add(x[0])

nodes = set(range(1,n+1))
ans = 1
for x in list(nodes):
    if x in nodes:
        nodes.remove(x)
        ans = max(ans, search(x, 0))
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e6))

def search(x, num):
    nodes.remove(x)
#     for y in edge[x]:
#         edge[y].discard(x)
#     for y in list(edge[x]):
    for y in edge[x]:
        if y in nodes:
            num = search(y, num)
    return num + 1

(n,m),*d  = [list(map(int, s.split())) for s in open(0)]

edge = [set() for _ in range(n+1)]
for x in d:
    edge[x[0]].add(x[1])
    edge[x[1]].add(x[0])

nodes = set(range(1,n+1))
ans = 1
for x in list(nodes):
    if x in nodes:
        ans = max(ans, search(x, 0))
print(ans)
X = int(input())
ans = 1
for b in range(1,x):
    for p in range(2,x):
        if X >= b**p and b**p > ans:
            ans = b**p
print(ans)

### FIXED CODE ###

X = int(input())
ans = 1
for b in range(1,101):
    for p in range(2,10):
        if X >= b**p and b**p > ans:
            ans = b**p
print(ans)
n=int(input())
a=list(map(int,input().split()))
import numpy as np
dp=np.full((n+1,n+1),-pow(10,15))
dp[:,0]=0
dp[1,1]=a[0]
for i in range(2,n+1):
    dp[i,1:]=np.maximum(dp[i-1,1:],dp[i-2,:-1]+a[i-1])
print(dp[n,n//2])

### FIXED CODE ###

from collections import defaultdict

n=int(input())
a=list(map(int,input().split()))
#n=2*pow(10,5)
#a=range(1,pow(10,5)+1)
# dp[i][j]:i番目の数字の中からj個数字を取った時の最大。(i//2)-1<=j<=(i+1)//2
# 求めるのはdp[n][n//2]
dp=defaultdict(lambda:-pow(10,18))
dp[(1,1)]=a[0]
for i in range(2,n+1): #i番目の数字はa[i-1]
      for j in range(i//2-1,(i+1)//2+1):
            if j==1:
                  dp[(i,j)]=max(dp[(i-1,1)],a[i-1])
            elif j==0:
                  dp[(i,j)]=0
            else:
                  dp[(i,j)]=max(dp[(i-2,j-1)]+a[i-1],dp[(i-1,j)])
print(dp[(n,n//2)])
N, K, Q = map(int, input().split())

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

dic = {}

for i in range(Q):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
    
    
for i in range(N):
  if K - (N - dic[A[i]]) <= 0:
    print('No')
    
  else:
    print('Yes')
  

### FIXED CODE ###

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

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

dic = {}

for i in range(N):
    dic[i+1] = 0

for i in range(Q):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
    
    
for i in range(N):
  if K - (Q - dic[i+1]) <= 0:
    print('No')
    
  else:
    print('Yes')
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([0,0,0]) + np.array([iarr() for i in range(n)])
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 1
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

ans = "Yes" if flag else "No"
print(ans)


### FIXED CODE ###

n=int(input())
ts=[]; xs=[]; ys=[]

for i in range(n):
    t,x,y = map(int,input().split())
    ts.append(t); xs.append(x); ys.append(y)

flag=1
for i in range(n):
    t = ts[i]
    d = abs(xs[i]) + abs(ys[i])
    if t>=d and (t-d)%2==0: continue
    else: flag=0; break

if flag: print("Yes")
else: print("No")
text = input()
i = 0
ans = "keyence"
for ob_n in range(len(lists)):
    if text[i] != lists[ob_n]:
        if text.endswith(ans[ob_n:]):
            flag = 1
            break
        else:
            flag = 0
            break
    i+=1
    if i == len(text):
        flag = 1
        break
if flag == 1:
    print("YES")
else :
    print("NO")

### FIXED CODE ###

text = input()
i = 0
ans = "keyence"
for ob_n in range(len(ans)):
    if text[i] != ans[ob_n]:
        if text.endswith(ans[ob_n:]):
            flag = 1
            break
        else:
            flag = 0
            break
    i+=1
    if i == len(text):
        flag = 1
        break
if flag == 1:
    print("YES")
else :
    print("NO")
a, b, c = map(int, raw_input().split())
l = [a, b, c].sort()
print l[0], l[1], l[2]

### FIXED CODE ###

a, b, c = map(int, raw_input().split())
l = sorted([a, b, c])
print l[0], l[1], l[2]
def main():

    N,M = map(int,input().split())
    A = [i for i in map(int,input().split())]
    A.sort()
    tmpB = []
    tmpC = 0
    targetList = []

    for i in range(M):

        element = list(map(int,input().split()))
        targetList.append(element)

    targetList.sort(key=lambda x:x[1],reverse=True)
    ans = 0
    for b,c in targetList:
        for j in range(b):
            if A[tmpC] < c and N > tmpC:
                A[tmpC] = c
                tmpC +=1


    print(sum(A))






if __name__== "__main__":
    main() 


### FIXED CODE ###


def main():

    N,M = map(int,input().split())
    A = [i for i in map(int,input().split())]
    A.sort()
    tmpC = 0
    targetList = []

    for i in range(M):

        element = list(map(int,input().split()))
        targetList.append(element)

    targetList.sort(key=lambda x:x[1],reverse=True)
    
    flag = False
    ans = 0
    for b,c in targetList:
        for j in range(b):
            if N > tmpC and A[tmpC] < c:
                ans += c
                tmpC +=1
            else:
                flag = True
                break
        if flag:
            break
    
    if tmpC < N:

        ans += sum(A[tmpC:])


    print(ans)






if __name__== "__main__":
    main()
n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for j in range(m)]

li=[[] for i in range(m+1)]

for a,b in ab:
    li[a].append(b)

li2=[]
for i in li[1]:
    li2.append(i)

ans=False
for i in li2:
    if n in li[i]:
        ans=True
print('POSSIBLE' if ans else 'IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for j in range(m)]

li=[[] for i in range(n+1)]

for a,b in ab:
    li[a].append(b)

li2=[]
for i in li[1]:
    li2.append(i)

ans=False
for i in li2:
    if n in li[i]:
        ans=True
print('POSSIBLE' if ans else 'IMPOSSIBLE')
from operator import itemgetter
import numpy

N, M = map(int,input().split())
a = []
R=[]
D = 0
X = 0
for i in range(N):
    a.append(list(map(int,input().split())))
a.sort(key = itemgetter(0))

for i in range(N):
    D += a[i][1]
    if D>M:
        R.append(i)
        break
for i in range(R[0]+1):
    X += a[i][0]*a[i][1]
Y = X-(D-M)*a[R[0]][0]
print(Y)

### FIXED CODE ###

from operator import itemgetter

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


a = [list(map(int,input().split())) for i in range(N)]

if N ==1:
    Z = M*a[0][0]
    print(Z)
else:
    a.sort(key = itemgetter(0))
    X = 0 
    D = 0
    var=0
    while M>D:
        D+=a[var][1]
        X+=a[var][0]*a[var][1]
        var+=1
        
    X += a[var-1][0]*(M-D)
    print(X)
#D
from collections import deque
Str = str(input())
Q = int(input())
S = deque()
S.append(Str)
A = 0
B = []
C = []

for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        if A%2==0:
            if len(B)>1:
                B_=B.reverse()
                S.extendleft(B_)
                B = []
            else:
                S.extendleft(B)
                B = []
            S.extend(C)
            C = []
        else:
            if len(C)>1:
                C_=C.reverse()
                S.extendleft(C_)
                C = []
            else:
                S.extendleft(C)
                C = []
            S.extend(B)
            B = []
        A += 1
    elif a[1] == '1':
        B.append(a[2])
    else:
        C.append(a[2])

if a[0] != '1':
    if A%2==0:
        if len(B)>1:
            B_=B.reverse()
            print(B_)
            S.extendleft(B_)
            B = []
        else:
            S.extendleft(B)
            B = []
        S.extend(C)
        C = []
    else:
        if len(C)>1:
            C_=C.reverse()
            S.extendleft(C_)
            C = []
        else:
            S.extendleft(C)
            C = []
        S.extend(B)

if A%2 != 0:
    S.reverse()
print(''.join(S))

### FIXED CODE ###

#D
from collections import deque
Str = str(input())
Q = int(input())
S = deque(list(Str))
#S.append(list(Str))
#上の方法ではダメ
A = 0
B = []
C = []

for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        if A%2==0:
            if len(B)>1:
                S.extendleft(B)
                B = []
            elif len(B) == 1:
                S.extendleft(B)
                B = []
            if len(C) > 0:
                S.extend(C)
                C = []
        else:
            if len(C)>1:
                S.extendleft(C)
                C = []
            elif len(C) == 1:
                S.extendleft(C)
                C = []
            if len(B) > 0:
                S.extend(B)
                B = []
        A += 1
    elif a[1] == '1':
        B.append(a[2])
    else:
        C.append(a[2])

if a[0] != '1':
    if A%2==0:
        if len(B)>1:
            S.extendleft(B)
            B = []
        elif len(B) == 1:
            S.extendleft(B)
            B = []
        if len(C) > 0:
            S.extend(C)
            C = []
    else:
        if len(C)>1:
            S.extendleft(C)
            C = []
        elif len(C) == 1:
            S.extendleft(C)
            C = []
        if len(B) > 0:
            S.extend(B)
            B = []

if A%2 != 0:
    S.reverse()
print(''.join(S))
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    elif tmp_square != 0 and len(possible_sides) == 0:
        print(tmp_square ** 2)
    elif tmp_square != 0 and len(possible_sides) == 1:
        print(max(tmp_square ** 2, tmp_square * possible_sides[0]))
    else:
        print(max(tmp_square ** 2, possible_sides[0] * possible_sides[1]))


solve()

### FIXED CODE ###

def solve(): # 071A - Meal Delivery
    x, A, B = list(map(int, input().split(" ")))
    da = abs(x - A)
    db = abs(x - B)
    if da > db:
        print("B")
    else:
        print("A")


solve()
n, strs, strt = [s for s in input().split()]
new = []
for i in range(0, n)
	new.append(strs[i])
  	new.append(strt[i])
print (new)

### FIXED CODE ###

n = int(input())
s,t = input().split()
new = ''
for i in range(n):
  new += s[i]
  new += t[i]
print (new)
from collections import deque
h,w=map(int,input().split())
s=[ input() for _ in range(h)]
dist=[ [float('inf') for _ in range(w)] for _ in range(h)]
#print(s)
#do a bfs 
dq=deque()
dist[0][0]=0
dq.append([0,0])
white=0
for i in s:
    white+=i.count('.')
#print(white)
while dq!=[]:
    xx,yy=dq.popleft()
    if xx==h-1 and yy==w-1:
        break
    for i,j in zip([-1,0,1,0], [0,1,0,-1]):
            x=xx+i
            y=yy+j
            def valid(x,y):
                if x>=0 and x<h and y>=0 and y<w and s[x][y]=='.':
                    return True
                return False
            if valid(x,y):
                if dist[x][y]>dist[xx][yy]+1:
                    dist[x][y]=1+dist[xx][yy]
                    dq.append([x,y])
#print(dist[h-1][w-1])
if dist[h-1][w-1]!=float('inf'):
    print(white-1-dist[h-1][w-1])
else:
    print(-1)





### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
s=[ input() for _ in range(h)]
dist=[ [float('inf') for _ in range(w)] for _ in range(h)]
#print(s)
#do a bfs 
dq=deque()
dist[0][0]=0
dq.append([0,0])
white=0
for i in s:
    white+=i.count('.')
#print(white)
while len(dq)>0:
    xx,yy=dq.popleft()
    if xx==h-1 and yy==w-1:
        break
    for i,j in zip([-1,0,1,0], [0,1,0,-1]):
            x=xx+i
            y=yy+j
            def valid(x,y):
                if not(x>=0 and x<h and y>=0 and y<w) == True:
                    return False
                if s[x][y]=='.':
                    return True
                else:
                    return False
            if valid(x,y):
                if dist[x][y]>dist[xx][yy]+1:
                    dist[x][y]=1+dist[xx][yy]
                    dq.append([x,y])
#print(dist[h-1][w-1])
if dist[h-1][w-1]!=float('inf'):
    print(white-1-dist[h-1][w-1])
else:
    print(-1)
import fraction

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

ans = a[0]
for i in range(n-1):
    ans = fraction.gcd(ans, a[i+1])
print(ans)


### FIXED CODE ###

import fractions

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

ans = a[0]
for i in range(n-1):
    ans = fractions.gcd(ans, a[i+1])
print(ans)
s = input()
l_s = s.split(' ')

a = sum(l_s)

if a <= 21:
  print("win")
else:
  print("bust")

### FIXED CODE ###

l_s = input().split(' ')
i_s = [int(i) for i in l_s]
a = sum(i_s)
 
if a <= 21:
  print('win')
else:
  print('bust')
import sys
from collections import defaultdict
readline = sys.stdin.readline

N, M = map(int, readline().split())
G = defaultdict(set)
for v in range(M):
    a, b = map(int, readline().split())
    G[a].add(b)
    G[b].add(a)


def main():

    if M % 2 != 0:
        print(-1)
        return
    ks = []
    for i in G:
        if len(G[i])%2 != 0:
            ks.append(i)
    if len(ks) not in [0, 2]:
        print(-1)
        return
    if len(ks) == 0:
        2//0
        s=t=1
    else:
        s,t=ks
    v=s
    tr = []
    es = set()
    while True:
        tr.append(v)
        if len(G[v]) == 0:
            break
        u = G[v].pop()
        G[u].remove(v)
        v = u
    tr = tr[::-1]
    tr2 = []
    cc = None
    for (i, t) in enumerate(tr):
        if len(G[t-1]) != 0:
            cc = i
            v = t-1
            while True:
                tr2.append(v+1)
                if len(G[v]) == 0:
                    break
                u = G[v].pop()
                G[u].remove(v)
                v = u
            break
    rs = []
    if cc != None:
        ind = 0
        for i in range(cc):
            if ind % 2 == 0:
                print(tr[i+1], tr[i])
            else:
                print(tr[i], tr[i+1])
            ind+=1
        for i in range(len(tr2)-1):
            if ind % 2 == 0:
                print(tr2[i+1], tr2[i])
            else:
                print(tr2[i], tr2[i+1])
            ind+=1
        owari = cc+len(tr2)-1
        nokori = M-owari
        for i in range(nokori):
            i = i + cc
            if ind % 2 == 0:
                print(tr[i+1], tr[i])
            else:
                print(tr[i], tr[i+1])
            ind+=1
    else:
        for i in range(M):
            if i %2 == 0:
                print(tr[i+1], tr[i])
            else:
                print(tr[i], tr[i+1])
    return

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
readline = sys.stdin.readline
def solve(p, v, rs):
    als = G[v]
    cs = g[v]
    c = 0
    for u in als:
        if u in cs:
            c += solve(v, u, rs)
        elif u != p:
            if v < u:
                c += 1
            rs.add((min(u,v), max(u,v)))
    if p == None:
        return
    elif c%2 != 0:
        rs.add((v, p))
        return 0
    else:
        rs.add((p,v))
        return 1

N, M = map(int, readline().split())
if M %2 != 0:
    print(-1)
else:
    G = defaultdict(set)
    for v in range(M):
        a, b = map(int, readline().split())
        G[a].add(b)
        G[b].add(a)

    stack=[1]
    vs = set([1])
    g = defaultdict(set)
    counter = 1
    while True:
        v = stack.pop()
        for u in G[v]:
            if u in vs:
                continue
            vs.add(u)
            g[v].add(u)
            stack.append(u)
            counter += 1
        if counter == N:
            break
    rs = set()
    solve(None,1, rs)
    for r in rs:
        print(r[0], r[1])
import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
H,W = inputs()
c = [inputs() for _ in range(10)]
HW = [inputs() for _ in range(H)]
A = (0,9,8,7,6,5,4,3,2)
B = list(itertools.permutations(A))
N = [c[i][1] for i in range(10)]
for i in B:
    a = i[0]
    ans = 0
    for j in range(1,10):
        ans +=c[i[j-1]][i[j]]
        if N[a]<=ans:
          break
        N[a] = min(ans+c[i[j]][1],N[a])    
ans = 0
for i in range(H):
    for j in range(W):
        if HW[i][j]!=-1:
            ans += N[HW[i][j]]
print(ans)

### FIXED CODE ###

import itertools
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
H,W = inputs()
c = [inputs() for _ in range(10)]
HW = [inputs() for _ in range(H)]
A = (0,9,8,7,6,5,4,3,2)
B = list(itertools.permutations(A))
N = [c[i][1] for i in range(10)]
for i in B:
    a = i[0]
    ans = 0
    for j in range(1,9):
        ans +=c[i[j-1]][i[j]]
        if N[a]<=ans:
          break
        N[a] = min(ans+c[i[j]][1],N[a])    
ans = 0
for i in range(H):
    for j in range(W):
        if HW[i][j]!=-1:
            ans += N[HW[i][j]]
print(ans)
import sys

while 1:
  a , b = map(int, sys.stdin.readline().split())
  if a == b == 0:
  break

### FIXED CODE ###

import sys

while 1:
  a , b = sys.stdin.readline().split()
  if a == b == "0":
    break
  elif int(a) > int(b) :
    print(b,a)
  else :
    print(a,b)
P=list(map(int,input().split()))
P=sorted(P)
x=bisect_left(P,X)
if x>=len(P):
    print(X)
    sys.exit()
if P[x]!=X:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    x1=bisect_left(P,A)
    x2=bisect_left(P,B)

    if x1<len(P) and P[x1]!=A:
        print(A)
        break
        
    if x2<len(P) and P[x2]!=B:
        print(B)
        break

### FIXED CODE ###

from bisect import bisect_left
import sys
X,N=list(map(int,input().split()))
if N==0:
    print(X)
    sys.exit()
P=list(map(int,input().split()))
P=sorted(P)
x=bisect_left(P,X)
if x>=len(P):
    print(X)
    sys.exit()
if P[x]!=X:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    x1=bisect_left(P,A)
    x2=bisect_left(P,B)
    if x1<len(P) and P[x1]!=A:
        print(A)
        break
    if x2<len(P) and P[x2]!=B:
        print(B)
        break
    if x2==len(P):
        print(B)
        break
import numpy as np
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    N, *A = map(int, open(0).read.split())
    # N = int(input())
    # A = list(map(int, input().split()))

    # def lcm(x, y):
    #     return x * y // fractions.gcd(x, y)
        
    
    # x = functools.reduce(lcm, A, 1)

    x=1
    for a in A:x*=a//fractions.gcd(x, a)

    
    b = sum(x//a%MOD for a in A)
    print(b%MOD)
if __name__== "__main__":
    main()


### FIXED CODE ###

import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    # N = int(input())
    # A = list(map(int, input().split()))
    N, *A = map(int, open(0).read().split())
            
    x = 1
    for a in A:
        x *= a //  fractions.gcd(x, a)
        
    b = sum(x//a for a in A)
    print(b%MOD)
    
if __name__== "__main__":
    main()
N = int(raw_input())
lis = [None]*86
lis[0] = 2
lis[1] = 1
for i in xrange(84):
	lis[i+2] = lis[i+1] + lis[i]
print lis[N]

### FIXED CODE ###

N = int(raw_input())
lis = map(int, list(str(N)))
if lis[1] == lis[2] and (lis[0] == lis[1] or lis[2] == lis[3]) :
    print "Yes"
else:
  print "No"