Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def solve():
    N = int(input())
    P = []
    for i in range(N):
        P.append(int(input()))

    # asc
    asc_num = 0
    target = 1
    _dict = {}
    for P_i in P:
        del_flag = False
        if P_i not in _dict.values():
            _dict[P_i] = P_i + 1
        for k, v in _dict.items():
            if v == P_i:
                _dict[k] = P_i + 1 
            elif k-1 == P_i:
                asc_num = max(asc_num, v-k)
        if del_flag:
            del _dict[k]
    for k, v in _dict.items():
        asc_num = max(asc_num, v-k)

    print(N-asc_num)



if __name__ == '__main__':
    solve()

### FIXED CODE ###

N = int(input())
P = []
Q = [0 for i in range(N+1)]
for i in range(1, N+1):
    Q[int(input())] = i

straight = 1
max_straight = 1
for i in range(1, N):
    if Q[i] < Q[i+1]:
        straight += 1
        max_straight = max(straight, max_straight)
    else:
        straight = 1

print(N - max_straight)
### BUGGY CODE ###

import sys
input=sys.stdin.readline

R,C,K=map(int,input().split())
rcv=[list(map(int,input().split())) for _ in range(K)]

MAP=[[0 for _ in range(C)] for _ in range(R)]
DP=[[[0 for _ in range(4)] for _ in range(C)] for _ in range(R)]
for r,c,v in rcv:
    MAP[r-1][c-1]=v

DP[0][0][1]=MAP[0][0]
for i in range(R):
    for j in range(C):
        score=max(DP[i][j])
        for num,point in enumerate([[1,0],[0,1]]):
            x,y=point
            X,Y=i+x,j+y
            if 0<=X<R and 0<=Y<C:
                for k in range(3):
                    if num==0:
                        DP[X][Y][1]=max(DP[X][Y][1],score+MAP[X][Y])
                    else:
                        DP[X][Y][k+1]=max(DP[X][Y][k+1],DP[X][Y][k],DP[i][j][k+1],DP[i][j][k]+MAP[X][Y])
print(max(DP[-1][-1]))

### FIXED CODE ###

import sys
input = sys.stdin.readline

R,C,K=map(int,input().split())
J=[tuple(map(int,input().split())) for i in range(K)]

#DP0=[[0]*(C+2) for i in range(R+2)]
DP1=[[0]*(C+2) for i in range(R+2)]
DP2=[[0]*(C+2) for i in range(R+2)]
DP3=[[0]*(C+2) for i in range(R+2)]

MAP=[[0]*C for i in range(R)]

for x,y,v in J:
    MAP[x-1][y-1]=v

for i in range(R):
    for j in range(C):
        DP1[i][j]=max(DP1[i][j-1],DP1[i-1][j]+MAP[i][j],DP2[i-1][j]+MAP[i][j],DP3[i-1][j]+MAP[i][j])
        DP2[i][j]=max(DP2[i][j-1],DP1[i][j-1]+MAP[i][j])
        DP3[i][j]=max(DP3[i][j-1],DP2[i][j-1]+MAP[i][j])

ANS=0
for i in range(R):
    for j in range(C):
        ANS=max(ANS,DP1[i][j],DP2[i][j],DP3[i][j])
print(ANS)
### BUGGY CODE ###

import queue
from collections import deque
import numpy as np
n, x, y = map(int,input().split())
g = [[] for _ in range(n)] 
for i in range(n-1):

    g[i].append(i+1)
    g[i+1].append(i)
g[x-1].append(y-1)
g[y-1].append(x-1)

# if n%2==0:
#     ma = int(n/2)
# else:
#     ma = int((n+1)/2)
# print(ma)

ans = [0]*n
for i in range(n):
    start = i
    dist = [-1] * n
    dist[start] = 0
    # que = queue.Queue()
    # que.put(start)
    q = deque([start])
    while q:
        # v = que.get()
        v = q.popleft()
        for nv in g[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v]+1
                # que.put(nv)
                q.append(nv)
    for i in dist:
        ans[i] += 1
    # d.append(dist)
# d = np.array(d).flatten()
for i in range(1,n):
    # print(int(np.count_nonzero(d==i)/2))
    print(int(ans[i]/2))


### FIXED CODE ###

def main():
    from collections import deque
    n,x,y=map(int,input().split())
    e=[[]for _ in range(n)]
    for i in range(n-1):
        e[i]+=i+1,
        e[i+1]+=i,
    e[x-1]+=y-1,
    e[y-1]+=x-1,
    a=[0]*n
    for s in range(n):
        d=[-1]*n
        d[s]=0
        q=deque([s])
        add,pop=q.append,q.popleft
        while q:
            v=pop()
            for w in e[v]:
                if d[w]<0:
                    d[w]=d[v]+1
                    add(w)
        for i in d:a[i]+=1
    print(' '.join(str(i//2)for i in a[1:]))
main()
### BUGGY CODE ###

from collections import deque

n,m,k= map(int, input().split())

fri = [[] for _ in range(n+1)]
blo = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    fri[a].append(b)
    fri[b].append(a)

for i in range(k):
    a, b = map(int, input().split())
    blo[a].append(b)
    blo[b].append(a)


gru = [-1] * (n+1)
gru[0] = 0
visited = [False]*(n+1)
D = {}

for root in range(1,n+1):
    if visited[root]:
        continue
    
    D[root]= set([root])
    d = deque()
    d.append(root)
    while d:
        v = d.popleft()
        visited[v] = True
        gru[v] = root
        for to in fri[v]:
            if visited[to]:
                continue
            D[root].add(to)
            d.append(to)


nans = [0]*n
for i in range(1,n+1):
    g = D[gru[i]]
    ans = len(g)-len(fri[i])-1
    for b in blo[i]:
        if b in g:
            ans -= 1
    nans[i-1] = ans

print(*nans, sep='\n')

### FIXED CODE ###

from collections import deque

n,m,k= map(int, input().split())

fri = [[] for _ in range(n+1)]
blo = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    fri[a].append(b)
    fri[b].append(a)

for i in range(k):
    a, b = map(int, input().split())
    blo[a].append(b)
    blo[b].append(a)


gru = [-1] * (n+1)
gru[0] = 0
visited = [False]*(n+1)
D = {}

for root in range(1,n+1):
    if visited[root]:
        continue
    
    D[root]= set([root])
    d = deque()
    d.append(root)
    while d:
        v = d.popleft()
        visited[v] = True
        gru[v] = root
        for to in fri[v]:
            if visited[to]:
                continue
            D[root].add(to)
            d.append(to)


nans = [0]*n
for i in range(1,n+1):
    g = D[gru[i]]
    ans = len(g)-len(fri[i])-1
    for b in blo[i]:
        if b in g:
            ans -= 1
    nans[i-1] = ans

print(*nans, sep='\n')
### BUGGY CODE ###

n = int(input())
arr = []
for i in range(n):
    num = int(input())
    if num not in arr:
        arr.append(num)
    else:
        arr.remove(num)
print(len(arr))

### FIXED CODE ###

n = int(input())
arr = set()
for i in range(n):
    num = int(input())
    if num in arr:
        arr.remove(num)
    else:
        arr.add(num)
print(len(arr))
### BUGGY CODE ###

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

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

l = np.zeros((n,n),dtype=int)
l = np.array(l)

for i in range(n-1):
    l[i][i+1] = 1
    l[i+1][i] = 1

l[x-1][y-1] = 1
l[y-1][x-1] = 1

a = shortest_path(l)

b = np.triu(a)

c = b.reshape(1,n**2)

d = list(map(int,c[0]))

e = [ i for i in d if i!=0 ]

for i in range(1,n):
    print(e.count(i))

### FIXED CODE ###

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

l = [0]*n

x -= 1
y -= 1

for i in range(n):
    for j in range(i+1,n):
        a = j - i
        if i<=x:
            b1 = x - i
        else:
            b1 = i - x
        if j<=y:
            b2 = y - j
        else:
            b2 = j - y
        b = b1 + b2 + 1
        l[min(a,b)] += 1

for i in range(1,n):
    print(l[i])
### BUGGY CODE ###

from collections import deque
N=int(input())
uvw=list(list(map(int,input().split())) for _ in range(N-1))

graph=[[0]*N for _ in range(N)]
for u,v,w in uvw:
    graph[u - 1][v - 1] = w
    graph[v - 1][u - 1] = w
colors=[2]*N
queue=deque([0])
colors[0]=0
while len(queue)>0:
    x=queue.popleft()
    for j in range(N):
        if colors[j]==2 and graph[x][j]!=0:
            queue.append(j)
            if graph[x][j]%2==0:
                colors[j]=colors[x]
            else:
                colors[j]=0 if colors[x]==1 else 1
for p in colors:
    print(p)


### FIXED CODE ###

from collections import deque
N=int(input())
uvw=list(list(map(int,input().split())) for _ in range(N-1))

graph_list=[[] for _ in range(N)]
for u,v,w in uvw:
    graph_list[u - 1].append([v,w])
    graph_list[v - 1].append([u,w])

colors=[-1]*N
colors[0]=0
queue=deque([1])

while len(queue)>0:
    x=queue.popleft()
    if all(colors[i]!=-1 for i in range(N)):
        break
    for j in graph_list[x-1]:
        if colors[j[0]-1]==-1:
            queue.append(j[0])
            colors[j[0]-1]=(2+colors[x-1]+j[1])%2
for p in colors:
    print(p)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Jan  4 16:42:19 2020

@author: masat
"""

X = int(input())

p_list = [2]

if X == 2:
    pass
else:
    tobetest_list = [2*i+3 for i in range(6 * 10**4)]
    for i in range(6 * 10**4):
        p_list.append(tobetest_list[0])
        #追加したtobetest_list[0]の倍数をtobetest_list[0]から除く
        k_list = []
        for k in tobetest_list:
            if k % tobetest_list[0] != 0:
                k_list.append(k)
            else:
                pass
        tobetest_list = k_list
        if p_list[-1] >= X:
            break
        else:
            pass
    
print(p_list[-1])



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Feb  2 17:14:11 2020

@author: masat
"""
import math

X = int(input())
i = X

if i == 2:
    pass
else:
    i_is_prime = True
    while True:
        for k in range(2, math.ceil(math.sqrt(i))+1):
            if i%k == 0:
                i_is_prime = False
                break
            else:
                pass
        if i_is_prime:
            break
        else:
            i_is_prime = True
            i += 1

print(i)
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
for i in range(a):
    print(b.count(i+1))


### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
c={}
for i in range(len(b)):
    try:
        c[b[i]]+=1
    except KeyError:
        c[b[i]]=1

    
for i in range(a):
    try:
        print(c[i+1])
    except KeyError:
        print(0)
### BUGGY CODE ###

import bisect
N, C, K = map(int, input().split())
T = [0]*N
for i in range(N):
    T[i] = int(input())

T = sorted(T)
j = 0
ans = 0
while j < N:
    t = T[j]
    ret = bisect.bisect_right(T, t+K, lo=j, hi=N)
    if ret-j > C:
        ret = C
    j += ret-j
    ans += 1
print(ans)


### FIXED CODE ###

import bisect
N, C, K = map(int, input().split())
T = [0]*N
for i in range(N):
    T[i] = int(input())

T = sorted(T)
j = 0
ans = 0
while j < N:
    t = T[j]
    ret = bisect.bisect_right(T, t+K, lo=j, hi=min(j+C, N))
    if ret-j > C:
        ret = C
    j += ret-j
    ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    print(A.count(i+1))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N-1):
    B[A.pop()-1]+=1
for i in range(N):
    print(B[i])
### BUGGY CODE ###

k = int(input())
num = ''
li = []

is_there = False
while not is_there:
    num = int(str(num)+'7')
    li.append(num)
    if num % k == 0:
        print(len(li))
        is_there = True

### FIXED CODE ###

k = int(input())
x = 7 % k
i = 1
set = set()
is_there = False

while not is_there:
    set.add(x)
    if x == 0:
        print(i)
        break
    x = (x*10+7) % k
    if x in set:
        is_there = True
    set.add(x)
    i += 1
    if x == 0:
        print(i)
        break
else:
    print('-1')
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from functools import lru_cache

shina = []


@lru_cache(maxsize=None)
def solve(i, j):
    if i == len(shina):
        return 0

    if shina[i][0] > j:
        return solve(i + 1, j)

    return max(solve(i + 1, j), solve(i + 1, j - shina[i][0]) + shina[i][1])


def main():
    N, W = [int(x) for x in input().split()]
    for i in range(N):
        a, b = [int(x) for x in input().split()]
        shina.append([a, b])

    ans = solve(0, W)

    print(ans)

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    N, W = [int(x) for x in input().split()]
    shina = []
    for i in range(N):
        a, b = [int(x) for x in input().split()]
        shina.append([a, b])

    dp = [[0 for i in range(N + 1)] for j in range(W + 1)]

    for i in range(N - 1, -1, -1):
        for j in range(W + 1):
            if shina[i][0] > j:
                dp[j][i] = dp[j][i + 1]
            else:
                dp[j][i] = max(dp[j][i + 1], dp[j - shina[i][0]][i + 1] + shina[i][1])

    ans = 0
    for j in range(W + 1):
        ans = max(ans, max(dp[j]))

    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    for i in range(1,10000000002):
        if i ==10000000001:
            print(-1)
            break
        if a[0]*i %a[1] >0:
            print(a[0]*i)
            break
        if a[0]*i >10000000001:
            print(-1)
            break

        

### FIXED CODE ###

import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    for i in range(1,100000002):
        if a[0] % a[1]==0:
            print(-1)
            break

        if i ==10**9+1:
            print(-1)
            break
        if a[0]*i %a[1] >0:
            print(a[0]*i)
            break
        if a[0]*i >10**18 +1:
            print(-1)
            break
### BUGGY CODE ###

s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]

  for i in index_list:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

### FIXED CODE ###

s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])
### BUGGY CODE ###



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

class UnionFind:
    def __init__(self, N):
        self.rank = [0] * N
        self.parent = [i for i in range(N)]
        self.n = N

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if (x == y):
            return

        if (self.rank[x] < self.rank[y]):
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_parents(self):
        count = 0
        for i in range(self.n):
            if self.find(i) == i:
                count += 1

        return count

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

def count(uf):
    count = 0
    for i in range(N):
        for j in range(i, N):
            if not uf.same(i, j):
                count += 1
    return count

uf = UnionFind(N)

i = M-1
ans = [0] * M
while i >= 0:
    ans[i] = count(uf)
    uf.unite(A[i], B[i])
    i -= 1

for i in ans:
    print(i)


### FIXED CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

class UnionFind:
    def __init__(self, N):
        self.rank = [0] * N
        self.parent = [i for i in range(N)]
        self.n = N
        self.size = [1 for i in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if (x == y):
            return

        if (self.rank[x] < self.rank[y]):
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
                self.size[x] += self.size[y]
            else:
                self.size[x] += self.size[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_parents(self):
        count = 0
        for i in range(self.n):
            if self.find(i) == i:
                count += 1

        return count

    def get_size(self, x):
        root = self.find(x)
        return self.size[root]



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

uf = UnionFind(N)

i = M-1
ans = [0] * M
x = (N*(N-1)//2)
while i >= 0:
    ans[i] = x

    if not uf.same(A[i], B[i]):
        x -= uf.get_size(A[i]) * uf.get_size(B[i])

    uf.unite(A[i], B[i])
    i -= 1


for i in ans:
    print(i)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    costs = [10**9]*(N)
    costs[0] = 0
    for i in range(1,len(costs)):
        for j in range(1,K+1):
            if i - j < 0:
                continue
            costs[i] = min(costs[i],costs[i-j]+abs(h[i]-h[i-j]))
    print(costs[-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    costs = [10**9]*(N)
    costs[0] = 0
    for i in range(1,len(costs)):
        for j in range(1,K+1):
            if i - j < 0:
                continue
            costs[i] = min(costs[i],costs[i-j]+abs(h[i]-h[i-j]))
    print(costs[-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np
import sys
def input():
	return sys.stdin.readline()[:-1]

def rank(a):
	n, m = len(a), len(a[0])
	#a = np.array([list(map(int, input().split())) for _ in [0]*n])
	if n > m:
		a = a.T
		n, m = m, n
	r = 0
	for i in range(n):
		if a[i][i] != 1:
			for j in range(i+1, m):
				if a[i][j] == 1:
					a[:, [i, j]] = a[:, [j, i]]
					break
			else:
				for j in range(i+1, n):
					if a[j][i] == 1:
						a[[i, j]] = a[[j, i]]
					break
				else:
					break
		if a[i][i] == 0:
			continue

		r += 1
		for j in range(i+1, m):
			a[:, j] ^= a[i][j] * a[:, i]
		for j in range(i+1, n):
			a[j] ^= a[j][i] * a[i]
	
	return r
	#print((pow(2, n+m-1, MOD) - pow(2, n+m-r-1, MOD)) % MOD)

t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = input()
	if s[-1] == "1":
		print(1)
		continue
	else:
		i = 0
		z, zo = [], []
		for i in range(n):
			if s[i] == "1":
				zo.append([(a[i] >> k) & 1 for k in range(60)])
				
			else:
				zo.append([(a[i] >> k) & 1 for k in range(60)])
				z.append([(a[i] >> k) & 1 for k in range(60)])
				
		#print(z, zo)
		if rank(np.array(z)) != rank(np.array(zo)):
			print(1)
		else:
			print(0)

### FIXED CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

def least_bit_set(x):
	return x & (-x)


def delete_zeros_from(values, start):
	i = start
	for j in range(start, len(values)):
		if values[j] != 0:
			values[i] = values[j]
			i += 1
	del values[i:]


def eliminate(values):
	values = list(values)
	i = 0
	while True:
		delete_zeros_from(values, i)
		if i >= len(values):
			return values
		j = i
		for k in range(i + 1, len(values)):
			if least_bit_set(values[k]) < least_bit_set(values[j]):
				j = k
		values[i], values[j] = (values[j], values[i])
		for k in range(i + 1, len(values)):
			if least_bit_set(values[k]) == least_bit_set(values[i]):
				values[k] ^= values[i]
		i += 1


def in_span(x, eliminated_values):
	for y in eliminated_values:
		if least_bit_set(y) & x != 0:
			x ^= y
	return x == 0



#values = [1, 5, 8, 2, 10]
#eliminated_values = eliminate(values)
#print(eliminated_values)
#x = int(input())
#print(in_span(x, eliminated_values))

t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = input()
	values = []
	ok = True
	for i in range(n-1, -1, -1):
		if s[i] == "0":
			values.append(a[i])
		else:
			elim = eliminate(values)
			if not in_span(a[i], elim):
				ok = False
				break
	if ok:
		print(0)
	else:
		print(1)
### BUGGY CODE ###

S = list(input())
ans = 0

while 'W' in S:
    ind = S.index('W')
    S.pop(ind)
    ans += ind

print(ans)

### FIXED CODE ###

S = list(input())
B = 0
ans = 0

for i in range(len(S)):
    if S[i] == 'B':
        B += 1
    else:
        ans += B

print(ans)
### BUGGY CODE ###

import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
# dp = np.full(100100, 1000000000)
dp = [999999999999 for i in range(100100)]
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            dp[i+j] = retmin(dp[i+j], abs(h[i+j]-h[i-1])+dp[i-1])
print(int(dp[n-1]))

### FIXED CODE ###

import sys
import numpy as np

input = sys.stdin.readline

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

h = np.array([int(x) for x in input().split()])

# 初期化
dp = np.zeros(n, dtype=int)

for i in range(1, n):
    start = max(0, i-k)
    dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))
print(dp[n-1])
### BUGGY CODE ###

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

streetMatrix = [[0]*N for i in range(N)]

for m in range(M):
    A, B = map(int, input().split())
    
    streetMatrix[A-1][B-1] = 1
    streetMatrix[B-1][A-1] = 1

countGood = 0

for i in range(N):
    if max(streetMatrix[i]) == 0:
        countGood += 1
    elif H[i] > max([x*y for x,y in zip(streetMatrix[i],H)]):
        countGood += 1
print(countGood)

### FIXED CODE ###

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

competitor_H = {}

for m in range(M):
    A, B = map(int, input().split())
    
    if A-1 not in competitor_H.keys():
        competitor_H[A-1] = []
    competitor_H[A-1].append(H[B-1])
    
    if B-1 not in competitor_H.keys():
        competitor_H[B-1] = []
    competitor_H[B-1].append(H[A-1])

countGood = 0
for i in range(N):
    if i not in competitor_H.keys():
        countGood += 1
    elif H[i] > max(competitor_H[i]):
        countGood += 1
print(countGood)
### BUGGY CODE ###

N = int(input())
ans = 0
for i in range(1,N+1):
    ans += i%N
print(ans)

### FIXED CODE ###

from math import ceil
N = int(input())
n = N -1
if n == 1:
    ans = 1
elif n%2 != 0:
    ans = (1+n)*(n//2) + ceil(n/2)
else:
    ans = (1+n)*(n//2)
print(ans)