Harryxun/stf_run huggingface dataset:
# g = [1000, 800, 100]
#takes = [300, 333, 400, 444, 500, 555, 600, 666]
#g = [100, 90, 80]
#takes = [100, 100, 90,90,90,80,80,80]
#  g = [100,90,80]
#  takes = [98, 40, 30, 21, 80, 0,0,0]
N,A,B,C = map(int, input().split())
g=[A, B, C]
takes =[]
for i in range(N):
    takes.append(int(input())
combis = []
for i in range(4):
    for j in rang e(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    for n in range(4):
                        for o in range(4):
                            for p in range(4):
                                #  print(i,j,k,l,m,n,o,p)
                                combis.append([i,j,k,l,m,n,o,p])
#  print(combis)
min_diff = 10**10
for combi in combis:
    A,B,C = 0,0,0
    for idx, el in enumerate(combi):
        if el == 0:
            A += takes[idx]
        elif el == 1:
            B += takes[idx]
        elif el == 2:
            C += takes[idx]

        if A == 0 or B == 0 or C == 0:
            continue

        A_diff = abs(g[0] - A) + (len([_ for _ in combi if _ == 0]) - 1)*10
        B_diff = abs(g[1] - B) + (len([_ for _ in combi if _ == 1]) - 1)*10
        C_diff = abs(g[2] - C) + (len([_ for _ in combi if _ == 2]) - 1)*10
        diff = A_diff + B_diff + C_diff
        min_diff = min(diff, min_diff)

print(minq_diff)


### FIXED CODE ###

N, A, B, C = map(int, input().split())
takes = []
for i in range(N):
    takes.append(int(input()))
#  g = [100,90,80]
#  takes = [98, 40, 30, 21, 80, 0,0,0]
takes = takes+[0,0,0,0,0,0,0]
takes = takes[:8]
g = [A, B, C]
combis = []
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                for m in range(4):
                    for n in range(4):
                        for o in range(4):
                            for p in range(4):
                                #  print(i,j,k,l,m,n,o,p)
                                combis.append([i,j,k,l,m,n,o,p])
#  print(combis)
min_diff = 10**10
for combi in combis:
    A,B,C = 0,0,0
    for idx, el in enumerate(combi):
        if el == 0:
            A += takes[idx]
        elif el == 1:
            B += takes[idx]
        elif el == 2:
            C += takes[idx]

        if A == 0 or B == 0 or C == 0:
            continue

        A_diff = abs(g[0] - A) + (len([_ for _ in combi if _ == 0]) - 1)*10
        B_diff = abs(g[1] - B) + (len([_ for _ in combi if _ == 1]) - 1)*10
        C_diff = abs(g[2] - C) + (len([_ for _ in combi if _ == 2]) - 1)*10
        diff = A_diff + B_diff + C_diff
        min_diff = min(diff, min_diff)

print(min_diff)
d, g = map(int, input().split())
p = []
c = []
su = []
ans = 1000
for i in range(d):
  a,b = map(int, input().split())
  p.append(a)
  c.append(b)
  su.append(a*100*(i+1)+b)
bit = [1,2,4,8,16,32,64,128,256,512]
for i in range(1024):
  count = 0
  for j in range(d):
    if i & bit[j] == 0:
      continue
    score += su[j]
    count += p[j]
  if score < g:
    continue
  for j in range(d):
    if i & bit[j] == 0 or score - su[j] >= g:
      continue
    rest = g - (score - su[j])
    count_tmp = count - p[j] + math.ceil(rest / ((d+i)*100))
    ans = min(ans, count_tmp)
print(ans)

### FIXED CODE ###

import math
d, g = map(int, input().split())
p = []
c = []
su = []
ans = 1000
for i in range(d):
  a,b = map(int, input().split())
  p.append(a)
  c.append(b)
  su.append(a*100*(i+1)+b)
bit = [1,2,4,8,16,32,64,128,256,512]
for i in range(int(math.pow(2,d))):
  count = 0
  score = 0
  for j in range(d):
    if i & bit[j] == 0:
      continue
    score += su[j]
    count += p[j]
  if score < g:
    continue
  for j in range(d):
    if i & bit[j] == 0 or score - su[j] >= g:
      continue
    rest = g - (score - su[j])
    count_tmp = min(count , count - p[j] + math.ceil(rest / ((j+1)*100)))
    ans = min(ans, count_tmp)
print(ans)
A = int(input())
B = int(input())
C = int(input())
X = int(input())

A_list = list()
for i in range(A) :
    A_list.append(i*500)
B_list = list()
for i in range(B) :
    B_list.append(i*100)
C_list = list()
for i in range(C) :
    C_list.append(i*50)

count = 0
for a in A_list :
    for b in B_list :
        for c in C_list :
            if (a + b + c) == X :
                count += 1

print count

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

A_list = list()
for i in range(A+1) :
    A_list.append(i*500)
B_list = list()
for i in range(B+1) :
    B_list.append(i*100)
C_list = list()
for i in range(C+1) :
    C_list.append(i*50)

count = 0
for a in A_list :
    for b in B_list :
        for c in C_list :
            if (a + b + c) == X :
                count += 1

print(count)
X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7
if (X+Y)%3==0:
    r = (X+Y)//3
    if r != X and r != Y and X != 2*Y:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
        ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
        print(ans%mod)  
    elif r != X and r != Y and X==2*Y:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        ans = num*pow(p,mod-2,mod)%mod
        print(ans%mod)  
    else:
        print(1)
else:
    print(0)

### FIXED CODE ###

X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7

if (X+Y)%3==0 and X<= 2*Y and Y<= 2*X :
    r = (X+Y)//3
    l = min
    if r != X and r != Y:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
        ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
        print(ans%mod)   
    else:
        print(1)
else:
    print(0)
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

dp=[0]*(N+1)
dp[1]=1
dp[2]=1
for i in range(3,N+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)

### FIXED CODE ###

N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+3)
dp[1]=1
dp[2]=1
for i in range(3,N+3):
  dp[i]=(dp[i-1]+dp[i-2])%mod

  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)
A,B=map(int,input().split())
X=A*B
Y=A-B
X=A+B
print(max(X,Y,Z))

### FIXED CODE ###

A,B=map(int,input().split())
X=A*B
Y=A-B
Z=A+B
print(max(X,Y,Z))
n=input()
mochi=[]
for i in range(n):
  k=int(input())
  mochi.append(k)
print(len(set(mochi)))

### FIXED CODE ###

n=int(input())
mochi=[]
for i in range(n):
  k=int(input())
  mochi.append(k)
print(len(set(mochi)))
y, m, d = input().split('/')
if m <= 4:
  print('Heisei')
else:
  print('TBD')


### FIXED CODE ###

y, m, d = list(map(int, input().split('/')))
if m <= 4:
  print('Heisei')
else:
  print('TBD')
r = int(input())
print(3 * a * a)

### FIXED CODE ###

r = int(input())
print(3*r**2)
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall
N,K,Q = map(int,input().split())
A=[]*Q
score = [K] * N

for i in range(Q):
    win = int(input())
    score[win] += 1

for i in range(N):
    if score[i]-Q > 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall
N,K,Q = map(int,input().split())
score = [K] * N

for i in range(Q):
    win = int(input())
    score[win-1] += 1

for i in range(N):
    if score[i]-Q > 0:
        print('Yes')
    else:
        print('No')
N=int(input())
b=1
for a in range(1,N+1):
    b*=a
numbers=[2]
for c in range(3,N+1):
    count=0
    for d in numbers:
        if not c%d==0:
            count+=1
        else:
            pass
    if count==len(numbers):
        numbers.append(c)
    else:
        pass
answers=[]
while b>1:
    for e in numbers:
        kazu=0
        while b%e==0:
            b=b/e
            kazu+=1
        answers.append(kazu)
kotae=1
for f in answers:
    kotae*=(f+1)
print(kotae%(10**9+7))


### FIXED CODE ###

N=int(input())
b=1
for a in range(1,N+1):
    b*=a
numbers=[2]
for c in range(3,N+1):
    count=0
    for d in numbers:
        if not c%d==0:
            count+=1
        else:
            pass
    if count==len(numbers):
        numbers.append(c)
    else:
        pass
answers=[]
while b>1:
    for e in numbers:
        kazu=0
        while b%e==0:
            b=b//e
            kazu+=1
        answers.append(kazu)
kotae=1
for f in answers:
    kotae*=(f+1)
print(kotae%(10**9+7))
import itertools

nums = [int(e) for e in input().split()]

list0 = []
for i in range(0, nums[0]):
    val = [int(e) for e in input().split()]
    list0.append(val)

A = []
A0 = list(range(0,nums[0]))
for i in range(0,nums[0]):
    for x in itertools.combinations(A0,i+1):
        A1 = list(x)
        A1 = list(set(A1))
        A.append(A1)

X = []
for i in range(0,len(A)):
    Y = [0] * (nums[1]+1)
    for j in range(0,len(A[i])):
        Y = [x + y for (x, y) in zip(Y,list0[A[i][j]])]
    if Y[1] >= nums[2] and Y[2] >= nums[2] and Y[3] >= nums[2]:
        X.append(Y[0])

if len(X) == 0:
    print('-1')
else:
    print(min(X))

### FIXED CODE ###

import itertools

nums = [int(e) for e in input().split()]

list0 = []
A = []
A0 = list(range(0,nums[0]))
for i in range(0, nums[0]):
    val = [int(e) for e in input().split()]
    list0.append(val)
    for x in itertools.combinations(A0,i+1):
        A.append(list(x))

Z = [0]
for i in range(1,nums[1]+1):
    Z.append(nums[2])

X = []
for i in range(0,len(A)):
    Y = [0] * (nums[1]+1)
    for j in range(0,len(A[i])):
        Y = [x + y for (x, y) in zip(Y,list0[A[i][j]])]
    W = [x - y for (x, y) in zip(Y,Z)]
    if min(W) >= 0:
        X.append(Y[0])

if len(X) > 0:
    print(min(X))
else:
    print('-1')
n = int(input())
for i in range(n):
    eq = input().replace("/","//")
    print(eval(eq))

### FIXED CODE ###

import re

class Num:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return str(self.x)

    def __add__(self, other):
        return Num(self.x + other.x)

    def __sub__(self, other):
        return Num(self.x - other.x)

    def __truediv__(self, other):
        return Num(int(self.x / other.x))

    def __mul__(self, other):
        return Num(self.x * other.x)

    def __neg__(self):
        return Num(-self.x)

n = int(input())
for _ in range(n):
    expr = input()[0:-1]
    expr = re.sub(r'(\d+)', r'Num(\1)', expr)
    print(eval(expr))
n = int(input())
a = input().split()
i = 0
while i < n:
  a[i] = int(a[i])
  i = i + 1 

i = 0
while i < n:
  j = i + 1
  while j < n:
    if a[i] < a[j]:
      temp = a[i]
      a[i] = a[j]
      a[j] = temp
    j = j + 1
  i = i + 1

sum = sum(a)
print(a[0])
if(sum-a[0] > a[0]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = input().split()
b = float(int(a[0]) / int(a[1]))
print(b)
n=int(input())
s=input()
r=[]
g=[]
b=[]
for i in range(n):
  if s[i]=='R':
    r.append(i)
  elif s[i]=='G':
    g.append(i)
  else:
    b.append(i)
ans=len(r)*len(g)*len(b)
for i in g:
  for j in b:
    i+j=a
    if a%2==0 and (a//2 in r):
      ans-=1
for i in r:
  for j in b:
    i+j=a
    if a%2==0 and (a//2 in g):
      ans-=1
for i in g:
  for j in r:
    i+j=a
    if a%2==0 and (a//2 in b):
      ans-=1
print(ans)


### FIXED CODE ###

import bisect
n=int(input())
s=input()
r=[]
g=[]
b=[]
for i in range(n):
  if s[i]=='R':
    r.append(i)
  elif s[i]=='G':
    g.append(i)
  else:
    b.append(i)
ans=len(r)*len(g)*len(b)
r.append(n*4)
g.append(n*4)
b.append(n*4)
for i in g:
  for j in b:
    a=i+j
    if a%2==0 and r[bisect.bisect_left(r, a//2)]==a//2:
      ans-=1
for i in r:
  for j in b:
    a=i+j
    if a%2==0 and g[bisect.bisect_left(g, a//2)]==a//2:
      ans-=1
for i in g:
  for j in r:
    a=i+j
    if a%2==0 and b[bisect.bisect_left(b, a//2)]==a//2:
      ans-=1
print(ans+3)
N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for i in range(N):
  ans[A[i]-1] = i+1
print(" ".join(ans))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(N)]
for i in range(N):
  ans[A[i]-1] = i+1
print(*ans)
ab, bc, ca = int(input())

print((ab * bc) // 2)

### FIXED CODE ###

AB, BC, CA = map(int, input().split())

print((AB * BC) // 2)
x = int(input())

if x == 1:
  print(0)
elif X == 0:
  print(1)

### FIXED CODE ###

x = int(input())

if x == 1:
  print(0)
elif x == 0:
  print(1)
else:
  pass
X=int(input())
a=100
for i in range(1,10**18):
  s=int(0.01*a)
  a+=s
  if X<=a:
    print(i)
    

### FIXED CODE ###

X=int(input())
a=100
for i in range(1,10**18):
  s=int(0.01*a)
  a+=s
  if X<=a:
    print(i)
    break
N,K=map(int,input().split())
mod=7+10**9
ans=0
l=range(0,N+1)
for i range(k,n+2):
    ans+=(sum(l[(-k%(n+1)9:])-sum(l[:k])+1)
print(ans%mod)



### FIXED CODE ###

N,K=map(int,input().split())
mod=7+10**9
ans=0
l=list(range(0,N+1))
for i in range(1,N+1):
    l[i]+=l[i-1]
for i in range(K,N+2):
    ans+=(l[-1]-l[-((1+i)%(N+2))]-l[i-1]+1)%mod
print(ans%mod)
5
70 80 100 90 20
3
80 80 80
0

### FIXED CODE ###

import math
while True:
    n = int(input())
    if n==0: break
    s = list(map(int,input().split()))
    m = sum(s)/float(n)
    print("{0:.8f}".format(math.sqrt(sum([(x-m)**2 for x in s])/n)))
n = int(input())
for i in range(n):
    arr = map(int, input().split())
    b,c = 0,0
    for i in range(len(arr)):
        if b < arr[i]:
            b = arr[i]
            continue
        if c < arr[i]:
            c = arr[i]
            continue
        print("NO")
        break
    else:
        print("YES")

### FIXED CODE ###

def ball(nums):
    b, c = 0, 0
    for i in range(len(nums)):
        if b < nums[i]:
            b = nums[i]
            continue
        if c < nums[i]:
            c = nums[i]
            continue
        return "NO"
    return "YES"

N = int(input())

for _ in range(N):
    a = list(map(int, input().split()))
    print(ball(a))
if X>=400 and X<=599:
  print(8)
elif X>=600 and X<=799:
  print(7)
elif X>=800 and X<=999:
  print(6)
elif X>=1000 and X<=1199:
  print(5)
elif X>=1200 and X<=1399:
  print(4)
elif X>=1400 and X<=1599:
  print(3)
elif X>=1600 and X<=1799:
  print(2)
elif X>=1800 and X<=1999:
  print(1)

### FIXED CODE ###

X=int(input())
if X>=400 and X<=599:
  print(8)
elif X>=600 and X<=799:
  print(7)
elif X>=800 and X<=999:
  print(6)
elif X>=1000 and X<=1199:
  print(5)
elif X>=1200 and X<=1399:
  print(4)
elif X>=1400 and X<=1599:
  print(3)
elif X>=1600 and X<=1799:
  print(2)
elif X>=1800 and X<=1999:
  print(1)
import numpy as np
import math
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

print(np.gcd.reduce(arr))

### FIXED CODE ###

import numpy as np

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

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)
# print(arr)

if len(arr) == 1:
    print(arr[0])
else:
    print(gcd(arr))
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  s+=B[A[i]-1]
  if i!=0 and A[i-1]+1==A[i]:
    s+=C[i]
print(s)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
s=0
for i in range(N):
  s+=B[A[i]-1]
  if i!=0 and A[i-1]+1==A[i]:
    s+=C[A[i]-2]
print(s)
#include <iostream>
using namespace std;
int main(void){
    int n,i,j;
    
    cin >> n;
    int a[n];
    
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    

    
    for(j=n-1;j>=0;j--){
        if(j==0)
            cout << a[j];
        else
            cout << a[j] << " ";
    }
    
}



### FIXED CODE ###

n = int(input())
numbers = list(map(int,input().split()))
for i in range(n):
  if i==0:
    print(numbers[n-1],end="")
  else:
    print("",numbers[n-1-i],end="")
print()
n=int(input())
if(n%1000==0):
  print(0)
else:
  print((math.ceil(n/1000)*1000)-n)

### FIXED CODE ###

import math
n=int(input())
if(n%1000==0):
  print(0)
else:
  print((math.ceil(n/1000)*1000)-n)
#N,Tの取得
N,M = map(int, input().split())
#秒のリストを取得
tl = list(map(int, input().split()))

bt = 0 #直前のスイッチを押した時間
gt = T #秒数総和
for t in tl(1:):
    if t - bt > T:
        gt += T #スイッチオフの時はT秒追加
    else:
        gt += t - bt #スイッチがオンのとき、前回からの経過時間を加算
    bt = t

print(str(gt))

### FIXED CODE ###

#N,Tの取得
l = list(map(int, input().split()))
N = l[0]
T = l[1]

#秒のリストを取得
tl = list(map(int, input().split()))

sw = 0 #スイッチオンオフの管理
bt = 0 #直前のスイッチを押した時間
gt = 0 #秒数総和
for i, t in enumerate(tl):
    if sw == 1 and t - bt > T:
        sw = 0 #全快スイッチを押してからT秒経過していたら、スイッチオフ
    if sw == 0:
        gt += T #スイッチオフの時はT秒追加
    else:
        gt += t - bt  #スイッチがオンのとき、前回からの経過時間を加算
    bt = t
    sw = 1 #スイッチオン。
        

print(str(gt))
n,m=map(int,input().split())
g=[[] for _ in range(n)]
indeg=[0]*n
touch=[0]*n
for _ in range(m):
    l,r,d=map(int,input().split())
    l-=1
    r-=1
    touch[l]=1
    touch[r]=1
    g[l].append((r,d))
    indeg[r]+=1
if m==0:
    print('Yes')
    exit()
entered=False
for i in range(n):
    if indeg[i]==0 and touch[i]==1:
        vis=[False]*n
        entered=True
        dist=[-1]*n
        dist[i]=0
        def dfs(u):
            vis[u]=1
            for v,wt in g[u]:
                if dist[v]==-1:
                    dist[v]=dist[u]+wt
                elif dist[v]!=dist[u]+wt:
                    print('No')
                    exit()
                if vis[v]==False:
                    dfs(v)
        dfs(i)

if entered==False:
    print('No')
else:
    print('Yes')



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
g=[[] for _ in range(n)]
indeg=[0]*n
touch=[0]*n
for _ in range(m):
    l,r,d=map(int,input().split())
    l-=1
    r-=1
    touch[l]=1
    touch[r]=1
    g[l].append((r,d))
    indeg[r]+=1
if m==0:
    print('Yes')
    exit()
entered=False
for i in range(n):
    if indeg[i]==0 and touch[i]==1:
        vis=[False]*n
        entered=True
        dist=[-1]*n
        dist[i]=0
        def dfs(u):
            vis[u]=1
            for v,wt in g[u]:
                if dist[v]==-1:
                    dist[v]=dist[u]+wt
                elif dist[v]!=dist[u]+wt:
                    print('No')
                    exit()
                if vis[v]==False:
                    dfs(v)
        dfs(i)

if entered==False:
    print('No')
else:
    print('Yes')
import sys
sys.setrecursionlimit(200000)
def main():
    def input():
        return sys.stdin.readline()[:-1]

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

    def dfs(ima):
        for tsugi in G[ima]:
            ans[tsugi] += ans[ima]
            dfs(tsugi)
    dfs(0)
    print(*ans,sep=" ")
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(200010)

def main():
    input = sys.stdin.readline
    N, Q = map(int,input().split())
    G = [[] for k in range(N+1)]
    for k in range(N-1):
        a, b = map(int,input().split())
        G[a].append(b)
    kyori = [0 for k in range(N+1)]
    for k in range(Q):
        p, x = map(int,input().split())
        kyori[p] -= x
    def dfs(now, dist):
        for tsugi in G[now]:
            if kyori[tsugi] <= 0:
                kyori[tsugi] = -kyori[tsugi]
                kyori[tsugi] += dist
                dfs(tsugi, kyori[tsugi])
    kyori[1] = -kyori[1]
    dfs(1,kyori[1])
    print(*kyori[1:], sep = " ")

if __name__ == '__main__':
    main()
N=int(input())
H=list(map(int,input().split()))
s=0
for i in range(N):
  if H[i]>=max(H[0:i]):
    s+=1
print(s)

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
s=1
for i in range(1,N):
  if H[i]>=max(H[0:i]):
    s+=1
print(s)
import numpy as np

n, k = map(int, input().split())
lst = list(map(int, input().split()))

array = np.array(lst)
po_array = array[array>=0]
ne_array = abs(array[array<0])
ne_array.sort()

if len(po_array) >= len(ne_array):
    long_array = po_array
    short_array = ne_array
else:
    long_array = ne_array
    short_array = po_array

if len(short_array) > k:
    min_len = k
else:
    min_len = len(short_array)
        
if min_len == 0:
    print(long_array[k-1])
else:
    min_dist = 10**10
    for i in range(min_len):
        if i == k-1:
            dist = short_array[i]
        elif k-i-2 >= 0:
            dist = short_array[i]*2 + long_array[k-i-2]
        if min_dist > dist:
            min_dist = dist
    if len(long_array) >= k:
        if min_dist > long_array[k-1]:
            min_dist = long_array[k-1]
    print(min_dist)

### FIXED CODE ###

import numpy as np

n, k = map(int, input().split())
lst = list(map(int, input().split()))

array = np.array(lst)
po_array = array[array>=0]
ne_array = abs(array[array<0])
ne_array.sort()

if len(po_array) >= len(ne_array):
    long_array = po_array
    short_array = ne_array
else:
    long_array = ne_array
    short_array = po_array

if len(short_array) > k:
    min_len = k
else:
    min_len = len(short_array)
        
if min_len == 0:
    print(long_array[k-1])
else:
    min_dist = 10**10
    for i in range(min_len):
        dist = 10**10
        if i == k-1:
            dist = short_array[i]
        elif k-i-1 <= len(long_array): 
            dist = min(short_array[i]*2 + long_array[k-i-2], short_array[i] + long_array[k-i-2]*2)
        if min_dist > dist:
            min_dist = dist
    if len(long_array) >= k:
        if min_dist > long_array[k-1]:
            min_dist = long_array[k-1]
    print(min_dist)
import sys

sys.setrecursionlimit(10000)

def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    dp = [-1] * (n+2)
    dp[0] = 0
    dp[1] = abs(h_list[1]- h_list[0])
    def dp_solve(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            dp_solve(i-1) + abs(h_list[i] - h_list[i-1]),
            dp_solve(i-2) + abs(h_list[i] - h_list[i-2]),
        )
        return dp[i]
    return dp_solve(n-1)


def main():
    n, h_list = input_from_console()
    print(solve(n, h_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

def input_from_console():
    n = int(input().strip())
    h_list = list(map(int, input().split()))
    return n, h_list


def solve(n, h_list):
    dp = [-1] * (n+2)
    dp[0] = 0
    dp[1] = abs(h_list[1]- h_list[0])
    def dp_solve(i):
        if dp[i] != -1:
            return dp[i]
        dp[i] = min(
            dp_solve(i-1) + abs(h_list[i] - h_list[i-1]),
            dp_solve(i-2) + abs(h_list[i] - h_list[i-2]),
        )
        return dp[i]
    return dp_solve(n-1)


def main():
    n, h_list = input_from_console()
    print(solve(n, h_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()