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

import heapq
X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
Q = [(-A[0]-B[0]-C[0],0,0,0)]
heapq.heapify(Q)
abc = [[[1 for i in range(Z)] for j in range(Y)] for k in range(X)]
for i in range(K):
    n,a,b,c = heapq.heappop(Q)
    if a < X-1 and abc[a+1][b][c]:
        abc[a+1][b][c] = 0
        heapq.heappush(Q,(n+A[a]-A[a+1],a+1,b,c))
    if b < Y-1 and abc[a][b+1][c]:
        abc[a][b+1][c] = 0
        heapq.heappush(Q,(n+B[b]-B[b+1],a,b+1,c))
    if c < Z-1 and abc[a][b][c+1]:
        abc[a][b][c+1] = 0
        heapq.heappush(Q,(n+C[c]-C[c+1],a,b,c+1))
    print(-n)

### FIXED CODE ###

from itertools import product
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
AB = sorted([a+b for a,b in product(A,B)],reverse=True)[:K]
ans = sorted([a+b for a,b in product(AB,C)],reverse=True)[:K]
for i in ans:
    print(i)
### BUGGY CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

nq = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            nq.append([i, j])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

cnt = 0
while sum(sum(grid, [])) < h * w:
    cnt += 1
    q = copy.deepcopy(nq)
    while q:
        curr = q.popleft()
        for m in moves:
            nx, ny = curr[0] + m[0], curr[1] + m[1]
            if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
                continue
            else:
                nq.append([nx, ny])
                grid[nx][ny] = True

print(cnt)

### FIXED CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

q = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            q.append([i, j, 0])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

ans = 0
while q:
    curr = q.popleft()
    ans = max(ans, curr[2])
    for m in moves:
        nx, ny = curr[0] + m[0], curr[1] + m[1]
        if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
            continue
        else:
            q.append([nx, ny, curr[2] + 1])
            grid[nx][ny] = True

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

from bisect import insort_left

X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            insort_left(Q, R[i])
            Q = Q[1:]
    else:
        if P[0] < R[i]:
            insort_left(P, R[i])
            P = P[1:]
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))

### FIXED CODE ###

import heapq
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))
### BUGGY CODE ###

ans = 0
n = int(input())
a = list(map(int,input().split()))

amax = max(a)
amin = min(a)

max = amax * 2

'''
if amin * 2 < n:
    print(0)
'''  
    
for i in range(n):
    j = i + 1 + amin

    while(j < n and j <= i + max):
        if abs(j - i) == a[i] + a[j]:
            ans = ans + 1
        j = j + 1

print(ans)


### FIXED CODE ###

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

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

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

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

ans=1
for i in range(n):
    ans*=a[i]

if ans>10**18:
    print(-1)
    exit()
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()

ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a];e[i]+=e[i-a];i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print(z+~s%2*e[s//2]*3)%M

### FIXED CODE ###

M,z,s=998244353,1,0
N,*A=map(int,open(0))
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for a in A:
 i=s;s+=a;z*=3
 while~i:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print((z+~s%2*e[s//2]*3)%M)
### BUGGY CODE ###

n = int(input())
# リスト内包表記
numList  = [input() for i in range(n)]

workList = numList.copy()
for j in range(n):
  workList.remove(numList[j])
  print(max(set(workList)))
  workList = numList.copy()

### FIXED CODE ###

n = int(input())
numList  = [int(input()) for i in range(n)]
maxVal = max(numList)
workList = numList[:]
workList.remove(maxVal)
secondVal = max(workList)
for num in numList:
  if num != maxVal:
    print(maxVal)
  else:
    print(secondVal)
### BUGGY CODE ###

def main():
    n = int(input())
    ans = [0]*(n+1)
    for p in range(1,n+1):
        for i in range(1,int(p**0.5+1)):
            for j in range(1,int(p**0.5+1)):
                t = (i+j)**2-4*(i**2+j**2+i*j-p)
                if t<0:
                    continue
                k = (t**0.5-i-j)/2
                if k.is_integer() and k>0:
                    ans[p] +=1

    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5+1)):
        for j in range(1,int(n**0.5+1)):
            for k in range(1,int(n**0.5+1)):
                t = i**2+j**2+k**2+i*j+j*k+k*i
                if t<=n:
                    ans[t] += 1
    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import heapq

mINF=-10**10

N,K=list(map(int,input().split(" ")))

arr=[mINF]*N
for z in range(N):
  heapq.heapreplace(arr,int(input()))

arr2=[mINF]*K
for z in range(K):
  heapq.heapreplace(arr2,heapq.heappop(arr))

r=max(arr2)-min(arr2)

try:
  while True:
    heapq.heapreplace(arr2,heapq.heappop(arr))
    rb=max(arr2)-min(arr2)
    if rb<r:
      r=rb
except Exception:
  pass

print(r)


### FIXED CODE ###

import heapq

N,K=list(map(int,input().split(" ")))

arr=[0]*N
for z in range(N):
  heapq.heapreplace(arr,int(input()))

arr2=[0]*K
for z in range(K):
  arr2[z]=heapq.heappop(arr)

r=arr2[-1]-arr2[0]

z=0
try:
  while True:
    arr2[z]=heapq.heappop(arr)
    if z==K-1:
      zz=0
    else:
      zz=z+1

    rb=arr2[z]-arr2[zz]
    if rb<r:
      r=rb

    z+=1
    if z==K:
      z=0

except Exception:
  pass

print(r)
### BUGGY CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

#targetまでの素数の数
import math
def sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, target+1)]
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)        
        target_list = [i for i in target_list if i%num_min!=0]
 
    return prime_list
   

a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    lis = sieve_of_eratosthenes(gcd)
    ans = sum([1 for i in lis if gcd%i==0]) + 1
    print(ans)


### FIXED CODE ###

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a


import random
def is_prime(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q % 2 == 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

def prime_num(target):
    ra = 2
    prime = 0
    while target>1:
        if target%ra == 0:
            prime += 1
            while target%ra==0:
                target = target//ra
            if is_prime(target):
                prime += 1
                break
        if ra == 2:
            ra += 1
        else:
            ra += 2
    return prime   
        
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = prime_num(gcd)    
    print(ans+1)
### BUGGY CODE ###

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

B=list(itertools.combinations(A, 2))
SUM=0

for b1, b2 in B:
  SUM += b1^b2
  SUM = SUM % (10**9+7)

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

### FIXED CODE ###

import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
 
for i in range(60):
    #一桁目が1か0か調べて1の個数をカウント
    c1 = np.count_nonzero(arr & 1) 
    #1の個数×0の個数(XORだから)
    ans += 2 ** i * c1 * (n - c1)
    #桁をシフト
    arr =arr >> 1

print(ans % mod)
### BUGGY CODE ###

dummy = list(map(int, input().split(" ")))
N = dummy[0]
K = dummy[1]

H = list(map(int, input().split(" ")))

count = 0
while(count < K):
    max = -1
    max_i = -1
    for i in range(N):
        if(H[i] > max):
            max = H[i]
            max_i = i
    H[max_i] = 0
    count += 1
print(sum(H))

### FIXED CODE ###

dummy = list(map(int, input().split(" ")))
N = dummy[0]
K = dummy[1]

H = list(map(int, input().split(" ")))

H.sort(reverse = True)

for i in range(N):
    if(i < K):
        H[i] = 0

print(sum(H))
### BUGGY CODE ###

n=int(input())
s=input()
r=[[0,0,0] for _ in range(n)]
c=0
l={"GB":0,"BG":0,"RB":1,"BR":1,"RG":2,"GR":2}
for i in range(n):
  if s[i] =="R":
    r[i][0]=r[i-1][0]+1
    r[i][1]=r[i-1][1]
    r[i][2]=r[i-1][2]
  elif s[i]=="G":
    r[i][1]=r[i-1][1]+1
    r[i][0]=r[i-1][0]
    r[i][2]=r[i-1][2]
  elif s[i]=="B":
    r[i][2]=r[i-1][2]+1
    r[i][0]=r[i-1][0]
    r[i][1]=r[i-1][1]

for i in range(n-2):
  for j in range(i+1,n-1):
    if s[i]==s[j]:
      continue
    else:
      c+=r[n-1][l[s[i]+s[j]]]-r[j][l[s[i]+s[j]]]
    
      
      if 2*j-i<n:
        if s[2*j-i]!= s[i] and s[2*j-i]!=s[j]:
          c-=1
   
  
print(c)
      

### FIXED CODE ###

n=int(input())
s=input()

r=[[0,0,0] for _ in range(n)]
c=0
l={"GB":0,"BG":0,"RB":1,"BR":1,"RG":2,"GR":2}
for i in range(n):
  if s[i] =="R":
    r[i][0]=r[i-1][0]+1
    r[i][1]=r[i-1][1]
    r[i][2]=r[i-1][2]
  elif s[i]=="G":
    r[i][1]=r[i-1][1]+1
    r[i][0]=r[i-1][0]
    r[i][2]=r[i-1][2]
  elif s[i]=="B":
    r[i][2]=r[i-1][2]+1
    r[i][0]=r[i-1][0]
    r[i][1]=r[i-1][1]

for i in range(n-2):
  for j in range(i+1,n-1):
    if s[i]==s[j]:
      continue
    else:
      c+=r[n-1][l[s[i]+s[j]]]-r[j][l[s[i]+s[j]]]
     # print("p",i,j,c)
      
      if 2*j-i<n:
        if s[2*j-i]!= s[i] and s[2*j-i]!=s[j]:
          c-=1
      #   print("m",i,j,c)
  
print(c)
### BUGGY CODE ###

n = int(input())
print(0, flush=True)
syo = 0
s = input()
if s == "Vacant":
  exit()
maes = s
dai = n-1
print(n-1, flush=True)
s = input()
dais = s
if s == "Vacant":
  exit()
for _ in range(18):
  mid = (dai+syo)//2
  print(mid, flush=True)
  s = input()
  if s == "Vacant":
    exit()
  if ((mid - syo)%2 == 0 and s != syos) or ((mid - syo)%2 == 1 and s == syos):
    dai = mid
    dais = s
  else:
    syo = mid
    syos = s

### FIXED CODE ###

n = int(input())
print(0, flush=True)
syo = 0
s = input()
if s == "Vacant":
  exit()
syos = s
dai = n-1
print(n-1, flush=True)
s = input()
dais = s
if s == "Vacant":
  exit()
for _ in range(18):
  mid = (dai+syo)//2
  print(mid, flush=True)
  s = input()
  if s == "Vacant":
    exit()
  if ((mid - syo)%2 == 0 and s != syos) or ((mid - syo)%2 == 1 and s == syos):
    dai = mid
    dais = s
  else:
    syo = mid
    syos = s
### BUGGY CODE ###

import math
N = int(input())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
for i in range(N):
    x[i], y[i] = map(int, input().split())


def mindis(p, q):
    j = 0
    for i in range(N):
        if (x[i]-p)**2+(y[i]-q)**2<(x[j]-p)**2+(y[j]-q)**2:
            j = i
    return j


r = [0 for i in range(N)]
M = 25*10**5
for i in range(M):
    c = math.cos(2*math.pi*i/M)*10**10
    s = math.sin(2*math.pi*i/M)*10**10
    k = mindis(c, s)
    r[k] += 1
S = sum(r)
for i in range(N):
    print(r[i]/S)


### FIXED CODE ###

import math
N = int(input())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
for i in range(N):
    x[i], y[i] = map(int, input().split())


def mindis(t):
    j = 0
    for i in range(N):
        if x[i]*math.cos(t)+y[i]*math.sin(t)<x[j]*math.cos(t)+y[j]*math.sin(t):
            j = i
    return j


r = [0 for i in range(N)]
M = 250000
for i in range(M):
    k = mindis(2*math.pi*i/M)
    r[k] += 1
S = sum(r)
for i in range(N):
    print(r[i]/S)
### BUGGY CODE ###

S = input()

counter = 0
arr = list(S)
while True:
    x = 0
    for i in range(len(arr)-1):
        if arr[i] == 'B' and arr[i+1] == 'W':
            arr[i] = 'W'
            arr[i+1] = 'B'
            counter += 1
            x = 1
    if x == 0:
        break

print(counter)

### FIXED CODE ###

S = input()

steps = 0
accumulated_W = 0

for i, x in enumerate(list(S)):
    if x == 'W':
        steps += i - accumulated_W
        accumulated_W += 1

print(steps)
### BUGGY CODE ###

N, M = map(int,input().split())
A = [list(map(int,input().split())) for z in range(M)]
a = sorted(A)

MAP = [[0] for b in range(N + 1)]

for i in range(M):
    x, y = A[i]
    MAP[x].append(y)
    MAP[x].sort()

for j in range(M):
    ans = str(A[j][0]).zfill(6)
    ans += str(MAP[A[j][0]].index(A[j][1])).zfill(6)

    print(ans)

### FIXED CODE ###

N, M = [int(_) for _ in input().split()]
PY = [[int(_) for _ in input().split()] + [_] for _ in range(M)]
# 2番目のKeyでソート
PY.sort(key = lambda x : x[1])
# 順番カウント用
cnt = [0] * (N + 1)
ans = [""] * M

for p, y, i in PY:
    # 何番目かカウント
    cnt[p] += 1
    # 答え
    ans[i] = str(p).zfill(6) + str(cnt[p]).zfill(6)

print("\n".join(ans))
### BUGGY CODE ###

import sys

#+++++

		
def main():
	h , w = map(int, input().split())
	mm=[input() for _ in range(h)]
	
	rr_lr=[[0]*(w) for _ in range(h)]
	rr_rl=[[0]*(w) for _ in range(h)]
	rr_ud=[[0]*(w) for _ in range(h)]
	rr_du=[[0]*(w) for _ in range(h)]
							
	for hi in range(h):
		ll=0
		for wj in range(w):
			if mm[hi][wj] == '.':
				ll+=1
				rr_lr[hi][wj]=ll
			else:
				ll=0				
				
	for hi in range(h):
		ll=0
		for wj in range(w):
			if mm[hi][w-1-wj] == '.':
				ll+=1
				rr_rl[hi][w-1-wj]=ll
			else:
				ll=0				
					
	for wi in range(w):
		ll=0
		for hj in range(h):
			if mm[hj][wi] == '.':
				ll+=1
				rr_ud[hj][wi]=ll
			else:
				ll=0
				
	for wi in range(w):
		ll=0
		for hj in range(h):
			if mm[(h-1)-hj][wi] == '.':
				ll+=1
				rr_du[(h-1)-hj][wi]=ll
			else:
				ll=0
				
	ret=0
	for i in range(w):
		for j in range(h):
			vv=rr_lr[j][i]-3
			vv+=rr_rl[j][i]
			vv+=rr_du[j][i]
			vv+=rr_ud[j][i]
			ret = max(ret,vv)
	
	return ret

	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

#+++++

		
def main():
	h , w = map(int, input().split())
	mm=[input() for _ in range(h)]
	
	rr_lr=[[0]*(w) for _ in range(h)]
	rr_rl=[[0]*(w) for _ in range(h)]
	rr_ud=[[0]*(w) for _ in range(h)]
	rr_du=[[0]*(w) for _ in range(h)]
							
	for hi in range(h):
		ll=0
		rl=0
		for wj in range(w):
			if mm[hi][wj] == '.':
				ll+=1
				rr_lr[hi][wj]=ll
			else:
				ll=0				
				
			if mm[hi][w-1-wj] == '.':
				rl+=1
				rr_rl[hi][w-1-wj]=rl
			else:
				rl=0				
					
	for wi in range(w):
		ll=0
		rl=0
		for hj in range(h):
			if mm[hj][wi] == '.':
				ll+=1
				rr_ud[hj][wi]=ll
			else:
				ll=0
				
			if mm[(h-1)-hj][wi] == '.':
				rl+=1
				rr_du[(h-1)-hj][wi]=rl
			else:
				rl=0
				
	ret=0
	for i in range(w):
		for j in range(h):
			vv=rr_lr[j][i]-3
			vv+=rr_rl[j][i]
			vv+=rr_du[j][i]
			vv+=rr_ud[j][i]
			ret = max(ret,vv)
	
	return ret

	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

S = str(input())
n = int(len(S))
ans = [str(0) for i in range(n)]
cntLo = 0
cntRo = 0
cntLe = 0
cntRe = 0
for i in range(n-1):
    if S[i] == "R" and S[i+1] == "L":
        j = 1
        k = 1
        while i-j >= 0 and S[i-j] == "R":
            if j % 2 == 0:
                cntRe += 1
            else:
                cntRo += 1
            j += 1
        while i+1+k <= n-1 and S[i+1+k] == "L":
            if k % 2 == 0:
                cntLe += 1
            else:
                cntLo += 1
            j += 1
        ans[i] = str(cntRe + cntLo+1)
        ans[i+1] = str(cntRo + cntLe+1)
        cntLo = 0
        cntRo = 0
        cntLe = 0
        cntRe = 0
print(" ".join(ans))

### FIXED CODE ###

S = str(input())
n = int(len(S))
ans = [str(0) for i in range(n)]
cntLo = 0
cntRo = 0
cntLe = 0
cntRe = 0
for i in range(n-1):
    if S[i] == "R" and S[i+1] == "L":
        j = 1
        k = 1
        while i-j >= 0 and S[i-j] == "R":
            if j % 2 == 0:
                cntRe += 1
            else:
                cntRo += 1
            j += 1
        while i+1+k <= n-1 and S[i+1+k] == "L":
            if k % 2 == 0:
                cntLe += 1
            else:
                cntLo += 1
            k += 1
        ans[i] = str(cntRe + cntLo+1)
        ans[i+1] = str(cntRo + cntLe+1)
        cntLo = 0
        cntRo = 0
        cntLe = 0
        cntRe = 0
print(" ".join(ans))
### BUGGY CODE ###

# import numpy as np
# import queue
# import heapq


def main():
    n_participants = int(input())
    heights = list(map(int, input().split()))

    """
    for j>i, j-i = Ai + Aj
    i + Ai = j -Aj
    """

    L = dict()
    R = dict()

    for i, height in enumerate(heights):
        idx = i + 1
        L[idx] = idx + height

        if idx-height not in R:
            R[idx - height] = {i}
        else:
            R[idx - height].add(i)

    count = 0
    for key, value in L.items():
        if value in R:
            for v in R[value]:
                if key < v:
                    count += 1

    print(count)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import defaultdict


def main():
    _ = int(input())
    heights = list(map(int, input().split()))

    """
    for j>i, j-i = Ai + Aj
    i + Ai = j -Aj
    """

    L = defaultdict(int)
    R = defaultdict(int)

    for i, height in enumerate(heights):
        L[i + height] += 1
        R[i - height] += 1

    total_count = 0
    for x, count_l in L.items():
        if x in R:
            count_r = R[x]
            total_count += count_l * count_r

    print(total_count)


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

n,*A=map(int,open(0).read().split())
ans=0
for i in range(1,n):
  for j in range(n):
    if j+i<n:
      if A[j]+A[j+i]==i:
        ans+=1
    else:
      break
print(ans)

### FIXED CODE ###

from collections import Counter
n,*a=map(int,open(0).read().split())
l=[0]*n
r=[0]*n
for i,c in enumerate(a):
  l[i]+=c+i+1
  r[i]+=i+1-c
L=Counter(l)
R=Counter(r)
def count(A):
  ret=0
  for i in A.values():
    ret+=i*(i-1)//2
  return ret
print(count(L+R)-count(L)-count(R))
### BUGGY CODE ###

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]

V[C[0]][C[1]] = 0

pool2 = [tuple(C)]
while(pool2):
    y, x = pool2.pop()
    pool = [(y, x)]
    p = [(y, x)]
    while(pool):
        y, x = pool.pop()
        for dx, dy in [(-1,0),(1,0),(0,-1),(0,1)]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if (dx, dy) in [(-1,0),(1,0),(0,-1),(0,1)]:
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
                    V[y+dy][x+dx] = V[y][x]
                    pool.append((y+dy, x+dx))
                    p.append((y+dy, x+dx))
    q = []
    for y, x in set(p):
        for dx in [-2,-1,0,1,2]:
            for dy in [-2,-1,0,1,2]:
                if y + dy < 0 or H <= y + dy:
                    continue
                if x + dx < 0 or W <= x + dx:
                    continue
                if S[y+dy][x+dx] == "#":
                    continue
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                    V[y+dy][x+dx] = V[y][x] + 1
                    q.append((y+dy, x+dx))
    pool2 += list(set(q))
print(V[D[0]][D[1]])


### FIXED CODE ###

from collections import deque

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]

V[C[0]][C[1]] = 0

pool = deque()
pool.append(tuple([0, C[0], C[1]]))
while(pool):
    c, y, x = pool.popleft()
    if c != V[y][x]:
        continue
    for dx in [-2, -1, 0, 1, 2]:
        for dy in [-2, -1, 0, 1, 2]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if (dx, dy) in [(-1,0),(1,0),(0,-1),(0,1)]:
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
                    V[y+dy][x+dx] = V[y][x]
                    pool.appendleft((c, y+dy, x+dx))
            elif V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                V[y+dy][x+dx] = V[y][x] + 1
                pool.append((c+1, y+dy, x+dx))
print(V[D[0]][D[1]])
### BUGGY CODE ###

import sys
a,b = map(int,input().split())
base = 1
for i in range(a,b+1):
    if i == 0:
        print('Zero')
        sys.exit()
    base = base * i
if base > 0:
    print('Positive')
elif base < 0:
    print('Negative')

### FIXED CODE ###

import sys
a,b = map(int,input().split())
if a > 0:
    print('Positive')
    sys.exit()
if b >= 0:
    print('Zero')
    sys.exit()
if (b-a+1)%2 == 1:
    print('Negative')
else:
    print('Positive')
### BUGGY CODE ###

###<AOJ.1-6>
###<B>
##n = int(input())
##for i in range(n):
##    x, y = map(str,input().split())
##    y = int(y)
##    

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += i * divisor_num(i
                           )
    #print(num_divisors_table(i))

print(ans)
    




### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, n + 1):
    x, y = i, (n // i) * i
    #等差数列の和は(1/2)*(項数(今回はn//i))*(初項＋末項)
    ans += ((n // i) * (x + y) // 2)
print(ans)