Harryxun/stf_run huggingface dataset:
def main():
    N, T = map(int, input().split())
    l = []
    for _ in range(N):
        a, b = map(int, input().split())
        l.append((a,b))
    l.sort(key=lambda x: x[0])
    m = [[0] * T for _ in range(N)]
    m[0] = [0 if t < l[0][0] else l[0][1] for t in range(T)]
    for i in range(1, N):
        t, v = l[i]
        for j in range(t):
            m[i][j] = m[i-1][j]
        for j in range(t, T):
            m[i][j] = max(l[i][1] + m[i-1][j-t], m[i-1][j])
    return max(l[i][1] + m[i-1][-1] if i > 0 else l[i][1] for i in range(N))

print(main())


### FIXED CODE ###

def main():
    N, T = map(int, input().split())
    l = []
    for _ in range(N):
        a, b = map(int, input().split())
        l.append((a,b))
    l.sort(key=lambda x: x[0])
    m = [[0] * T for _ in range(N)]
    m[0] = [0 if t < l[0][0] else l[0][1] for t in range(T)]
    for i in range(1, N):
        t, v = l[i]
        for j in range(min(t, T)):
            m[i][j] = m[i-1][j]
        for j in range(t, T):
            m[i][j] = max(l[i][1] + m[i-1][j-t], m[i-1][j])
    return max(l[i][1] + m[i-1][-1] if i > 0 else l[i][1] for i in range(N))

print(main())
def main():
    A, B = raw_input()
    print('{}'.format((A+B)%24))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    A, B = tuple(map(int, input().split(' ')))
    print('{}'.format((A+B)%24))


if __name__ == '__main__':
    main()
n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(min(k,41)):
    imos=[0]*(n+1)
    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n-1,i+a[i])+1]-=1
    for i in range(n-1):
        imos[i+1]+=imos[i]
    for i in range(n):
        a[i]=imos[i]
print(*a)

### FIXED CODE ###

s=input()
print(s[:3])
n,m,k=map(int,input().split())
mod=998244353
cntb=1
for i in range(k+1):
    # cntb*=(n-i)//i
    ans+=((m*pow(m-1,n-1-i,mod)％mod)*cntb)%mod
    ans%=mod
    cntb*=((n-i−1)*pow(i+1,mod-2,mod))%mod
print(ans%mod)

### FIXED CODE ###

n,m,k=map(int,input().split())
mod=998244353
cntb=1
ans=0
for i in range(k+1):
    ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod
    ans=ans%mod
    cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod
print(ans%mod)
from heapq import *

def search(s, length, N, M, R):

    d = [100000+1]*N
    d[s-1] = 0

    prev = [None]*N

    pq = [(100000+1, i+1) for i in range(N)]
    heapify(pq)
    heapreplace(pq, (0, s))

    while len(pq) > 0:
        u = heappop(pq)
        for v, c in length.get(u[1], []):
            alt = d[u[1]-1] + c
            if d[v-1] > alt:
                d[v-1] = alt
                prev[v-1] = u
                heapreplace(pq, (alt, v))
    return d

def main():
    length = {}

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

    r = [int(a) for a in input().split()]

    for _ in range(M):
        a, b, c = list(map(int, input().split(' ')))
        length[a] = length.get(a, []) + [(b, c)]
        length[b] = length.get(b, []) + [(a, c)]

    res = 0
    for i in range(R):
        d = search(r[i], length, N, M, R)
        if i+1 < R:
            res += d[r[i+1]-1]

    print(res)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import itertools
import sys

def readline():
    return sys.stdin.readline()

def read_int_list():
    return list(map(int, readline().split()))

def read_int():
    return int(readline())

def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())

    inf = float("inf")
    d = [[inf] * (N + 1) for _ in range(N + 1)]
    for n in range(1, N + 1):
        d[n][n] = 0

    for _ in range(M):
        a, b, c = map(int, input().split())
        d[a][b] = c
        d[b][a] = c

    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    min_cost = inf
    for p in itertools.permutations(r):
        cost = 0
        for i in range(len(p) - 1):
            src, dst = p[i:i + 2]
            cost += d[src][dst]
        min_cost = min(min_cost, cost)

    print(min_cost)


if __name__ == '__main__':
    main()
n,m=map(int,input().split())
dic =[0]*12345
for _ in range(m):
	dic[int(input())]+=1

mod=10**9+7
if n==1:
	print(1)
	exit()
dp = [0]*(n+1)
dp[0]=1
dp[1]=1 if dic[1]!=1 else 0

for i in range(2,n+1):
	if dic[i]:
		continue
	dp[i] = dp[i-2]+dp[i-1]
	dp[i]%=mod
print(dp[n])


### FIXED CODE ###

n,m=map(int,input().split())
dic =[0]*1234567
for _ in range(m):
	dic[int(input())]+=1

mod=10**9+7
if n==1:
	print(1)
	exit()
dp = [0]*(n+1)
dp[0]=1
dp[1]=1 if dic[1]!=1 else 0

for i in range(2,n+1):
	if dic[i]:
		continue
	dp[i] = dp[i-2]+dp[i-1]
	dp[i]%=mod
print(dp[n])
from heapq import heappush, heappop
import sys

ans = [None]*Q
def solve():
    readline = sys.stdin.readline
    N, Q = map(int, readline().split())
    qs = [0]*(N+1)
    for i in range(N):
        s, t, x = map(int, readline().split())
        qs[i] = (s-x, t-x, x)
    qs[N] = (10**10, 10**10, 0)
    qs.sort()

    que = []
    D = [int(readline()) for i in range(Q)]
    j = 0
    it = iter(qs).__next__
    s, t, x = it()
    v = w = N
    for d in D:
        while j < N and s <= d:
            heappush(que, (x, t))
            v, w = que[0]
            s, t, x = it()
        while que and w <= d:
            heappop(que)
            if que:
                v, w = que[0]
        if que:
            yield "%d\n" % v
        else:
            yield "-1\n"
ans[:] = solve()
sys.stdout.writelines(ans)

### FIXED CODE ###

from heapq import heappush, heappop
import sys
from __pypy__ import builders
readline = sys.stdin.readline
N, Q = map(int, readline().split())
qs = [0]*N
for i in range(N):
    s, t, x = map(int, readline().split())
    qs[i] = (s-x, t-x, x)
qs.sort()

b = builders.StringBuilder(Q)
que = []
D = [int(readline()) for i in range(Q)]
j = 0
for d in D:
    while j < N and qs[j][0] <= d:
        s, t, x = qs[j]
        heappush(que, (x, t))
        j += 1
    while que and que[0][1] <= d:
        heappop(que)
    if que:
        b.append("%d\n" % que[0][0])
    else:
        b.append("-1\n")
sys.stdout.write(b.build())
import math
n, c = map(int, input().split())

a = input()
print(math.ceil((n-1)//(c-1)))


### FIXED CODE ###

s = input()
n, m  = s.count('+'), s.count('-')
print(n-m)
N=int(input())
A=input()
b=0
for i in range(N):
  b=b+1/A[i]
print 1/b


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
b=0
for i in range(N):
  b=b+1/A[i]
print(1/b)
N=int(input())
A=list(map(int,input().split()))

a=0
i=-1
while True:
  i+=1
  if A.count(A[i])>=2:
    print("NO")
    a=1
    break
  else:
    A.remove(A[i])
    i-=1
    
if a==0:
  print(A)
  print("YES")

### FIXED CODE ###

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

if len(A) == len(set(A)):
  print("YES")
else:
  print("NO")
a, b, x = map(int, input().split())
e = False
first = True
n = 0
chk = ''

if a * 1000000000 + b * len(str(1000000000)) <= x:
    print(1000000000)
    exit()


n = int((x -(len(str(int(x // a)))*b))//a) - 1000000
if n < 0:
    n = 0
    
while e == False:
    p = a * n + b * len(str(n))
    if p <= x:
        chk = 'kaeru'
    elif p > x:
        chk += 'kaenai'
    if first == True and chk == 'kaenai':
        print(0)
        break
        
    if chk == 'kaerukaenai':
        print(n - 1)
        break
    n += 1
    first = False


### FIXED CODE ###

s = input()
a = ''
if s == 'SUN':
    a = 7
elif s == 'MON':
    a = 6
elif s == 'TUE':
    a = 5
elif s == 'WED':
    a = 4
elif s == 'THU':
    a = 3
elif s == 'FRI':
    a = 2
elif s == 'SAT':
    a = 1
    
print(a)
a = int(input)
b = int(input)
print(6 - a - b)

### FIXED CODE ###

a = int(input())
b = int(input())
print(6 - a - b)
import sys
sys.setrecursionlimit(10**9) 
S=str(input())
s=list(S)
x1=0
x2=1
y=0
for i in range(len(s)-1):
  if s[i+1]==s[i]:
    x2=x2+1
  else:
    if i==0:
      x2=0
    if s[i]=='>':
      if x2<x1:
        x2=x2-1
      else:
          x1=x1-1
    y+=x1*(x1+1)/2
    x1=x2
    x2=1
if s[i+1]=='>':
      if x2<x1:
        x2=x2-1
      else:
          x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(int(y))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647) 
S=str(input())
s=list(S)
x1=0
x2=1
y=0
len=len(s)-1
for i in range(len):
  if s[i+1]==s[i]:
    x2=x2+1
  else:
    if i==0:
      x2=0
    if s[i]=='>':
      if x2<x1:
        x2=x2-1
      else:
          x1=x1-1
    y+=x1*(x1+1)/2
    x1=x2
    x2=1
if s[len]=='>':
  if x2<x1:
    x2=x2-1
  else:
    x1=x1-1
y+=x1*(x1+1)/2
y+=x2*(x2+1)/2
print(int(y))
def insertionSort( nums, n, g ):
	cnt = 0
	i = g
	while i < n:
		v = nums[i]
		j = i - g
		while 0 <= j and v < nums[j]:
			nums[ j+g ] = nums[j]
			j -= g
			cnt += 1
		nums[ j+g ] = v
		i += 1
	return cnt

n = int( input( ) )
nums = []
for i in range( 0, n ):
	nums.append( int( input( ) ) )

cnt = 0
g = []
val =0
for i in range( n ):
	val = 3*val+1
	if  n < val:
		break
	g.append( val )
	
g.reverse( )
m = len( g )
print( m )
print( " ".join( map( str, g ) ) )
for i in range( m ):
	cnt += insertionSort( nums, n, g[i] )
print( cnt )

shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )

### FIXED CODE ###

import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )
a,b,c,d=map(int,input().split())
print('Yes' if abs(a-b)<=d or abs(a-c)+abs(b-c)<=2d else 'No')

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print('Yes' if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else 'No')
second=input()
first=splitlines(second)
P=first[0]
S=first[1]
count=0
for t in range(0,len(P)-1):
  if P[t] is S[t]:count=count+1
    else count=count
print(int(count))

### FIXED CODE ###

a=[input() for i in range(2)]
P=a[0]
S=a[1]
count=0
for t in range(len(P)):
  if P[t] != S[t]:
    count=count+1
print(count)
root = int(int(input())**0.5)
print(min([i + N //i -2 for i in range(1, root+1) if N % i == 0])

### FIXED CODE ###

N = int(input())
root = int(N**0.5)

pairs = [[i, N //i] for i in range(1, root+1) if N % i == 0]

move = min([pair[0] + pair[1] -2 for pair in pairs])
print(move)
n, m = map(int, input().split())
print()(n * (n - 1) / 2) + (m * (m - 1) / 2))


### FIXED CODE ###

N,M = map(int, input().split())
print(int((N * (N - 1) / 2 ) + (M * (M - 1) / 2 )))
N, K, M = map(int, input().split())
L = list(map(int, input().split()))
diff = N*M-sum(L)
if diff <= K:
  print(max(0, diff))
else:
  print(-1)

### FIXED CODE ###

print(chr(ord(input())+1))
a,b=open(0);c=1;
for i in range(int(a)):c*=int(b[2*i])
if c>10**18:print(-1);exit()
print(c)

### FIXED CODE ###

a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)
n, m = map(int, input().split())
if -2 < (n -m) < 2:
  ans = 1
  for i in range(n):
    ans *= n
    ans %= 10_0000_0007
  for i in range(m):
    ans *= n
    ans %= 10_0000_0007
  print(ans)
else:
  print(0)

### FIXED CODE ###

def solve():
    n, m = map(int, input().split())
    if -2 < (n - m) < 2:
        ans = 1
        for i in range(1, n+1):
            ans *= i
            ans %= 1000000007
        for i in range(1, m+1):
            ans *= i
            ans %= 1000000007
        if n != m:
            print(ans)
        else:
            print(((ans) * 2) % 1000000007)
    else:
        print(0)


if __name__=="__main__":
    solve()
N, Q = list(map(int, input().split()))
nodes = {i:[] for i in range(1, N+1)}
for i in range(N-1):
  r, e = list(map(int, input().split()))
  nodes[r].append(e)
  nodes[e].append(r)
#print(nodes)

result = [0] * N
for i in range(Q):
  r, s = list(map(int, input().split()))
  result[r-1] += s

def dfs(r, prev=-1):
  for i in nodes[r]:
    if i == prev:
      continue
    result[i-1] += result[r-1]
    dfs(i, r)

dfs(1)
print(" ".join(map(str, result)))

### FIXED CODE ###

#人の（ほぼ同じなのにうまくいかないので）
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)
l = map(int,input().split)
print(l[0] * l[1])
print(" " + l[0] * 2 + l[1] * 2)

### FIXED CODE ###

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

s = a * b
shu = a * 2 + b * 2
fmt = "{s} {shu}"
s = fmt.format(s = s,shu = shu)
print(s)
s=str(input())
t=str(input())
for i in range s:
 if s[i]!=t[i]:
  print("No")
 else:
  pass
if len(t2)==1 and re.sub(r"[a-z]","",t2)=="":
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import re
s=str(input())
t=str(input())
for i in range(len(s)):
 if s[i]!=t[i]:
  print("No")
  exit()
 else:
  pass
if re.sub(r"[a-z]","",t)=="":
  print("Yes")
else:
  print("No")
from scipy.special import comb
def solve(i,k,smaller):
    print("i="+str(i))
    if i == len(S):
        if k == 0:
            #0以外の個数がkと等しいので答えとしてカウントできる
            return 1
        else:
            #0以外の個数がkと等しくないので答えとしてカウント不可
            return 0 
    
    if k ==0:
        #kの個数を使い切りこれ以上下の桁は0で埋まり1通りの為
        return 1
    
    if smaller :
        return comb(len(S)-i,k)*pow(9,k)
    else:
        if S[i] =="0":
            return solve(i+1,k,False)
        else:
            zero = solve(i+1,k,True)
            aida = solve(i+1,k-1,True)*(int(S[i])-1)
            ici  = solve(i+1,k-1,False)
            return zero+aida+ici
            
N = int(input())
S = str(N)
K = int(input())

ans = solve(0,K,False)
print(ans)

### FIXED CODE ###

from scipy.misc import comb
def solve(i,k,smaller):
    if i == len(S):
        if k == 0:
            #0以外の個数がkと等しいので答えとしてカウントできる
            return 1
        else:
            #0以外の個数がkと等しくないので答えとしてカウント不可
            return 0 
    
    if k ==0:
        #kの個数を使い切りこれ以上下の桁は0で埋まり1通りの為
        return 1
    
    if smaller :
        return comb(len(S)-i,k)*pow(9,k)
    else:
        if S[i] =="0":
            return solve(i+1,k,False)
        else:
            zero = solve(i+1,k,True)
            aida = solve(i+1,k-1,True)*(int(S[i])-1)
            ici  = solve(i+1,k-1,False)
            
            return zero+aida+ici
            
N = int(input())
S = str(N)
K = int(input())

ans = round(solve(0,K,False))

print(int(ans))
import sys
sys.setrecursionlimit(10 ** 5)

n, q = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(n - 1)]
query = [tuple(map(int, input().split())) for _ in range(q)]

tree = [[] for _ in range(n)]
for a, b in edge:
    tree[a - 1].append(b - 1)
p = [0] * n
for x, y in query:
    p[x - 1] += y

counter = [0] * n

def solve(i=0, c=0):
    c += p[i]
    counter[i] = c
    for j in tree[i]:
        solve(j, c)
    return

solve()
for c in counter:
    print(c, end=' ')

### FIXED CODE ###

import collections

n, q = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(n - 1)]
counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p - 1] += x

tree = [[] for _ in range(n)]
edge = collections.deque(edge)
while len(edge) != 0:
    a, b = edge.popleft()
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

que = collections.deque([0])
flag = [False] * n
while len(que) != 0:
    i = que.popleft()
    flag[i] = True
    for j in tree[i]:
        if flag[j]: continue
        counter[j] += counter[i]
        que.append(j)

print(' '.join([str(c) for c in counter]))
n = input()
a_n = map(int,raw_input().split())
j = -1
for i in range(n):
	print(??? ???),
	sys.stdout.write(str(a_n[j])
	j -= 1

### FIXED CODE ###

import sys
n = input()
a_n = map(int,raw_input().split())
j = -1
for i in range(n):
	if j == -1 :
			sys.stdout.write(str(a_n[j]))
			j -= 1
	else :		
		print (' '),
		sys.stdout.write(str(a_n[j]))
		j -= 1
print ''
from functools import reduce

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

def xor(x, y):
  return x ^ y

print(reduce(xor, list(range(A, B+1))))

### FIXED CODE ###


# XORの性質を覚える必要がある
# 解説動画を"最後まで"みるとわかりやすい

from functools import reduce

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

def get(x):
  # 何かしらの法則をみつける
  return [x, 1, x + 1, 0][x % 4]

# XORの性質
print( get(B) ^ get(A - 1) )
def main():
    s = input()
    n = len(s)
    k = int(input())
    # dp[使った回数][左端からの距離][左端]
    dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]

    dp2 = dp[0][1]
    for i in range(n-1):
        if s[i] == s[i+1]:
            dp2[i] = 2
    if k > 0:
        for cnt in range(1, k+1):
            dp2 = dp[cnt][1]
            for i in range(n-1):
                dp2[i] = 2

    for cnt in range(k):
        dp2 = dp[cnt]
        for d in range(2, n):
            dp3 = dp2[d]
            for left in range(n-d):
                right = left+d
                plus = (s[left] == s[right])*2
                dp3[left] = max(
                    dp3[left], dp2[d-1][left],
                    dp2[d-1][left+1], dp2[d-2][left+1]+plus)
                dp[cnt+1][d][left] = max(
                    dp[cnt+1][d][left], dp3[left], dp2[d-2][left+1]+2)
    dp2 = dp[k]
    for d in range(2, n):
        dp3 = dp[d]
        for left in range(n-d):
            right = left+d
            plus = (s[left] == s[right])*2
            dp3[left] = max(
                dp3[left], dp2[d-1][left], dp2[d-1][left+1], dp2[d-2][left+1]+plus)
    print(dp[-1][-1][0])


main()

### FIXED CODE ###

def main():
    s = input()
    n = len(s)
    k = int(input())
    # dp[使った回数][左端からの距離][左端]
    dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]

    for i in range(n-1):
        if s[i] == s[i+1]:
            dp[0][1][i] = 2
    if k > 0:
        for cnt in range(1, k+1):
            for i in range(n-1):
                dp[cnt][1][i] = 2

    for cnt in range(k):
        for d in range(2, n):
            for left in range(n-d):
                right = left+d
                plus = (s[left] == s[right])*2
                dp[cnt][d][left] = max(
                    dp[cnt][d][left], dp[cnt][d-1][left],
                    dp[cnt][d-1][left+1], dp[cnt][d-2][left+1]+plus)
                dp[cnt+1][d][left] = max(
                    dp[cnt+1][d][left], dp[cnt][d][left], dp[cnt][d-2][left+1]+2)
    for d in range(2, n):
        for left in range(n-d):
            right = left+d
            plus = (s[left] == s[right])*2
            dp[k][d][left] = max(
                dp[k][d][left], dp[k][d-1][left], dp[k][d-1][left+1], dp[k][d-2][left+1]+plus)
    print(dp[-1][-1][0])


main()
# coding: utf-8
(a,b,c) = int(raw_input().split())
print "YES" if b - a == c - b else "NO"

### FIXED CODE ###

# coding: utf-8
(a,b,c) = map(int, raw_input().split())
print "YES" if b - a == c - b else "NO"
S = input()
Ans = 0
box = []

for i in range(2 ** (len(S)-1)):  # 文字の間に挿入するので、len(S)-1
    for j in range((len(S)-1)):
        box.append(S[j])
        
        if (i >> j) & 1:
            Ans += int("".join(box))
            box.clear()
            
    box.append(S[-1])
    Ans += int("".join(box))
    box.clear()

print(Ans)

### FIXED CODE ###

S = input()
Ans = 0
box = []

for i in range(2 ** (len(S)-1)):  # 文字の間に挿入するので、len(S)-1
    for j in range((len(S)-1)):
        box.append(S[j])
        
        if (i >> j) & 1:
            Ans += int("".join(box))
            box.clear()
            
    box.append(S[-1])
    Ans += int("".join(box))
    box.clear()

print(Ans)
#C

ans = []
x,n = map(int,input().split())
l = list(map(int,input().split()))
l.sort()

nl = [0] * 100

for i in l:
    nl[i] = i

if(not (n == 0)):

    mx = x+1
    if(mx <= 100):
        for i in range(x+1,len(nl)+1):
            if( nl[i] ==  0):
                #ans.append(mx)
                break
            mx = mx + 1
    else:
        mx = 999
    
    
    mi = x - 1
    if(mi >= 1):
        for i in range(x-1,1,-1):
            if( nl[i] ==  0):
                #ans.append(mi)
                break
            mi = mi - 1
    else:
        mi = 999
    
    if(abs(x - mi) > abs(x - mx)):
        print(mx)
    else:
        print(mi)
        
else:
    print(x)

### FIXED CODE ###

import sys

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

for d in range(X + 1):
    for s in [-1, +1]:
        a = X + s * d
        if p.count(a) == 0:
            print(a)
            sys.exit(0)
a, b = int(input())

if b >= a:
    print(a)
else:
    print(a)


### FIXED CODE ###

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

if b >= a:
    print(a)
else:
    print(a-1)
import collections

h, w = map(int, input().split())
a = [[""]*(w+2)]
for _ in range(h):
    _a = list(input())
    _a.append("")
    _a.insert(0, "")
    a.append(_a)
a.append([""]*(w*2))

visited = [[-float("inf")]*(w+2) for _ in range(h+2)]
init = []
for i in range(h+2):
    for j in range(w+2):
        if a[i][j] == "#":
            init.append([i, j])
            visited[i][j] = 0

q = collections.deque(init)

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]

while 0 < len(q):
    cy, cx = q.pop()
    for _dx, _dy in zip(dx, dy):
        x = cx + _dx
        y = cy + _dy
        if a[y][x] == "." and visited[y][x] == -float("inf"):
            visited[y][x] = visited[cy][cx] + 1
            q.appendleft([y, x])

ans = -1
for _v in visited:
    ans = max(ans, max(_v))

print(ans)


### FIXED CODE ###

from subprocess import call
call (('pypy3', '-c', """
from collections import deque

def main():
    h, w = map(int, input().split())
    A = [list(input()) for _ in range(h)]
    d = [[10**9] * w for _ in range(h)]
    que = deque([])
    
    for i in range(h):
        for j in range(w):
           if A[i][j] == "#":
               que.append([i, j])
               d[i][j] = 0
           else:
               d[i][j] = 10 ** 9
            
    while que:
        x, y = que.popleft()
        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4): 
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < h and 0 <= ny < w and d[nx][ny] == 10**9:
                d[nx][ny] = d[x][y] + 1
                que.append([nx, ny])
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, d[i][j])
    print(ans)
    
    return
    
main()

"""))
a = int(input())
b = int(input())
r = a + b if b % a == 0 else b - a
print(r)


### FIXED CODE ###

a,b = list(map(int, input().split()))
r = a + b if b % a == 0 else b - a
print(r)
n = int(input())
s, t = map(str,input())

ans = '' 
for i in range(n):
    ans += s[i]
    ams += t[i]
    
print(ans)

### FIXED CODE ###

n = int(input())
s, t = map(str,input().split())

ans = ''
for i in range(n):
    ans += s[i]
    ans += t[i]

print(ans)
X*X*X


### FIXED CODE ###

x=int(input())
print(x*x*x)
A = int(input())
B = int(input())
C = int(input())
if A == B:
  if C!=A:
    print("true")
  else: 
    print("false")
elif A == C:
  if B!=A:
    print("true")
  else : 
    print("false")
elif B == C:
  if A!=B :
    print("true")
  else:
    print("false")
else:
  print("false")
    


### FIXED CODE ###

def Main(A,B,C):

  if A == B:
    if C!=A:
      print("Yes",end="")
    else:
      print("No",end="")
  elif A == C:
    if B!=A:
      print("Yes",end="")
    else :
      print("No",end="")
  elif B == C:
    if A!=B :
      print("Yes",end="")
    else:
      print("No",end="")
  else:
    print("No",end="")
A,B,C = [int(num) for num in input().split(' ')]
Main(A,B,C)