Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
data=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    data[a].append(b)
lst=[]
for i in range(1,n+1):
    h=[str(i)]
    while h:
        H=[]
        for u in h:
            a=int(u[-1])
            for v in data[a]:
                if v==i:
                    lst.append(int(u))
                    break
                else:
                    H.append(u.join(str(v)))
            else:
                continue
            break
        else:
            h=H
            continue
        break
print(lst)
lst.sort()
li=[]
flag=[0]*(n+1)
for u in lst:
    u=list(str(u))
    for v in u:
        if flag[int(v)]==1:
            break
    else:
        for v in u:
            flag[int(v)]=1
        li.append(u)
print(li)
for u in li:
    a=int(u[0])
    que=[a]
    while h:
        H=[]
        for i in que:
            if i==a:
                break
            H+=data[i]
        else:
            h=H
            continue
        break
    for i in u:
        if i in h:
            break
    else:
        print(len(u))
        for i in u:
            print(i)
        break
else:
    print(-1)

### FIXED CODE ###

N,M=map(int,input().split())
data=[[] for i in range(N+1)]
for i in range(M):
    A,B=map(int,input().split())
    data[A].append(B)
lst=[]
for i in range(1,N+1):
    flag=[0]*(N+1)
    parent=[0]*(N+1)
    que=[i]
    while que:
        h=[]
        for u in que:
            for v in data[u]:
                if flag[v]==0:
                    flag[v]=1
                    parent[v]=u
                    h.append(v)
        que=h
    if parent[i]==0:
        continue
    lsls=[i]
    zzz=i
    while True:
        zzz=parent[zzz]
        if zzz==i:
            break
        lsls.append(zzz)
    lst.append(lsls)
inf=float("inf")
k=inf
ans=None
for u in lst:
    if k>len(u):
        ans=u
        k=len(u)
if k==inf:
    print(-1)
else:
    print(k)
    for v in ans:
        print(v)
N = int(input())
arare = input().split()
y = 0
for i in arare:
  if arere[i] == "Y":
    y += 1
    break
if y == 1:
  print("Four")
else:
  print("Three")

### FIXED CODE ###

N = int(input())
arare = input().split()
y = 0
for i in range(len(arare)):
  if arare[i] == "Y":
    y += 1
    break
if y == 1:
  print("Four")
else:
  print("Three")
import math

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

x=math.floor(m/n)

ans=[]
for i in range(2,x+1):
  if(m % i==0):
    ans.append(i)

ans.sort()
ans.reverse()
print(ans[0])

### FIXED CODE ###

import math

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

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if int(m/i)*n<=m:
      ans=max(ans,int(m/i))
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
ab = b-a
ac = c-a
ad = d-a
ae = e-a
bc = c-b
bd = d-b
be = e-b
cd = d-c
ce = e-c
de = e-d
if ab <=	k and ac <= k and ad <= k	and ae <= k and bc <= k and bd <= k and be <= k and cd <= k and ce <= k and d\
e <= k:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
ab = b-a
ac = c-a
ad = d-a
ae = e-a
bc = c-b
bd = d-b
be = e-b
cd = d-c
ce = e-c
de = e-d
if ab <= k and ac <= k and ad <= k and ae <= k and bc <= k and bd <= k and be <= k and cd <= k and ce <= k and de <= k:
    print("Yay!")
else:
    print(":(")
s = input()
vis_a = 0
vis_b = 0

for i in s:
  if i == 'A':
    vis_a = 1
  if i == 'B':
    vis_b = 1

if vis_a and vis_b:
  print("Yes")
else
  print("No")


### FIXED CODE ###

s = input()
vis_a = 0
vis_b = 0

for i in s:
  if i == 'A':
    vis_a = 1
  if i == 'B':
    vis_b = 1

if vis_a and vis_b:
    print("Yes")
else:
    print("No")
import sys

input = lambda : sys.stdin.readline().rstrip()

def pow_mod(x, y, mod):
    tmp = x
    ret = 1
    while y > 0:
        if y % 2 == 1:
            ret = ret * tmp % mod
        tmp = tmp * tmp % mod
        y //= 2
    return ret

def inverse(x, mod):
    return pow_mod(x, mod - 2, mod)

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

MOD = 1000000007

def factorial(x):
    if x <= 1:
        return 1
    else:
        return x * factorial(x - 1) % MOD

f = factorial(N - 1)

h = [0]
for _ in range(N):
    h.append((h[-1] + f * inverse(len(h), MOD)) % MOD)

ans = 0
for i in range(N - 1):
    ans += h[i + 1] * (x[i + 1] - x[i])
    ans %= MOD

print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)
input = lambda : sys.stdin.readline().rstrip()

def pow_mod(x, y, mod):
    tmp = x
    ret = 1
    while y > 0:
        if y % 2 == 1:
            ret = ret * tmp % mod
        tmp = tmp * tmp % mod
        y //= 2
    return ret

def inverse(x, mod):
    return pow_mod(x, mod - 2, mod)

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

MOD = 1000000007

def factorial(x):
    if x <= 1:
        return 1
    else:
        return x * factorial(x - 1) % MOD

f = factorial(N - 1)

h = [0]
for _ in range(N):
    h.append((h[-1] + f * inverse(len(h), MOD)) % MOD)

ans = 0
for i in range(N - 1):
    ans += h[i + 1] * (x[i + 1] - x[i])
    ans %= MOD

print(ans)
import math
def LCM(a, b):
    return(a // math.gcd(a, b) * b)

n = int(input())
a = list(map(int, input().split()))
lc = 1;

for i in range(n):
    lc = LCM(lc, a[i])

res = 0;
for i in range(n):
    res = res + (lc // a[i])

print(res % 1000000007)



### FIXED CODE ###

import fractions
def LCM(a, b):
    return(a // fractions.gcd(a, b) * b)

n = int(input())
a = list(map(int, input().split()))
lc = 1;

for i in range(n):
    lc = LCM(lc, a[i])

res = 0;
for i in range(n):
    res = res + (lc // a[i])

print(res % 1000000007)
from bisect import bisect
from bisect import insort

X,N=list(map(int,input().split()))
if N != 0:
	p=list(map(int,input().split()))

	not_list=[]
	for i in range(1,101):
		if i not in p:
			not_list.append(i)

		a=bisect(not_list,X)
		insort(not_list,X)

		ans1=not_list[a]-not_list[a-1]
		ans2=not_list[a+1]-not_list[a]

		if ans1 < ans2:
			print(not_list[a-1])
		elif ans1 == ans2:
			print(not_list[a-1])
		else:
			print(not_list[a+1])
            
else:
	print(X)

### FIXED CODE ###

X, N = map(int, input().split())
p = list(map(int, input().split()))

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break
a, b, m = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = []
for _ in range(m):
  coupon.append(list(map(int, input().split())))
  
a_copy = a_price.copy()
a_copy.sort()
b_copy = b_price.copy()
b_copy.sort()
a_min = a_copy[0]
b_min = b_copy[0]
min = a_min + b_min
totals = [min]
for list in coupon:
  tmp = a_list[list[0]-1] + b_list[list[1]-1] - list[2]
  totals.append(tmp)

totals.sort()
ans = totals[0]

print(ans)


### FIXED CODE ###

a, b, m = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = []
for _ in range(m):
    coupon.append(list(map(int, input().split())))

a_copy = a_price.copy()
a_copy.sort()
b_copy = b_price.copy()
b_copy.sort()
a_min = a_copy[0]
b_min = b_copy[0]
min = a_min + b_min
totals = [min]
for list in coupon:
    tmp = a_price[list[0] - 1] + b_price[list[1] - 1] - list[2]
    totals.append(tmp)

totals.sort()
ans = totals[0]

print(ans)
n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(m)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i))

### FIXED CODE ###

n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i)
import numpy as np

r = input()
c = 1*(np.pi**2)
c2 = r*(np.pi**2)
print(int(c2/c))

### FIXED CODE ###

import numpy as np
r = int(input())
c = int(np.pi)*(1**2)
c2 = int(np.pi)*(r**2)
print(int(c2/c))
import sys
import io, os
def main():
    input = sys.stdin.readline
    inputb = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
    N=int(input())
    A=[int(input()) for _ in range(N)]
    from collections import Counter
    C=Counter(A)
    ans=0
    for v in C.values():
        if v&1: ans+=1
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    A=[int(input()) for _ in range(N)]
    from collections import Counter
    C=Counter(A)
    ans=0
    for v in C.values():
        if v&1: ans+=1
    print(ans)


if __name__ == '__main__':
    main()
s = str(input())
ans = ['YYMM','MMYY','AMBIGUOUS','NA']
#print(s[:2],s[-2:])
if (0==int(s[:2]) or 13<=int(s[:2])) and (0==int(s[-2:]) or 13<=int(s[-2:])):
    print(ans[4])
if 0<int(s[:2])<=12 and 0<int(s[-2:])<=12:
    print(ans[3])
elif 0<int(s[:2])<=12:
    print(ans[2])
elif 0<int(s[-2:])<=12:
    print(ans[1])

    

### FIXED CODE ###

s = str(input())
ans = ['YYMM','MMYY','AMBIGUOUS','NA']
#print(s[:2],s[-2:])
if (0==int(s[:2]) or 13<=int(s[:2])) and (0==int(s[-2:]) or 13<=int(s[-2:])):
    print(ans[3])
if 0<int(s[:2])<=12 and 0<int(s[-2:])<=12:
    print(ans[2])
elif 0<int(s[:2])<=12:
    print(ans[1])
elif 0<int(s[-2:])<=12:
    print(ans[0])
N, K = map(int, input().split())
S = input()

L = []
R = []
before = S[0]
cnt_zero = 0
cnt_one = 0
len_l = 0
len_r = 0
for i in range(N):
    if before == '0' and S[i] == '0':
        cnt_zero += 1
    elif before == '0' and S[i] == '1':
        before = '1'
        L.append(cnt_zero)
        len_l += 1
        cnt_zero = 0
        cnt_one += 1
    elif before == '1' and S[i] == '0':
        before = '0'
        R.append(cnt_one)
        len_r += 1
        cnt_zero += 1
        cnt_one = 0
    else:
    	cnt_one += 1
if cnt_zero > 0:
    L.append(cnt_zero)
    len_l += 1

if cnt_one > 0:
	R.append(cnt_one)
	len_r += 1
ans = 0
sum_one = 0
if S[0] == '0':
	sum_one = sum(L[:K]) + sum(R[:K])
else:
	sum_one = sum(L[:K]) + sum(R[:K+1])

ans = sum_one
for i in range(len_l)[1:]:
    if i + K > len_l:
        break
    elif i + K == len_l:
        if i + K > len_r:
            sum_one += (L[K+i-1] - L[i-1] - R[i-1])
            ans = max(ans, sum_one)
            break
        else:
            sum_one += (L[K+i-1] + R[K+i] - L[i-1] - R[i-1])
            ans = max(ans, sum_one)
            break
    if S[0] == '0' and i == 1:
        sum_one += (L[K] + R[K] - L[0])
    else:
        sum_one += (L[K+i-1] + R[K+i] - L[i-1] - R[i-1])
    ans = max(ans, sum_one)
print(ans)


### FIXED CODE ###

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

before = S[0]
cnt = 0
same_nums = []
if S[0] == '0':
  same_nums.append(0)
for i in range(N):
  if S[i] == before:
    cnt += 1
  else:
    same_nums.append(cnt)
    before = S[i]
    cnt = 1
same_nums.append(cnt)
if S[-1] == '0':
  same_nums.append(0)
  
sum_nums = sum(same_nums[:2*K+1])
ans = sum_nums
for i in range(0, len(same_nums)-2*K, 2):
  sum_nums = sum_nums - sum(same_nums[i:i+2]) + sum(same_nums[i+2*K+1:i+2*K+3])
  ans = max(ans, sum_nums)
print(ans)
from sys import stdin
a,b = [int(x) for x in stdin.readline().rstrip().split()]
"""
a,b = map(int,input().split())
s = input()
s = s.split(" ")
a = int(s[0])
b = int(s[1])
"""

count = 0
while b > 0:
  count += 1
  b -= (count*(a-1)+1):
    
print(count)


### FIXED CODE ###

s = list(map(int,input().split()))
a = int(s[0])
b = int(s[1])

count = 0
while (b - (count*(a-1)+1)) > 0:
  count += 1
  
print(count)
N, Y = map(int, input().split())
# N = 9
# Y = 45000
  

def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            # z = n - x - y
            tmp = total - 10000 * x + 5000 * y
            if z == tmp / 1000:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'
 
 
print(judge(N, Y))

### FIXED CODE ###

N, Y = map(int, input().split())
# N = 9
# Y = 45000


def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            z = n - x - y
            total = 10000 * x + 5000 * y + 1000 * z
            if total == target:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'


print(judge(N, Y))
import math

a, b, c, d = map(int, (raw_input()).split())
ans = (c-a)**2 + (d-b)**2
print math.sqrt(ans)

### FIXED CODE ###

import math

a, b, c, d = map(float, (raw_input()).split())
ans = (c-a)**2 + (d-b)**2
print math.sqrt(ans)
import collections
n=int(input())
a=list(map(int,input().split()))
A=collections.Counter(a)
b=list(A.values())
b.sort()
lst=[]
for i in range(len(b)-1):
  lst.append(b[i]+b[i+1])
print(max(lst))
  


### FIXED CODE ###

import collections
import sys
n=int(input())
a=list(map(int,input().split()))
b=list(collections.Counter(a).items())
b.sort(key=lambda x:int(x[0]))
if len(b)==1:
  print(n)
  sys.exit()
lst=[]
num=b[0][1]
if int(b[1][0])-int(b[0][0])==1:
  num+=b[1][1]
lst.append(num)
for i in range(1,len(b)-1):
  num=b[i][1]
  if int(b[i+1][0])-int(b[i][0])==1:
    num+=b[i+1][1]
  if int(b[i][0])-int(b[i-1][0])==1:
    num+=b[i-1][1]
  lst.append(num)
num=b[len(b)-1][1]
if int(b[len(b)-1][0])-int(b[len(b)-2][0])==1:
  num+=b[len(b)-2][1]
lst.append(num)
print(max(lst))
a = input().split()
b = input().split()
if a == reverse(b):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a = list(input())
b = list(input())
if a == list(reversed(b)):
    print("YES")
else:
    print("NO")
N=int(input())
while for i in N:
  if i**2>N:
    break
  answer=i**2
print(answer)

### FIXED CODE ###

N=int(input())
for i in range(1,N+1):
  if i**2>N:
    break
  answer=i**2
print(answer)
import collections

def main():
  N = int(input())
  A = [int(a) for a in input().split(" ")]
  CA = collections.Counter(A)
  minA = min(A)
  maxA = max(A)
  X = [CA[i] for i in range(minA, maxA + 1)]
  if len(X) == 1:
    print(X[0])
    return 0
  if len(X) == 2:
    print(X[0] + X[1])
    
  Y = [X[j] + X[j+1] + X[j+2] for j in range(len(X) - 2)]
  print(max(Y))

main()

### FIXED CODE ###

import collections

def main():
  N = int(input())
  A = [int(a) for a in input().split(" ")]
  CA = collections.Counter(A)
  minA = min(A)
  maxA = max(A)
  X = [CA[i] for i in range(minA, maxA + 1)]
  if len(X) == 1:
    print(X[0])
    return 0
  if len(X) == 2:
    print(X[0] + X[1])
    return 0
    
  Y = [X[j] + X[j+1] + X[j+2] for j in range(len(X) - 2)]
  print(max(Y))

main()
a,b,c,d = map(int,input().split())
print(min(a,b) + min(c,d))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b) + min(c,d))
def main():
    A = int(input())
    B = int(input())
    print(A - B + 1)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    A, B = [int(i) for i in input().split()]
    print(A - B + 1)
if __name__ == "__main__":
    main()
#coding:utf-8
s = input()
a = 0
for c in s:
  a = a + 1 if c == "+" else a = a - 1
print(a)

### FIXED CODE ###

#coding:utf-8
s = input()
a = 0
for c in s:
  a = a + 1 if c == "+" else a - 1
print(a)
N,X=input().split()
n=int(N)
x=int(X)
i=list(map(int,input().split()))
D=0
k=0
while D<=x:
  if k<=n+1:
    D=D+i[k]
    k=k+1
  else:
    k=n+1
print(k)

### FIXED CODE ###

X,A=input().split()
x=int(X)
a=int(A)
if x<a:
  print(0)
else:
  print(10)
N, A, B = map(int, input().split())
print(N*A if N*A < B else B)


### FIXED CODE ###

N, A, B = map(int, input().split())
print(N*A if N*A < B else B)
ss = input()
s = int(ss)

nums = input().split()
type(nums)
type(nums[0])

count = 0
for val in range(s -2):
    if list[val] > list[val + 1] > list[val + 1] or list [val] < list[val + 1] < list[val + 2]:
        count += 1
        
print(count)

### FIXED CODE ###

ss = input()
s = int(ss)
nums = list(map(int,input().split()))
count = 0
for val in range(s -2):
    if nums[val] > nums[val + 1] > nums[val + 2] or nums[val] < nums[val + 1] < nums[val + 2]:
        count += 1
        
print(count)
def main():
    inputs = input()

    roop_num = len(inputs)

    cnt = 0
    flag = False
    for start in range(roop_num-3):
        roop_num_end = roop_num - start
        ans_list = []
        ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]
        cnt += len(ans_list)

    print(cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    inputs = input().split(' ')
    sheep = int(inputs[0])
    wolf = int(inputs[1])

    if sheep > wolf:
        print('safe')

    else:
        print('unsafe')

if __name__ == '__main__':
    main()
from collections import defaultdict
from heapq import heappush, heappop

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

for _ in range(N):
  a,b = map(int,input().split())
  d[a].append(b)
  
h = []
res = 0

for a in range(1,M + 1):
  for b in d[a]:
    heappush(h,-b)
  if h > 0:
    c = heappop(h)
    res -=c
    
print(res)

### FIXED CODE ###

from collections import defaultdict
from heapq import heappush, heappop

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

for _ in range(N):
  a,b = map(int,input().split())
  d[a].append(b)
  
h = []
res = 0

for a in range(1,M + 1):
  for b in d[a]:
    heappush(h,-b)
  if len(h) > 0:
    c = heappop(h)
    res -=c
    
print(res)
isPair=True
isSet=True

def gen_factorization(N):
    tables=[-1]*(N+1)
    for i in range(2,N):
        if tables[i]!=-1:continue
        tmp=i
        while tmp<=N:
            tables[tmp]=i
            tmp+=i
    def fuctorization(n):
        if n==1:return 1
        elif n<0:n=abs(n)
        elif n>N:return -1
        ans={}
        while n!=1:
            tmp=tables[n]
            #debug print
            #print(tmp,n)
            ans.setdefault(tmp,0)
            ans[tmp]+=1
            n//=tmp
        return ans
    return fuctorization

N=int(input())
f=gen_factorization(10**6)
A=list(map(int,input().split()))
primes={}
for i in A:
  d=f(i)
  for j in d:
    primes.setdefault(j,0)
    primes[j]+=1

ansMax=max(primes.values())
ansMin=min(primes.values())

if ansMax==1:
  print('pairwise coprime')
elif ansMax==N:
  print('not coprime')
else:
  print('setwise coprime')

### FIXED CODE ###


def gen_factorization(N):
    tables=[-1]*(N+1)
    for i in range(2,N+1):
        if tables[i]!=-1:continue
        tmp=i
        while tmp<=N:
            tables[tmp]=i
            tmp+=i
    def fuctorization(n):
        if n==1:return {1:1}
        elif n<0:n=abs(n)
        if n>N:return "error"
        ans={}
        while n!=1:
            tmp=tables[n]
            #debug print
            #print(tmp,n)
            ans.setdefault(tmp,0)
            ans[tmp]+=1
            n//=tmp
        return ans
    return fuctorization

N=int(input())
f=gen_factorization(10**6+10)
A=list(map(int,input().split()))
primes={}
for i in A:
  d=f(i)
  for j in d:
    primes.setdefault(j,0)
    primes[j]+=1
primes[1]=1
ansMax=max(primes.values())

if ansMax==1:
  print('pairwise coprime')
elif ansMax==N:
  print('not coprime')
else:
  print('setwise coprime')
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

### FIXED CODE ###

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

#２整数の最大公約数を求める

def gcd2(x,y): 
    while y != 0:
        x , y = y , x % y 
    return x



#N 整数の最大公約数を求める
#A = [A[0],...,A[N]] とする

def gcd(A):
    ans = A[0]
    for i in range(1,N): #range(1,N)= 1,2,...,N-1
        ans = gcd2(ans, A[i])
    return ans
print(gcd(A))
nums = input(a).split(b)
a = int(nums[0])
b = int(nums[1])
print(a*b,(a+b)*2)

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
print(a * b,(a + b) * 2)
first = -1
for i,point in enumerate(ls):
    if point >= 0:
        first = i
        break
size=k+1
ans = []
for i in range(size):
    if first-size+i+1>=0 and first+i-1< len(ls):
        temp = [0,ls[first-size+i+1],ls[first+i-1]]
        temp = [abs(min(temp)),abs(max(temp))]
        ans.append((2*min(temp)+max(temp)))
print (min(ans))

### FIXED CODE ###

#coding:utf-8
import numpy as np
n,k = map(int,input().split())
ls = list(map(int,input().split()))

# n, k = 5, 3
# ls = [-30,-10,10,20,50]
#
# n,k = 3,2
# ls=[10,20,30]

# n,k = 1,1
# ls = [0]

# n,k=8,5
# ls=[-9,-7,-4,-3,1,2,3,4]
if not (0 in ls):
    ls.append(0)
    k+=1
#print (ls)

ls = np.array(ls)
ls.sort()
#print (ls)

idx = np.where(ls==0)[0][0]
#print (idx,k)
#print (idx+k)
start = max(0,idx-k)
goal = min(idx+k,len(ls)-1)

#print (start,goal)
answer = []
for i in range(goal-(k-1)+1):
    #print (i,i+k-1)
    mi = min(abs(ls[i]),abs(ls[i+k-1]))
    ma = max(abs(ls[i]),abs(ls[i+k-1]))
    #print (mi,ma)
    answer.append(2*mi+ma)
print (min(answer))
# def set_max(ls):
#     if len(ls)>0:
#         return set([max(ls)])
#     else:
#         return set()
# def set_min(ls):
#     if len(ls)>0:
#         return set([min(ls)])
#     else:
#         return set()
#
#
# plus = list(filter(lambda n:n>=0, ls))
# minus = list(filter(lambda n:n<=0, ls))
#
# neighbor = set_max(minus) | set_min(plus)
#
# #print (neighbor)
# answer = []
# cnt = 0
# for i in range(n-k+1):
#     if len(set(ls[i:i+k])&neighbor)>0:
#
#         #print (ls[i:i+k])
#         #print (np.sign(ls[i]*ls[i+k-1]))
#         temp = [abs(ls[i]),abs(ls[i+k-1])]
#         if np.sign(ls[i]*ls[i+k-1])<0:
#
#             answer.append(2*min(temp)+max(temp))
#         else:
#             answer.append(max(temp))
#         cnt += 1
#         if cnt == k + 1:
#             break
# print (min(answer))

# first = -1
# for i,point in enumerate(ls):
#     if point >= 0:
#         first = i
#         break
# size=k+1
# ans = []
# for i in range(size):
#     if first-size+i+1>=0 and first+i-1< len(ls):
#         temp = [0,ls[first-size+i+1],ls[first+i-1]]
#         temp = [abs(min(temp)),abs(max(temp))]
#         ans.append((2*min(temp)+max(temp)))
# print (min(ans))
n=input()
s=input()
s2=list(s)
for i in range(len(s2)):
    a=ord(s2[i])+n
    if a>90:
        a-=26
    s2[i]=chr(a)
print(''.join(s2))

### FIXED CODE ###

n=int(input())
s=input()
s=list(s)
for i in range(len(s)):
    a=ord(s[i])+n
    if a>90:
        a-=26
    s[i]=chr(a)
print(''.join(s), end='')
n, m = map(int, input().split())

w = [[] for _ in range(10001)]

for i in range(n):
  a, b = map(int, input().split())
  if a == 0:
    continue
  w[a-1].append(b)

money = 0
l = []
for i in range(m):
  l += w[i]
  if len(l) == 0:
    continue

  x = max(l)
  l.remove(x)
  money += x

print(money)

### FIXED CODE ###

from heapq import heappush, heappop

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

w = [[] for _ in range(10**5)]

for i in range(n):
  a, b = map(int, input().split())
  w[a-1].append(b)

money = 0
l = []
for i in range(m):
  for item in w[i]:
    heappush(l, item * (-1))
  if len(l) == 0:
    continue

  money += heappop(l) * (-1)

print(money)
a, b = map(int, input().ssplit())
print(a * b)


### FIXED CODE ###

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