Harryxun/stf_run huggingface dataset:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd, log10
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 8)


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]




n, m = LI()
graph = [[] for _ in range(m)]
v = [False] * n

for i in range(m):
    a, b = LI()
    graph[a - 1].append(b)
    graph[b - 1].append(a)


def dfs(now, depth):
    if v[now - 1]:
        return 0
    if depth == n-1:
        return 1
    ans = 0
    v[now - 1] = True
    for node in graph[now - 1]:
        ans += dfs(node, depth+1)

    v[now - 1] = False

    return ans


print(dfs(1, 0))


### FIXED CODE ###

#Nはノード数、Mはエッジ数
N, M = map(int, input().split())

path_matrix = []

#無向行列の初期化
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    line = map(int, input().split())
    paths = [x - 1 for x in line]
    path_matrix[paths[0]][paths[1]] = True
    path_matrix[paths[1]][paths[0]] = True

#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N


#再帰関数、ここが難しいかもしれない。
def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1

    visited[now] = True
    total_paths = 0
    for i in range(0, N):
        if path_matrix[now][i]:
            total_paths += dfs(i, depth + 1)

    visited[now] = False

    return total_paths

print(dfs(0, 0))
N, M = map(int, input().split())

L = []
R = []
for i in range(M):
  a, b = map(int, input().split())
  L.append(a)
  R.append(b)

min = min(L)
max = max(R)

ans = max(0, max - min + 1)
print(ans)

### FIXED CODE ###

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

L = []
R = []
for i in range(M):
  a, b = map(int, input().split())
  L.append(a)
  R.append(b)

minmin = max(L)
maxmax = min(R)

ans = maxmax - minmin + 1
if ans < 0:
  ans = 0
print(ans)
n=input()
print(round(n/2))

### FIXED CODE ###

n=int(input())
if n%2==0:
  print(n//2)
else:
  print(n//2+1)
h,n = [int(x) for x in input().split()]

# dp[i] = min magic points to decrease i health points
maxmax = 99999999
dp = [maxmax for x in range(h+1)]
dp[0] = 0
for x in range(n):
    a,b = [int(r) for r in input().split()]
    
    for j in range(h):
        dp[min(j+a, h)] = min(dp[min(j+a, h)], dp[j]+b)

print(dp[h])


### FIXED CODE ###

import math
a,b = [int(x) for x in input().split()]

print(math.ceil(a/b))
import sys
import re

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

h = l[0]
w = l[1]

out = 0
for i in range(0,w):
 if( i % 2 == 0):
  if( h % 2 == 1 ):
    out += h/2 + 1 
  else:
    out += h/2
 else:
  out += h/2

print(out)
sys.stdout.flush()


### FIXED CODE ###

import sys
import re

l = sys.stdin.readline()
l = l.split(' ')
l = [int(str) for str in l]

h = l[0]
w = l[1]

if ( h == 1):
  print("1")
  exit(0)
if ( w == 1):
  print("1")
  exit(0)

out = 0
if( w % 2 == 0):
  if( h % 2 == 0):
    out = h*w/2
  else:
    out = h*w/2
else:
  if( h % 2 == 0):
    out = h*w/2
  else:
    out = h*(w-1)/2+(h+1)/2
  

print(out)
sys.stdout.flush()
def naiseki(x1,y1,x2,y2,x3,y3,x4,y4)
    if (x1-x2)*(x3-x4)+(y1-y2)*(y3-y4) == 0:
        print("YES")
    else:
        print("NO")
a = int(input())
for i in range(a):
    f = input()
    try:
        g=map(lambda:float(),f.split())
        x1=g[0]
        y1=g[1]
        x2=g[2]
        y2=g[3]
        x3=g[4]
        y3=gf5]
        x4=g[6]
        y4=g[7]
    naiseki(x1,y1,x2,y2,x3,y3,x4,y4)
except:
    print("NO")

    

### FIXED CODE ###

n = int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4=map(float,input().split())
    print("YES" if abs((y2-y1)*(x4-x3)-(x2-x1)*(y4-y3)) < 1e-10 else "NO")
x, n= input().split()
x = int(x)
n = int(n)

array = [[0]]*100

for i in range(100):
    array[i] = 0
tmp = input().split(' ')
for i in range(n):
    array[int(tmp[i])] += 1
dif_tmp = 999
ret = 999
for i in range(100):
    if array[99-i] == 0:
        if abs(x-(99-i)) < dif_tmp:
            ret = 99-i
            dif_tmp = abs(x-(99-i))
for i in range(100):
    if abs(x+i) <= dif_tmp:
        ret = -i
        dif_tmp = abs(x+i)
print(ret)

### FIXED CODE ###

x, n= input().split()
x = int(x)
n = int(n)

array = [[0]]*200
if n == 0:
    print(x)
else:
    for i in range(200):
        array[i] = 0
    tmp = input().split(' ')
    for i in range(n):
        array[int(tmp[i])] = 1
    
    dif_tmp = 999
    ret = 999
    for i in range(200):
        if array[199-i] == 0:
            if abs(x-(199-i)) <= dif_tmp:
                ret = 199-i
                dif_tmp = abs(x-(199-i))
    for i in range(1,100):
        if abs(x+i) <= dif_tmp:
            ret = -i
            dif_tmp = abs(x+i)
    print(ret)
a = list(map(int, input().split()))

cont = 0

for i in sorted(a):
    x -= i
    if x >= 0:
        cont += 1
    else:
        break

if x > 0:
    cont -= 1

print(cont)

### FIXED CODE ###

N, x = map(int, input().split())
a = list(map(int, input().split()))

cont = 0

for i in sorted(a):
    x -= i
    if x >= 0:
        cont += 1
    else:
        break

if x > 0:
    cont -= 1

print(cont)
n = int(input())
A = sorted(tuple(map(int, input().split())))
B = tuple(map(int, input().split()))
C = sorted(tuple(map(int, input().split())))

count = 0
for b in B:
    # Aの候補
    la = -1
    ra = n
    while (ra - la) > 1:
        mid = (la+ra)//2
        if A[mid] > b:
            ra = mid
        else:
            la = mid
    if A[la] != b:
        la += 1

    # Cの候補
    lc = -1
    rc = n
    while (rc - lc) > 1:
        mid = (lc+rc)//2
        if C[mid] < b:
            lc = mid
        else:
            rc = mid
    if C[rc] == b:
        rc += 1
        
        count += la*(n-rc)
    
    print(count)


### FIXED CODE ###

n = int(input())
A = sorted(tuple(map(int, input().split())))
B = tuple(map(int, input().split()))
C = sorted(tuple(map(int, input().split())))

import bisect

count = 0
for b in B:
    # Aの候補
    la = bisect.bisect_left(A, b)
    # Cの候補
    rc = bisect.bisect_right(C, b)
    
    count += la*(n-rc)

print(count)
N,K=map(int,input().split())
li=[]
for i in range(N):
  a,b=map(int,input().split())
  K-=b
  li.append(a)
  if K<=0:
    li.sort()
    print(li[K-1])
    exit()

### FIXED CODE ###

N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
  K-=l[1]
  if K<=0:
    print(l[0])
    exit()
a,s,b=input(),split()
print(a(0)+c(0)+b(0))


### FIXED CODE ###

a,b,c=input().split()
print(a[0]+b[0]+c[0])
A, B, C = map(int, input().split())
print("YES" if A<=C && B>=C else "NO")

### FIXED CODE ###

A, B, C = map(int, input().split())
print("YES" if (A<=C and A+B>=C) else "NO")
a,b = map(int,raw_input().split())
print(a+b,a-b,a*b)

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import defaultdict

def main():
    N, K = LI()
    A = LI_()
    edges = defaultdict(list)
    for i, a in enumerate(A[1:], 1):
        edges[a].append(i)

    ans = 0
    if A[0] != 0:
        ans += 1
    def DFS(v, parent):
        global ans
        height = 0
        for to in edges[v]:
            height = max(height, DFS(to, v) + 1)
        if parent != 0 and height > K - 1:
            height = 0
            ans += 1
        return height
    DFS(0, 0)
    return ans

print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import defaultdict

def main():
    N, K = LI()
    A = LI_()
    edges = defaultdict(list)
    for i, a in enumerate(A[1:], 1):
        edges[a].append(i)

    global ans
    ans = 0
    if A[0] != 0:
        ans += 1
    def DFS(v, parent):
        global ans
        height = 0
        for to in edges[v]:
            height = max(height, DFS(to, v))
        if parent != 0 and height >= K - 1:
            height = -1
            ans += 1
        return height + 1
    DFS(0, 0)
    return ans

print(main())
N = input()

if N%2 ==0:
  ans = N%2
  print(ans)
  
else :
  ans = N%2 + 0.5
  print(int(ans))

### FIXED CODE ###

N = int(input())

if N%2 ==0:
  ans = N/2
  print(int(ans))
  
else :
  ans = N/2 + 0.5
  print(int(ans))
n, m = list(map(int, input().split()))
a = list(map(float, input().split()))

a.sort()
for t in range(m):
  discount = a.pop() / 2.
  inserted = False
  for i in range(n):
    if a[i] > discount:
      a.insert(i, discount)
      inserted = True
      break
  if not inserted:
    a.append(discount)
    
print(sum(map(int, a)))

### FIXED CODE ###

import heapq

n, m = list(map(int, input().split()))
a = list(map(lambda x: -float(x), input().split()))

heapq.heapify(a)
for t in range(m):
  discount = heapq.heappop(a) / 2.
  heapq.heappush(a, discount)
    
print(sum(map(lambda x: int(-x), a)))
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

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

p = 998244353

comb = Combination(N-1,p)

# 何個を同じ色の組にするか0~K
cnt = 0
for k in range(K+1):
    buf = 0
    # N-1個の組のうちどれを同じ色にするかN-1Ck
    buf = comb(N-1,k)

    # それぞれで、N-k個を別の色の順列にする
    # M*(M-1)**(N-k-1)
    if N-k-1 >= 0:
        buf *= M
        buf *= pow((M-1),(N-k-1),p)
        buf %= p
        cnt += buf
        cnt %= p

print(cnt)


### FIXED CODE ###

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

p = 998244353
# 何個を同じ色の組にするか0~K
cnt = 0
com = 1
for k in range(K+1):
    l = N-k
    # N-1個の組のうちどれを同じ色にするかN-1Ck
    # それぞれで、N-k個を別の色の順列にする
    # M*(M-1)**(N-k-1)
    x = pow((M-1),(l-1),p)
    cnt += M * x * com
    cnt %= p

    # 次のkのnCk
    com *= N-(k+1)
    com *= pow(k+1,p-2,p)
    com %= p


print(cnt)
N = int(input())
S = list(input())

def fun(list,c=0):
    if len(list) == 1:
        return c+1
    if list[0] == list[1]:
        return fun(list[1:],c)
    else:
        return fun(list[1:],c+1)

print(fun(S))

### FIXED CODE ###

N = int(input());S = list(input());print(len([(x,i) for i,x in enumerate(S) if i != N-1 if x != S[i+1]])+1)
12 3
4 56 78 901 2 345 67 890 123 45 6 789

### FIXED CODE ###

n, m = map(int,input().split())
ls = list(map(int,input().split()))
a = 0
s = sum(ls)

for i in range(n):
    if ls[i] * m * 4 >= s:
        a += 1

if a >= m:
    print("Yes")
else:
    print("No")
import sys
input = sys.stdin.readline
q = int(input())

p=1000003
    
factorial_list=[1 for i in range(p)]
for i in range(1,p):
    factorial_list[i]=factorial_list[i-1]*i%p
    
inv_list=[1 for i in range(p)]
inv_list[-1]=factorial_list[-1]
for i in range(p-1,1,-1):
    inv_list[i-1]=inv_list[i]*i%p
    
for i in range(q):
    x,d,n=(int(i) for i in input().split())
    if d==0:
        ans=pow(x,n,p)
        print(ans)
    elif x<=p*d<=x+(n-1)*d:
        print(0)
    else:
        x=x*pow(d,p-2,p)%p
        ans=factorial_list[x+n-1]*inv_list[x-1]*pow(d,n,p)
        print(ans%p)




### FIXED CODE ###

import sys
input = sys.stdin.readline
q = int(input())

p=1000003

flist=[1 for i in range(p)]
for i in range(1,p):
    flist[i]=flist[i-1]*i%p

for i in range(q):
  x,d,n=(int(i) for i in input().split())
  if d==0:
    ans=pow(x,n,p)
  else:
    x=x*pow(d,p-2,p)%p    
    if p<=x+n-1:
      ans=0
    else:
      ans=pow(d,n,p)*flist[x+n-1]*pow(flist[x-1],p-2,p)%p
  print(ans%p)
N = int(input())
a = list(map(int, input().split()))
count = 0
number = 1

for i in range(N):
  if a[i] == number:
    for j in range(i):
      count += 1
      a.pop[number - 1]
    number += 1
print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
brick = [0]
number = 1

import sys

if min(a) > 1:
  print('-1')
  sys.exit()

for i in range(N):
  if a[i] == number:
    brick.append(number)
    number += 1
print(N - max(brick))
n=int(input())
node={i:[] for i in range(1,n+1)}
visited=[False for i in range(n+1)]
q=[]
for _ in range(n-1):
    a,b=map(int,input().split())
    node[a].append(b)
    node[b].append(a)
    q.append((a,b))

mother=q[0][0]
visited[mother]=True

d=[]
e=[]


paint={i:{} for i in range(1,n+1)}

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

#使う要素 node visited paint mother_paint の四つのリスト
c=1
for child in node[mother]:
    visited[child]=True
    paint[mother][child]=c
    paint[child][mother]=c
    mother_paint[child]=c
    c+=1
    d.append(child)
    
while d:
    for parent in d:
        p=1 
        for child in node[parent]:
            if visited[child]==False:
                visited[child]=True
                if p!=mother_paint[parent]:
                    paint[parent][child]=p
                    paint[child][parent]=p
                    mother_paint[child]=p
                    p+=1
                    e.append(child)
                else:
                    p+=1
                    paint[parent][child]=p
                    paint[child][parent]=p
                    mother_paint[child]=p
                    p+=1
                    e.append(child)
    if e:
        d=e.copy()
        e=[]
    else:
        d=[]
        e=[]
K=0
for i in range(1,n+1):
    K=max(K,len(node[i]))
print(K)
for i in range(n-1):
    s,t=q[i][0],q[i][1]
    print(paint[s][t])


### FIXED CODE ###

#幅優先探索
from collections import deque
d=deque()
e=deque()
import sys
sys.setrecursionlimit(1000000000)
n=int(input())
start_node=0
querie=[]
edge={i:[]for i in range(1,n+1)}
for j in range(n-1):
    a,b=map(int,input().split())
    querie.append((a,b))
    edge[a].append(b)
    edge[b].append(a)
    if j==0:
        start_node=a  

d.append((start_node,0))

#はじめにdequeに入れておいて幅優先探索を行うものを決める。そして、塗り分けの結果はans_dictに保存する
#print(edge) 
ans_dict={i:{}for i in range(1,n+1)}
K=0
for some in edge.values():
    K=max(K,len(some))
    
#幅優先探索に使用する すでに訪れたか確認するためのリスト

visited=[False for i in range(n+1)]
visited[start_node]=True

#使う頂点の数を記録した
#nodeをリスト型にしたリストを返す
#start_nodeを記録しておく
def determine_edge_color(node,color):
    new_color=0
    for some in edge[node]:
        if visited[some]==False:
            visited[some]=True
            new_color+=1
            if new_color==color:
                new_color+=1
                ans_dict[node][some]=new_color
                ans_dict[some][node]=new_color
                e.append((some,new_color))
            else:
                ans_dict[node][some]=new_color
                ans_dict[some][node]=new_color
                e.append((some,new_color))
        else:
            pass
            
while d:
    for some in d:
        if visited[some[0]]==True:
            determine_edge_color(some[0],some[1])
        else:
            determine_edge_color(some[1],some[0])
    d=e
    e=deque()
    
#ans_dictの完成
print(K)
#答えの出力
for item in querie:
    a,b=item[0],item[1]
    print(ans_dict[a][b])
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
D.append(0)
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)

### FIXED CODE ###

X,A=map(int,input().split())
if X<A:
  print(0)
else:
  print(10)
N = input()
if "a","e","i","o","u" in N
	print("vowel")
else
	print("consonant")
  

### FIXED CODE ###

N = input()
if N in "aiueo":
	print("vowel")
else:
	print("consonant")
nums = inpu().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a < b < c:
    print(a, d, c)

### FIXED CODE ###

a, b, c = map(int, input().split())
print('Yes' if a < b < c else 'No')
n = int(input())
t, a = input().split(' ')
t = int(t)
a = int(a)
h = input().split(' ')

diff = 100
point = 10000

for x in range(n):
    tmp = t - h[x] * 0.006 
    if tmp < diff:
        diff = tmp
        point = x + 1

print(point)

### FIXED CODE ###

n = int(input())
t, a = input().split(' ')
t = int(t)
a = int(a)
h = input().split(' ')

diff = 10000
point = 10000

for x in range(n):
    temp = t - int(h[x]) * 0.006
    tmp = abs(a - temp)

    if tmp < diff:
        diff = tmp
        point = x + 1

print(point)
n=int(input())
for i in range(n):
    a,b,c = input().split()
    x = int(a)
    y = int(b)
    z = int(c)
    p = [a,b,c]
    p.sort()
    if pow(p[0],2) + pow(p[1],2) == pow(p[2],2):
        print('YES')
    else:
        print('NO')


### FIXED CODE ###

n=int(input())
for i in range(n):
    a,b,c = input().split()
    x = int(a)
    y = int(b)
    z = int(c)
    p = [x,y,z]
    p.sort()
    if pow(p[0],2) + pow(p[1],2) == pow(p[2],2):
        print('YES')
    else:
        print('NO')
a, b , c = map(int, input().split())

if a > c > c or a < c < b:
    print("YES)
else:
    print("No")

### FIXED CODE ###

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

if a > c > b or a < c < b:
    print("Yes")
else:
    print("No")
a=input()
if a=="SUN":
  print(7)
if a=="MON":
  print(6)
if a=="TUE":
  print(5)
if a=="WED":
  print(4)
if a=="THU":
  print(3)
if a=="FRI":
  print(2)
if a=="SAT"
  print(1)

### FIXED CODE ###

a=input()
if a=="SUN":
  print(7)
if a=="MON":
  print(6)
if a=="TUE":
  print(5)
if a=="WED":
  print(4)
if a=="THU":
  print(3)
if a=="FRI":
  print(2)
if a=="SAT":
  print(1)
# stdin
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
N = int(ss[0])
p = list(map(lambda x: int(x), ss[1].split()))
rev_index = []
for i in range(N-1):
    if p[i] > p[i+1]:
        if len(rev_index) > 0:
            rev_index.append(i+1)
        else:
            rev_index.append(i)
elif len(rev_index) > 0:
    p[rev_index[0]], p[rev_index[1]] = p[rev_index[1]], p[rev_index[0]]
if p == list(range(1,N+1)):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

# stdin
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
N = int(ss[0])
p = list(map(lambda x: int(x), ss[1].split()))
rev_index = []
for i in range(N-1):
    if p[i] > p[i+1]:
        if len(rev_index) > 0:
            rev_index.append(i+1)
        else:
            rev_index.append(i)
if len(rev_index) == 2:
    p[rev_index[0]], p[rev_index[1]] = p[rev_index[1]], p[rev_index[0]]
if p == list(range(1,N+1)):
    print("YES")
else:
    print("NO")
N = int(input())
a = [int(i) for i in input().split()]
b = a[0]
c = 0
ans = 0
for i in range(N):
  c += 1
  if b < a[c] and a[c - 1]  <a[c] :
    ans += 1
print(ans + 1) 

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
b = a[0]
c = 0
ans = 0
for i in range(N-1):
  c += 1
  if b <= a[c] :
    b = a[c]
    ans += 1
print(ans + 1)
a = raw_input()
b = raw_input()

print ''.join(x+y for x,y in zip(a,b))

### FIXED CODE ###

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

if a - b == b - c:
  print 'YES'
else:
  print 'NO'
N = int(input())
dp = [[0 for _ in range(N+1)] for i in range(3)]

for i in range(1,N+1):
  ai,bi,ci = map(int,input().split())
  
  dp[i][0] = ai + max(dp[i-1][1],dp[i-1][2])
  dp[i][1] = bi + max(dp[i-1][0],dp[i-1][2])
  dp[i][2] = ci + max(dp[i-1][1],dp[i-1][0])
  
print(max(dp[N]))
  

### FIXED CODE ###

N = int(input())
dp = [[0 for i in range(3)] for _ in range(N+1)] 

for i in range(1,N+1):
  ai,bi,ci = map(int,input().split())
  
  dp[i][0] = ai + max(dp[i-1][1],dp[i-1][2])
  dp[i][1] = bi + max(dp[i-1][0],dp[i-1][2])
  dp[i][2] = ci + max(dp[i-1][1],dp[i-1][0])
  
print(max(dp[N]))
def main():
    inputs = sorted([int(x) for x in input().split()])
    fst = inputs[-1]
    lst = inputs[0]
    mid = inputs[1]

    print(eval(f'{fst}{mid} + {lst}'))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    inputs = sorted(input().split())
    fst = inputs[-1]
    lst = inputs[0]
    mid = inputs[1]

    print(eval('{}{} + {}'.format(fst, mid, lst)))


if __name__ == "__main__":
    main()
x,n = map(int, input().split())
p = sorted(map(int, input().split()))
if p == []:
    print(x)
else:
    a = p[-1]
    d =[]
    e = 1
    E = 0
    b = 1000
    c = 0
    for i in range(a):
        d += [e]
        e += 1
    for i in range(n):
        d.remove(p[E])
        E += 1
    for i in range(n):
        b = min(abs(x-d[c]),b)
        c += 1
    if (x+b) in d:
        print(x+b)
    else:
        print(x-b)

### FIXED CODE ###

x,n = map(int, input().split())
p = set(map(int, input().split()))
for i in range(101):
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break
from sys import stdin
input = stdin.readline
 
A,V = input().rstrip().split()
B,W = input().rstrip().split()
T = input().rstrip()
s=0
for t in range(T):
  if B<A:
    A-=V
    B-=W
    if B>=A:
      print('Yes')
      s=1
      break
  else:
    A+=V
    B+=W
    if B<=A:
      print('Yes')
      s=1
      break
 
if s!=1:
  print('No')

### FIXED CODE ###

from sys import stdin
input = stdin.readline
 
A,V = input().rstrip().split()
B,W = input().rstrip().split()
T = int(input().rstrip())
A,V,B,W = int(A),int(V),int(B),int(W)
s=0
L1=A-B
L2=B-A
S=V-W
if V<=W:
  print('NO')
  s=1
else:
    if B<A:
      if L1/S<=T:
        print('YES')
      else:print('NO')
    else:
      if L2/S<=T:
        print('YES')
      else:print('NO')
(x, y) = (int(i) for i in input().split())
if x = 0 and y = 0:
    break
elif x <= y:
    print(x, y)
elif x >= y:
    print(y, x)

### FIXED CODE ###

while True:
    (x, y) = (int(i) for i in input().split())
    if x == 0 and y == 0:
        break
    elif x <= y:
        print(x, y)
    else:
        print(y, x)
import numpy as np

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
Asorted = sorted(A)[:-(P-1)]

n = len(Asorted)
start=0
end = n
Ap = A[-1]
total = V*M
while start < end -1:
  #print(start, end)
  i = (start+end-1)//2
  Ai = Asorted[i]
  if i == n-1:
    start = n-1
    break
  limit = (Ai + M)*(n-i-1) - sum(Asorted[i+1:]) + (i+P)*M
  if limit >= total:
    end = i+1
  else:
    start = i+1
print(np.sum(np.asarray(A)>=Asorted[start]))

### FIXED CODE ###

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

dif = B-A
if dif%2 == 0:
  print(dif//2)
else:
  print(min(A-1, N-B)+1+((dif-1)//2))