Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**8)

n = int(input())
x = list(input())
bit_cnt = x.count('1')

# bitを一つ増やす場合
pos = [0] * n
pos_total = 0

# bitを一つ減らす場合
neg = [0] * n
neg_total = 0

base = 1
for i in range(n):
    pos[i] = base%(bit_cnt+1)
    if x[n-i-1] == '1':
        # 同時にmod(bit_cnt+1)の法でトータルを作成
        pos_total = pos_total + base % (bit_cnt+1)
    base = (base*2) % (bit_cnt+1)
pos = pos[::-1]

base = 1
for i in range(n):
    neg[i] = base%(bit_cnt-1)
    if x[n-i-1] == '1':
        # 同時にmod(bit_cnt-1)の法でトータルを作成
        neg_total = neg_total + base % (bit_cnt-1)
    base = (base*2) % (bit_cnt-1)
neg = neg[::-1]

def popcount(n):
    s = list(bin(n)[2:])
    return s.count('1')

memo = {}
memo[0] = 0
def dfs(n, depth=0):
    if n in memo:
        return depth + memo[n]
    else:
        ret = dfs(n%popcount(n), depth+1)
        # memo[n] = ret
        return ret

ans = []
for i in range(n):
    if x[i] == '0':
        st = (pos_total + pos[i]) % (bit_cnt+1)
        print(dfs(st, depth=1))
    elif bit_cnt == 1:
        # コーナーケース：すべてのbitが0となる
        print(0)
    else:
        st = (neg_total - neg[i]) % (bit_cnt-1)
        print(dfs(st, depth=1))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

n = int(input())
x = list(input())
bit_cnt = x.count('1')

# bitを一つ増やす場合
pos = [0] * n
pos_total = 0

# bitを一つ減らす場合
neg = [0] * n
neg_total = 0

base = 1
for i in range(n):
    pos[-i-1] = base%(bit_cnt+1)
    if x[-i-1] == '1':
        # 同時にmod(bit_cnt+1)の法でトータルを作成
        pos_total = (pos_total + base) % (bit_cnt+1)
    base = (base*2) % (bit_cnt+1)

base = 1
if bit_cnt == 1:
    # mod取れない
    pass
else:
    for i in range(n):
        neg[-i-1] = base%(bit_cnt-1)
        if x[-i-1] == '1':
            # 同時にmod(bit_cnt-1)の法でトータルを作成
            neg_total = (neg_total + base) % (bit_cnt-1)
        base = (base*2) % (bit_cnt-1)

def popcount(n):
    s = list(bin(n)[2:])
    return s.count('1')

memo = {}
memo[0] = 0
def dfs(n, depth=0):
    if n in memo:
        return depth + memo[n]
    else:
        ret = dfs(n%popcount(n), depth+1)
        # memo[n] = ret
        return ret

ans = []
for i in range(n):
    if x[i] == '0':
        st = (pos_total + pos[i]) % (bit_cnt+1)
        print(dfs(st, depth=1))
    elif bit_cnt == 1:
        # コーナーケース：すべてのbitが0となる
        print(0)
    else:
        st = (neg_total - neg[i]) % (bit_cnt-1)
        print(dfs(st, depth=1))
import fractions


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


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = arr[0]
for i in range(1, n):
    g = lcm(g, arr[i])

answer = 0
for i in range(n):
    answer += g / arr[i]

print(int(answer % mod))


### FIXED CODE ###

import fractions

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

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

def solve():
    memo = A[0]
    for i in range(1, N):
        memo = lcm(memo, A[i])

    ans = 0
    for i in range(N):
        ans += memo // A[i]

    return ans % (10 ** 9 + 7)

print(solve())
import math
A, B = map(int, input().split())
bi_list = [n for n in range(math.ceil(math.log2(B)) + 1)]

if A == B:
    print(A)
    exit()

odd_num = 0
count_list = [0] * (len(bi_list) + 1)
for i in range(A, B + 1):
    if i % 2 != 0:
        odd_num +=1
    for b in bi_list:
        if i >= b and i % (2 ** b) == 0:
            count_list[b] += 1

result_list = [0] * (len(bi_list) + 1)
for i, elem in enumerate(reversed(count_list)):
    if elem % 2 == 0:
        result_list[i] = "0"
    else:
        result_list[i] = "1"

if odd_num % 2 != 0:
    result_list[-1] = "1"
print(int("".join(result_list), 2))


### FIXED CODE ###

import math

# f(x) = 0からxまでのxor
def f(x):
    div = (x // 2) % 2
    if x % 2 == 0:
        return div ^ x
    else:
        return div ^ 1

A, B = map(int, input().split())
print(f(A - 1) ^ f(B))
N, M = [int(c) for c in input().split()]
F = np.zeros((N+2, M+2))
C = F.copy()
c = np.ones((N, M))
C[1:-1, 1:-1] += c

F[:-1, :] += C[1:, :]
F[1:, :] += C[:-1, :]
F[:, :-1] += C[:, 1:]
F[:, 1:] += C[:, :-1]
F[:-1, 1:] += C[1:, :-1]
F[1:, :-1] += C[:-1, 1:]
F[:-1, :-1] += C[1:, 1:]
F[1:, 1:] += C[:-1, :-1]

print(np.sum(np.where(F[1:-1, 1:-1] % 2, 0, 1)))

### FIXED CODE ###

N, M = [int(c) for c in input().split()]

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(M+N - 3)
else:
    print((M-2) * (N-2))
s=input()
if s="ABC":
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

s=input()
if s=="ABC":
  print("ARC")
else:
  print("ABC")
n,m=map(int,input().split())
L=100000
R=100000
for i in range(m):
  l=int(input())
  r=int(input())
  L=max(L,l)
  R=min(R,r)
print(max(0,R-L+1))

  


### FIXED CODE ###

n,m=map(int,input().split())
l=[]
r=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
lm=max(l)
rm=min(r)
if rm-lm<0:
  print(0)
else:
  print(rm-lm+1)
n=int(input())
print((n+1)//2n)

### FIXED CODE ###

n=int(input())
if n%2==0:
  print(0.5)
else:
  print((n+1)/(2*n))
from collections import deque,defaultdict
import sys
input = sys.stdin.readline

def min_kinder(kinder_max):
  ret = float('inf')
  for x in kinder_max:
    if x==0:
      continue
    else:
      ret = min(ret,x)
  return(ret)
N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(Q)]
kinder = [defaultdict(int) for _ in range(2*10**5 + 5)]
kinder_max = [0] * (2*10**5 + 5)
kinder_num = [0] * (2*10**5 + 5)

for a,b in AB:
  kinder[b][a] += 1
  kinder_max[b] = max(kinder_max[b], a)
  kinder_num[b] += 1
  
equality = min_kinder(kinder_max)
for c,d in CD:
  a,b = AB[c-1]
  AB[c-1][1] = d
  kinder[b][a] -= 1
  kinder[d][a] += 1
  kinder_num[b] -= 1
  kinder_num[d] += 1
  
  if (kinder_max[b]==equality)or(kinder_max[d]==equality):
    judge = True
  else:
    judge = False
  
  if kinder_max[b]==a:
    if kinder[b][a]!=0:
      pass
    else:
      x = 0
      for key,value in kinder[b].items():
        if value<=0:
          continue
        else:
          x = max(x,key)
      kinder_max[b] = x

  kinder_max[d] = max(kinder_max[d], a)

    
  print(equality)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
if N==1:
  print(1)
else:
  A.sort()
  import numpy as np

  l = np.array([0] * (10**6 + 10))
  m = np.array([0] * (10**6 + 10))
  for i in range(N):
    l[A[i]] += 1
    m[A[i]] += 1

  ans = 0
  length = len(l)
  for i in range(length):
    if l[i]==1:
      ans += 1
    
    if m[i]>=1:
      l[i::i] = 0

  print(ans)
#input 2 integers K and X
K,X = (int(x) for x in input().split())

#define answer vaiable
for x in range(X-(K-1), X+(K-1))
	ans.append(x)

#display ans
print(ans)

### FIXED CODE ###

#input 2 integers K and X
K,X = (int(x) for x in input().split())

#define answer vaiable
for x in range(X-(K-1), X+K):
    print(x, end=' ')
a,b = map(int,input())

if a%b==0:
    print(a+b)
else:
    print(a-b)

### FIXED CODE ###

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

if b%a==0:
    print(a+b)
else:
    print(b-a)
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    return dp[v]

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    ans = max(ans, memo(v))
    
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+10)
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    return ans

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    ans = max(ans, memo(v))
    
print(ans)
a,b=map(int,input().split())
c=0
for i in range(a,b+1):
  if str(i)[::0] == str(i):
    c += 1
print(c)


### FIXED CODE ###

a,b=map(int,input().split())
c=0
for i in range(a,b+1):
  if str(i)[::-1] == str(i):
    c += 1
print(c)
while 1:
 H,W = map(int, raw_input().split())
 if h == w == 0:
  break
 print '#'*w
 for i in range(h-2):
  if w >= 2:
   print '#'+'.'*(w-2)+'#'
  else:
   print '#'
 print '#'*w

### FIXED CODE ###

while True:
 H, W = map(int, raw_input().split())
 if (H+W) == 0:
  break
 print "#"*W
 for h in range(1, (H-1)):
  print  "#" + ('.'*(W-2)) + "#"
 print "#"*W
 print ""
import decimal
r = int(input())
print('{:.6f}'.format( r * r * 3.1415926))
print('{:.6f}'.format((r + r) * 3.1415926))

### FIXED CODE ###

import math
r = float(input())
cc = r * r * math.pi
ab = (r + r) * math.pi
print("%.6f"%(cc), "%.6f"%(ab))
n,k= [int(i) for i in input().split()]
if k==1:
    return 0
else:
    return n-k

### FIXED CODE ###

n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)
a=input().split
print(a[0][0]+a[1][0]+a[2][0])

### FIXED CODE ###

a=input().split()
print(a[0][0]+a[1][0]+a[2][0])
h,w = map(int,input().split())

f = []

for i in range(h):
    f.append(list(input()))
    
a = []
    
for i in range(len(f)):
    if f[i] == ["."]*len(f[i]):
        a.append(i)
        
for i in a:
    del f[i]
    for s in range(len(a)):
        a[s] -= 1
        
f2 = []

for i in range(w):
    s = []
    
    for k in f:
        s.append(k[i])
        
    f2.append(s)
    
b = []
    
for i in range(len(f2)):
    if f2[i] == ["."]*len(f2[i]):
        b.append(i)
        
for i in b:
    del f2[i]
    for s in range(len(b)):
        b[s] -= 1
        
ff = []

for i in range(len(f2)):
    s = []
    
    for k in f2:
        s.append(k[i])
        
    ff.append(s)
        
for i in ff:
    for s in range(len(i)-1):
        print(i[s],end = "")
    
    print(i[-1])

### FIXED CODE ###

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

f = []

for i in range(h):
    f.append(list(input()))
    
a = []
    
for i in range(len(f)):
    if f[i] == ["."]*len(f[i]):
        a.append(i)
        
for i in a:
    del f[i]
    for s in range(len(a)):
        a[s] -= 1
        
f2 = []

for i in range(w):
    s = []
    
    for k in f:
        s.append(k[i])
        
    f2.append(s)
    
b = []
    
for i in range(len(f2)):
    if f2[i] == ["."]*len(f2[i]):
        b.append(i)
        
for i in b:
    del f2[i]
    for s in range(len(b)):
        b[s] -= 1
        
ff = []

for i in range(len(f2[0])):
    s = []
    
    for k in f2:
        s.append(k[i])
        
    ff.append(s)
        
for i in ff:
    for s in range(len(i)-1):
        print(i[s],end = "")
    
    print(i[-1])
import math
def myAnswer(N:int,A:list) -> int:
   A.sort()
   return math.gcd(A[0],A[1])

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

### FIXED CODE ###

import fractions
def myAnswer(N:int,A:list) -> int:
   A.sort()
   pre = A.pop(0)
   ans = 10**10
   for a in A:
      ans = min(fractions.gcd(pre,a),ans)
      pre = a
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()
a,b,c,d = map(int,input().split())
print("Left" if a+b > c+d elif a+b == c+d "Balanced" else "Right")

### FIXED CODE ###

a,b,c,d = map(int,input().split())
if a+b > c+d:
    print("Left")
elif a+b < c+d:
    print("Right")
else:
    print("Balanced")
A,B= map(int,input().split())

if A >= B*2:
  print(A-2B)
else:
  print(0)

### FIXED CODE ###

def func():
    A,B=map(int,input().split())
    
    if A>=B*2:
        C=A-2*B
        print(C)
    else:
        print(0)
        
if __name__=="__main__":
    func()
S = input()
Q = int(input())
query_list = []
for i in range(Q):
    query_list.append(input())
# print(S, Q, query_list)

result = S
reverse_flag = False

for i in range(Q):
    # print(i + 1)
    q = query_list[i]
    # print(q)
    t = int(q[0])
    if t == 1:
        reverse_flag = not reverse_flag
    else:
        t, f, c = q.split()
        f = int(f)
        if f == 1:
            if reverse_flag:
                result = f"{result}{c}"
            else:
                #result = c + result
                result = f"{c}{result}"
        else:
            if reverse_flag:
                #result = c + result
                result = f"{c}{result}"
            else:
                #result = result + c
                result = f"{result}{c}"
    # print(t, f, c, result)
    # print("--------")
if reverse_flag:
    result = result[::-1]
print(result)

### FIXED CODE ###

S = input()
Q = int(input())
query_list = []
for i in range(Q):
    query_list.append(input())
# print(S, Q, query_list)

M = 10 ** 6
start_position = int(M / 2)
left_position = start_position
right_position = start_position + len(S)
result = ["-"] * M
for i in range(len(S)):
    # print(i + left_position)
    result[i + left_position] = S[i]

# result = "".join(result[left_position:right_position])
# print(result)
# exit(0)
reverse_flag = False

for i in range(Q):
    # print(i + 1)
    # print(result[left_position:right_position])
    q = query_list[i]
    # print(q)
    t = int(q[0])
    if t == 1:
        reverse_flag = not reverse_flag
    else:
        t, f, c = q.split()
        f = int(f)
        c = c
        if f == 1:
            if reverse_flag:
                result[right_position] = c
                right_position += 1
            else:
                result[left_position - 1] = c
                left_position -= 1
        else:
            if reverse_flag:
                result[left_position - 1] = c
                left_position -= 1
            else:
                result[right_position] = c
                right_position += 1
    # print(t, f, c, result)
    # print("--------")
    #print(result[left_position:right_position])
# result = str(result)
# result = "".join(result)
# print(result)
# print(result[left_position:right_position])

result = "".join(result[left_position:right_position])
if reverse_flag:
    result = result[::-1]
print(result)
A,B,C = map= (int, input().split())
print(C,A,B)

### FIXED CODE ###

A,B,C= map(int,input().split())
print(C,A,B)
import numpy as np

N = input().strip()
K = int(input().strip())
lenN = len(N)

dp = np.zeros((lenN+1, 2, 4))
dp[0][1][0] = 1
for keta in range(lenN):
    for flag in range(2):
        for k in range(K+1):
            for i in range(10):
                nk = k
                nflag = flag
                if flag:
                    if i > int(N[keta]):
                        continue
                    if i < int(N[keta]):
                        nflag = 0
                if i != 0:
                    nk = k + 1
                if nk > K:
                    continue
                dp[keta+1][nflag][nk]+=dp[keta][flag][k]

print(int(dp[lenN][0][K] + dp[lenN][1][K]))


### FIXED CODE ###

from collections import defaultdict

N = input().strip()
K = int(input().strip())
lenN = len(N)

memo = defaultdict(lambda :defaultdict(lambda :defaultdict(int)))
def f(keta, flag, k):
    if keta == lenN-1:
        if k == K:
            return 1
        else:
            return 0
    if keta in memo and flag in memo[keta] and k in memo[keta][flag]:
        return memo[keta][flag][k]
    nketa = keta + 1
    maxi = int(N[nketa]) if flag else 9
    res = 0
    for i in range(maxi+1):
        nflag = flag and (int(N[nketa]) == i)
        nk = k if i == 0 else k + 1
        if nk > K:
            continue
        res += f(nketa, nflag, nk)
    memo[keta][flag][k] = res
    return res

print(f(-1, True, 0))
def isOver(a,b):
    return True if (a[0]-b[0])**2 + (a[1]-b[1])**2 < 4.0+1.0e-12 else False

def largestGroup(mtrx,num):
	mx = 1
	ls = [num]
	for i in mtrx[num]:
		if i == num:
			continue
		m = youKnow(mtrx,ls,i)
		mx = max(mx,m)
	return mx

def youKnow(mtrx,ls,num):
	mx = len(ls)
	if set(ls) <= set(mtrx[num]):
		if num not in ls:
			ls.append(num)
		for i in list(set(mtrx[num])-set(ls)):
			m = youKnow(mtrx,ls,i)
			mx = max(mx,m)
	return mx

while True:
	max_over = 0
	n = int(raw_input())
	if n == 0: break
	seals = [map(float, raw_input().split(",")) for i in range(n)]

	overs = []
	for i in range(n):
		over = []
		for j in range(n):
			if isOver(seals[i],seals[j]):
				over.append(j)
		overs.append(over)
		
	ref = [i for i in range(n)]
	for i in ref:
		num_over = largestGroup(overs,i)
		for j in overs[i]:
			ref.remove(j)
		if num_over > max_over:
			max_over = num_over
	print max_over

### FIXED CODE ###

def isOver(array,x,y):
	return True if (array[0]-x)**2+(array[1]-y)**2 <= 1.01 else False
	
while True:
    mx = 0
    n = int(raw_input())
    if n == 0: break
    seals = [map(float, raw_input().split(",")) for i in range(n)]
    x = 0
    while x < 10.0:
    	y = 0.0
    	while y < 10.0:
    		num = 0
    		for seal in seals:
    			if isOver(seal,x,y):
    				num += 1
    		mx = max(mx,num)
    		y += 0.1
        x += 0.1
    print mx
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = [list(input().split()) for i in range(m)]

for i in range(m):
    A[i][0] = int(A[i][0])

P = [0] * n
AC = [0] * n

for i in range(m):
    if A[i][1] == "WA":
        if AC[A[i][0]] == 0:
            P[A[i][0]] += 1
    else:
        AC[A[i][0]] = 1
    
p=0
ac=sum(AC)
for i in range(len(P)):
    if AC[i] == 1:
        p += P[i]
print(ac,p)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = [list(input().split()) for i in range(m)]

for i in range(m):
    A[i][0] = int(A[i][0])-1

P = [0] * n
AC = [0] * n

for i in range(m):
    if A[i][1] == "WA":
        if AC[A[i][0]] == 0:
            P[A[i][0]] += 1
    else:
        AC[A[i][0]] = 1
    
p=0
ac=sum(AC)
for i in range(len(P)):
    if AC[i] == 1:
        p += P[i]
print(ac,p)
A = input()
B = input()
C = input()
D = input()
L = str(A)+str(B)
R = str(C)+str(D)
if L>R:
  print("Left")
elif L == R:
  print("Balanced")
else :
  print("Right")

### FIXED CODE ###

A = input().split(" ")
L = int(A[0])+int(A[1])
R = int(A[2])+int(A[3])
if L>R:
  print("Left")
elif L == R:
  print("Balanced")
else :
  print("Right")
abc=input().split()
if abc[0] == abc[1] and abc[1]==abc[2]
    print("Yes")
else:
  print("No")

### FIXED CODE ###

abc=input().split()
if abc[0] == abc[1] and abc[1]==abc[2]:
    print("Yes")
else:
  print("No")
x = list(map(int,input().split()))
count=0
for a in range(0,x[0]+1):
    for b in range(0,x[0]+1):
        for c in range(0,x[0]+1):
            if(a+b+c==x[1]):
                count+=1
print(count)

### FIXED CODE ###

print(input().replace(","," "))
h,w = list(map(int,input().split())
h1,w1 = list(map(intinput().split())

print((h-h1)*(w-w1))

### FIXED CODE ###

h,w = list(map(int,input().split()))
h1,w1 = list(map(int,input().split()))

print((h-h1)*(w-w1))
r = int(input())
print(r * r * 3.14159265359, 2 * r * 3.14159265359)


### FIXED CODE ###

r = float(input())
print("{:.6f} {:.6f}".format(r * r * 3.14159265359, 2 * r * 3.14159265359))
A = list(map(int, input().split()))

A.sort()
sumtab = [0] * (N + 1)
tmp_tab = 0
for i, Ai in enumerate(A):
    tmp_tab += Ai
    sumtab[i + 1] = tmp_tab

l = 0
r = N
while True:
    i = l + (r - l) // 2
    # print("#", l, r, i)
    #
    B = list(A)
    # everyone vote: i
    score_i = A[i] + M
    B[i] += M
    M_tmp = M * (V - 1)
    #
    rslt = False
    # print("#", i, B)
    for j in list(range(N))[::-1]:
        # print("##", j, M_tmp, B)
        if j == i:
            continue # me
        elif j > N - P:
            # make stronger problems stronger as possible
            tmp = min(M, M_tmp)
            #
            M_tmp -= tmp
            B[j] += tmp
        else:
            # make weaker problems weaker as possible
            if A[j] + M <= score_i:
                tmp = min(M, M_tmp)
            else:
                tmp = min(score_i - A[j], M_tmp)
            #
            M_tmp -= tmp
            B[j] += tmp
        #
        if M_tmp <= 0: break
    #
    # print("##", 'e', M_tmp, B)
    if M_tmp <= 0 and score_i >= B[N - P]:
        r = i
    else:
        l = i + 1
    #
    if l >= r: break
        
print(N - l)

### FIXED CODE ###

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

A.sort()
sumtab = [0] * (N + 1)
tmp_tab = 0
for i, Ai in enumerate(A):
    tmp_tab += Ai
    sumtab[i + 1] = tmp_tab

l = 0
r = N
while True:
    i = l + (r - l) // 2
    # print("#", l, r, i)
    #
    B = list(A)
    # everyone vote: i
    score_i = A[i] + M
    B[i] += M
    M_tmp = M * (V - 1)
    #
    rslt = False
    # print("#", i, B)
    for j in list(range(N))[::-1]:
        # print("##", j, M_tmp, B)
        if j == i:
            continue # me
        elif j > N - P:
            # make stronger problems stronger as possible
            tmp = min(M, M_tmp)
            #
            M_tmp -= tmp
            B[j] += tmp
        else:
            # make weaker problems weaker as possible
            if A[j] > score_i:
                break
            if A[j] + M <= score_i:
                tmp = min(M, M_tmp)
            else:
                tmp = min(score_i - A[j], M_tmp)
            #
            M_tmp -= tmp
            B[j] += tmp
        #
        if M_tmp <= 0: break
    #
    # print("##", 'e', M_tmp, B)
    if i >= N - P:
        r = i
    elif M_tmp <= 0 and score_i >= B[N - P]:
        r = i
    else:
        l = i + 1
    #
    if l >= r: break
        
print(N - l)
s=input()
x=['A','T','C','G']
a=[0]*len(s)
a[0]=1 if s[0] in x
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))
  
  

### FIXED CODE ###

s=input()
x=['A','T','C','G']
a=[0]*len(s)
if s[0] in x:
  a[0]=1
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))
i = 1
while True:
  x = int(input())
  if x: print("Case {}: {}".format(i, x)) else brek
  i+=1


### FIXED CODE ###

i,x = 1,input()
while x != "0":
  print('Case '+str(i)+': '+x)
  i,x = i+1,input()
import numpy as np
import math
n = int(input())
A = np.fromstring(input(),dtype=np.int64,sep=" ")
rng = int(math.log2(np.max(A)))+1
sum = 0
for bit in range(60):
    c = int((A & 1).sum())
    sum += c *(n-c)*(1<<bit)
    A = A>>1

print(sum %(10**9+7))


### FIXED CODE ###

import numpy as np
 
 
def solve(string):
    n, *a = map(int, string.split())
    # a = ["{:060b}".format(_a) for _a in a]
    a = np.asarray(a, dtype=np.int64)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        # ans += s * (n - s) * pow(2, 59 - i, m)
        ans += s * (n - s) * pow(2, i, m) % m
        ans %= m
    return str(ans)
 
 
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    ans=ans*a[i]
    i+=1
    if(ans>1000000000000000000):
        if(0 in a==false):
            print(-1)
            exit()
        else:
            print(0)
            exit()
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n=int(input())
a=input().split()
a=list(map(int,a))
ans=1
if(0 in a):
    print(0)
    exit()

for calc in a:
    ans*=calc
    if(ans>10**18):
        print(-1)
        exit()
if(ans>10**18):
    print(-1)
else:
    print(ans)
n = int(input())
 
spot = input().split()

for i in range(len(spot)):
    spot = int(spot)

for i in range(n):
    total = 0
 
    pos = 0
    
    for l in range(n):
        if i != l:
            money = pos - spot[l]
            pos = spot[l]
            
            if money < 0:
                money *= -1
            total += money
 
    if pos < 0:
        pos *= -1
    total += pos
    
    print(total)

### FIXED CODE ###

from collections import deque

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

A.append(0)
A.appendleft(0)

A_diff = [abs(A[i+1] - A[i]) for i in range(N+1)]
A_sum = sum(A_diff)

for i in range(N):
    print(A_sum - (A_diff[i] + A_diff[i+1]) + abs(A[i+2] - A[i]))