Harryxun/stf_run huggingface dataset:
n, x, y = map(int, input().split())

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1,k):
    if i<=l:
      M += g(m,k-i)*2/m
  return M

A=[n]
for i in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(c)
for i in range(n-1):
  print(A[i])
    

### FIXED CODE ###

n, x, y = map(int, input().split())

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1, k):
    if  i<=l and k-i >1:
      M += g(m,k-i)*2/m
    elif i<=l:
      M +=1 
  return M
    
A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(int(c))

for i in range(n-1):
  print(A[i])
x, y = map(int, input().split())
print("{}".format(x+y/2)

### FIXED CODE ###

x, y = map(int, input().split())
print("{}".format(int(x+y/2)))
n, d, a = map(int, input().split())
x = []
h = []
for i in range(n):
    x_, h_ = map(int, input().split())
    x.append(x_)
    h.append(h_)
n_list = range(max(x))

count = 0
j = 0

for i in range(n):
    if x[i] > 0:
        print(h)
        s = x[i]
        bakuha = (h[i]//a)
        h[i] = 0
        count += bakuha
        if i < n-1:
            j = i+1
            while x[j] <= s+(2*d):
                h[j] -= bakuha*a
                if j < n-1:
                    j += 1
                    if h[j] <= 0:
                        h[j] = 0
                        break
                else:
                    break
print(count)



### FIXED CODE ###

from collections import deque
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
que = deque()
ans = 0
atk = 0
for x, h in xh:
    while que and que[0][0] <= x:
        atk -= que.popleft()[1]
    h -= a*atk
    if h <= 0:
        continue
    count = -(-h//a)
    ans += count
    atk += count
    que.append((x+2*d+1, count))
print(ans)
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()
 
start = 0
moves = []
for i in range(N-1):
    if H[i] < H[i+1]:
	    moves.append(i - start)
   	    start = i + 1
if H[N-2] >= H[N-1]:
    moves.append(i - start + 1)
print(max(moves))

### FIXED CODE ###

def solve(string):
    n, *h = map(int, string.split())
    ans = count = 0
    for h0, h1 in zip(h, h[1:]):
        if h0 >= h1:
            count += 1
        else:
            ans = max(ans, count)
            count = 0
    return str(max(ans, count))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
N,P=map(int,raw_input().split())

import sympy

Soin=sympy.factorint(P)
Soin_s=sorted(Soin.items(), key=lambda x: x[1])
Ans=1
for s_s in Soin_s:
    if s_s[1]>=N:
        Ans=Ans*(s_s[0]**(s_s[1]/N))
print Ans

### FIXED CODE ###

import collections
N,P=map(int,raw_input().split())

Soin=[]
for i in range(2,int(P**0.5)+1):
    while P%i==0:
        P=P/i
        Soin.append(i)
if P!=1:
    Soin.append(P)

Soin_s=collections.Counter(Soin)

Ans=1
for s in Soin_s:
    if Soin_s[s]>=N:
        Ans=Ans*(s**(Soin_s[s]/N))
print Ans
N, M = map(int, input().split())

even = N*(N-1)/2
odd = M*(M-1)/2

ans = even + add

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())

even = N*(N-1)/2
odd = M*(M-1)/2

print(int(even + odd))
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys
import math

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]


def main():
    n, a, b = _ia()
    count = math.ceil(n/(a+b))
    ball = []
    for _ in range(count):
        ball += ["b"] * a
        ball += ["r"] * b
    print(ball[:n].count("b"))



if __name__=="__main__":
    main()


### FIXED CODE ###

#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]


def main():
    n, a, b = _ia()
    #
    ab = n//(a+b)
    cnt = a * ab
    print(cnt + min(n-(a+b)*ab, a))


if __name__=="__main__":
    main()
a, b, c, k = [int(i) i in input().split(" ")]
print(min(a, k) - max(0, k-a-b))


### FIXED CODE ###

a, b, c, k = [int(i) for i in input().split(" ")]
print(min(a, k) - max(0, k-a-b))
import codecs

n = input()
s = input()

codecs.decode(s,'rot'+ n)

### FIXED CODE ###

n = int(input())
s = list(input())
l = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
a = []

for i in s:
  t = l.index(i)+n
  if t < 26:
    a.append(l[t])
  else:
    a.append(l[t-26])

print("".join(a))
s = input()
for '7' in list(s):
	print('Yes')
else:
	print('No')

### FIXED CODE ###

s = input()
if '7' in list(s):
	print('Yes')
else:
	print('No')
s=list(str(input()))
b=0
while len(s)>=5:
  if s[-1]=='r':
    sd=[s[-7],s[-6],s[-5],s[-4],s[-3],s[-2],s[-1]]
    se=[s[-6],s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='dreamer':
      del s[-7:]
    elif ''.join(se)=='eraser':
      del s[-6:]
    else:
      print('NO')
      b+=1
      break
  elif s[-1]=='m':
    sd=[s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='dream':
      del s[-5:]
    else:
      print('NO')
      b+=1
      break
  elif s[-1]=='e':
    sd=[s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='erase':
      del s[-5:]
    else:
      print('NO')
      b+=1
      break  
  else:
    print('NO')
    b+=1
    break
if len(s)==0:
  print('YES')
elif b!=1:
  print('NO')

### FIXED CODE ###

s=list(str(input()))
b=0
while len(s)>=7:
  if s[-1]=='r':
    sd=[s[-7],s[-6],s[-5],s[-4],s[-3],s[-2],s[-1]]
    se=[s[-6],s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='dreamer':
      del s[-7:]
    elif ''.join(se)=='eraser':
      del s[-6:]
    else:
      print('NO')
      b+=1
      break
  elif s[-1]=='m':
    sd=[s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='dream':
      del s[-5:]
    else:
      print('NO')
      b+=1
      break
  elif s[-1]=='e':
    sd=[s[-5],s[-4],s[-3],s[-2],s[-1]]
    if ''.join(sd)=='erase':
      del s[-5:]
    else:
      print('NO')
      b+=1
      break  
  else:
    print('NO')
    b+=1
    break
if len(s)==0 or (len(s)==6 and ''.join(s)=='eraser') or (len(s)==5 and ''.join(s)=='dream') or (len(s)==5 and ''.join(s)=='erase'):
  print('YES') 
elif b!=1:
  print('NO')
N, M = map(int, input().split())

B = [list(map(int, input().split())) for _ in range(M)][::-1]

S = []
pt = []
G = [-1] * (N+1)
idx = 0
cnt = 0
for pair in B:
    d = []
    for i, x in enumerate(pair):
        if G[x] >= 0:
            d.append(G[x])

    if len(d) <= 0:
        pt.append(1)
        for x in pair:
            G[x] = idx
        idx += 1
    elif len(d) == 1:
        pt.append(G.count(d[0]))
        for x in pair:
            G[x] = d[0]
    else:
        if d[0] == d[1]:
            pt.append(0)
        else:
            pt.append(G.count(d[0]) * G.count(d[1]))
            for i, x in enumerate(G):
                if x == d[1]:
                    G[i] = d[0]

cnt = 0
for x in pt[::-1]:
    cnt += x
    print(cnt)


### FIXED CODE ###

N, M = map(int, input().split())
print("{:.0f}".format((1900 * M + 100 * (N-M)) / pow(1/2, M)))
S = str(input())

data = []

count = 0
for i in range(len(S)):
    for j in range(i+4, min(i+7,len(S)+1)):
        if(int(S[i:j]) % 2019 == 0):
            count += 1
            data.append([i,j])

for i in range(len(data)):
    if(data[i][1] == data[i+1][0]):
        count += 1

print(count)

### FIXED CODE ###

from collections import Counter

S = str(input())

memo = [0]
d = 0
mod = 2019


for s in S[::-1]:
    tmp = int(s) * pow(10, d, mod) % mod
    tmp = memo[-1] + tmp
    memo.append(tmp%mod)
    d += 1

c = Counter(memo)
ans = sum(v * (v-1)/2 for v in c.values())
print(int(ans))
import heapq

q = int(input())
inf = 10000000000
left = [inf]
right = [inf]
minval = 0
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        _, a, b = query
        if a < -left[0]:
            v = -heapq.heappop(left)
            heapq.heappush(right, v)
            heapq.heappush(left, -a)
            heapq.heappush(left, -a)
            minval += abs(v - a) + b
        elif a > right[0]:
            v = heapq.heappop(roght)
            heapq.heappush(left, -v)
            heapq.heappush(right, a)
            heapq.heappush(right, a)
            minval += abs(v - a) + b
        else:
            heapq.heappush(left, -a)
            heapq.heappush(right, a)
            minval += b
    else:
        print(right[0], minval)

### FIXED CODE ###

import heapq

q = int(input())
inf = 10000000000
left = [inf]
right = [inf]
minval = 0
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        _, a, b = query
        if a < -left[0]:
            v = -heapq.heappop(left)
            heapq.heappush(right, v)
            heapq.heappush(left, -a)
            heapq.heappush(left, -a)
            minval += abs(v - a) + b
        elif a > right[0]:
            v = heapq.heappop(right)
            heapq.heappush(left, -v)
            heapq.heappush(right, a)
            heapq.heappush(right, a)
            minval += abs(v - a) + b
        else:
            heapq.heappush(left, -a)
            heapq.heappush(right, a)
            minval += b
    else:
        print(-left[0], minval)
n=int(input())
a=int(input())
N=n%500
if N<=a:
    pritnt("Yes")
else:
    peint("No")

### FIXED CODE ###

n=int(input())
a=int(input())
N=n%500
if N<=a:
    print("Yes")
else:
    print("No")
x = input()
print( x ** 3)

### FIXED CODE ###

x = int( input())
print( x ** 3)
import sys
 
size = int(input())
a = map(int, input().split())
cnt = 0
 
while True:
  for i in range(size):
    if(a[i]%2 == 1):
      print(cnt)
      sys.exit()
    
  a = list(map(lambda x:x/2, a))
  cnt+=1

### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()
S = input()

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else :
    print('Sunny'

### FIXED CODE ###

s = list(input())
a = 0

for i in range(len(s)):
    if i%2 == 0:
        if s[i] == 'L':
            a += 1
    else:
        if s[i] == 'R':
            a += 1
        else:
            a = a

if a == 0:
    print('Yes')
else:
    print('No')
N,M = map(int,input().split())

a = int(M/N)

if M % 2 == 0:
    m = M / 2
    a =  int(a/2) + 1

for i in range(a,0,-1):
    if m % i == 0:
        c = i
        break

if c == 1 and M % 2 == 0:
    c = 2

print(c)



### FIXED CODE ###

import math

N,M = map(int,input().split())

a = int(M/N)
q = int(math.sqrt(M))

m = 0
for i in range(1,q+1):
    if M % i == 0:
        if i <= a:
            m = max(m,i)
        b = int(M / i)
        if b <= a:
            m = max(m,b)

print(m)
import sys
sys.setrecursionlimit(10**8)
n,w=map(int,input().split())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
dp=[[-1 for i in range(w+1)] for j in range(n+1)]
def knap(x,y):
  if dp[x][y]!=-1:
    return dp[x][y]
  if x==n+1:
    res=0
  elif y<l[x][0]:
    res=knap(x+1,y)
  else:
    res=max(knap(x+1,y),knap(x+1,y-l[x][0])+l[x][1])
  dp[x][y]=res
  return res
knap(0,w)
print(dp[0][w])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def knapsack(N,W,weight,value):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0

  #DP
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
      else: #入る可能性はない
        dp[i+1][w]=dp[i][w]
  return dp[N][W]
n1,w1=map(int,input().split())
lw=[]
lv=[]
for i in range(n1):
  w,v=map(int,input().split())
  lw.append(w)
  lv.append(v)
print(knapsack(n1,w1,lw,lv))
from collections import Counter
from operator import itemgetter

def sub(prefers, canceled):
    res = Counter()
    for pref in prefers:
       p = pref[-1]
        while p in canceled:
            pref.pop()
            p = pref[-1]
        res[p] += 1
    return max(res.items(), key=itemgetter(1))

def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in [0] * m:
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [list(map(int, input().split()))[::-1] for _ in [0] * N]
    print(solve(M, A))

### FIXED CODE ###

from collections import Counter
from operator import itemgetter

def sub(prefers, canceled):
    res = Counter()
    for pref in prefers:
        pt = -1
        while pref[pt] in canceled:
            pt -= 1
        res[pref[pt]] += 1
    return max(res.items(), key=itemgetter(1))

def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in [0] * m:
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [list(map(int, input().split()))[::-1] for _ in [0] * N]
    print(solve(M, A))
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
    if B[i] >= A[i]:
        a += (B[i] - A[i] + 1) // 2
        b += (B[i] - A[i]) % 2
    else:
        b += A[i] - bytes[i]
print('Yes' if a >= b else 'No')


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
    if B[i] >= A[i]:
        a += (B[i] - A[i] + 1) // 2
        b += (B[i] - A[i]) % 2
    else:
        b += A[i] - B[i]
print('Yes' if a >= b else 'No')
s=input()
k=int(input())
ss=[]
for i in range(len(s)):
	ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
	if i==len(s)-1:
		ss[i]=(k+ss[i])%26
		break
	elif k>=26-ss[i] and ss[i]!="a":
		k-=(26-ss[i])
		ss[i]=0
	i+=1
ans=""
for i in range(len(s)):
	ans+=chr(ord("a")+ss[i])
print(ans)


### FIXED CODE ###

s=input()
print(s[:4]+" "+s[4:])
H,W=map(int,input().split())
a=[]
for i in range(H):
    a.append(list(input()))

from collections import deque
d = [(1,0),(0,1),(-1,0),(0,-1)]
l = deque()
for i in range(H):
    for j in range(W):
        if a[i][j]=="#":
            l.append((j,i))
            a[i][j] = 0
            while l:
                x,y = l.popleft()
            for o,p in d:
                if y+p<0 or y+p>=H or x+o<0 or x+o>=W:
                    continue
                if a[y+p][x+o] == ".":
                    a[y+p][x+o] = a[y][x] + 1
                    l.append((x+i,y+j))
for k in range(5):
    for i in range(H):
        for j in range(W):
            if a[i][j]==k:
                l.append((j,i))
                while l:
                    x,y = l.popleft()
                for o,p in d:
                    if y+p<0 or y+p>=H or x+o<0 or x+o>=W:
                        continue
                    if a[y+p][x+o] == ".":
                        a[y+p][x+o] = a[y][x] + 1
                        l.append((x+i,y+j))

aa=[flatten for inner in a for flatten in inner]
print(max(aa))


### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
a=[input() for _ in range(h)]
dxy=[(0,1),(1,0),(-1,0),(0,-1)]
inf=float("inf")

dp=[[inf]*w for _ in range(h)]
q=deque()

for y,l in enumerate(a):
    for x,c in enumerate(l):
        if c=="#":
            dp[y][x]=0
            q.append((x,y))
ans=0
while q:
    x,y=q.popleft()
    d=dp[y][x]
    for dx,dy in dxy:
        nx,ny=x+dx,y+dy
        if not 0<=nx<w: continue
        if not 0<=ny<h: continue
        if dp[ny][nx]<=d+1: continue
        dp[ny][nx]=d+1
        q.append((nx,ny))
        ans=max(ans,d+1)
print(ans)
import math
import sys
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while True:
        if num==1:
            print(ans)
            sys.exit()
        else:
            if num%count==0:
                ans+=1
                while num%count==0:
                    num= num/count
                count+=1
            else:
                count+=1


### FIXED CODE ###

from fractions import gcd
a,b = map(int, input().split())
# ans = 1
count = 2
n=gcd(a,b)

ans = set([1])
while n % 2 == 0:
    ans.add(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        ans.add(f)
        n //= f
    else:
        f += 2
if n != 1:
    ans.add(n)
print(len(ans))
n,m = map(int,input().split())
L = [-1]*n
lia,lib = [],[]
flag = True

for i in range(m):
    a,b = map(int,input().split())
    lia.append(a-1)
    lib.append(b)

for i in range(len(lia)):
    if L[i] == -1:
        L[lia[i]] = lib[i]

if n == 1:
    if L[0] != -1:
        print(L[0])
        exit()
else:
    if L[0] == 0:
        print(-1)
        exit()
    elif L[0] == -1:
        L[0] = 1
    
for i in range(n):
    if L[i] == -1:
        L[i] = 0
L = [str(x) for x in L]
print("".join(L))

### FIXED CODE ###

n,m = map(int,input().split())
L = []
for i in range(m):
    L.append(list((map(int,input().split()))))

for i in range(1000):
    p = str(i)
    flag = False
    for j in range(m):
        if len(p) >= L[j][0]:
            if int(p[L[j][0]-1]) != L[j][1]:
                break
    else:
        if len(p) == n:
            flag = True

    if flag:
        print(i)
        exit()
print(-1)
li = []

def is_prime(n):
        return False
    for m in li:
        if m * m > n: 
            return True
        if n % m == 0:
            return False
    return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

while True:
  if is_prime(n):
    print(n)
    break
  n += 1

### FIXED CODE ###

li = []

def is_prime(n):
  for m in li:
    if m * m > n: 
      return True
    if n % m == 0:
      return False
  return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

while True:
  if is_prime(n):
    print(n)
    break
  n += 1
P=[1,10,9,12,3,4]
m=10**9+7
def f(A,p,N):
    if p==0:return [1&(i in N) for i in range(13)]
    p%=6
    B=[0]*13
    for n in N:
        for i in range(13):
            c=(i+(n*P[p]))%13
            B[c]=(B[c]+A[i])%m
    return B

S=reversed(input())
A=[0]
for p,s in enumerate(S):
    if s=="?":A=f(A,p,range(10))
    else:A=f(A,p,[int(s)])
print(A[5])

### FIXED CODE ###

a, b = map(int, input().split())
if a%2 == b%2:
    print(int((a+b)/2))
else:
    print("IMPOSSIBLE")
s = int(input())
s = str(s)
if(s[-4]==s[-3] or s[-3]==s[-2] or s[-2]==s[-1]):
  print("Bad")
else:
  print("Good")

### FIXED CODE ###

s = int(input())
a = [0]*4
a[0] = s//1000 
s = s-a[0]*1000
a[1] = s//100
s = s-a[1]*100
a[2] = s//10
s = s-a[2]*10
a[3] = s
if(a[0]==a[1] or a[1]==a[2] or a[2]==a[3]):
  print("Bad")
else:
  print("Good")
import sys
from collections import defaultdict
import bisect
import itertools
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import numpy as np


def main():
    N, M = geta(int)
    A = np.array(list(geta(int)))
    A.sort()

    def c(x):
        """
        @return  # of handshake where hapiness >= x
        """
        X = np.searchsorted(A, x - A)
        return N * N - X.sum()

    left, right = 0, 2 * A[-1] + 1

    while left + 1 < right:
        middle = (left + right) // 2
        if c(middle) >= M:
            left = middle
        else:
            right = middle

    ans = 0
    Acum = np.zeros(N + 1, np.int64)
    Acum[:-1] = np.cumsum(A[::-1])[::-1]
    X = np.searchsorted(A, right - A)

    ans = Acum[X].sum() + (A * (N - X)).sum()

    ans += left * (M - (N * N - X.sum()))

    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import defaultdict
import bisect
import itertools
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N, M = geta(int)
    A = list(geta(int))
    A.sort()

    def c(x):
        """
        @return  # of handshake where hapiness >= x
        """
        ret = 0
        for a in A:
            ret += bisect.bisect_left(A, x - a)
        return N * N - ret

    left, right = 0, 2 * A[-1] + 1

    while left + 1 < right:
        middle = (left + right) // 2
        if c(middle) >= M:
            left = middle
        else:
            right = middle

    ans = 0
    Acum = list(itertools.accumulate(A[::-1]))[::-1]
    for a in A:
        idx = bisect.bisect_left(A, right - a)
        if idx < N:
            ans += Acum[idx] + a * (N - idx)
    ans += left * (M - c(right))

    print(ans)


if __name__ == "__main__":
    main()
N = input()
A = map(int, raw_input().split())

"""
import itertools

ans = 0
for p in itertools.permutations(range(N)):
  F = [True]*N
  for i in range(N):
    ans += A[p[i]]
    F[p[i]] = False
    t = p[i]-1
    while 0<=t and F[t]:
      ans += A[t]
      t -= 1
    t = p[i]+1
    while t<N and F[t]:
      ans += A[t]
      t += 1
print ans
"""

M = 10**9+7

F = [0]*(N+1)
F[0] = 1
for i in range(1,N+1):
  F[i] = F[i-1]*i%M

R = [0]*(N+1)
for i in range(1,N+1):
  R[i] = pow(i, M-2, M)

T = [F[N]]*N
for i in range(N):
  T[i] = T[i]*R[i+1]%M

ans = 0
x = sum(T)
for i in range((N+1)/2):
  ans += (A[i] + (A[N-i-1] if N-i-1!=i else 0))*x
  ans %= M
  x -= T[-i-1]
  x += T[i+1]
  x %= M
print ans


### FIXED CODE ###

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

"""
import itertools

ans = 0
for p in itertools.permutations(range(N)):
  F = [True]*N
  for i in range(N):
    ans += A[p[i]]
    F[p[i]] = False
    t = p[i]-1
    while 0<=t and F[t]:
      ans += A[t]
      t -= 1
    t = p[i]+1
    while t<N and F[t]:
      ans += A[t]
      t += 1
print ans
"""

if N==1:
  print A[0]
  exit(0)

M = 10**9+7

F = [0]*(N+1)
F[0] = 1
for i in range(1,N+1):
  F[i] = F[i-1]*i%M

R = [0]*(N+1)
for i in range(1,N+1):
  R[i] = pow(i, M-2, M)

T = [F[N]]*N
for i in range(N):
  T[i] = T[i]*R[i+1]%M

ans = 0
x = sum(T)
for i in range((N+1)/2):
  ans += (A[i] + (A[N-i-1] if N-i-1!=i else 0))*x
  ans %= M
  x -= T[-i-1]
  x += T[i+1]
  x %= M
print ans
N = int(input())
list = []
flag = True
for n in range(0, N):
  input = input()
  if n == 0:
    list.append(input)
  else:
    if input in list:
      flag = False
    else:
      list.append(input)
if flag == True:
  print('Yes')


### FIXED CODE ###

a, b = map(int, input().split())
for c in range(1, 4):
  if a*b*c % 2 == 1:
    print('Yes')
    break
  else:
    if c == 3:
      print('No')
c = 10**9+7

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

def combinations_count_mod(n, r):
  ret = 1
  for i in range(r):
    ret *= (n-i)/(r-i) % c
  return ret

for i in range(1, k+1):
  a = combinations_count_mod(k-1, i-1) 
  if n-k > i-1:
#    if n-k-i >= 1:
    b = (combinations_count_mod(n-k-1, i-1) * ((n-k-1-(i-1))/i + 2)) 
#    else:
#      b = (n-k-1) * 3
  elif n-k == i-1:
    b = 1
  else:
    b = 0
  print(int((a*b) % c))

### FIXED CODE ###

import math
c = 10**9+7

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

def combinations_count(n, r):
  if n <= r:
    return 1
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, k+1):
  a = combinations_count(k-1, i-1) 
  if n-k >= i-1:
    b = combinations_count(n-k+1, i)
  else:
    b = 0
  print(int((a*b) % c))
import sys
param = sys.argv
print( int(param[1]) ** 3 )

### FIXED CODE ###

import sys
p = sys.stdin.readline()
p = int(p)
o = p ** 3
print o
import fractions
A,B = map(int,input().split())
print(int(A*B/fractions.gcd(A,B)))

### FIXED CODE ###

print(6-int(input())-int(input()))