Harryxun/stf_run huggingface dataset:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

def cal(A, N):
    cnt1 = 0
    cnt2 = 0
    for i in range(N):
        for j in range(i+1,N):
            if A[N-1-j] > A[N-1-i]:
                cnt1 += 1
    for i in range(N):
        for j in range(N):
            if A[N-1-i] < A[j]:
                cnt2 += 1
    
    return int(cnt1), int(cnt2)
    
    
x, y = cal(A,N)
R = int(1*10**9 +7)
tmp = int(K*(K-1)/2)
ans =  tmp*y + x*K
print(int(ans%R))






### FIXED CODE ###

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

def cal(A, N):
    cnt1 = 0
    cnt2 = 0
    for i in range(N):
        for j in range(i+1,N):
            if A[N-1-j] > A[N-1-i]:
                cnt1 += 1
    for i in range(N):
        for j in range(N):
            if A[N-1-i] < A[j]:
                cnt2 += 1
    
    return int(cnt1), int(cnt2)
    
    
x, y = cal(A,N)
R = int(1*10**9 +7)
tmp = K*(K-1)//2
ans =  tmp*y + x*K
print(int(ans%R))
n=int(input())
print(n*800-adder*200)

### FIXED CODE ###

n=int(input())
print(n*800-(n//15)*200)
import sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

R = aint()
print(2*R*math.pi())

### FIXED CODE ###

import sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

R = aint()
print(2*R*math.pi)
A, B = map(int, input())

print(max(A + B, A - B, A * B))


### FIXED CODE ###

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

print(max([A + B, A - B, A * B]))
import numpy as np
import math
import collections

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(math.gcd(A,B)))
print(len(c)+1)

### FIXED CODE ###

import numpy as np
A,B=np.array(list(map(int, input().split())))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
C=np.array(prime_factorize(gcd(A,B)))
print(len(np.unique(C))+1)
a, b, k = map(int, input().split())
divisers = []

for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        divisers.append(i)

print(divisers[-k])


### FIXED CODE ###

a, b, c = map(int, input().split())
print(min(b // a, c))
n = int(input())
st = str(input()).split(' ')
ans = ''
for i in range(n):
    ans += st[i][0]
    ans += st[i][1]
print(ans)

### FIXED CODE ###

n = int(input())
st = str(input()).split(' ')
ans = ''
for i in range(n):
    ans += st[0][i]
    ans += st[1][i]
print(ans)
import sys

def f(b, n):
    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i


    for p in range(1, int(n**0.5)):
        b = (n - s) // p + 1
        if f(b, n) == s:
            return b

    return -1


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys

def f(b, n):
    if b < 2:
        return -1    

    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s > n:
        return -1

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i

    for p in range(int(n**0.5) + 1, 0, -1):
        if (n - s) % p != 0:
            continue

        b = (n - s) // p + 1
        if f(b, n) == s:
            return b

    return -1


if __name__ == '__main__':
    print(main())
N,K = map(int,input().split())

print(min(N % K,K-t))

### FIXED CODE ###

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

print(min(N % K,K-N % K))
import collections
c=Counter()
N=int(input())
for i in range(N):
    c[int(input())]+=1
d=list(filter(lambda x:c[x]%2==1,c))
print(len(d))

### FIXED CODE ###

import collections
c=collections.Counter()
N=int(input())
for i in range(N):
    c[int(input())]+=1
d=list(filter(lambda x:c[x]%2==1,c))
print(len(d))
arr = (input()).split()

for i,temp in enumerate(arr):
  arr[i] = int(arr[i])
  
result = 0
for i in range(2):
  result += max(arr)
  index = arr.index(mac(arr))
  arr[index] = arr[index] -1
  
print(result)

### FIXED CODE ###

arr = (input()).split()

for i,temp in enumerate(arr):
  arr[i] = int(arr[i])
  
result = 0
for i in range(2):
  result += max(arr)
  index = arr.index(max(arr))
  arr[index] = arr[index] -1
  
print(result)
*a=map(int,input().split())
print(max(a)-max(b))

### FIXED CODE ###

*a,=map(int,input().split())
print(max(a)-min(a))
X = int(input())
N = X // 100
n = X % 100

if n / N > 5:
  print(0)
else:
  print(1)

### FIXED CODE ###

X = int(input())
N = X // 100
n = X % 100

if N == 0:
  print(0)
elif n / N > 5:
  print(0)
else:
  print(1)
a = input()
b = input()

m = a*b
s = a+b*2

print("m,s")

### FIXED CODE ###

x, y = input().split()
print(int(x)*int(y), (int(x)+int(y))*2)
import sys
sys.setrecursionlimit(200200)

mod = 10 ** 9 + 7

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a - 1].append((b - 1, i))
    E[b - 1].append((a - 1, i))

X = [0] * N

def dfs(u, p):
    X[p] = 1 + sum(dfs(v, c) for v, c in E[u] if p != c)
    return X[p]

dfs(0, -1)

I = [1] * (N + 1)
inv = pow(2, mod - 2, mod)
for i in range(N):
    I[i + 1] = I[i] * inv % mod

ans = (I[N] + 1) * (N - 1) - inv * N - I[N] + 1
for e in range(N - 1):
    ans -= I[X[e]] + I[N - X[e]]
    ans %= mod

print(ans)

### FIXED CODE ###

from itertools import accumulate

MAX = 2 * 10 ** 5 + 5

N, M, *A = map(int, open(0).read().split())

B = [0] * MAX
for a in A:
    B[a] += 1

C = list(accumulate(reversed(B)))[::-1]

ng, ok = 1, MAX
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    if sum(C[max(0, m - a)] for a in A) >= M:
        ng = m
    else:
        ok = m

D = list(accumulate(reversed(list(i * b for i, b in enumerate(B)))))[::-1]
print(sum(D[max(0, ng - a)] - (ng - a) * C[max(0, ng - a)] for a in A) + ng * M)
N,K = map(int(input(),split()))
out = N - K + 1
print(out)

### FIXED CODE ###

N,K = list(map(int,input().strip().split(" ")))
out = N - K + 1
print(out)
class Node:
    def __init__(self, i):
        self.num = i
        self.ken = set()
        self.kenken = set()
        self.kenkenpa = set()

N, M = map(int, input().split())
nodes = [Node(i+1) for i in range(N)]

for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    nodes[v].ken.add(nodes[u])

s, t = map(int, input().split())
s -= 1
t -= 1

for i in range(N):
    for pre in nodes[i].ken:
        nodes[i].kenken = nodes[i].kenken | pre.ken

for i in range(N):
    for prepre in nodes[i].kenken:
        nodes[i].kenkenpa = nodes[i].kenkenpa | prepre.ken

node = nodes[t]
step = 0
check_list = [[node, step]]
check = [False] * N
ok = False
while len(check_list) > 0:
    node, step = check_list.pop(0)
    for pre in node.kenkenpa:
        if pre == nodes[s]:
            print(step+1)
            ok = True
            break
        if not check[pre.num]:
            check[pre.num] = True
            check_list.append([pre, step+1])
    if ok:
        break
if not ok:
    print(-1)


### FIXED CODE ###

N, M = map(int, input().split())
nodes = [[] for i in range(N)]

for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    nodes[u].append(v)

s, t = map(int, input().split())
s -= 1
t -= 1

num = s
step = 0
q = [[num, step]]
check = [[False for i in range(N)] for j in range(3)]
ok = False
while len(q) > 0:
    num, step = q.pop(0)
    tmp = step % 3
    if tmp == 0 and num == t:
        print(step//3)
        ok = True
        break
    for next in nodes[num]:
        if not check[tmp][next]:
            check[tmp][next] = True
            q.append([next, step+1])
if not ok:
    print(-1)
a, b, n = map(int, input().split())
ans = 0
for i in range(int(b/a), n+1):
  if ans < int(a*i/b)-a*int(i/b);
    ans = ans, int(a*i/b)-a*int(i/b)
  else:
    break
print(ans)

### FIXED CODE ###

a, b, n = map(int, input().split())
ans = 0
e = min(n+1,b)
s = max(int(b/a),e-1000)
for i in range(s, e):
  x = (int(a*i/b)-a*int(i/b))
  if ans < x:
    ans = x
print(ans)
n,m = map(int,input().split())
h = [int(i) for i in input().split()]
nn = [[-1]]*n

for i in range(m):
    a,b = map(int,input().split())
    nn[a-1].append(b-1)
    nn[b-1].append(a-1)
c=0
for i	in range(n):
    f=0
    for k in nn[i]:
	if k==-1:continue
        if h[i] < k:
            f=1
    if f==0:
	c+=1
print(c)


### FIXED CODE ###

n,m = map(int,input().split())
h = [int(i) for i in input().split()]
nn = [1]*n
for _ in range(m):
    a,b = map(int,input().split())
    if h[a-1] ==h[b-1]:
        nn[a-1]=0
        nn[b-1]=0
    elif h[a-1] < h[b-1]:
        nn[a-1]=0
    else:
        nn[b-1]=0

print(sum(nn))
n = int(input())

if n % 2 = 0:
  a = n / 2
  print(a)
  
else:
  b = n / 2 + 1
  print(b)
  


### FIXED CODE ###

n = int(input())

if n % 2 == 0:
  a = n / 2
  print(int(a))
  
else:
  b = n / 2 + 1
  print(int(b))
a, b = [int(i) for i in input().split(" ")]
num1 = int(a / b)
num2 = a % b
num3 = "{:.5f}".format(a / b)

print(a, b, c)

### FIXED CODE ###

a, b = [int(i) for i in input().split(" ")]
num1 = a // b
num2 = a % b
num3 = "{:.8f}".format(a / b)

print(num1, num2, num3)
n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

b = [a[x] for x in range(n - p)]

total = sum(b)

vote=(v - p) * m

ans = p

for i in b:
    if (total - i + vote) // (len(b) - 1) < i + m:
        ans += 1
        
print(ans)

### FIXED CODE ###

from math import ceil
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)[p - 1:]
l = 0
r = n - p

while l != r:
    k = ceil((l + r) / 2)
    b = a[k] + m
    if b < a[0] or (v - (n - k)) * m > (k * b - sum(a[:k])):
        r = k - 1
    else:
        l = k
print(p+l)
N = int(input())
arr = [int(input()) for _ in range(N)]
ans = [0] * (max(arr)+1)
for i in range(N):
    ans[arr[i]] += 1
a = 0
for i in ans:
    if i % 2 == 1:
        a += 1
print(a)

### FIXED CODE ###

N = int(input())
arr = [int(input()) for _ in range(N)]
dic = {}
for i in arr:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
a = 0
for value in dic.values():
    if value % 2 == 1:
        a += 1
print(a)
x = int(input())
y = int(input())

print(x*y)

### FIXED CODE ###

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

print(a*b,a*2+b*2)
N = int(input())

W = []
for i in range(N):
    if i == 0:
        x = input()
        W.append(x)
    else:
        x = input()
        if x in W:
            print("No")
            exit()
        elif W[i-1][len(W[i-1]) - 1] != x[0]:
            print("No")
        else:
            W.append(x)

print("Yes")

### FIXED CODE ###

N = int(input())

W = []
for i in range(N):
    if i == 0:
        x = input()
        W.append(x)
    else:
        x = input()
        if x in W:
            print("No")
            exit()
        elif W[i-1][-1] != x[0]:
            print("No")
            exit()
        else:
            W.append(x)

print("Yes")
h,w = map(int,input().split())
s = [[x for x in input()] for _ in range(h)]

ls = ['.' for i in range(w)]

s.insert(0,ls)
s.insert(-1,ls)

for i in range(h+2):
    s[i].insert(0,".")
    s[i].insert(-1,".")

for j in range(1,h+1):
    for k in range(1,w+1):
        
        if s[i][j] == ".":
            ls = [ls[j-1][k-1],ls[j-1][k],ls[j-1][k+1],ls[j][k-1],ls[j][k+1],ls[j+1][k-1],ls[j+1][k],ls[j+1][k+1]]
    
            s[i][j] = ls.count("#")

ls = ls[1:h+1][1:w+1]
for l in range(h):
    print(''.join(ls[l]))


### FIXED CODE ###

h,w = map(int,input().split())

ls = [[x for x in input()] for _ in range(h)]

for i in range(h):
    ls[i].append(".")
    ls[i].insert(0,".")
a = ["." for _ in range(w+2)]
ls.append(a)
ls.insert(0,a)

ans = [['#' for _ in range(w)] for _ in range(h)]

for j in range(1,h+1):
    for k in range(1,w+1):
        if ls[j][k] == ".":
            c = [ls[j-1][k-1],ls[j-1][k],ls[j-1][k+1],ls[j][k-1],ls[j][k+1],ls[j+1][k-1],ls[j+1][k],ls[j+1][k+1]]
            ans[j-1][k-1] = str(c.count("#"))

for l in ans:
    print("".join(l))
import sys

N = int(sys.argv[1])
K = int(sys.argv[2])
count = 0
numbers = list(range(1, N+1))
while True:
    if len(numbers) >= K:
        numbers.pop(0)
        count = count + 1
    else:
        print(count)
        break


### FIXED CODE ###

t = input()
l = t.split(" ")
N = int(l[0])
K = int(l[1])
count = 0
numbers = list(range(1, N+1))
while True:
    if len(numbers) >= K:
        numbers.pop(0)
        count = count + 1
    else:
        print(count)
        break
s = str(input())
t = str(input())
S = []
T = []

for i in s:
    S.append(ord(i))
for j in t:
    T.append(ord(j))

S = sorted(S)
T = sorted(T, reverse=True)

ans = 'Yes'

for n in range(len(S)):
    if S[n] < T[n]:
        break
    elif S[n] == T[n]:
        continue
    else:
        ans = 'No'

if S == T:
    ans = 'No'

print(ans)

### FIXED CODE ###

s = str(input())
t = str(input())
S = []
T = []

for i in s:
    S.append(i)
for j in t:
    T.append(j)

S = sorted(S)
T = sorted(T, reverse=True)

S = ''.join(S)
T = ''.join(T)

if S < T:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)
n, m = sorted([int(x) for x in input().split()])
gap = m - n
if gap > 1:
    print(0)
    exit()
mod = 10 ** 9 + 7
f = 1
for i in range(2, m + 1):
    f *= i
    if i == n:
        f_n = f % mod
f_m = f % mod
ans = f_n * f_m % mod
if gap == 0:
    ans = ans * 2 % mod
print(ans)

### FIXED CODE ###

from math import factorial
n, m = [int(x) for x in input().split()]
temp = abs(n - m)
if temp > 1:
    print(0)
    exit()
mod = 10 ** 9 + 7
f_n = factorial(n) % mod
f_m = factorial(m) % mod
ans = f_n * f_m % mod
if temp == 0:
    ans = ans * 2 % mod
print(ans)
n,p = list(map(int,input().split()))
S = input()

if p == 2 or p == 5:
  ans = 0
  for i,s in enumerate(S):
    if int(s)%p == 0:
      ans += i+1
  print(ans)
  exit()

M = [0]*p
pre = 0
ans = 0
i = 1
for s in S[::-1]:
  pre += s*i
  pre %= p
  M[pre] += 1
  i *= 10

M[0] += 1
ans = sum(map(lambda m:(m*(m-1))//2, M))
print(ans)



### FIXED CODE ###

n,p = list(map(int,input().split()))
S = input()

if p == 2 or p == 5:
  ans = 0
  for i,s in enumerate(S):
    if int(s)%p == 0:
      ans += i+1
  print(ans)
  exit()

def MS(i,s,pre):
  return (s*i +pre)%p
 
M = [0]*p
M[0] = 1
t = 1
now = 0
for i in S[::-1]:
    i = int(i)
    now += i*t
    now %= p
    M[now] += 1
    t = t*10%p

ans = sum(map(lambda m:(m*(m-1))//2, M))
print(ans)
N = int(input())
S = input()

ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N):
  for j in range(i+1,N):
    if (i+j)%2 :
      continue
    k = (i+j)//2
    if len(set([S[i],S[k],S[j]])) == 3:
      ans -= 1
      
print(ans)

### FIXED CODE ###

N = input()

if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")
S = input()
T = ''
for _ in len(S):
  T += 'x'
print(T)


### FIXED CODE ###

s = input()
print('x' * len(s))
minCount = 10000
i = 0
while i < len(s):
    countSame = 0
    j = 0
    while j < len(t) and i+j < len(s):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)

### FIXED CODE ###

s = input()
t = input()
minCount = len(t)
i = 0
while i < len(s) and i + len(t) <= len(s):
    countSame = 0
    j = 0
    while j < len(t):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)
N = int(input())
    A = [int(i) for i in input().split(" ")]
def bubble(A, N):
    count = 0
    flag = True
    while flag == True:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j - 1]:
                A[j -1],A[j] = A[j], A[j - 1]
                count += 1
                flag = True
        print(" ".join(map(str, A)))
        print(count)

bubble(A, N)

### FIXED CODE ###

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


def bubble_sort(A, N):
    cnt = 0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1, 0, -1):
            if(A[i-1] > A[i]):
                A[i-1], A[i] = A[i], A[i-1]
                cnt += 1
                flag = True

    print(" ".join(list(map(str, A))))
    print(cnt)

bubble_sort(A, N)
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A, BC):
    A.sort()
    BC.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b, c in BC:
        for j in range(i, i+b):
            if c > A[j]:
                A[j] = c
                i = j + 1
            else:
                break
                
        if i != j + 1:
            break
    return sum(A)


def main():
    N, M = read_int_n()
    A = read_int_n()
    BC = [read_int_n() for _ in range(M)]
    print(slv(N, M, A, BC))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A, BC):
    A.sort()
    BC.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b, c in BC:
        for j in range(i, i+b):
            if j < N and c > A[j]:
                A[j] = c
                i = j + 1
            else:
                break

        if i != j + 1:
            break
    return sum(A)


def main():
    N, M = read_int_n()
    A = read_int_n()
    BC = [read_int_n() for _ in range(M)]
    print(slv(N, M, A, BC))


if __name__ == '__main__':
    main()
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
        else:
            continue
        break
print(ans)


### FIXED CODE ###

L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
        else:
            continue
        break
    print(ans)
import collections

N = int(input())
S = input()
Q = int(input())
querys = [list(map(str, input().split())) for i in range(Q)]
for i in range(Q):
    query = querys[i]
    if query[0] == "1":
        qi = int(query[1])
        S = S[:qi-1] + query[2] + S[qi:]
    else:
        c = collections.Counter(S[int(query[1]) - 1:int(query[2])])
        print(len(c))

### FIXED CODE ###

N = int(input()) 
if N % 2 == 1:
    print((N//2) + 1)
else:
    print(N//2)
n, p = map(int, input().split())

ans = 1
q = p
if n == 1:
    ans = p
else:
    for d in range(2, 1000001):
        cnt = 0
        while q % d == 0:
            q //= d
            cnt += 1
        if p < d**n:
            break
        ans *= d**(cnt // n)
print(ans)

### FIXED CODE ###

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

ans = 1
if n == 1:
    ans = p
else:
    q = p
    for d in range(2, 1000001):
        if q < d**2:
            break
        cnt = 0
        while q % d == 0:
            q //= d
            cnt += 1
        ans *= d**(cnt // n)
print(ans)
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1c
print(ans)

### FIXED CODE ###

#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1
print(ans)
r,d,x=map(int,input().split())
for i in range(10):
  x=r*d-x
    print(x)

### FIXED CODE ###

r,d,x=map(int,input().split())
for i in range(10):
    x=r*x-d
    print(x)
n = int(input())
w = [int(i) for i in input().split()]
ans = []
for t in range(n):
    s1 = sum(w[:t])
    s2 = sum(w[t:])
print(min(ans))

### FIXED CODE ###

n = int(input())
w = [int(i) for i in input().split()]
ans = []
for t in range(n):
    s1 = sum(w[:t])
    s2 = sum(w[t:])
    ans.append(abs(s2-s1))
print(min(ans))