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

import collections
from itertools import combinations
N = int(input())
ab = [tuple(map(int, input().split())) for i in range(N-1)]
M = int(input())
uv = [tuple(map(int, input().split())) for i in range(M)]


def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)

    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


G = [[-1]*N for i in range(N)]
for i in range(N-1):
    a, b = ab[i]
    a -= 1
    b -= 1
    G[a][b] = i
    G[b][a] = i

q = collections.deque()

G2 = [[0 for j in range(N)] for i in range(N)]

for i in range(N):
    q.append((i, 0))
    reached = [False]*N
    reached[i] = True
    while(q):
        x, s = q.popleft()
        for y in range(N):
            if G[x][y] == -1 or reached[y]:
                continue
            else:
                G2[i][y] = s | (1 << G[x][y])
                q.append((y, s | 1 << G[x][y]))
                reached[y] = True


ans = 2**(N-1)
ans2 = 0
for i in range(1, M+1):
    for x in combinations(range(M), i):
        tmp = 2**(N-1) - 1
        for y in x:
            u, v = uv[y]
            u -= 1
            v -= 1
            tmp &= ~G2[u][v]
        ans2 += ((-1)**(i-1)) * 2 ** popcount(tmp)
    # print(ans2, i)

print(ans-ans2)


### FIXED CODE ###

import collections
from itertools import combinations
N = int(input())
ab = [tuple(map(int, input().split())) for i in range(N-1)]
M = int(input())
uv = [tuple(map(int, input().split())) for i in range(M)]


def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


G = [[-1]*N for i in range(N)]
for i in range(N-1):
    a, b = ab[i]
    a -= 1
    b -= 1
    G[a][b] = i
    G[b][a] = i

q = collections.deque()

G2 = [[0 for j in range(N)] for i in range(N)]

for i in range(N):
    q.append((i, 0))
    reached = [False]*N
    reached[i] = True
    while(q):
        x, s = q.popleft()
        for y in range(N):
            if G[x][y] == -1 or reached[y]:
                continue
            else:
                G2[i][y] = s | (1 << G[x][y])
                q.append((y, s | 1 << G[x][y]))
                reached[y] = True


ans = 2**(N-1)
ans2 = 0
for i in range(1, 2**M):
    tmp = 2**(N-1) - 1
    for j in range(M):
        if (i >> j) % 2 == 1:
            u, v = uv[j]
            u -= 1
            v -= 1
            tmp &= ~G2[u][v]
    ans2 += ((-1)**(popcount(i)-1)) * (1 << popcount(tmp))
    # print(ans2, i)
print(ans-ans2)
### BUGGY CODE ###

import numpy as np

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = np.zeros(Q, dtype=np.int32), np.zeros(Q, dtype=np.int32)
for i in range(Q):
    [b, c] = list(map(int, input().split()))
    B[i], C[i] = b, c


for i in range(Q):
    A = np.where(A==B[i], C[i], A)
    print(np.sum(A))


### FIXED CODE ###

import array

N = int(input())
A = array.array('L', list(map(int, input().split())))
MAX = 10**5+1
X = array.array('L', [0]) * MAX
Y = array.array('L', range(MAX))

for i in range(len(A)): X[A[i]] += 1
    
Q = int(input())
cur = sum(array.array('L', (X[i]*Y[i] for i in range(len(X)))))

for i in range(Q):
    [b, c] = list(map(int, input().split()))
    cur = cur - X[b]*b + X[b]*c
    print(cur)
    X[c] += X[b]
    X[b] = 0
### BUGGY CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import bellman_ford, connected_components
from scipy.sparse import csr_matrix
input = sys.stdin.readline


def main():
    n, m, p = map(int, input().split())
    
    l = np.zeros((n, n))
    for i in range(m):
        a, b, c =map(int, input().split())
        c = p-c
        if c == 0:
            c = 10**(-7.9)
        if l[a-1][b-1] == 0:
            l[a-1][b-1] = c
        else:
            l[a-1][b-1] = min(l[a-1][b-1], c)
    x = l[-1, 0]
    l[-1][0] = 10**(-7.9)
    n, labels = connected_components(l, connection="strong")
    l = l[labels == labels[0]][:, labels == labels[0]]
    l[-1, 0] = x
    
    try:
        print(max(0, int(bellman_ford(csr_matrix(l))[0][-1])*(-1)))
    except:
        print(-1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import bellman_ford, connected_components
input = sys.stdin.readline


def main():
    n, m, p = map(int, input().split())
    
    l = np.zeros((n, n))
    for i in range(m):
        a, b, c =map(int, input().split())
        c = p-c
        if c == 0:
            c = 10**(-7.9)
        if l[a-1][b-1] == 0:
            l[a-1][b-1] = c
        else:
            l[a-1][b-1] = min(l[a-1][b-1], c)
    x = l[-1, 0]
    l[-1][0] = 10**(-7.9)
    n, labels = connected_components(l, connection="strong")
    l = l[labels == labels[0]][:, labels == labels[0]]
    l[-1, 0] = x
    
    try:
        print(max(0, int(round(bellman_ford(l, indices=0)[-1]))*(-1)))
    except:
        print(-1)


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

r, g, b, n = map(int, input().split())
ans = 0
for i in range(3001):
    if r * i > n:
        break
    for j in range(3001):
        if r * i + g * j > n:
            break
        if (n - r * i - g * j) % b == 0:
            ans += 1
print(ans)

### FIXED CODE ###

r, g, b, n = map(int, input().split())
ans = 0
for i in range(3001):
    if r * i > n:
        break
    for j in range(3001):
        if r * i + g * j > n:
            break
        if (n - r * i - g * j) % b == 0:
            ans += 1
print(ans)
### BUGGY CODE ###

a = input()
list = input().split()
b = len(list)
for j in range(b):
	list[j] = int(list[j])
for k in range(b-1):
	l = k + 1
	while l < b:
		if list[k] > list[l]:
			temp = list[k]
			list[k] = list[l]
			list[l] = temp
		l += 1
gcd = int(list[0])
for i in range(b):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)

### FIXED CODE ###

a = input()
list = list(map(int,input().split()))
b = len(list)
gcd = int(list[0])
for i in range(b):
	m = list[i] 
	n = gcd
	while n != 0:
		m,n = n,m%n
	if(m<gcd):
		gcd = m
print(gcd)
### BUGGY CODE ###

n,x=map(int,input().split())
B=[1]
for i in range(n):
    B=[0]+B+[1]+B+[0]
print(sum(B[:x]))

### FIXED CODE ###

n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)


class Node:
    def __init__(self, index):
        self.index = index
        self.ref = []
        self.visited = False

    def append(self, node):
        self.ref.append(node)
        node.ref.append(self)

    def visit(self):
        self.visited = True
        for r in self.ref:
            if not r.visited:
                r.visit()


def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    nodes = [Node(i) for i in range(N)]
    X = [x-1 for x in X]
    Y = [y-1 for y in Y]
    for i in range(M):
        nodes[X[i]].append(nodes[Y[i]])
    sum = 0
    for i in range(N):
        if not nodes[i].visited:
            sum += 1
            nodes[i].visit()
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    Z = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
        Z[i] = int(next(tokens))
    solve(N, M, X, Y, Z)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)


class Node:
    def __init__(self, index):
        self.index = index
        self.ref = []
        self.visited = False

    def append(self, node):
        self.ref.append(node)
        node.ref.append(self)

    def visit(self):
        self.visited = True
        for r in self.ref:
            if not r.visited:
                r.visit()


def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    nodes = [Node(i) for i in range(N)]
    X = [x-1 for x in X]
    Y = [y-1 for y in Y]
    for i in range(M):
        nodes[X[i]].append(nodes[Y[i]])
    sum = 0
    for i in range(N):
        if not nodes[i].visited:
            sum += 1
            nodes[i].visit()
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    Z = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
        Z[i] = int(next(tokens))
    solve(N, M, X, Y, Z)


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

import sys
sys.setrecursionlimit(10 ** 7)


def dfs(tree, count, p):
    # print(p, tree[p])
    for i in tree[p]:
        # if i == p:
        #     continue
        count[i] += count[p]
        dfs(tree, count, i)


# def solve(tree, count):

def remove_parents(tree, p):
    for i in tree[p]:
        tree[i].remove(p)
        remove_parents(tree, i)


def main():
    N, Q = map(int, input().split())
    tree = {i+1: set() for i in range(N)}
    count = {i+1: 0 for i in range(N)}

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

    for _ in range(Q):
        p, x = map(int, input().split())
        count[p] += x

    # print(count)

    # visited = {k+1: False for k in range(N)}
    # visited[1] = True

    remove_parents(tree, 1)
    # print(tree)
    dfs(tree, count, 1)

    ans = [str(count[k]) for k in sorted(count.keys())]
    print(" ".join(ans))


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict, deque


def main():
    N, Q = map(int, input().split())

    tree = defaultdict(list)
    counter = defaultdict(int)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p, x = map(int, input().split())
        counter[p] += x

    # bfs
    q = deque([1])
    visited = {1}

    while q:
        i = q.popleft()

        for j in tree[i]:
            if j not in visited:
                q.append(j)
                counter[j] += counter[i]
                visited.add(j)

    counts = [counter[i] for i in range(1, N+1)]
    ans = " ".join(map(str, counts))
    print(ans)



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

from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len({i for i in s})
for i in range(1,set_s+1):
    koho=tuple(combinations(s,i))
    ex=tuple([j for j in koho if len(j)==len(tuple(set(j)))])
    ans+=len(ex)
print(ans%(10**9+7))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))
### BUGGY CODE ###

n = int(input())
c = input()
c = list(c)
arr = []
for i in range(n + 1):
  a =  c[:i].count('W')
  b = c[i:].count('R')
  arr.append(max(a, b))
ans = min(arr)
print(ans)

### FIXED CODE ###

n = int(input())
c = input()
c = list(c)
arr = []
a = 0
b = c.count('R')
arr.append(max(a, b))
for i in range(n):
  if c[i] == 'W':
    a += 1
  elif c[i] == 'R':
    b -= 1
  arr.append(max(a, b))
ans = min(arr)
print(ans)
### BUGGY CODE ###

def solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = map(sorted, [abc[:x], abc[x:x + y], abc[x + y:]])
    ans = []
    for ia, _a in enumerate(a[::-1]):
        for ib, _b in enumerate(b[::-1]):
            for ic, _c in enumerate(c[::-1]):
                if ia * ib * ic < k:
                    ans.append(_a + _b + _c)
                else:
                    break
    return "\n".join(list(map(str, sorted(ans, reverse=True)[:k])))


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(4)])))


### FIXED CODE ###

def solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a = abc[:x]
    b = abc[x:x + y]
    c = abc[x + y:]
    ab = sorted([_a + _b for _b in b for _a in a])[-k:]
    *abc, = map(str, sorted([_ab + _c for _c in c for _ab in ab], reverse=True)[:k])
    return "\n".join(abc)


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(4)])))
### BUGGY CODE ###

N,K=map(int, input().split())
K2 = 2*K
inmap = [[0]*(K) for _ in range(K2)]
accmap = [[0]*(K+1) for _ in range(K2+1)]
inmapdeb = {}
for i in range(N):
    line = input().split()
    x, y, wb = int(line[0]), int(line[1]), line[2]
    if wb == 'W':
        x += K
    y %= K2
    if y >= K:
        y = y%K
        x = (x+K) %K2
    else:
        x = x % K2
    inmap[x][y] += 1
#     if not (x,y) in inmapdeb:
#         inmapdeb[(x,y)] = 1
#     else:
#         inmapdeb[(x,y)] += 1
# print(inmapdeb)

for i in range(K2):
    for j in range(K):
        accmap[i+1][j+1] = inmap[i][j] + accmap[i+1][j] + accmap[i][j+1] - accmap[i][j]

res = 0
for i in range(K):
    for j in range(K):
        # print(i,j)
        cand = 2*(accmap[i][j] - accmap[i+K][j]) + accmap[i+K][K] - accmap[i][K] + accmap[K2][j]
        # print("i{} j{} res:{}".format(i,j,cand))
        res = max(res, cand, N-cand)

print(res)


### FIXED CODE ###

N,K=map(int, input().split())
K2 = 2*K
inmap = [[0]*(K) for _ in range(K2)]
accmap = [[0]*(K+1) for _ in range(K2+1)]
inmapdeb = {}
for i in range(N):
    line = input().split()
    x, y, wb = int(line[0]), int(line[1]), line[2]
    if wb == 'W':
        x += K
    y %= K2
    if y >= K:
        y = y%K
        x = (x+K) %K2
    else:
        x = x % K2
    inmap[x][y] += 1
#     if not (x,y) in inmapdeb:
#         inmapdeb[(x,y)] = 1
#     else:
#         inmapdeb[(x,y)] += 1
# print(inmapdeb)

def calc(x, y):
    return accmap[x][y] \
        + (accmap[x+K][K] - accmap[x][K] - accmap[x+K][y] + accmap[x][y]) \
        + (accmap[K2][y] - accmap[x+K][y])

for i in range(K2):
    for j in range(K):
        accmap[i+1][j+1] = inmap[i][j] + accmap[i+1][j] + accmap[i][j+1] - accmap[i][j]

res = 0
for i in range(K):
    for j in range(K):
        # print(i,j)
        cand = calc(i, j)
        # print("i{} j{} res:{}".format(i,j,cand))
        res = max(res, cand, N-cand)

print(res)
### BUGGY CODE ###

n ,k = map(int,input().split())
a = list(map(int,input().split()))
 
max_d = 0
 
for i in range(n - k + 1):
    d = 0
    for j in range(k):
        d += (1 + a[i + j])/2
    if d > max_d:
        max_d = d
 
 
print(max_d)

### FIXED CODE ###

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

max_d = sum(a[0:k])
max_i = 0
total = sum(a[0:k])


for i in range(1,n - k + 1):
    total = total - a[i - 1] + a[i + k - 1]

    if total > max_d:
        max_d = total
        max_i = i

ans = 0
for i in range(max_i,max_i + k):
    ans += (1 + a[i])/2
print("{:7f}".format(ans))
### BUGGY CODE ###

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

reverse = False
for i in range(Q):
    inp = input().split()
    if inp[0] == "1":
        reverse = not reverse
        #S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            if reverse:
                S.append(c)
            else:
                S.insert(0, c)
        else:
            if reverse:
                S.insert(0, c)
            else:
                S.append(c)
S = "".join(S)
print(S[::-1] if reverse else S)

### FIXED CODE ###

from collections import deque

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

reverse = False
cnt = 0
for i in range(Q):
    inp = input().split()
    if inp[0] == "1":
        cnt += 1
        reverse = (cnt % 2 != 0)
        #S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            if reverse:
                S.append(c)
            else:
                S.appendleft(c)
        else:
            if reverse:
                S.appendleft(c)
            else:
                S.append(c)
S = "".join(S)
print(S[::-1] if reverse else S)
### BUGGY CODE ###

def main():
  from collections import defaultdict
  from heapq import heappush,heappop
  inf=10**18
  n,m,*t=map(int,open(0).read().split())
  e=defaultdict(list)
  s=[]
  l=[]
  f=g=False
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    if a<2:f=True
    if b==n:g=True
    x,y=a+n*c,b+n*c
    if b==n:l.append(y)
    e[a].append((1,x))
    e[b].append((1,y))
    ex,ey=e[x].append,e[y].append
    ex((0,a))
    ex((0,y))
    ey((0,b))
    ey((0,x))
    s.extend([a,b,x,y])
  if not(f and g):
    print(-1)
    exit()
  d={i:v for v,i in enumerate(sorted(set(s)))}
  l=[d[i]for i in l]
  n=len(d)
  edge=[[]for _ in range(n)]
  for i in e:
    edge[d[i]]=[(c,d[j])for c,j in e[i]]
  edge=tuple(edge)
  d=[inf]*n
  used=[True]*n
  d[0]=0
  used[0]=False
  edgelist=[]
  for e in edge[0]:
    heappush(edgelist,e)
  while len(edgelist):
    minedge=heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    d[v]=minedge[0]
    used[v]=False
    for e in edge[v]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+d[v],e[1]))
  a=min(d[i]for i in l)
  print([a,-1][a==inf])
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  from heapq import heappush,heappop,heapify
  inf=2**31-1
  n,m,*t=map(int,open(0).read().split())
  z=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    z.extend([a,b,a+n*c,b+n*c])
  z={i:v for v,i in enumerate(sorted(set(z)))}
  try:
    z[1]
  except:
    print(-1)
    exit()
  edge=[[]for _ in range(len(z))]
  d={}
  l=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    i,j,x,y=z[a],z[b],z[a+n*c],z[b+n*c]
    if b==n:
      l.append(y)
    edge[i].append((1,x))
    edge[j].append((1,y))
    edge[x].extend([(0,i),(0,y)])
    edge[y].extend([(0,j),(0,x)])
  used=[False]+[True]*~-len(z)
  d=[0]+[inf]*~-len(z)
  edgelist=edge[0]
  heapify(edgelist)
  while edgelist:
    m=heappop(edgelist)
    if not used[m[1]]:
      continue
    d[m[1]]=m[0]
    used[m[1]]=False
    for e in edge[m[1]]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+m[0],e[1]))
  a=min([d[i]for i in l]or[inf])
  print([a,-1][a==inf])
if __name__=='__main__':
  main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
H, W = map(int, input().split())
Maze = [[0]*W for _ in range(H)]
Memo = [[0]*W for _ in range(H)]
Memo[H-1][W-1] = 1
for i in range(H):
    S = input()
    for j in range(W):
        Maze[i][j] = S[j]

dx = [1, 0]
dy = [0, 1]


def clear_maze(x, y):
    if (x == W) and (y == H):
        return 1
    if Memo[y-1][x-1] != 0:
        return Memo[y-1][x-1]
    ans = 0
    for z in range(2):
        nx = x + dx[z]
        ny = y + dy[z]
        if (nx > W) or (ny > H):
            continue
        if Maze[ny-1][nx-1] == '.':
            ans += clear_maze(nx, ny)
    ans %= mod
    Memo[y-1][x-1] = ans
    return ans


print(clear_maze(1, 1) % mod)

### FIXED CODE ###

mod = 10**9 + 7
H, W = map(int, input().split())
Maze = [[0]*(W+1) for _ in range(H+1)]
Memo = [[0]*(W+1) for _ in range(H+1)]
Memo[H-1][W-1] = 1
for i in range(H):
    S = input()
    for j in range(W):
        Maze[i][j] = S[j]

for a in range(H-1, -1, -1):
    for b in range(W-1, -1, -1):
        if Maze[a][b] == '#':
            Memo[a][b] = 0
        elif (a == H-1) and (b == W-1):
            continue
        else:
            Memo[a][b] = Memo[a+1][b] + Memo[a][b+1]
            Memo[a][b] %= mod
print(Memo[0][0])
### BUGGY CODE ###

import bisect

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

S = [A[0]]
for i in range(1,N):
    S.append(S[i-1]+A[i])

ans = 1e18
for i in range(2, N-1):
    left = S[:i]
    m = bisect.bisect(left, left[-1]/2)

    if m == 0:
        L = [left[0], left[-1]-left[0]]
    else:
        L = [left[m], left[-1]-left[m]]
        L2 = [left[m-1], left[-1]-left[m-1]]

        if(abs(L[0]-L[1]) > abs(L2[0]-L2[1])): L = L2

    right = S[i:]
    m = bisect.bisect(right, (right[-1]-left[-1])/2 + left[-1])
    if m == 0:
        R = [right[0]-left[-1], right[-1]-right[0]]
    else:
        R = [right[m]-left[-1], right[-1]-right[m]]
        R2 = [right[m-1]-left[-1], right[-1]-right[m-1]]

        if(abs(R[0]-R[1]) > abs(R2[0]-R2[1])): R = R2

    #print(L)
    #print(R)

    ans = min(ans, max(L[0],L[1],R[0],R[1]) - min(L[0],L[1],R[0],R[1]))

print(ans)



### FIXED CODE ###

import bisect

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

S = [A[0]]
for i in range(1,N):
    S.append(S[i-1]+A[i])

ans = 1e18
for i in range(2, N-1):
    # 左側 [0,i)
    left_sum = S[i-1]
    m = bisect.bisect(S, left_sum/2)

    L = [S[m], left_sum-S[m]]

    if m != 0:
        L2 = [S[m-1], left_sum - S[m-1]]
        if(abs(L[0]-L[1]) > abs(L2[0]-L2[1])): L = L2

    # 右側 [i,N)
    m = bisect.bisect(S, (S[-1]+left_sum)/2)
    R = [S[m]-left_sum, S[-1]-S[m]]

    if m != i:
        R2 = [S[m-1]-left_sum, S[-1]-S[m-1]]
        if(abs(R[0]-R[1]) > abs(R2[0]-R2[1])): R = R2


    ans = min(ans, max(L[0],L[1],R[0],R[1]) - min(L[0],L[1],R[0],R[1]))

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

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []
for i in range(tmp[0]):
    H.append(int(input()))

cnt = 0
while True:
    H = list(sorted(H))[::-1]
    flg = 0
    cnt += 1
    H[0] = H[0] - a
    for i in range(len(H)):
        if i == 0:
            if H[0] > 0:
                flg = 1
            continue
        H[i] = H[i] - b
        if H[i] > 0:
            flg = 1
    if flg == 0:
        break

print(cnt)


### FIXED CODE ###

import math

def calc(H, T, a, b):
    cnt = 0
    for h in H:
        if (h -b*T) >= 0:
            cnt += math.ceil((h - b * T) / (a - b))
    if cnt <= T:
        return True
    else:
        return False

tmp = [int(n) for n in input().split()]
a = tmp[1]
b = tmp[2]
H = []

H = sorted([int(input()) for i in range(tmp[0])])[::-1]
minT = 0
maxT = math.ceil(H[0] / b)
T = int((maxT + minT) / 2)

while True:
    T = math.ceil((maxT + minT) / 2)
    if calc(H, T, a, b):
        maxT = T
    else:
        minT = T
    if maxT - minT <= 1:
        break
print(maxT)
### BUGGY CODE ###

def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    #print(kitalis)
    ans = 0
    for i in range(len(kitalis)-k+1):
        if ans < sum(kitalis[i:i+k]):
            ans = sum(kitalis[i:i+k])
            #print(kitalis[i:i+k])
    print(ans)



    
if __name__ == "__main__":
    main()


### FIXED CODE ###

def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = tuple(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    kitadic = {}
    kitadic[0] = kitalis[0] 
    for i in range(1, n):
        kitadic[i] = kitadic[i-1] + kitalis[i]
       
    tmp = 0
    if n == k:
        print(kitadic[n-1])
    else:
        for i in range(n - k):
            atai = kitadic[i+k] - kitadic[i]
            if tmp < atai:
                tmp = atai
        print(tmp)
        exit()



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

N = int(input())
m = [0] * (N+1)
counter = 0
for i in range(1,N+1):
    j = 1
    while i*j <= N:
        m[i*j] += 1
        j += 1
    counter += m[i] * i
print(counter)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1,N+1):
    x = N // i
    ans += x * (x+1) * i // 2
print(ans)