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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def abc077_c():
    N = int(readline())
    A = np.fromiter(readline().split(), dtype=np.int32)
    B = np.fromiter(readline().split(), dtype=np.int32)
    C = np.fromiter(readline().split(), dtype=np.int32)
    A.sort()
    B.sort()
    C.sort()
    ans = 0

    # 二分探索で Ai < Bj < Ck となる個数を数える
    for i in range(N):
        # 真に大きいが条件なので Ai + 1 が入るポイントを探す
        jst = np.searchsorted(B, A[i] + 1)
        if jst == N: continue
        for j in range(jst, N):
            kst = np.searchsorted(C, B[j] + 1)
            ans += N - kst
    print(ans)

abc077_c()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc077_c():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))
    A.sort()
    B.sort()
    C.sort()
    ans = 0

    from bisect import bisect_left

    # Bjに対するCの使える個数は、前処理で求めておく
    B2C = [0] * N
    # 真に大きいが条件なので Ai + 1 が入るポイントを探す
    for j in range(N):
        B2C[j] = N - bisect_left(C, B[j]+1)
    # 累積和
    accum = [0]
    for j in range(N):
        accum.append(accum[-1] + B2C[j])

    # Ai -> B は二分探索
    for i in range(N):
        jst = bisect_left(B, A[i]+1)
        if jst == N: continue
        # 前処理済みなので、Bj以降を使ったときにCが何個使えるかはすぐわかる
        ans += accum[N] - accum[jst]
    print(ans)

abc077_c()
### BUGGY CODE ###

import sys
a = sys.stdin.readline()
A = int(a)
P = 1
W = 10 ** 9 + 7
for i in range(A):
    P *= (i+1)
P %= W
print(P)

### FIXED CODE ###

import sys
a = sys.stdin.readline()
A = int(a)
P = 1
I = 1 
W = 10 ** 9 + 7
while I <= A:
    P *= I
    I += 1
    P %= W
print(P)
### BUGGY CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
if n<1000:
  for i in range(1,n):
    if m%i==0 and is_prime(i) and is_prime(m//i) and (i==1 or m//i<n):
      print('1')
      exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break


### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
### BUGGY CODE ###

from itertools import accumulate
from bisect import bisect_right

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


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(2 * N + 2)  # N+1番目が真ん中
target = (N * (N + 1) // 2 + 1) // 2

# にぶたん
l, r = -1, 10 ** 9 + 1

while r - l > 1:
    X = (r + l) // 2
    Binary = [0] + [(1 if a > X else -1) for a in A]
    Binary = list(accumulate(Binary))

    BIT.reset()

    temp = sorted(Binary)
    order = [bisect_right(temp, b) for b in Binary]
    inversion = 0

    for x in order:
        inversion += BIT.sum(x)
        BIT.add(x, 1)

    if inversion >= target:
        l = X
    else:
        r = X

print(r)


### FIXED CODE ###

from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
A_sorted = sorted(A)


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(2 * N + 1)  # N+1番目が真ん中
target = (N * (N+1)) // 4

# にぶたん
l, r = -1, 10**9+1
if N == 1:
    print(A[0])
    exit()
while r - l > 1:
    X = (r + l) // 2
    Binary = [(1 if a > X else -1) for a in A]
    Binary = list(accumulate(Binary))

    BIT.reset()

    inversion = 0

    for j in range(N):
        inversion += BIT.sum(Binary[j] + N + 1) + (Binary[j] >= 0)
        BIT.add(Binary[j] + N + 1, 1)

    #print(X, inversion, Binary)
    if inversion >= target:
        l = X
    else:
        r = X

#print(X, inversion)
print(r)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
h, w = map(lambda x: int(x)+2, input().split())
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]

LAMP = [[0]*w for _ in range(h)]

for i in range(1, h-1):
    for j in range(1, w-1):
        if MAZE[i][j] == '.':
            L[i][j+1] = L[i][j]+1
            U[i+1][j] = U[i][j]+1
        if MAZE[i][w-j] == '.':
            R[i][w-j-1] = R[i][w-j]+1
        if MAZE[h-i][j] == '.':
            D[h-i-1][j] = D[h-i][j]+1

ans = 0
for i in range(1, h-1):
    for j in range(1, w-1):
        if MAZE[i][j] == '#':
            continue
        LAMP[i][j] = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
        ans = max(ans, LAMP[i][j])

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w = map(lambda x: int(x)+2, input().split())
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]

LAMP = [[0]*w for _ in range(h)]

for i in range(1, h-1):
    for j in range(1, w-1):
        if MAZE[i][j] == '.':
            L[i][j+1] = L[i][j]+1
        if MAZE[i][w-j] == '.':
            R[i][w-j-1] = R[i][w-j]+1

for j in range(1, w-1):
    for i in range(1, h-1):
        if MAZE[i][j] == '.':
            U[i+1][j] = U[i][j]+1
        if MAZE[h-i][j] == '.':
            D[h-i-1][j] = D[h-i][j]+1

ans = 0
for i in range(1, h-1):
    for j in range(1, w-1):
        if MAZE[i][j] == '#':
            continue
        LAMP[i][j] = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
        ans = max(ans, LAMP[i][j])

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

N, X, Y = [int(i) for i in input().split()]

p = []

for i in range(1, N):
    for j in range(1, N+1):
        if j<=X:
            p.append(j-i)
        elif j<=Y:
            if i <= X:
                p.append(min(j-i, X-i+1+Y-j))
            else:
                p.append(min(j-i, i-X+1+Y-j))
        else:
            if i <= X:
                p.append(j-i-(Y-X)+1)
            elif i <=Y:
                p.append(min(j-i, i-X+1+j-Y))
            else:
                p.append(j-i)
for k in range(1,N):
    print(p.count(k))    

### FIXED CODE ###

N, X, Y = [int(i) for i in input().split()]

p = []

for i in range(1, N):
    for j in range(i+1, N+1):
        if j<=X:
            p.append(j-i)
        elif j<=Y:
            if i <= X:
                p.append(min(j-i, X-i+1+Y-j))
            else:
                p.append(min(j-i, i-X+1+Y-j))
        else:
            if i <= X:
                p.append(j-i-(Y-X)+1)
            elif i <=Y:
                p.append(min(j-i, i-X+1+j-Y))
            else:
                p.append(j-i)
    
import collections
c = collections.Counter(p)
for k in range(1,N):
    print(c[k])
### BUGGY CODE ###

from bisect import bisect_left

n,m,q=map(int,input().split()) #0-indexed
tree=[[] for i in range(n)]
lentree=[0]*n

for i in range(m):
  l,r=map(int,input().split())
  tree[l-1].append(r-1)

for i in range(n):
  if tree[i]!=[]:
    tree[i].sort()


for i in range(n):
  lentree[i]+=len(tree[i])


for i in range(q):
  l,r=map(int,input().split())
  l-=1
  r-=1
  ans=0

  for j in range(l,r+1):
    xxx=tree[j]
    ans+=bisect_left(xxx,r+1)

  print(ans)

### FIXED CODE ###

import itertools

n,m,q=map(int,input().split()) #0-indexed

LR=[[0]*(n+1) for i in range(n+1)]

for i in range(m):
  l,r=map(int,input().split())
  LR[l][r]+=1

for i in range(n):
  LR[i]=list(itertools.accumulate(LR[i]))


for i in range(q):
  l,r=map(int,input().split())
  ans=0
  for j in range(l,r+1):
    ans+=LR[j][r]-LR[j][l-1]

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

from heapq import heappop,heappush
import math

xs,ys,xt,yt = map(int,input().split())
n = int(input())

v = [[xs,ys,0]]
for _ in range(n):
    x,y,r = map(int,input().split())
    v.append([x,y,r])
v.append([xt,yt,0])

def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[] for i in range(n+2)]
for i in range(n+2):
    for j in range(n+2):
        if i != j:
            edges[i].append((dd(v[i],v[j]),j))
            edges[j].append((dd(v[i],v[j]),i))

def dijkstra(s,n,edges):
    #edges[source] = [(cost_1,target_1),(cost_2,target_2),...]
    #import 'heap'
    d = [float('inf')] * n
    d[s] = 0
    q = [[d[s],s]]
    while q:
        dist_u, u = heappop(q)
        for c, v in edges[u]:
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q,[d[v],v])
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
from heapq import heappop,heappush
import math
 
xs,ys,xt,yt = map(int,input().split())
n = int(input())
 
v = [[xs,ys,0]]
for _ in range(n):
    x,y,r = map(int,input().split())
    v.append([x,y,r])
v.append([xt,yt,0])
 
def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[0]*(n+2) for _ in range(n+2)]
for i in range(n+2):
    for j in range(i+1,n+2):
        edges[i][j] = dd(v[i],v[j])
        edges[j][i] = dd(v[i],v[j])

def dijkstra(s,n,edges):
    #edges[i][j] : the cost of i→j
    #import 'heap'
    d = [float('inf') for _ in range(n)]
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])
### BUGGY CODE ###

#!/usr/bin/env python3
from itertools import product, permutations, combinations
N=int(input())
A=sorted(list(map(int, input().split())), reverse=True)
B=sorted(list(map(int, input().split())), reverse=True)
C=sorted(list(map(int, input().split())), reverse=True)

ret = 0
for i in C:
    small_b = [b for b in B if b < i]
    for j in small_b:
        small_a = [a for a in A if a < j]
        ret += len(small_a)

print(ret)

### FIXED CODE ###

#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
N=int(input())
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))


ret = 0
for i in range(N):
    # 中段を決めた時、その値より小さくなる上段を探す
    new_A = bisect_left(A, B[i])
    # 中段を決めた時、その値より大きくなる下段を探す
    new_C = bisect_right(C, B[i])
    # 組み合わせ
    ret += new_A * (N - new_C)

print(ret)
### BUGGY CODE ###

N = int(input())
s = []
for i in range(N):
    s.append("".join(sorted(input())))

result = 0

for i in range(N):
    for j in range(i + 1, N):
        if s[i] == s[j]:
            result += 1

print(result)

### FIXED CODE ###

from collections import Counter

N = int(input())

s = []
s_ap = s.append

for i in range(N):
    s_ap("".join(sorted(input())))

result = 0

for i in Counter(s).values():
    if not i == 1:
        result += int(i * (i - 1) / 2)
        
print(result)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
r,c,K=map(int, input().split())
grid=[[0]*(c+1) for _ in range(r+1)]
for i in range(K):
    ri,ci,vi=map(int, input().split())
    grid[ri][ci]=vi

dp=[[[0]*4 for _ in range(c+1)] for _ in range(r+1)]

for i in range(1,r+1):
    for j in range(1,c+1):
        dp[i][j][0]=max(dp[i][j][0],max(dp[i-1][j]))
        v=grid[i][j]
        if v==0:
            for k in range(4):
                dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k])
        if v!=0:
            dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0])
            dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][j])+v)
            for k in range(1,4):
                dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+v,dp[i][j-1][k])

print(max(dp[-1][-1]))

### FIXED CODE ###

R,C,K = map(int,input().split())

grid=[[0]*C for _ in range(R)]
for i in range(K):
    x,y,v = map(int,input().split())
    grid[x-1][y-1] = v
dp1 = [[0]*(C+1) for _ in range(R+1)]
dp2 = [[0]*(C+1) for _ in range(R+1)]
dp3 = [[0]*(C+1) for _ in range(R+1)]

for i in range(R):
    for j in range(C):
        dp1[i][j] = max(dp1[i][j-1],dp1[i-1][j]+grid[i][j],
                    dp2[i-1][j]+grid[i][j],dp3[i-1][j]+grid[i][j])
        dp2[i][j] = max(dp2[i][j-1],dp1[i][j-1]+grid[i][j])
        dp3[i][j] = max(dp3[i][j-1],dp2[i][j-1]+grid[i][j])
ans=0
for i in range(R):
    for j in range(C):
        ans=max(ans,dp1[i][j],dp2[i][j],dp3[i][j])
print(ans)
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split(" ")))
a = 0
for r in range(min(p) - 1, max(p)+1):
    abc = list(filter(lambda x: x < r, p))
    arc = list(filter(lambda x: x >= r, p))
    if len(abc) == len(arc) :
        a += 1
print(a)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split(" ")))
a = 0
p.sort()
n_2 = int(n / 2)
abc = p[:n_2]
arc = p[n_2:]
a = arc[0] - (abc[len(abc) - 1]) 
print(a)
### BUGGY CODE ###

import numpy as np
n = int(input())
a =  [int(input()) for i in range(n)]

[print(int(max(np.concatenate([a[:i], a[i+1:]])))) for i in range(n)]

### FIXED CODE ###

import numpy as np
n = int(input())
a =  [int(input()) for i in range(n)]
max_a_num = a.count(max(a))
b = sorted(a, reverse=True)
m1, m2 = b[0], b[1]
for i in range(n):
  if max_a_num == 1:
    if a[i] == m1:
      print(m2)
    else:
      print(m1)
  else:
    print(m2)
### BUGGY CODE ###

#!/usr/local/bin/python3
_ = int(input())
A = list(map(int, input().split()))[::-1]

ans = 0
while len(A) != 0:
    m = max(A)
    idx = A.index(m) + 1
    for i in A[:idx]:
        ans += m - i
    A = A[idx:]

print(ans)


### FIXED CODE ###

#!/usr/local/bin/python3
N = int(input())
A = list(map(int, input().split()))

m = ans = 0
for i in range(N):
    m = max(m, A[i])
    ans += m - A[i]

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

import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	NKAF=np.array(read().split(),np.int64)
	N=NKAF[0]
	K=NKAF[1]
	AF=NKAF[2:]
	A,F=np.split(AF,2)
	A.sort()
	F.sort()
	F=F[::-1]
	
	lt=0
	rt=10**12+1
	
	Asum=sum(A)
	
	while rt-lt>1:
		mid=(rt+lt)//2
		if Asum-sum(np.minimum(A,mid//F))<=K:
			rt=mid
		else:
			lt=mid
	print(rt if Asum-K>0 else 0)
	
if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	NKAF=np.array(read().split(),np.int64)
	N=NKAF[0]
	K=NKAF[1]
	AF=NKAF[2:]
	A,F=np.split(AF,2)
	A.sort()
	F.sort()
	F=F[::-1]
	
	lt=0
	rt=10**12+1
	
	Asum=sum(A)
	
	while rt-lt>1:
		mid=(rt+lt)//2
		if Asum-np.minimum(A,mid//F).sum()<=K:
			rt=mid
		else:
			lt=mid
	print(rt if Asum-K>0 else 0)
	
if __name__ == '__main__':
	main()
### BUGGY CODE ###

from collections import defaultdict
from fractions import Fraction

memo = {}

def dfs(i, a, b):
    if a != 0 and b != 0 and Fraction(a, b) == Fraction(Ma, Mb):
        return 0
    if i == N:
        return 10 ** 10

    if (i, a, b) in memo:
        return memo[(i, a, b)]

    ans = dfs(i + 1, a + l[i][0], b + l[i][1]) + l[i][2]
    ans = min(ans, dfs(i + 1, a, b))

    memo[(i, a, b)] = ans
    return ans


if __name__ == '__main__':

    N, Ma, Mb = map(int, input().split())
    l = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        l.append((a, b, c))

    s = dfs(0, 0, 0)
    if s >= 10 ** 10:
        print(-1)
    else:
        print(s)


### FIXED CODE ###

from collections import defaultdict
from fractions import Fraction

INF = int(1e14)


def main():
    N, Ma, Mb = map(int, input().split())
    l = []
    for _ in range(N):
        l.append(tuple(map(int, input().split())))

    ans = INF
    dp = [[[INF] * 401 for i in range(401)] for j in range(N + 1)]
    dp[0][0][0] = 0

    max_a, max_b = 1, 1
    for i in range(N):

        for a in range(max_a, -1, -1):
            for b in range(max_b, -1, -1):
                if dp[i][a][b] != INF:
                    dp[i + 1][a + l[i][0]][b + l[i][1]] = min(dp[i + 1][a + l[i][0]][b + l[i][1]], dp[i][a][b] + l[i][2])
                    dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])

                    max_a = max(max_a, a + l[i][0])
                    max_b = max(max_b, b + l[i][1])

    for a in range(1, len(dp[0])):
        for b in range(1, len(dp[1])):
            if a * Mb == b * Ma:
                ans = min(ans, dp[N][a][b])

    print((-1 if ans == INF else ans))

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

# 初期入力
N = int(input())
k = list(map(int, input().split()))

# 書かれている数字のぼーるがいくつあるか、辞書
from collections import Counter
A =Counter(k)

from math import factorial
def nC2(n): # 組み合わせ n「C」r
    if  n<2:
        return 0
    return n*(n-1)//2

# 順番付きの辞書
from collections import OrderedDict
D = OrderedDict()
D2 = OrderedDict()

# 各数字を連続でとる場合の数
futatu_onaji =0

x =[ nC2(v) for i,v in A.items() ]    # n個の中から2つをとる組み合わせ
futatu_onaji = sum(x)

#D =[0]*N
D =[]

D = [ futatu_onaji - (vj -1) for i,v in enumerate(k) for ij,vj in A.items() if v == ij] #vj-1 = 最初のボールと同じ番号を次に取る場合の数
print(*D,sep="\n")

### FIXED CODE ###

from collections import Counter 
N = int(input())
A = list(map(int, input().split()))
c_A = Counter(A)
all =sum( [i*(i-1)//2 for i in c_A.values()] )

for i in range(N):
    ans =all -( c_A[A[i]] -1)
    print(ans)
### BUGGY CODE ###

s=input()
d=s.split()
n=int(d[0])
q=int(d[1])
end_t=0
processes=[]
for i in range(n):
    processes.append([])
    s=input()
    d=s.split()
    processes[i].append(d[0])
    processes[i].append(int(d[1]))

cnt=0
i=0
while True:
    if processes[i][1]<=q:
       if processes[i][1]==0:
           i=(i+1)%n
           continue
       end_t+=processes[i][1]
       processes[i][1]=0
       print(processes[i][0],end_t)
       i=(i+1)%n
       cnt+=1
       if cnt==n:
           break
   
    else:
       processes[i][1]-=q
       end_t+=q
       i=(i+1)%n



### FIXED CODE ###

s=input()
d=s.split()
n=int(d[0])
q=int(d[1])
end_t=0
processes=[]
for i in range(n):
    processes.append([])
    s=input()
    d=s.split()
    processes[i].append(d[0])
    processes[i].append(int(d[1]))

cnt=0
i=0
while True:
    if processes[0][1]<=q:
       end_t+=processes[0][1]
       print(processes[0][0],end_t)
       processes.pop(0)
       cnt+=1
       if cnt==n:
           break
   
    else:
       processes[0][1]-=q
       end_t+=q
       processes.append(processes[0])
       processes.pop(0)
       i+=1
### BUGGY CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(10**6)

@lru_cache(maxsize=None)
def dfs(v,p,d):
    for i, j in tree[v]:
        if i != p:
            depth[i] = d + j
            dfs(i,v,d+j)

N = int(input())

tree = [[] for _ in range(N)]

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

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

depth = [0 for i in range(N)]
depth[K-1] = 0

dfs(K-1,-1,0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(depth[x-1] + depth[y-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
def dfs(v,p,d):
    for i, j in tree[v]:
        if i != p:
            depth[i] = d + j
            dfs(i,v,d+j)

N = int(input())

tree = [[] for _ in range(N)]

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

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

depth = [0 for i in range(N)]
depth[K-1] = 0

dfs(K-1,-1,0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(depth[x-1] + depth[y-1])
### BUGGY CODE ###

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
a=lnii()

p=1
for i in range(k):
  p*=a[i]

for i in range(k,n):
  old_p=p
  p//=a[i-k]
  p*=a[i]
  if old_p<p:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
a=lnii()

for i in range(k,n):
  old=a[i-k]
  new=a[i]
  if old<new:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

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


A = [0] + A + [0]

for i in range(N):
	ans = []
	ans_list = A[:i+1] + A[i+2:]
	for i in range(N):
		ans.append(abs(ans_list[i+1] - ans_list[i]))
	print(sum(ans))

### FIXED CODE ###

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


A = [0] + A + [0]
d = 0
for i in range(N+1):
	d += abs(A[i+1]- A[i])

for i in range(N):
	ans = d - abs(A[i+2]- A[i+1]) - abs(A[i+1]- A[i]) + abs(A[i+2]-A[i])
	print(ans)