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

#input
X = int(input())

#output
left = 1
right = 10**2
while left + 1 < right:
    mid = (left + right)//2
    if mid **5  > X:
        right = mid
    else:
        left = mid

A = right
C = A**5 -X

if C >= 0:
    B = pow(C, 1/5)
else:
    B = -pow(-C, 1/5)

while not B.is_integer():
    A -= 1
    C = A**5 - X
    if C >= 0:
        B = pow(C, 1/5)
    else:
        B = -pow(-C, 1/5)
print(A, int(B))

### FIXED CODE ###

#input
X = int(input())

#output
for a in range(200):
    for b in range(-200, 200):
        if a**5 - b**5 == X:
            print(a, b)
            exit()
### BUGGY CODE ###

#配るDP（多分
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0
for i in range(1,n):
    for j in range(k):
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i-1]+abs(h[i+j]-h[i-1]))

print(dp[-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
def ch_min(a,b):
    if a>b:
        return b
    
    return a
def solve():
    dp=[float('inf')]*n
    dp[0]=0

    for i in range(1,n):
    
        for j in range(1,1+k):
            if i-j>=0:
                dp[i]=ch_min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
                
                if dp[i]==0:
                    break
                
    print(dp[-1])
    

solve()
### BUGGY CODE ###

b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort(key=lambda x: x[0])
x=0
z=0
y=b[1]
while y>=0 and not LL==[]:
    if LL==[]:
        print(x-y*(-1)*w)
        z=1
        break
    else:
        y-=LL[0][1]
        x+=LL[0][1]*LL[0][0]
        z=LL[0][1]*LL[0][0]
        w=LL[0][0]
        LL=LL[1:]
print(x-y*(-1)*w)

### FIXED CODE ###

b=list(map(int,input().split()))
LL=[]
for i in range(b[0]):
    LL.append(list(map(int,input().split())))
LL.sort()
x=0
z=0
y=b[1]
i=-1
while y>=0 and not LL==[]:
    i+=1
    if y<=LL[i][1]:
        print(x+LL[i][0]*y)
        break
    else:
        y-=LL[i][1]
        x+=LL[i][1]*LL[i][0]
### BUGGY CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]

memo = {}
def dfs(i, j):
    if i < 0 or i >= H or j < 0 or j >= W:
        return set()
    if i == j == 0:
        return {C[i][j]}
    if (i, j) in memo:
        return memo[(i, j)]
    st = dfs(i, j-1) | dfs(i-1, j)
    ret = set()
    for n in st:
        ret.add(abs(n-C[i][j]))
        ret.add(abs(n+C[i][j]))
    memo[(i, j)] = ret
    return ret

ans = list(dfs(H-1, W-1))
ans.sort()
print(ans[0])

### FIXED CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]

M = (H+W)*80
dp = [[0] * W for _ in range(H)]
dp[0][0] |= 1 << (M-C[0][0])
for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        bit = 0
        if i > 0:
            bit |= dp[i-1][j]
        if j > 0:
            bit |= dp[i][j-1]
        dp[i][j] = (bit >> C[i][j]) | (bit << C[i][j])
ans = M
for i in range(M+1):
    if (dp[-1][-1] >> i) & 1:
        ans = min(ans, abs(M-i))
print(ans)
### BUGGY CODE ###

N,M= list(map(int,input().split()))
list_A = [0] * N
for i in range(M):
    A,B = list(map(int,input().split()))
    list_A[A-1:B] = map(lambda x: x+1,list_A[A-1:B])
print(list_A.count(M))


### FIXED CODE ###

N,M= list(map(int,input().split()))
end = []
start = []
for i in range(M):
    A,B = list(map(int,input().split()))
    end.append(B)
    start.append(A)
end_min = min(end)
start_max = max(start)
if start_max > end_min:
    print(0)
else:
    print(end_min-start_max+1)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for r in range(N+1):
    for g in range(N+1):
        b =( N - R * r - G * g) / B
        if b >= 0 and b.is_integer():
            ans += 1
print(ans)


### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        v = R * r + G * g
        if v > N:
            break
        if (N - v) % B == 0:
            ans +=1 
        
print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())

for i in range(Q):
    t = input()
    if t == "1":
        S = S[::-1]
    else:
        t,f,c = t.split()
        if f == "1":
            S = c + S
        else:
            S = S + c
            
print(S)

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())

a = 0
for i in range(Q):
    t = input()
    if t == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        t,f,c = t.split()
        if f == "1":
            if a == 0:
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if a == 0:
                S.append(c)
            else:
                S.appendleft(c)
            
if a == 1:
    S = reversed(S)
    
S = ''.join(S)
print(S)
### BUGGY CODE ###

from itertools import accumulate

n, k = map(int, input().split())
a = list(map(int, input().split())) + [0]

for _ in range(k):
    l = [0] * (n + 1)
    for i in range(n):
        l[max(0, i - a[i])] += 1
        l[min(n, i + a[i] + 1)] -= 1
    a = list(accumulate(l))

print(*a[:-1])

### FIXED CODE ###

import numpy as np
from numba import jit


@jit("i8, i8, i8[:]")
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


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

n,a,b = map(int,input().split())
m = 10**9+7

def nCr(n_, r_, m_):
  c = min(r_ , n_ - r_)
  bunshi = 1
  bunbo = 1
  for i in range(1,c+1):
    bunshi *= (n_+1-i) % m_
    bunbo *= i % m_
  return bunshi * pow(bunbo, m_-2, m_) % m_

ans = pow(2,n,m)-1
ans -=nCr(n,a,m)
ans = ans%m
ans -=nCr(n,b,m)
ans = ans%m
print(ans)

### FIXED CODE ###

n,a,b = map(int,input().split())
m = 10**9+7

def nCr(n_, r_, m_):
  c = min(r_ , n_ - r_)
  bunshi = 1
  bunbo = 1
  for i in range(1,c+1):
    bunshi = bunshi * (n_+1-i) % m_
    bunbo = bunbo * i % m_
  return bunshi * pow(bunbo, m_-2, m_) % m_


ans = pow(2,n,m)-1
ans -= nCr(n,a,m)
ans %= m
ans -= nCr(n,b,m)
ans %= m
print(ans)
### BUGGY CODE ###

h,n = map(int, input().split())
magic = []
INF = 10**8

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

dp = [[INF for j in range(h+1)] for i in range(n+1)] #体力がjのモンスターをi番目の魔法までを使って倒せる消費魔力の最小値

for i in range(n):
    for j in range(h):
        if j+1 > magic[i][0]:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-magic[i][0]] + magic[i][1], dp[i+1][j+1-magic[i][0]] + magic[i][1])
        else:
            dp[i+1][j+1] = min(dp[i][j+1], magic[i][1])
            
print(dp[n][h])

### FIXED CODE ###

h,n = map(int, input().split())
magic = []
INF = 10**8
dp = [[INF for j in range(h+1)] for i in range(n+1)] #体力がjのモンスターをi番目の魔法までを使って倒せる消費魔力の最小値
 
for i in range(n):
    a,b = map(int, input().split())
    magic.append([a, b])
 
for i in range(n):
    for j in range(h):
        if j+1 > magic[i][0]:
            dp[i+1][j+1] = min(dp[i][j+1], dp[i][j+1-magic[i][0]] + magic[i][1], dp[i+1][j+1-magic[i][0]] + magic[i][1])
        else:
            dp[i+1][j+1] = min(dp[i][j+1], magic[i][1])
            
print(dp[n][h])
### BUGGY CODE ###

import math

print (int(math.factorial(input())))%(10**9+7)

### FIXED CODE ###

def factorialMod(n, modulus):
    ans=1
    if n <= modulus//2:
        #calculate the factorial normally (right argument of range() is exclusive)
        for i in range(1,n+1):
            ans = (ans * i) % modulus
    else:
        #Fancypants method for large n
        for i in range(n+1,modulus):
            ans = (ans * i) % modulus
        ans = modinv(ans, modulus)
        ans = -1*ans + modulus
    return ans % modulus


print factorialMod(input(),10**9+7)
### BUGGY CODE ###

n,m=map(int,input().split())
lst = set()
fst = set()
for i in range(m): 
  r = list(map(int,input().split()))
  if r[1] == n:
    lst.add(r[0])
  elif r[0] == 1:
    fst.add(r[1])
  if len(lst & fst) != 0:
    break
print('IMPOSSIBLE' if len(fst & lst) == 0 else 'POSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
lst = set()
fst = set()
for i in range(m): 
  r = list(map(int,input().split()))
  if r[1] == n:
    lst.add(r[0])
  elif r[0] == 1:
    fst.add(r[1])
print('IMPOSSIBLE' if len(fst & lst) == 0 else 'POSSIBLE')
### BUGGY CODE ###

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

count = 0
for i in range(N):
    for j in range(N - 1):
        if A[j] == i + 1:
            count += 1
    print(count)
    count = 0


### FIXED CODE ###

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

ans = [0] * N
for i in A:
    ans[i - 1] += 1

[print(i) for i in ans]
### BUGGY CODE ###

n = int(input())
participant = list(map(int, input().split()))

ans = 0
for i in range(len(participant)-1):
  for j in range(i+1, len(participant)):
    if j - i == participant[i] + participant[j]:
      ans += 1

print(ans)

### FIXED CODE ###

import collections
 
input()
p = list(map(int, input().split()))
map1 = collections.defaultdict(lambda:0)
map2 = collections.defaultdict(lambda:0)
 
for i, v in enumerate(p):
  map1[i+v] += 1
  map2[i-v] += 1

ans = 0
for i in map1:
  if i in map2:
    ans += map1[i] * map2[i]

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

n = int(input())
r = [[0 for _ in range(26)] for i in range(n)]
for i in range(n):
    s = str(input())
    for j in range(10):
        r[i][ord(s[j])-97] += 1
w = []
cnt = []
for i in range(n):
    if r[i] in w:
        cnt[w.index(r[i])] += 1
    else:
        w.append(r[i])
        cnt.append(1)
ans = 0
for i in range(len(cnt)):
    ans += (cnt[i]*(cnt[i]-1))//2
print(ans)

### FIXED CODE ###

n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)
### BUGGY CODE ###

import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')


def solve(test):
	s = [''] + list(input())
	t = [''] + list(input())
	rec = [[0 for j in range(len(t))] for i in range(len(s))]
	for i in range(1, len(s)):
		for j in range(1, len(t)):
			if s[i] == t[j]:
				rec[i][j] = 1 + rec[i - 1][j - 1]
			else:
				rec[i][j] = max(rec[i - 1][j], rec[i][j - 1])

	ans = []
	i, j = len(s) - 1, len(t) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			ans.append(s[i])
			i -= 1
			j -= 1
		elif rec[i - 1][j] > rec[i][j - 1]:
			i -= 1
		else:
			j -= 1

	print(''.join(ans[::-1]))


if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)


### FIXED CODE ###

import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')


def solve(test):
	s = [''] + list(input())
	t = [''] + list(input())
	rec = [[0 for j in range(len(t))] for i in range(len(s))]
	for i in range(1, len(s)):
		for j in range(1, len(t)):
			if s[i] == t[j]:
				rec[i][j] = 1 + rec[i - 1][j - 1]
			else:
				rec[i][j] = max(rec[i - 1][j], rec[i][j - 1])

	ans = []
	i, j = len(s) - 1, len(t) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			ans.append(s[i])
			i -= 1
			j -= 1
		elif rec[i - 1][j] > rec[i][j - 1]:
			i -= 1
		else:
			j -= 1

	print(''.join(ans[::-1]))


if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)
### BUGGY CODE ###

n = int(input())
l_li = [int(x) for x in input().split()]
l_li.sort()

count = 0

for i in range(n):
  for j in range(i+1,n):
    wa = l_li[i] + l_li[j]
    for k in range(j+1,n):
      if l_li[k] >= wa:
        break
      count += 1
print(count)

### FIXED CODE ###

import bisect
n = int(input())
l_li = [int(x) for x in input().split()]
l_li.sort()

count = 0
  
for i in range(n):
  for j in range(i+1,n):
    wa = l_li[i] + l_li[j]
    count += bisect.bisect_left(l_li, wa) - j - 1
    
print(count)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
for n in range(N):
    tmp = A.copy()
    tmp.pop(n)
    print(max(tmp))

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
B=sorted(A,reverse=True)
max=B[0]
sec=B[1]

if max==sec:
    for n in range(N):
        print(max)
else:
    for a in A:
        if a==max:
            print(sec)
        else:
            print(max)
### BUGGY CODE ###

#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    print(0)
    g = {'Vacant':0, 'Male':1, 'Female':2}
    sl = g[input()]
    if sl == 0:
        return
    print(N-1)
    sr = g[input()]
    if sr == 0:
        return
    l = 0
    r = N-1
    while r-l>1:

        m = (l+r)//2
        print(m)
        a = g[input()]
        if a == 0:
            return
        
        if (m-l) % 2 == 1 and sl == a:
            r = m
            sr = a
        else:
            l = m
            sl = a
        




if __name__ == '__main__':
    main()

### FIXED CODE ###

#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    g = {'Vacant':0, 'Male':1, 'Female':2}



    print(0,flush=True)
    sl = g[input()]
    if sl == 0:
        return

    print(N-1,flush=True)
    sr = g[input()]
    if sr == 0:
        return
    
    l = 0
    r = N-1
    while r-l>1:

        m = (l+r)//2
        print(m,flush=True)
        a = g[input()]
        if a == 0:
            return
        
        if (m-l) % 2 == 1:
            if sl == a:
                r = m
                sr = a
            else:
                l = m
                sl = a

        else:
            if a != sl:
                r = m
                sr = a
            else:
                l = m
                sl = a
        

    print(-1)


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

n ,x, y = map(int, input().split())
degree_all = []
d = [float('inf')]*n
for i in range(n):
    degree_all.append(d)
for i in range(n):
    degree_all[i][i] = 0
    if i != n-1:
        degree_all[i][i+1] = 1
        #degree_all[i+1][i] = 1
sub_degree = [0]*n
for i in range(n):
    for j in range(i+1, n):
        sub_degree[min(abs(j-i), abs(x-1-i)+1+abs(j-y+1), abs(y-1-i)+1+abs(j-x+1))-1]+=1
'''
for i in range(n-1):
    for j in range(i+1, n):
        sub_degree[degree_all[i][j]-1] +=1
        #print(degree_all[i][j])
#print("aaaa")
'''
for i in range(n-1):
    print(sub_degree[i])


### FIXED CODE ###

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

ans = [0]*N

for i in range(1,N):
    for j in range(i+1,N+1):
        road = min(abs(j-i),abs(X-i)+abs(j-Y)+1,abs(Y-i)+abs(j-X)+1)
        ans[road] += 1

for i in range(1,N):
    print(ans[i])
### BUGGY CODE ###

import math

def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
# k,x = map(int,input().split())
s_l = []
for i in range(n):
        s_l.append(input())

for i in range(n):
        a = ''
        for x in sorted(s_l[i]):
                a += x
        s_l[i] = a

cnt = 0
# for i in range(n):
#         for j in range(1,n-i):
#                 if s_l[i] == s_l[i+j]:
#                         cnt += 1
set_s_l = set(s_l)
if len(s_l) == len(set_s_l):
        print(0)
else:
        l = []
        for val in set_s_l:
                l.append(s_l.count(val))
        for i in l:
                if i > 1:
                        cnt += c(i,2)
        print(cnt)

### FIXED CODE ###

import math
from collections import defaultdict

n = int(input())
# k,x = map(int,input().split())
s_l = []
for i in range(n):
        s = list(input())
        s.sort()
        s_l.append(''.join(s))

# for i in range(n):
#         s_l.append(''.join(sorted(s_i_l[i])))
#         # for x in sorted(s_l[i]):
#         #         a += x
#         # s_l[i] = a
cnt = 0

d = defaultdict(lambda: 0)
for s in s_l:
        d[s] += 1

for v in d.values():
        cnt += int(v*(v-1)/2)
print(cnt)
### BUGGY CODE ###

from collections import deque
import numpy as np

H, W = map(int, input().split())
d = [[-1]*W for i in range(H)]
#temp = [[float("inf")]*W for i in range(H)]
maze = [list(input()) for i in range(H)]

black_cells = deque()
for i in range(H):
    for j in range(W):
        if maze[i][j]=="#":
            black_cells.append((i,j))
            d[i][j] = 0

def bfs():
    #max = 0
    #dx = [1, 0, -1, 0]
    #dy = [0, 1, 0, -1]

    #que = deque([])
    s = 0
    while black_cells:
        p = black_cells.popleft()
        s = d[p[0]][p[1]]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            nx = p[1] + dx
            ny = p[0] + dy
            #a = temp[ny][nx]
            if 0<=nx<W and 0<=ny<H and d[ny][nx]==-1:
                #que.append((nx))
                #temp[ny][nx] = d[p[0]][p[1]] + 1
                #a = temp[ny][nx]
                #d[ny][nx] = d[p[0]][p[1]] + 1
                #if a < d[ny][nx]:
                black_cells.append((ny, nx))
                d[ny][nx] = s + 1
                    #if max < d[ny][nx]:
                        #max = d[ny][nx]

    return s






#for i in slist:
#    s = bfs(i[0], i[1])

print(bfs())
#print(s)


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)
### BUGGY CODE ###

N = int(input())

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

sum  = 0
for i in range(N):
    for j in range(i+1,N):
        sum+=A[i]^A[j]

div = pow(10,9)+7

print(sum%div)

### FIXED CODE ###

from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

if __name__=='__main__':
    mod = 10**9 + 7
    n = I()
    a = LI()
    ans = 0
    for i in range(60):
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
        ans += ((n-c1)*c1*(2**i)%mod)%mod
    print(ans%mod)
### BUGGY CODE ###

from collections import deque
def insert():
    a.appendleft(command[1])

def delete():
    try:
        a.remove(command[1])
    except ValueError:
        pass

def deleteFirst():
    a.popleft()

def deleteLast():
    a.pop()

n = int(input())
a = deque([])
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        insert()
    elif command[0] == "delete":
        delete()
    elif command[0] == "deleteFirst":
        deleteFirst()
    else:
        deleteLast()

for i, e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=' ')



### FIXED CODE ###

from collections import deque
a = deque([])
for i in range(int(input())):
    c = input().split()
    if c[0] == "insert":
        a.appendleft(c[1])
    elif c[0] == "delete":
        try:
            a.remove(c[1])
        except ValueError:
            pass
    elif c[0] == "deleteFirst":
        a.popleft()
    else:
        a.pop()
for i,e in enumerate(a):
    if i == len(a) - 1:
        print(e)
    else:
        print(e, end=" ")
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n-k+1):
  cnt=0
  for j in range(i,i+k):
    cnt+=(1/p[j])*(p[j]*(1+p[j])/2)
  ans=max(ans,cnt)
  
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
e=[]
for i in range(n):
  e.append((1/p[i])*(p[i]*(1+p[i])/2))

a=0
for i in range(k):
  a+=e[i]

ans=[a]
for i in range(1,n-k+1):
  a=a-e[i-1]+e[i+k-1]
  ans.append(a)

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

N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 18

ans = A[0]

for i in range(1, N):
    if A[i] == 0:
        print(0)
        exit()
    ans = ans * A[i]

if ans > INF:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 18

if 0 in A:
    print(0)
    exit()

A.sort(reverse=True)
ans = A[0]

for i in range(1, N):
    if A[i] > INF:
        print(-1)
        exit()
    if A[i] == 1:
        break
    ans = ans * A[i]
    if ans > INF:
        print(-1)
        exit()

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

N, P = map(int,input().split())
ans = 1
k = 1
while k**N <= P:
    if P%(k**N)==0:
        ans = k
    k += 1

print(ans)

### FIXED CODE ###

from collections import Counter
import math

N, P = map(int,input().split())
if N >= 41:
    print(1)
    exit(0)
if N >= P:
    print(1)
    exit(0)
if N == 1:
    print(P)
    exit(0)
if N == 2:
    M = P
    Q = []
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            Q.append(k)
        else:
            k += 1
    if M > 1:
        Q.append(M)
    R = Counter(Q)
    ans = 1
    for k in R:
        if R[k] >= 2:
            ans *= k**(R[k]//2)
    print(ans)
    exit(0)

ans = 1
k = 1
while pow(k,N) <= P:
    if P%pow(k,N)==0:
        ans = k
    k += 1

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

N=int(input())
A=list(map(int,input().split()))
 
import itertools
B=list(itertools.accumulate(A))

ans=3*(10**9)
for i in range(N-1):
  l=B[i]
  D=abs(l-(sum(A)-l))
  if ans > D:
    ans=D
 
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
 
import numpy as np

def getNearestValue(list, num):
  idx = np.abs(np.asarray(list) - num).argmin()
  return list[idx]

a=(np.cumsum(A))
l=getNearestValue(a, sum(A)/2)

ans=abs(sum(A)-2*l)
print(ans)