Harryxun/stf_run huggingface dataset:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
wv = [inpl() for _ in range(n)]
rwv = wv[::-1]
udp = [[0] * t for _ in range(n+5)]
ddp = [[0] * t for _ in range(n+5)]

for i in range(n-1):
    w,v = wv[i]
    for j in range(t):
        if j < w:
            udp[i+1][j] = udp[i][j]
        else:
            udp[i+1][j] = max(udp[i][j], udp[i][j-w] + v)
res = udp[n-1][t-1] + wv[n-1][1]

for i in range(n-1):
    w,v = rwv[i]
    for j in range(t):
        if j < w:
            ddp[i+1][j] = ddp[i][j]
        else:
            ddp[i+1][j] = max(ddp[i][j], ddp[i][j-w] + v)
    res = max(res,ddp[n-1][t-1] + wv[0][1])

for i in range(1,n-1):
    u = i; d = n-i-1
    mx = 0
    for j in range(t):
        tmp = udp[u][j] + ddp[d][n-1-j]
        mx = max(mx, tmp)
    res = max(res, mx)
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,w = inpl()
wv = [inpl() for i in range(n)]
dp = [[0 for i in range(w+1)] for j in range(n+1)]
wv.sort()
wv.sort(key=lambda x:x[1])
ww = [0] * n
vv = [0] * n
for i in range(n):
    ww[i],vv[i] = wv[i][0], wv[i][1]
for i in range(n-1):
    for j in range(w+1):
        if j >= ww[i]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-ww[i]]+vv[i])
        else:
            dp[i+1][j] = dp[i][j]
res = dp[n-1][w-1]+wv[n-1][1]

dp = [[0 for i in range(w+1)] for j in range(n+1)]
ww[-1],ww[-2] = ww[-2],ww[-1]
vv[-1],vv[-2] = vv[-2],vv[-1]
for i in range(n-1):
    for j in range(w+1):
        if j >= ww[i]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-ww[i]]+vv[i])
        else:
            dp[i+1][j] = dp[i][j]
print(max(res,dp[n-1][w-1]+vv[n-1]))
N=int(input())
A=map(int, input().split())
print(max(A)-min(A))


### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
print(max(A)-min(A))
N  = input()
cost = []
dp = [0]*(N)

for i in range(0,N):
	cost.append(input())

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-1]) + dp[n-2])

return dp[N-1]

### FIXED CODE ###

N  = input()
line = raw_input()
cost = line.split(' ')

for i in range(0,N):
	cost[i] = int(cost[i])

dp = [0]*(N)

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-2]) + dp[n-2])

print(dp[N-1])
print('Christmas'+' Eve'*(25-int(input()))

### FIXED CODE ###

print('Christmas'+' Eve'*(25-int(input())))
k,s=map(int,input().split())

c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1-x)
    for z in range(m+1-x-y)
      if x+y+z==s:
        c+=1
print(c)
  

### FIXED CODE ###

k,s=map(int,input().split())
 
c=0
m=min(s,k)
for x in range(m+1):
  for y in range(m+1):
    if s<x+y:
      break
    elif s>x+y+k:
      continue
    else:
      c+=1
print(c)
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**7
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = [0] + LI()
    ans = []
    x = []
    xn = []

    def make_x(x,xn,p):
        for i in range(N+1):
            for j in range(N+1):
                if j == p:
                    x.append((A[i]*2+A[j],i,j))
                    xn.append(A[i]*2+A[j])
                else:
                    x.append((A[i]+A[j],i,j))
                    xn.append(A[i]+A[j])

        x.sort()
        xn.sort()

    for i in range(2,N+1):
        if A[i-1] > A[i]:
            make_x(x,xn,i-1)
            j = bisect.bisect(xn,A[i]-A[i-1])
            if j > 0 and i == 2:
                for k in x[j-1][1:]:
                    if k > 0:
                        ans.append((k,i-1))
                    A[i-1] += xn[j-1]
            else:
                make_x(x,xn,i)
                j = bisect.bisect_left(xn,A[i-1]-A[i])
                for k in x[j][1:]:
                    if k > 0: ans.append((k,i))
                A[i] += xn[j]

    print(len(ans))
    for x in ans:
        print(x[0],x[1])

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**7
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    ans = []

    max_a = max(A)
    min_a = min(A)

    if max_a * min_a < 0:
        p = max_a if abs(max_a) > abs(min_a) else min_a
        q = A.index(p)
        for i in range(N):
            ans.append((q+1,i+1))
            A[i] += p
        min_a = min(A)

    if min_a >= 0:
        for i in range(1,N):
            ans.append((i,i+1))
    else:
        for i in range(N,1,-1):
            ans.append((i,i-1))

    print(len(ans))
    for x in ans:
        print(x[0],x[1])

if __name__ == '__main__':
    main()
n,m,x = map(int, input().split())
arr = list(map(int,input().split()))
i = 0
while arr[i] < x:
  i += 1

print(min(len(arr)-i, i)

### FIXED CODE ###

n,m,x = map(int, input().split())
arr = list(map(int,input().split()))
i = 0
while arr[i] < x:
  i += 1

print(min(len(arr)-i, i))
import sys
N = int(input())
base = ['AC','WA','TLE','RE']
array = [ input() for a in range(N) if input() in base]

if not ( 1 <= N <= 10**5 ): sys.exit()

for I in base:
    print(I+' x '+str(array.count(I)))

### FIXED CODE ###

import sys
N = int(input())
array = [ input() for a in range(N) ]
base = ['AC','WA','TLE','RE']

for I in base:
    print(I+' x '+str(array.count(I)))
def f(n):
    if n==0:
        return 1
    return 2*f(n-1)+1

N, X = map(int, input().split())
l, r = 0, g(N)
ans = 0

while N:
    m = (l+r)//2
    if m<=X:
        l = m
        ans += f(N-1) + 1
    else:
        r = m
    N -= 1

print(ans)

### FIXED CODE ###

#l==0 P
#l==n B+bg(l-1)+P+bg(l-1)+B
#f(n,x) returns the number of bans below x layers

#a[i] returns the size of level i burger -> a[0]=1
#b[i] returns the numbers of patties in level i burger -> b[0]=1

n,x=map(int,input().split())
a,p=[1]*(n+1),[1]*(n+1)
for i in range(n):
    a[i+1]=2*a[i]+3
    p[i+1]=2*p[i]+1

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=a[n-1]+1:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))
a,b = map(int, input().split())
if a < 10 and b < 10:
  return a * b
else:
  return -1

### FIXED CODE ###

a,b = map(int, input().split())
if a < 10 and b < 10:
  print(a * b)
else:
  print(-1)
PDList = list(input())


for index, PD in enumerate(PDList):
    if PD != '?': continue

    if PD == '?' and len(PDList) == 1:
        PDList[index] = 'D'
        break

    if index == 1:
        if PDList[index + 1] == 'D' or PDList[index + 1] == '?': PDList[index] = 'P'
        else: PDList[index] = 'D'
        continue

    if PD == '?' and index == len(PDList) - 1:
        PDList[index] = 'D'
        continue


    if PDList[index - 1] == 'P':
        PDList[index] = 'D'
        continue

    if PDList[index + 1] == 'D':
        PDList[index] = 'P'
        continue

    if PDList[index - 1] == 'D' and PDList[index + 1] == '?':
        PDList[index] = 'P'
        continue


    PDList[index] = 'D'
    continue


print(''.join(PDList))

### FIXED CODE ###

PDList = list(input())


for index, PD in enumerate(PDList):
    if PD != '?': continue

    if PD == '?' and len(PDList) == 1:
        PDList[index] = 'D'
        break

    if index == 0:
        if PDList[index + 1] == 'D' or PDList[index + 1] == '?': PDList[index] = 'P'
        else: PDList[index] = 'D'
        continue

    if PD == '?' and index == len(PDList) - 1:
        PDList[index] = 'D'
        continue


    if PDList[index - 1] == 'P':
        PDList[index] = 'D'
        continue

    if PDList[index + 1] == 'D':
        PDList[index] = 'P'
        continue

    if PDList[index - 1] == 'D' and PDList[index + 1] == '?':
        PDList[index] = 'P'
        continue


    PDList[index] = 'D'
    continue


print(''.join(PDList))
s = input()
s.sort()
for i in range(len(s)-1):
  if s[i+1] == s[i]:
    print('no')
    
print('yes')

### FIXED CODE ###

s = input()
m = []
for i in s:
  m.append(i)
m.sort()
for i in range(len(m)-1):
  if m[i] == m[i+1]:
    print('no')
    exit()
    
print('yes')
# -*- coding: utf-8 -*-
"""
Created on Sat May  5 20:54:36 2018

@author: sakas
"""

X = int(input().strip())
Y = int(input().strip())

if X > Y:
    print(X - 1)
else:
    print(X)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat May  5 20:54:36 2018

@author: sakas
"""

X, Y = map(int, input().split())

if X > Y:
    print(X - 1)
else:
    print(X)
from itertools import combinations_with_replacement as comb

n,m,q = map(int, input().split(' '))
lis = [list(map(int, input().split())) for _ in range(q)]
tes = comb(range(1,m))
res = 0
for i in tes:
    te = 0
    for a,b,c,d in lis:
        if c == i[b-1] - i[a-1]:
            te += d
    res = max(te,res)
print(res)

### FIXED CODE ###

from itertools import combinations_with_replacement as comb

n,m,q = map(int, input().split(' '))
lis = [list(map(int, input().split())) for _ in range(q)]
tes = comb(range(1,m+1),n)
res = 0
for i in tes:
    te = 0
    for a,b,c,d in lis:
        if c == i[b-1] - i[a-1]:
            te += d
    res = max(te,res)
print(res)
a = input()
print(a + a * a + a * a * a)

### FIXED CODE ###

a = int(input())

print(a + a ** 2 + a ** 3)
n, k = map(int, input().split())
h =  list(map(int, input().split()))

s = sum(h)
for _ in range(k):
    a = 0
    m = 0
    index = 0
    for i, j in enumerate(h):
        if j > m:
            m = j
            index = i
    a += m
    del h[i]
print(s - m)

### FIXED CODE ###

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

def solve():
    global n, k, h
    if n <= k:
        return 0
    s = sum(h)
    h = sorted(h, reverse=True)
    for i in range(k):
        s -= h[i]
    return s

print(solve())
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np
import queue

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = []
for i in range(N):
    routes[i] = []
for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = np.array([[mod,mod,mod] for i in range(N)])

q = queue.Queue()
q.put((S,0))
# Deep First Serch
while q.empty() == False:
    now, cost = q.get()
    state = cost % 3
    if used[now,state] == mod:
        used[now,state] = cost
        for route in routes[now]:
            q.put((route,cost+1))

# print(used)
try:
    ans = used[T, 0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np
import queue

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]

for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [[mod,mod,mod] for i in range(N)]

from collections import deque

# q = queue.Queue()
q = deque()
q.append((S,0))
# Deep First Serch
while q:
    now, cost = q.popleft()
    for route in routes[now]:
        n_state = (cost + 1) % 3
        if used[route][n_state] == mod:
            used[route][n_state] = cost + 1
            q.append((route,cost+1))


# print(used)
try:
    ans = used[T][0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, K = map(int, input().split())
l = list(range(A, B+1))
if K >= len(l):
    print(*l, sep="\n")
    quit()
ans = list(set(l[:K] + l[-K:]))
ans.sort()

print(*ans, sep="\n")


### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
  ans.append(i)
for i in range(max(b-k+1,a),b+1):
  ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
  print(i)
N, M = map(int, input().split())
A = []
B = [0]*N
for m in range(M):
    s, c = map(int, input().split())
    A.append([s, c])
res = True
for a in A:
    if a[0] == 1:
        if B[0] != 0:
            if B[0] != a[1]:
                res = False
                break
        else:
            B[0] = a[1]
    elif a[0] == 2:
        if B[1] != 0:
            if B[1] != a[1]:
                res = False
                break
        else:
            B[1] = a[1]
    elif a[0] == 3:
        if B[2] != 0:
            if B[2] != a[1]:
                res = False
                break
        else:
            B[2] = a[1]
# for b in range(len(B)-2):
    # if B[b] == 0 and B[b+1] == 0 and B[b+2] == 0:
        # res = False
B = str(B[0]) + str(B[1]) + str(B[2])
if res:
    print(B)
else:
    print('-1')

### FIXED CODE ###

N, M = map(int, input().split())
S = []
C = []
for m in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
cnt = -1
man = False
for n in range(1000):
    num = str(n)
    res = True
    if len(num) != N:
        res = False
        continue
    for m in range(M):
        if num[S[m]-1] != str(C[m]):
            res = False
    if res:
        cnt = int(num)
        man = True
        break
if man:
    print(cnt)
else:
    print(cnt)
while 1:
    m,f,r = map(int,input().split())
    if m == -1 or f == -1 or m + f < 30:
        print("F")
    elif 80 <= m + f :
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m == -1 and f == -1 and r == -1:
            break

### FIXED CODE ###

while 1:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break

    if m == -1 or f == -1 or m + f < 30:
        print("F")
    elif 80 <= m + f :
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
a = int(input())
b = a//100
c = a//10 - b*10
d = a%10
if b != 7 and c != 7 and d != 7:
  print(No)
else:
  print(Yes)

### FIXED CODE ###

a = int(input())
b = a//100
c = a//10 - b*10
d = a%10
if b != 7 and c != 7 and d != 7:
  print('No')
else:
  print('Yes')
@n, @a, @b, @c = gets.chomp.split(" ").map(&:to_i)

@l = []
@n.times do
  @l << gets.chomp.to_i
end
INF = 10**9

def dfs(cur, a, b, c)
  if cur == @n
    if [a, b, c].min > 0
      return (a - @a).abs + (b - @b).abs + (c - @c).abs - 30
    else
      return INF
    end
  end
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + @l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a , b + @l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + @l[cur]) + 10
  return [ret0, ret1, ret2, ret3].min
end

puts dfs(0, 0, 0, 0)

### FIXED CODE ###

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))
a = input()

if a[2] == "+":
    answer = int(a[0]) + int(a[4])
elif a[2] == "-":
    answer = int(a[0]) - int(a[4])

print(answer)

### FIXED CODE ###

a = eval(input())
print(a)
import math
a, b, t = (float(i) for i in input().split())
print(int(math.fllor((t + 0.5) / b)) * a)

### FIXED CODE ###

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

ans = T//A * B
print(ans)
# D - Coloring Edges on Tree

n = int(input())
A = []
B = []

# 2次元配列で辺（頂点,遷移先の頂点）を管理する
D = [[] for _ in range(n)]

# 2次元配列で塗る色（頂点,遷移先の頂点）を管理する
C = [[0]*n for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    D[a].append(b)
    D[b].append(a)
    A.append(a)
    B.append(b)

print(max([len(d) for d in D]))

def dfs(node, par, col):
    cid = 1
    for chi in D[node]:
        if chi==par:
            continue
        else:
            if cid==col:
                cid += 1
            C[node][chi] = cid
            dfs(chi, node, cid)
            cid += 1

dfs(0,0,0)

for a, b in zip(A, B):
    print(C[a][b])

### FIXED CODE ###

# D - Coloring Edges on Tree
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = []
B = []

# 2次元配列で辺（頂点,遷移先の頂点）を管理する
D = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    D[a].append(b)
    D[b].append(a)
    A.append(a)
    B.append(b)

print(max([len(d) for d in D]))

C = {}

def dfs(node, par, col):
    cid = 1
    for chi in D[node]:
        if chi==par:
            continue
        else:
            if cid==col:
                cid += 1
            C[(node, chi)] = cid
            C[(chi, node)] = cid
            dfs(chi, node, cid)
            cid += 1

dfs(0,0,0)

for a, b in zip(A, B):
    print(C[(a,b)])
N = int(input())

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

ans = []
[ans.extend(A.index(i)+1) for i in range(1,N+1)]
print(*ans)

### FIXED CODE ###

N = int(input())

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

ans = [0]*N
for i,j in enumerate(A):
    ans[j-1]=i+1
print(*ans)
n, k = map(int, input().split())
a = list(map(int, input().split()))

zyun = [a[0]]
alr = [False]*n
alr[0] = True
crr = a[0]
idx = []

if k == 1:
    print(a[0])
    exit()
key = True

while key:
    if not alr[crr - 1]:
        alr[crr - 1] = True
        crr = a[crr - 1]
        zyun.append(crr)
        continue
    else:
        key = False

for i in range(n):
    if a[i] == crr:
        idx.append(a[i])
        break

index = idx[0]

if index - 1 == 0:
    zyun1 = zyun
    zyun2 = zyun
else:
    zyun1 = zyun[:index]
    zyun2 = zyun[index:]

# print(zyun1, zyun2)

if len(zyun1) >= k:
    ind = k % len(zyun1)
    if ind == 0:
        print(zyun1[-1])
    else:
        print(zyun1[ind - 1])
else:
    ind = (k - len(zyun1)) % len(zyun2)
    if ind == 0:
        print(zyun2[-1])
    else:
        print(zyun2[ind - 1])


# https://atcoder.jp/contests/abc167/submissions/13051707

### FIXED CODE ###

n, k = map(int, input().split())
a = [int(n) - 1 for n in input().split()]  # indexに合うように調整する
v = [-1] * n  # 到達してるかどうかを格納するリスト

D = [0]  # Dは循環するもののindexを格納する
v[0] = 0  # 初期スタート位置の到達ステータスは0

cur = a[0]  # 初期位置はindex=0
i = 1

while v[cur] == -1:
    D.append(cur)
    v[cur] = i # 到達済みに変更(iは何番目に到達したか）
    if k == i:  # 循環が発生する前にkの上限に達してしまった場合
        print(cur + 1)
        exit()

    i += 1
    cur = a[cur]

# 循環している場合を考える
k -= v[cur]  # 1回目の到達点を引く
k %= (i - v[cur])  # kを循環する回数で割った余りを考える = 循環した中でどれかという事が分かる

print(D[v[cur] + k] + 1)  # v[cur]で循環しない部分を表し、kで循環した中でどこかを表す
import sys
sys.setrecursionlimit(100000)


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

INF=float("inf")

DP=[INF]*(N+1)

def rec(n):
    if DP[n]<INF: return DP[n]
    if n==0:
        return 0
    ans=INF
    ans=min(ans,rec(n-1)+abs(h[n]-h[n-1]))
    if n>1:
        ans=min(ans,rec(n-2)+abs(h[n]-h[n-2]))
    DP[n]=ans

    return DP[n]

ans=rec(N-1)
print(ans)


### FIXED CODE ###

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

DP=[100000]*N

DP[0]=0
DP[1]=abs(h[1]-h[0])

for i in range(2,N):
    DP[i]=min(DP[i-2]+abs(h[i]-h[i-2]),DP[i-1]+abs(h[i]-h[i-1]))

print(DP[N-1])
N = int(input())

l = []
for i in range(N):
    l.append(input())

#重複チェック
if len(set(l)) != n:
    print("No")
    exit()

#しりとりチェック
for i in range(n-1):
    if l[i][-1] != l[i+1][0]:
        print("No")
        exit()

print("Yes")


    


### FIXED CODE ###

N = int(input())

l = []
for i in range(N):
    l.append(input())

#重複チェック
if len(set(l)) != N:
    print("No")
    exit()

#しりとりチェック
for i in range(N-1):
    if l[i][-1] != l[i+1][0]:
        print("No")
        exit()

print("Yes")
import numpy as np
n = int(input())
xls = []
end = 0
for _ in range(n):
    x, l = map(int, input().split())
    end = max(end, x+l)
    xls.append([x-l, x+l])
    
line = np.zeros(end+1)
ans = 0
for i in xls:
    start = i[0]
    if start <= 0:
        start = 0
    line[start:i[1]-1] += 1
    if np.amax(line[start:i[1]]) <= 1:
        ans += 1
    else:
        line[start:i[1]] -= 1

print(ans)

### FIXED CODE ###

n = int(input())
scope = []
for _ in range(n):
    x, l = map(int, input().split())
    scope.append([x+l, x-l])
    
scope.sort()
ans = 1
border = scope[0][0]
for i, r in enumerate(scope[1:]):
    if border <= r[1]:
        ans += 1
        border = r[0]
print(ans)
N=int(input())
a,b,c,d=0,1e10,-1e10,1e10
for i in range(N):
  A,B=int(input().pulit())
  a=max(a,A+B)
  b=min(b,A+B)
  c=max(c,A-B)
  d=min(d,A-B)
print(max(abs(a-b),abs(c-d))

### FIXED CODE ###

N=int(input())
a,b,c,d=0,1e10,-1e10,1e10
for i in range(N):
  A,B=input().split()
  A=int(A)
  B=int(B)
  a=max(a,A+B)
  b=min(b,A+B)
  c=max(c,A-B)
  d=min(d,A-B)
print(max(abs(a-b),abs(c-d)))
N = list(int(input())
S = list(input())
S.count('ABC')

### FIXED CODE ###

n = int(input())
s = input()
print (s.count('ABC'))
import sys

s = input()
c = 0
C = 0

for i in range(len(s)):
    if s[i] == 'A':
        while(s[i] != 'Z'):
            c += 1
            i += 1
        if s[i] == 'Z':
            i += 1
            c += 1
            if s[i] == 'Z':
                c += 1
                break
    else:
        continue
    break
            
print(c)

### FIXED CODE ###

import sys

s = input()
c = 0
C = 0

for i in range(len(s)):
    if s[i] == 'A':
        break

for j in range(len(s)):
    if s[-j] == 'Z':
        break
print(len(s[i:len(s) - j + 1]))
ef main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        tmp = i
        for j in range(i, n):
            if a[j] < a[tmp]:
                tmp = j
        if i != tmp:
            a[i], a[tmp] = a[tmp], a[i]
            ans += 1

    print(*a)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        tmp = i
        for j in range(i, n):
            if a[j] < a[tmp]:
                tmp = j
        if i != tmp:
            a[i], a[tmp] = a[tmp], a[i]
            ans += 1

    print(*a)
    print(ans)


if __name__ == '__main__':
    main()
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if (A-B)//(V-W) <= T:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if abs(B-A)<=(V-W)*T:
    print("YES")
else:
    print("NO")