Harryxun/stf_run huggingface dataset:
S = input()
d = []
lt = 0
gt = 0
for i in range(len(S)):
    if i == 0:
        continue
    if S[i - 1]  == S[i] and S[i] == "<":
        lt += 1
    if S[i - 1] == S[i] and S[i] == ">":
        gt += 1
    if S[i - 1] != S[i] and S[i-1] == "<":
        d.append("<" * (lt + 1))
        lt = 0
    if S[i - 1] != S[i] and S[i - 1] == ">":
        d.append(">" * (gt + 1))
        gt = 0
    if i == len(S) - 1 and S[i] == "<":
        d.append("<" * (lt + 1))
    if i == len(S) - 1 and S[i] == ">":
        d.append(">" * (gt + 1))
    
print(d)
ans=0

if d[0][0] == "<":
    i = 0
    while i < len(d) - 1:
        if i != len(d) - 1:
            if len(d[i]) >= len(d[i + 1]):
                for i in range(1, len(d[i])+1):
                    ans += i
                for i in range(1, len(d)):
                    ans += i
                i += 2
            elif len(d[i]) < len(d[i + 1]):
                for i in range(1, len(d[i])+1):
                    ans += i
                for i in range(1, len(d)):
                    ans += i
                i+= 2
        elif i  == len(d) - 1:
            for i in range(1, len(d[i])+1):
                ans += i
                i += 1

if d[0][0] ==">":
    ans += (len(d[i]) + 1) * len(d[i]) / 2
    i = 1
    while i < len(d) - 1:
        if i != len(d) - 1:
            if len(d[i]) >= len(d[i + 1]):
                ans += (len(d[i]) + 1) * len(d[i]) / 2 + (len(d[i+1])) * len(d[i + 1]) / 2
                i += 2
            elif len(d[i]) < len(d[i + 1]):
                ans += (len(d[i])) * len(d[i]) / 2 + (len(d[i+1])+1) * len(d[i + 1]) / 2
                i += 2
        elif i  == len(d) - 1:
            ans +=  (len(d[i]) + 1) * len(d[i]) / 2

print(ans)
    

                

        
# min_d = 0
# for i in d:
#     min_d = min(min_d, d[i])

# d = list(map(lambda x: x + abs(min_d), d))

# if S[0] == "<":
#     d[0] = 0

# ans = 0
# for i in range(len(S)):
#     ans += d[i]
# print(d)
# print(ans)
            

### FIXED CODE ###

S = input()
a = [0] * (len(S) + 1)
for i in range(len(S)):
    if S[i] == "<":
        a[i+1] = max(a[i+1], a[i] + 1)
for i in range(len(S)-1,-1,-1):
    if S[i] == ">":
        a[i] = max(a[i], a[i+1] + 1)
        
print(sum(a))
x = int(input)
h = x // 3600
m = x % 3600//60
s = x % 3600 % 60
print('{}:{}:{}'.format(h, m, s))

### FIXED CODE ###

x = int(input())
# x = 46979
h = x // 3600
m = x % 3600//60
s = x % 3600 % 60
print('{}:{}:{}'.format(str(h), str(m), str(s)))
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

a,b,n = inL()

i = 0

l = [0]*(b+1)
for i in range(1,min(b,n)+1):
    l[i] = int(a*i/b)-a*int(i/b)


print(max(l)) 


### FIXED CODE ###

def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

a,b,n = inL()

x = min(b-1,n)
print(int(a*x/b)-a*int(x/b))
A, B = map(int, input().split())
1 <= A <= B <= 20

if B % A == 0：
    print(A + B)
else:
    print(B - A)

### FIXED CODE ###

A, B = map(int, input().split())
 
if B % A == 0:
    print(A + B)
else:
    print(B - A)
n,k = map(int,input().split())
h = list(map(int,input().split()))
x = 0
for i in n:
  if h[i-1]>=k:
    x += 1
print(x)

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
x = 0
for i in range(n):
  if h[i-1]>=k:
    x += 1
print(x)
import bisect, functools
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

@functools.lru_cache(maxsize=None)
def a(n):
    return bisect.bisect_left(A, n)

@functools.lru_cache(maxsize=None)
def b_i(i):
    if i >= 1:
        return b_i(i - 1) + a(B[i - 1])
    return 0

@functools.lru_cache(maxsize=None)
def b(n):
    return b_i(min(len(B), bisect.bisect_left(B, n)))

def c():
    return sum(b(x) for x in C)

print(c())

### FIXED CODE ###

import bisect, functools, sys
sys.setrecursionlimit(10**6)
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

@functools.lru_cache(maxsize=None)
def a(n):
    return bisect.bisect_left(A, n)

b_cache = [0] * (N + 1)
b_cached = [False] * (N + 1)
def b_i(i):
    global b_cache, b_cached
    if i >= 1:
        if not b_cached[i - 1]: b_i(i - 1)
        t = b_cache[i - 1] + a(B[i - 1])
        b_cache[i] = t
        b_cached[i] = True
        return t
    return 0

@functools.lru_cache(maxsize=None)
def b(n):
    return b_i(min(N, bisect.bisect_left(B, n)))

def c():
    return sum(b(x) for x in C)

print(c())
def gcd(a, b):
    while True:
        bigger=max(a,b)
        smaller=min(a,b)
        mod=bigger%smaller
        if mod==0:
            return smaller
        else:
            return gcd(smaller, mod)

n = int(input())
a = list(map(int, input().split()))
ansers=[]
non_remove=a[0]
ansers.append(a[1])
for i in range(1, n):
    ansers = [ gcd(ans, a[i]) for ans in ansers ]
    ansers.append(non_remove)
    non_remove = gcd(non_remove, a[i])
print(max(ansers))

### FIXED CODE ###

a, b, t = map(int, input().split())
print(t//a*b)
N = input()
vals = input().split()
count = 0
while True:
    for val in vals:
        if val % 2 == 1:
            break
    else:
        count += 1
        vals = map(lambda x: x/2, vals)
        continue
    break
print (count)

### FIXED CODE ###

N = int(input())
vals = list(map(int, input().split()))
count = 0
is_odd = False
while True:
    for i in range(0, N):
        if vals[i] % 2 == 1:
            is_odd = True
        vals[i] /= 2
    if is_odd:
        break
    count += 1
print (count)
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    A, B, C = list(map(int, input().split()))

    if (A + B) >= C:
        print('Yes')
    else:
        print('No')
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    A, B, C = list(map(int, input().split()))

    if (A + B) >= C:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    A, B, C = list(map(int, input().split()))

    if (A + B) >= C:
        print('Yes')
    else:
        print('No')
a = int(input())
b = int(input())
c = a * b
d = 2 * (a + b)
print(c)
print(d)


### FIXED CODE ###

a,b = (int(x) for x in input().split())
c = a * b
d = (a + b) * 2
print(c,d)
def mrinfinit(a, b):
    if len(a) > 1:
        if '1' in a:
            a = a.replace('1', '')
            return a[0]
        else:
            return a[0]
    return a[0]


if __name__ == '__main__':
    la = input()
    lb = int(input())
    print(mrinfinit(la, lb))


### FIXED CODE ###

def mrinfinit(a, b):
    bf = list(set(a))
    rr = a[:b]
    sf = list(set(rr))

    if len(bf) == 1 and bf[0] == '1':
        return a[0]
    elif len(sf) == 1 and sf[0] == '1':
        return a[0]
    elif len(a) > 1:
        if '1' in a:
            a = a.replace('1', '')
            return a[0]
        else:
            return a[0]
    else:
        return a[0]


if __name__ == '__main__':
    la = input()
    lb = int(input())
    print(mrinfinit(la, lb))
_ = input()
a = list(map(int, input().strip().strip(' ')))
print(max(a)-min(a))


### FIXED CODE ###

_ = input()
a = list(map(int, input().strip().split(' ')))
print(max(a)-min(a))
S = input()
idx = 0
cnts = []
while idx < len(S):
    char = S[idx]
    cnt = 0
    while idx < len(S) and S[idx] == char:
        idx += 1
        cnt += 1
    cnts.append(cnt)
if len(cnts) <= 2:
    print(max(cnts))
    quit()
ans = (len(S) + 1) // 2
for i in range(len(cnts) - 2):
    ans = max(ans, min(cnts[i] + cnts[i + 1], cnts[i + 1] + cnts[i + 2]))
ans = max(ans, max(cnts))

flips = []
for i in range(len(cnts) - 1):
    flips.append((cnts[i] + cnts[i + 1], i))
flips.sort()

from bisect import bisect_left
left, right = (len(S) + 1) // 2, len(S)
while left + 1 < right:
    mid = (left + right) // 2
    _, mid_idx = bisect_left(flips, (mid, -1))
    ret = [False] * (len(cnts))
    for _, idx in flips[mid_idx:]:
        ret[idx] = ret[idx + 1] = True
    if all(x for x in ret):
        left = mid
    else:
        right = mid
ans = max(left, ans)
print(ans)


### FIXED CODE ###

S = input()
if all(S[0] == x for x in S):
    print(len(S))
else:
    print(min(max(i + 1, len(S) - (i + 1)) for i in range(len(S) - 1) if S[i] != S[i + 1]))
# -*- coding: utf-8 -*-

N,W = map(int, input().split())
wN = []
vN = []
for i in range(N):
    w,v = map(int, input().split())
    wN.append(w)
    vN.append(v)

dp = [[0] * (wN[0]+3)*N for i in range(N+1)]

if W < wN[0]:
    print(0)
    exit()
elif W >= (wN[0]+3)*N:
    print(sum(vN))

# wNの範囲はかなり限定されているので、オフセットを用意
# (-1するのは0地点を残すため)
offset = wN[0]-1
W -= offset

for i in range(N):
    for j in range(offset, (wN[0]+3)*N + offset):

        if wN[i] <= j:
            # max(0,～)で0未満を探しに行くのを避ける
            dp[i+1][j-offset] = max(dp[i][max(0,j-wN[i]-offset)] + vN[i], dp[i][j-offset])
        else:
            dp[i+1][j-offset] = dp[i][j-offset]

print(dp[N][W])

### FIXED CODE ###

# -*- coding: utf-8 -*-

"""
・メモ化再帰
"""

import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)

from collections import defaultdict

N, W = map(int, input().split())
wN = [0] * N
vN = [0] * N
for i in range(N):
    wN[i], vN[i] = map(int, input().split())

# memo[i][j]: i番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値
memo = [defaultdict(lambda: -1) for i in range(N+1)]

def dfs(cur, wei):
    # 既に調べた場所はそのまま返却
    if memo[cur][wei] != -1:
        return memo[cur][wei]
    # 品物を最後まで見た
    if cur == N:
        res = 0
    # まだ余力があるから両方試す
    elif wei >= wN[cur]:
        res = max(dfs(cur+1, wei-wN[cur]) + vN[cur], dfs(cur+1, wei))
    # もうこの回の荷物は入らない
    else:
        res = dfs(cur+1, wei)
    # ここまでのベストな値をメモに記録してから返却
    memo[cur][wei] = res
    return res
# 0番目以降で容量W以下の場合の結果を表示
print(dfs(0, W))
n=int(input())
d=[int(input())-1for i in range(n)]
s=set(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s+=d[b]
  ans+=1
  if b==1:
    break
print(ans)

### FIXED CODE ###

n=int(input())
d=[int(input())-1for i in range(n)]
s=set()
s.add(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)
n,k = map(int,input().split())
s = list(input())
a = []
switch = 0
tmp = 0
for i in range(n):
    if switch == 0:
        if s[i] == "1":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 1
    else:
        if s[i] == "0":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 0
a.append(tmp)

tmp = 0
if k*2 <= len(a):
    tmp = k
else:
    if len(a)%2 == 0:
        tmp = len(a)/2
    else:
        tmp = len(a)//2 


ans = sum(a[0:tmp*2+1])
tmpans = sum(a[0:tmp*2+1])
i = 2
while i+tmp*2<=len(a):
    tmpans -= a[i-2]+a[i-1]
    if i+tmp*2 == len(a):
        tmpans += a[i+tmp*2-1]
    else:
        tmpans += a[i+tmp*2-1]+a[i+tmp*2] 
    ans = max(ans,tmpans)
    i+=2
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
s = list(input())
a = []
switch = 0
tmp = 0
for i in range(n):
    if switch == 0:
        if s[i] == "1":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 1
    else:
        if s[i] == "0":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 0
a.append(tmp)

tmp = 0
if k*2 <= len(a):
    tmp = k
else:
    if len(a)%2 == 0:
        tmp = int(len(a)/2)
    else:
        tmp = len(a)//2 


ans = sum(a[0:tmp*2+1])
tmpans = sum(a[0:tmp*2+1])
i = 2
while i+tmp*2<=len(a):
    tmpans -= a[i-2]+a[i-1]
    if i+tmp*2 == len(a):
        tmpans += a[i+tmp*2-1]
    else:
        tmpans += a[i+tmp*2-1]+a[i+tmp*2] 
    ans = max(ans,tmpans)
    i+=2
print(ans)
from collections import Counter
n = int(input())
A = Counter(list(input()))
B = Counter(list(input()))
C = Counter(list(input()))
ans = []
for key,value in A.items():
  ans.append(str(key)*min(value,B[key],C[key]))
print(join(sorted(ans)),end="")

### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))
s = input()
k = int(input())

l=0

while s[l] == '1':
    l+=1

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)

### FIXED CODE ###

s = input()
k = int(input())

l=0

while s[l] == '1':
    l+=1
    if l >= len(s):
        l -= 1
        break

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)
a, b, c, d = list(map(int, input().split()))
ops = ['+', '-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      s = str(a)+op1+str(b)+op2+str(c)+op3+str(d)
      res = eval(s)
      if res == 7:
        print(s+'=7')
        break

### FIXED CODE ###

a, b, c, d = list(input())
ops = ['+', '-']
fin = False
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            s = a+op1+b+op2+c+op3+d
            res = eval(s)
            if res == 7:
                print(s+'=7')
                fin = True
                break
        if fin == True:
            break
    if fin == True:
        break
N = int(input())
X = set()
for i in range(2,32):
  for j in range(2, 10):
    if pow(i,j) <= N:
      X.add(pow(i, j))
    else:
      break
print(max(X))


### FIXED CODE ###

N = int(input())
X = set()
for i in range(1,32):
  for j in range(2, 10):
    if pow(i,j) <= N:
      X.add(pow(i, j))
    else:
      break
print(max(X))
if __name__ == '__main__':
	l = input().split()

	for i in range(l):
		l[i] = int(l[i])
	(W, H, x, y, r) = (l[i] for i in range(5))

	if x >= r and y >= r:
		if x <= W - r and y <= H - r:
			print("Yes")
		else:
			print("No")
	else:
		print("No")



### FIXED CODE ###

if __name__ == '__main__':
	l = input().split()

	for i in range(len(l)):
		l[i] = int(l[i])
	W, H, x, y, r = l[0], l[1], l[2], l[3], l[4]

	if x >= r and y >= r:
		if x <= W - r and y <= H - r:
			print("Yes")
		else:
			print("No")
	else:
		print("No")
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

s = input()
result = s.replace(",", " ")

print(result)
A, B, K = [int(x) for x in input().split(" ")]

if A >= K:
  print("{} {}".format(A-K, B))
elif A < K and A+B => K:
  print("{} {}".format(0, A+B-K))
else:
  print(0)

### FIXED CODE ###

A, B, K = [int(x) for x in input().split(" ")]

if A >= K:
  print("{} {}".format(A-K, B))
elif A < K and A+B >= K:
  print("{} {}".format(0, int(A-K/2+B-K/2)))
else:
  print(0, 0)
s = input()

for i in s:
	if(i.isupper()):
		print(i.lower(), end="")
	else
		print(i.upper(), end="")

### FIXED CODE ###

s = input()

for i in s:
	if(i.isupper()):
		print(i.lower(), end="")
	else:
		print(i.upper(), end="")
print()
A=int(input())
B=int(input())
print(A*B-(A+B-1))

### FIXED CODE ###

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

print(listA[0]*listA[1]-(listA[0]+listA[1]-1))
# coding: utf-8

N, C = map(int, input().split())
x_list = []
v_list = []
for i in range(N):
    xi, vi = map(int, input().split())
    x_list.append(xi)
    v_list.append(vi)

#energy_clock = list(N)
# energy_reverse= list(N)
energy = [0 for i in range(N)]

# スタートから近い方向で回ったときに獲得するエネルギーを初期値とする
for i in range(N):
    #energy_clock[i] = sum(v_list[0:i]) - x_list[i]
    # energy_reverse[i] = sum(v_list[N-1:N-1-i:-1]) - (C-x_list[N-1-i])
    if x_list[i] <= C/2:
        energy[i] = sum(v_list[0:i+1]) - x_list[i]
    else:
        energy[i] = sum(v_list[i:N]) - (C - x_list[i])

for i in range(1, N-1):
    # エネルギーが前より増えた地点があったら反対周りからのエネルギー獲得もチェックする
    if energy[i] < energy[i+1]:
        tmp_en = energy[i-1]

        if x_list[i-1] <= C/2:
            for j in range(N, i + 1, -1):
                tmp_en += (v_list[j] - (C - x_list[j]))

            if tmp_en > energy[i+1]:
                energy[i+1] = tmp_en
        else:
            for j in range(i+1):
                tmp_en += (v_list[j] - x_list[j])

            if tmp_en > energy[i+1]:
                energy[i+1] = tmp_en

ans = max(energy)

print(ans)

### FIXED CODE ###

# coding: utf-8

N, C = map(int, input().split())
x_list = []
v_list = []
for i in range(N):
    xi, vi = map(int, input().split())
    x_list.append(xi)
    v_list.append(vi)

e_clock = [0] * N
e_counter = [0] * N
e_clock0 = [0] * N # 時計回りしたあと、初期位置に戻った状態
e_counter0 = [0] * N # 反時計回りしたあと、初期位置に戻った状態

# 時計回り、反時計回りはそれぞれ多くて１回ずつである
# (何度も切り替えしても、距離だけ増えて効率的でない

# 時計回りに回ったときの各地点までの取得エネルギーで最大値を格納する
cal = 0
e = 0
e0 = 0
for i in range(N):
    cal += v_list[i]
    x = x_list[i]
    e = max(e, cal - x)
    e0 = max(e0, cal - 2*x)

    e_clock[i] = e
    e_clock0[i] = e0


# 反時計回りに回ったときの各地点までの取得エネルギーで最大値を格納する
cal = 0
e = 0
e0 = 0
for i in range(N-1, -1, -1):
    cal += v_list[i]
    x = C - x_list[i]
    e = max(e, cal - x)
    e0 = max(e0, cal - 2*x)
    e_counter[i] = e
    e_counter0[i] = e0

ans = 0

for i in range(N-1):
    # 時計回りのあと、反時計回りをしたとき
    e1 = e_clock0[i] + e_counter[i+1]
    # 反時計回りのあと、時計回りをしたとき
    e2 = e_counter0[i+1] + e_clock[i]

    ans = max(ans, e1, e2)

# 上はrange(N-1)のforなので
# 時計回りと反時計回りのそれぞれでまるまる１周した場合も加える
ans = max(ans, e_clock[N-1], e_counter[0])

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

def calc_num(N):
  if N==0:
    return 0
  if N % 4 == 1:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  if N % 4 == 3:
    return (0, 0)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
A[-1] %= 2
B[-1] += subB
B[-1] %= 2

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [str((A[i]+B[i])%2) for i in range(len(A))]
#print(res)
print(int("".join(res), 2))


### FIXED CODE ###

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

def calc_num(N):
  if N==0:
    return 0
  if N % 4 == 1:
    return 1
  if N % 4 == 2:
    return N ^ 1
  if N % 4 == 3:
    return 0
  return N ^ 0

A = calc_num(A-1)
B = calc_num(B)

print(A^B)
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
elif filter(lambda x:x%10>0,s) == False:
    print(0)
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))



### FIXED CODE ###

n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

s.sort(key=lambda x:x%10)

if sum(s) % 10 != 0:
    print(sum(s))
elif s[-1] % 10>0:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
else:
    print(0)
print("AABBDC"[int(input())<1000::2]

### FIXED CODE ###

print("AABBDC"[int(input())<1000::2])
N = input()

A = int(N)

if A>=30:
  return 'Yes'
else:
  return 'No'

### FIXED CODE ###

N = input()
 
A = int(N)
 
if A>=30:
  print('Yes')
else:
  print('No')
s=str(input().replace('/','').strip())
if s<=20190430:print('Heisei')
else:print('TBD')

### FIXED CODE ###

s=input().split('/')
if int(s[0])<2018:print('Heisei')
elif int(s[0])==2019 and int(s[1])<=4:print('Heisei')
else:print('TBD')
N = int(input())

alphabet = ['a', 'b', 'c','d','e','f','g', 'h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
mm = 1
name = ''
while True:
    if N > 26 ** mm:
        N = N - 26 ** mm
        mm += 1
    else:
        break
#mmけた

for i in range(mm):
    
    

    if N< 1:
        name =  'a' +name
    else:
            if N%26 == 0:
                name = alphabet[26] + name
            else:
                name = alphabet[N%26-1] + name
                N = N//26 +1
print(name)

### FIXED CODE ###

N = int(input())

alphabet = ['a', 'b', 'c','d','e','f','g', 'h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
mm = 1
name = ''
while True:
    if N > 26 ** mm:
        N = N - 26 ** mm
        mm += 1
    else:
        break
#mmけた

for i in range(mm):
    
    

    if N< 1:
        name =  'a' +name
    else:
            if N%26 == 0:
                name = alphabet[25] + name
                N = N//26
            else:
                name = alphabet[N%26-1] + name
                N = N//26 +1
print(name)
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    neg_dists = []
    pos_dists = []
    exists_zero = False
    for xi in x:
        if xi < 0:
            neg_dists.append(abs(xi))
        elif xi > 0:
            pos_dists.append(abs(xi))
        else:
            exists_zero = True
    neg_dists.sort()
    pos_dists.sort()
    ans = 10 ** 9
    count = K - int(exists_zero)
    for i in range(count):
        d = 0
        if i >= len(neg_dists):continue
        d += neg_dists[i]
        if count-2-i >= len(pos_dists):continue
        d += pos_dists[count-2-i] + neg_dists[i]
        ans = min(ans, d)
    if count < len(neg_dists):ans = min(ans, neg_dists[count-1])
    if count < len(pos_dists):ans = min(ans, pos_dists[count-1])
    if exists_zero and len(neg_dists) == 0 and len(pos_dists) == 0:ans = 0
    print(ans)
            
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    neg_dists = []
    pos_dists = []
    exists_zero = False
    for xi in x:
        if xi < 0:
            neg_dists.append(abs(xi))
        elif xi > 0:
            pos_dists.append(abs(xi))
        else:
            exists_zero = True
    neg_dists.sort()
    pos_dists.sort()
    ans = 10 ** 9
    count = K - int(exists_zero)
    for i in range(count):
        d = 0
        if i >= len(neg_dists):continue
        d += neg_dists[i]
        if len(pos_dists) == 0 or count-2-i >= len(pos_dists):continue
        d += pos_dists[count-2-i] + neg_dists[i]
        ans = min(ans, d)
    for i in range(count):
        d = 0
        if i >= len(pos_dists):continue
        d += pos_dists[i]
        if len(neg_dists) == 0 or count-2-i >= len(neg_dists):continue
        d += neg_dists[count-2-i] + pos_dists[i]
        ans = min(ans, d)
    if len(neg_dists) > 0 and count <= len(neg_dists):ans = min(ans, neg_dists[count-1])
    if len(pos_dists) > 0 and count <= len(pos_dists):ans = min(ans, pos_dists[count-1])
    if exists_zero and len(neg_dists) == 0 and len(pos_dists) == 0:ans = 0
    print(ans)
            
if __name__ == "__main__":
    main()