peterverebics/CodeNet_Python_118 huggingface dataset:
N,K=map(int,input().split())
mod=10**9+7
ans=0
for i in range(K,N+2):
    ans+=(N*(N+1))//2-((N-i)*(N-i+1))//2-(i*(i-1))//2+1
    ans%=mod
print(ans)
N, M = map(int, input().split())

N += 1
n_patterns = 0
remain_min = 0
remain_max = 0

for i in range(M-1):
    remain_min += i
    remain_max += N - 1 - i

for i in range(M-1, N):
    remain_min += i
    remain_max += N - 1 - i
    n_remain = remain_max - remain_min + 1
    n_patterns += n_remain


print(n_patterns % (10**9 + 7))
def main():
    n, k = map(int, input().split())
    mod = 10**9+7
    ans = 0
    for i in range(k, n+2):
        ans = (ans+i*(n-i+1)+1) % mod
    print(ans)


main()
mod = 10**9+7
n,k = map(int, input().split())

ans = 0
for i in range(k, n+2):
    bot = n+1-i
    ans += bot*i+1
    ans %= mod
print(ans)
a = list(map(int,input().split()))
n = a[0]
k = a[1]

count = 0

#10**100の係数のリスト作成,bは係数の個数。
b=n+1-k+1
keisu=[0]*b
for i in range(b):
  keisu[i]=k+i

#係数毎に個数を求める,iは係数。
for i in keisu:
  mn = (i-1)*i/2
  mx = ((n-i+1)+n)*i/2
  count += (mx-mn+1)
  count %= (10**9+7)
  
print(int(count))
N,K = map(int,input().split())

dp = []
dp.append(K*(2*N-K+1)//2-K*(K-1)//2+1)
for k in range(K+1,N+1+1):
    s_min = k*(k-1)//2
    s_max =  k*(2*N-k+1)//2
    dp.append((dp[k-1-k]+s_max-s_min+1)%(10**9+7))

ans = dp[-1]
print(ans)
#D
from collections import deque
N,K = map(int,input().split())
numbers = [i for i in range(0,N+1)]
large  = deque([N])
small = deque([0])
for i in range(1,N+1):
    large.append(large[-1]+numbers[-i-1])
    small.append(small[-1]+numbers[i])

mod = 10**9+7

ans = 1
for i in range(K,N+1):
    ans += (large[i-1] - small[i-1] + 1)%mod
print(ans%mod)
n, k = map(int, input().split())

MOD = 10 ** 9 + 7

def calc(a):
	smallest = a * (a - 1) // 2
	largest = n * a - smallest
	return largest - smallest + 1

res = 0
for a in range(k, n + 2):
	res += calc(a)
	res %= MOD

print(res)
n, k = map(int, input().split())
ans = 0
mod = 1000000007

maxNum = 0
minNum = 0

for i in range(k):
    maxNum += n - i
    minNum += i

for i in range(k, n+2):
    ans += maxNum - minNum + 1
    ans %= mod
    maxNum += n-i
    minNum += i

print(ans)
def rangesum(n, k):
    return k * n + (k - 1) * k // 2

def calc(N, K):
    x = 0
    for i in range(K, N + 2):
        x += rangesum(N + 1 - i, i) - rangesum(0, i) + 1
    return x % (10 ** 9 + 7)


(N, K) = tuple([int(s) for s in input().split()])
print(calc(N, K))
n,k=map(int,input().split());print((((~n+k-1)*(2*k**2-k*(n+2)-n**2-n-6)))//6%(10**9+7))
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 7

N, K = map(int, read().split())

k = np.arange(K, N + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = N * k - low
cnt = high - low + 1
print(cnt.sum() % MOD)
n,k=map(int,input().split())
ans=0
mod=10**9+7
for i in range(k,n+2):
    ans+=(n-i+1)*i+1
    ans%=mod
print(ans)
n,k=map(int,(input().split()))
ans=0
max=sum(range(n-k+1,n+1))*(n-k+2)
min=sum(range(k))*(n-k+2)
for i in range(1,n-k+2):
    min+=(k-1+i)*(n-k+2-i)
for i in range(1,n-k+2):
    max+=(n-k+1-i)*(n-k+2-i)
ans=(max-min+n-k+2)%(10**9+7)
print(ans)
n,k = map(int,input().split())
ans = 0
num = n+1
for i in range(1,n+2):
  #i個選ぶとき
  if i>=k:
    ans += num
  num += n-(2*i)
print(ans%(10**9+7))
n, k = (int(x) for x in input().split())

mod = 1000000007

count = 0

for i in range(k, n+2):
    sum_i = i * (i-1) /2
    count_i = i*n - 2*sum_i + 1
    count+=count_i
    count%=mod
print(int(count))
N, K = map(int, input().split())

count = 0
for i in range(K, N + 2): 
  count += (i * (N + N - i + 1) / 2 - i * (i - 1) / 2 + 1) % 1000000007
  
print(int(count % 1000000007))
N,K = map(int,input().split())

ans = 0
for k in range(K,N+2):
    mn = (k-1)*k//2
    mx = (N+N-k+1)*k//2
    ans += mx - mn + 1
MOD = 10**9+7
print(ans%MOD)
N, K = map(int, input().split())
mod = 10**9+7

ans = 0

for i in range(K, N+2):
	l = (i - 1) * i // 2
	r = (2 * N - i + 1) * i // 2
	ans += r - l + 1
	ans %= mod

print(ans)
n,k = map(int,input().split())
ans = 0
mod = 10**9+7
for i in range(k,n+2):
  min = (i**2-i)//2
  max = (2*n-i+1)*i//2
  ans += max-min+1
print(ans%mod)
n,k=map(int,input().split())
s=[]
count=0
for i in range(n+1):
  count+=i
  s.append(count)

t=[n]
tmp=n
for i in range(1,n+1):
  tmp-=1
  t.append(t[i-1]+tmp)
# print(t)

ans=0
for i in range(k-1,n+1):
  ans+=t[i]-s[i]+1
  ans%=(10**9+7)

print(ans)
n, k = map(int, input().split())
ans = 0
mod = 10 **9 + 7
for i in range(k, n+2):
    # i個(k<= i <= n+1)を選ぶとき
    # i * 10^100 + (1+2+・・・+(i-1)) 〜 i * 10^100 + (n + (n-1) + ・・・ + (n-(i-1) ) )
    # の間の値をとりうるので
    # i*(n + n-(i-1))//2 - (i-1)*i//2 + 1 = i * (n-i+1) + 1
    ans += i * (n - i + 1) + 1
print(ans % mod)
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
a = [int(x) for x in range(n + 1)]
a_rev = a[::-1]
mod = 10**9 + 7

left = sum(a[:k])
right = sum(a_rev[:k])

ans = right - left + 1

for i in range(k, n + 2):
    if i > n:
        break
    left += a[i]
    right += a_rev[i]
    ans += right - left + 1
    ans %= mod

print(ans)
N, K = [int(x) for x in input().split()]

ans = 0
for k in range(K, N + 2):
    ans = (ans + k * (N - k + 1) + 1) % (10 ** 9 + 7)

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

su = 0
for i in range(k, n+2):
    co = (n+(n-i+1))*i/2 - (i-1)*i/2 + 1
    su = (su + int(co)) % (10**9 + 7)
    
print(su)
nk=list(map(int, input().split()))
n=nk[0]
k=nk[1]
answer=0
for i in range(k,n+2):
    answer=int((answer-(0+i-1)*i/2+(n-(i-1)+n)*i/2+1)%(10**9+7))
print(answer)
# D - Sum of Large Numbers

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

cnt = 0
for i in range(K, N + 2):
    mn = i * (i - 1) // 2
    mx = i * (N + (N - i + 1)) // 2
    cnt += mx - mn + 1

print(cnt % ((10 ** 9) + 7))
def sigma(x, d):
    if d == 1:
        return x * (x + 1) // 2
    if d == 2:
        return x * (x + 1) * (2 * x + 1) // 6


def calc(x):
    return -sigma(x, 2) + (n + 1) * sigma(x, 1) + x


# N+1個の数からK個の数を選ぶとき、その和としてあり得る数は-K^2+(N+1)K+1個

n, k = map(int, (input().split()))
p = 10 ** 9 + 7

print((calc(n + 1) - calc(k - 1)) % p)
N,K=map(int,input().split())

# まずKこちょうどを選ぶとして，Kこの選び方はN_C_K通り，これについて実際の和を計算して同じものを省いていくととてつもなくめんどくさい
count=0
for i in range(K,N+1+1):
    count+=1
    yoyu=N-i
    count += (N+1-i)*i % (10**9+7)
    count %= (10**9+7)
print(count)
def main():
  mod = 10**9 + 7
  n, k = map(int, input().split(' '))
  A = list(range(n+1))
  A_rev = A[::-1]
  cumsum_A = [0]
  cumsum_A_rev = [0]
  for i in range(len(A)):
    cumsum_A.append(A[i]+cumsum_A[i])
    cumsum_A_rev.append(A_rev[i]+cumsum_A_rev[i])
  ans = 0
  
  for i in range(k, n+2):
    tmp_min = cumsum_A[i]
    tmp_max = cumsum_A_rev[i]
    ans += (tmp_max - tmp_min + 1)
  print(ans%mod)
    

if __name__ == '__main__':
  main()
MOD = 10**9+7

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

cnt = 0
for k in range(K,N+2):

    t = (N-k+1)*k+1
    cnt += t
    cnt %= MOD
print(cnt)
n,k  = map(int,input().split())
cnt = 0
m = 10**9+7
a = [o for o in range(n+1)]
b = sorted(a,reverse = True)
for i in range(k,n+2):
    t = int((n*(n+1))/2-((i-1)*i)/2+1)
    if i < n:
        t -= int(((n-i)*(n-i+1))/2)
    cnt += t
print(cnt%m)
N,K=map(int,input().split(" "))
total = 0
for k in range(N+1,K-1,-1):
  total+=k*(N)-k*(k-1)+1
print(total%(10**9+7))
n, k = map(int, input().split())
s = 0
lim = (10**9+7)
for i in range(k, n + 2):
    s += (((n - i + 1 + n) * i // 2) - (i-1) * (i) // 2 + 1) % lim
print(s % lim)
import sys, math
MOD = 10**9+7
n, k = map(int, sys.stdin.readline().split())
res = 0
for kk in range(k, n+2):
    mm = (kk-1)*kk // 2
    MM = (n-kk + n + 1) * kk // 2
    #print (mm,MM)
    res = (res + (MM-mm+1)) % (MOD)
print(res)
n, k = map(int, input().split())
mod = 10 ** 9 + 7
premin = 0
premax = 0
ans = 0
list = [i for i in range(n + 1)]
for x in range(n + 1):
    premin += list[x]
    premax += list[n - x]
    if x < k - 1: continue
    ans += (premax - premin + 1)
    if ans >= mod: ans %= mod
print(ans)
N,K = map(int,input().split())

sum_N = N*(N+1)//2
ans   = 1
ue    = sum_N
shita = sum_N

for i in range(N-K+1):
    ue    -= i
    shita -= (N-i)
    ans   += (ue-shita+1)

print(ans%(10**9+7))
n, k = map(int, input().split())
ans=0
for i in range(k,n+2):
    ans+=(((2*n-i+1)*i)//2)-(i*(i-1)//2)+1
print(ans%(10**9+7))
n,k=map(int,input().split())
mod=10**9+7
ll=[0]*(n+1)
ml=[0]*(n+1)
ml[0]=n
ans=0
for i in range(1,n+1):
  ll[i]=ll[i-1]+i
  ml[i]=ml[i-1]+n-i
for i in range(k-1,n+1):
  ans+=ml[i]-ll[i]+1
print(ans%mod)
n, k = map(int, input().split())

ans = 0

l = [0] * (n+2)
minv = 0
maxv = n

#print(l)
for i in range(1, n+2):
  #print(i)
  l[i] = maxv - minv + 1
  minv += i
  maxv += (n-i)

for i in range(k, n+2):
  ans = (ans + l[i]) % (10**9 + 7)

print(ans)
N,K=map(int,input().split())
mod=7+10**9
ans=0
l=list(range(0,N+1))
for i in range(1,N+1):
    l[i]+=l[i-1]
for i in range(K,N+2):
    ans+=(l[-1]-l[-((1+i)%(N+2))]-l[i-1]+1)%mod
print(ans%mod)
n, k = map(int,input().split())
list = [i for i in range(n+1)]
ans = 0
min = sum(list[0:k-1])
max = sum(list[n+1-k+1:n+1])

for i in range(k,n+2):
    if i == n+1:
        ans += 1
    else:
        min += list[i-1]
        max += list[n+1-i]
        ans += max-min+1

print(ans%(7+10**9))
n , k = map(int,input().split())
u = 1000000007
ans = 0
for i in range(k,n+2):
    ans += (i*(n+n-i+1)//2 - i*(i-1)//2 + 1)%u
    ans %= u
print(ans)
import sys
input = sys.stdin.readline

mod = 10**9+7

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

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

ans = 0
for k in range(K, N+2):
    if k == N+1:
        ans = (ans + 1)%mod
    else:
        ans = (ans + (A[-1]-A[-k-1]) - A[k-1] + 1) % mod
print(ans)
N, K = [int(x) for x in input().split(' ')]

counter = 0

for i in range(N + 1, K - 1, -1):
  # m = sum(range(N, N - i, -1)) - sum(range(i)) + 1
  m = (i * (2 * N - (i - 1)) - (i - 1) * i) / 2 + 1
  counter += int(m)

print(counter % (10 ** 9 + 7))
import sys
input = sys.stdin.readline

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

ans = 0
over = 0
down = 0
for i in range(N+1):
    over +=  N  - i
    down += i
    if i >= K-1:
        ans += over - down + 1
print(ans % (10 ** 9 + 7))
#!/usr/bin/python3

M = 1000000007

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

c = ((6 * n - 6 * k + 12 + 3 * (n + 1) * (k + n + 1) * (n - k + 2) - (n + 1) * (n + 2) * (2 * n + 3) + k * (k - 1) * (2 * k - 1)) // 6) % M

print(c)
n, k = map(int, input().split())
n += 1
MOD = 10 ** 9 + 7

ans = 0
for i in range(k, n + 1):

    sum_min =  (i - 1) * (i) // 2
    sum_max = i * (2*n - i - 1) // 2
    ans += sum_max - sum_min + 1
    ans %= MOD
print(ans)
n, k = map(int, input().split())

ans = 0

def select(l, r):
    return (l+r)*(r-l+1) // 2

for i in range(k, n+2):
    l = select(0, i-1)
    r = select(n-i+1, n)
    ans += (r-l+1) 
    ans %= (pow(10, 9) + 7)

print(ans)
N,K = map(int,input().split())

l = 0
for i in range(K ,N+2):
    l += i*( N - i + 1 ) + 1

m = l % (7 + 10**9)

print(m)
N, K = map(int, input().split())

calc = lambda x: x * (N-x+1) + 1

ans = 0
for i in range(K, N+2):
  t = calc(i)
  # print(t)
  ans += t

print(ans % (10**9+7))
n, k = map(int, input().split())

counter = 0

for i in range(k, n+2):
    min_sum = i * (i-1) / 2
    max_sum = i * (n + (n - i + 1)) / 2
    
    counter += (max_sum - min_sum + 1) % (10**9 + 7)


print(int(counter % (10**9 + 7)))
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#n = int(input())
n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

x = 0
y = 0
for i in range(1, k):
    x += i-1
    y += n-i+1

ans = 0
for i in range(k, n+2):
    x += (i-1)
    y += (n-i+1)
    ans += (y-x+1)
    ans = ans % (10**9+7)


print(ans)
N, K = map(int, input().split())

total = 0
mod = 10**9+7
s = [0]
for i in range(0, N+1):
    s.append(s[-1] + i)

for i in range(K, N+2):
    total = (total + ((s[-1]-s[-(i+1)]) - s[i] + 1)) % mod
print(total)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()

MOD = 10**9+7
ans = 0

for kk in range(k,n+2):
  # print()
  aa = (n-kk+n+1)*kk//2
  bb = (0+kk-1)*kk//2
  # print(aa)
  # print(bb)
  a=aa-bb
  # print(a)
  ans+=a+1%MOD

print(ans%MOD)
N , K = map(int,input().split())
counter_ = 0
for i in range(N+2-K):
    counter_ += ((N - (K+i) + 1) * (K+i)) + 1
print(counter_%(10**9 + 7))
N,K = map(int,input().split())

a = 0
for i in range(K,N+1):
    a = (i-1)*(N-i)+(N+1)+a
    a = a%(10**9+7)
    #print(i)
print(a+1)
n,k=map(int,input().split())

sum=0
for i in range(k,n+2):
    sum += -i**2 + i*n + i + 1
    sum %= (10**9+7)

print(sum)
def by_k(k):
    return k*(N+2) - k*(k+1) + 1

M = 10**9+7
N, K = [int(x) for x in input().split()]
ans = 0
for k in range(K, N+2):
    ans += by_k(k)
    while ans > M:
        ans -= M
print(ans)
n,k = map(int,input().split())
num  = 0
for select_num in range(k,n+2):
    st = (select_num*(2*0+(select_num - 1)*( 1)))/2
    ed = (select_num*(2*n+(select_num - 1)*(-1)))/2
    sum = ed - st + 1
    num += sum
print(int(num)%1000000007)
n,k = map(int,input().split()) 
ans = 0

# bikkuri_n1 = math.factorial(n+1) % (10**9+7)

# bikkuri_k = math.factorial(k) % (10**9+7)

for i in range(k,n+2):
  
    small = i*(i-1)//2
    big = i*(2*n-i+1)//2
    
    ans += big-small+1
    ans %= (10**9+7)
    
  
    
print(ans)
def rangesum(a, b=0):
    return (abs(a-b)+1) * (a+b) // 2

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

mod = 10**9+7
res = 1
for i in range(k, n+1):
    res += rangesum(n-i+1, n) - rangesum(i-1) + 1
    res %= mod

print(res)
def main():
    n,k = map(int,input().split())
    mod = 10**9+7
    ans = 0
    for i in range(k,n+2):
        ans += (i*(n-i+1)+1) % mod
        ans = ans % mod
    print(ans)

if __name__ == "__main__":
    main()
N, K = map(int, input().split())
mod = 1000000000+7

z=0

zz = ((N-K+1)+N)*K//2 - (0+(K-1))*K//2 + 1
zz = zz % mod

for x in range(K+1, N+3):
#  print(zz)
  z = (z + zz) % mod
  zz += (N-x+1) - (x-1)
  zz = zz % mod
#
print(z)
def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    cnt = 0
    for i in range(k, n+2):
        l = (i-1)*i//2
        h = (n+n-i+1)*i//2
        cnt += h - l + 1
    print(cnt % mod)

if __name__ == '__main__':
    main()
n, k = map(int, input().split())

count = 0
for i in range(k, n+2):
    count += i*(n - i + 1) + 1
    count %= 10**9+7

print(count)
N,K = (int(i) for i in input().split())

ans = 0

# i個選んだ時の数を足していく
for i in range(K,N+2):
  min_sum_num = i*(i-1)//2
  max_sum_num = N*i - (i*(i-1)//2)
  ans += max_sum_num - min_sum_num + 1


print(ans%(10**9+7))
N, K = map(int, input().split())
MOD = 10**9 + 7

low = high = 0
ans = 0
for i in range(K, N+2):
  low = i*(i-1)//2  # i個取った時の和の最小値
  high = i*(2*N - i + 1)//2  # i個取った時の和の最大値
  ans += (high - low + 1)  # i個取った時の和の場合の数
  ans %= MOD
  
print(ans)
n,k=map(int,input().split())
mod=pow(10,9)+7
ans=0
for i in range(k,n+2):
    ans+=(i*(n+n-i+1))//2-(i*(i-1))//2+1
    ans%=mod
print(ans)
N, K =map(int, input().split())
mod = 10**9 + 7
A = int(-(N+1)*(N+2)*(2*N+3)/6)%mod
B = int((N+1)*(N+1)*(N+2)/2)%mod
C = N+1
a = int(-(K-1)*K*(2*K-1)/6)%mod
b = int((N+1)*(K-1)*K/2)%mod
c = K-1
print((A+B+C-a-b-c)%mod)
n, k = map(int, input().split())
s = 0
for i in range(k, n + 2):
    s += i * (n - i + 1) + 1
    s %= 10 ** 9 + 7
print(s)
import sys
input = sys.stdin.readline


def log(v):
    print(v, file=sys.stderr)


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

mod = 10**9 + 7
log(mod)
ans = 0
for i in range(K, N + 2):
    max = (N - i + 1 + N) * i // 2
    min = (i - 1) * i // 2
    ans += max - min + 1
    ans %= mod
print(ans)
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    mi=i*(i-1)//2
    ma=n*(n+1)//2-(n-i)*(n-i+1)//2
    ans+=ma-mi+1
print(ans%(10**9+7))
def input_1line_number():
    return map(int, input().split())

def sum_of_equal_number_sequence(first_term, difference, number_of_terms):
    return (2*first_term + (number_of_terms-1)*difference) * number_of_terms // 2

def mod_number():
    return 10**9+7

def main():
    n, k = input_1line_number()

    answer = 0

    for i in range(k, n+2):
        number_of_fractions = sum_of_equal_number_sequence(n-i+1, 1, i) - sum_of_equal_number_sequence(0, 1, i) + 1
        answer += number_of_fractions

    answer %= mod_number()

    print(answer)

if __name__ == "__main__":
    main()
n, k = map(int,input().split())
mod = 10**9+7
ans = 0

for i in range(k,n+2):
    num = ((n*(n+1)-(n-i+1)*(n-i)-(i-1)*i)//2+1)%mod
    ans = (ans+num)%mod

print(ans)
N,K = map(int,input().split())
ad = 0
mod = 10 **9 + 7
for k in range(K,N+2):
  ma = (N*(N+1) - (N-k)*(N-k+1))//2
  mi = (k-1)*k//2
  ad += (ma - mi+1)
print(ad%mod)
N,K=map(int,input().split())
ans=0
for i in range(K,N+2):
    saidai=(N+N-i+1)*i//2
    saisyou=(i-1)*i//2
    ans+=saidai-saisyou+1

ans%=10**9+7
print(ans)
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
mod=10**9+7
ans=0
for i in range(k,n+2):
  l=(i-1)*i//2
  r=(2*n-i+1)*i//2
  ans+=r-l+1
  if ans>=mod:
    ans%=mod
print(ans)
N, K = map(int,input().split())
mod = 10**9+7
res = 0
total = (N) * (N+1) // 2
for k in range(K, N + 2):
	tmp = k - 1
	X = tmp * (tmp + 1) // 2
	tmp = N-k
	Y = total - (tmp * (tmp + 1) // 2)
	res+= Y - X + 1
	res %= mod
print(res % mod)
N, K = map(int, input().split())
mod = int(1e9) + 7
S = 0
for i in range(K, N+2):
    S += (N - i + 1) * i + 1
    S %= mod
print(S)
def main():
    N, K = map(int, input().split())
    mod = 10**9 + 7
    ans = 0
    for i in range(K, N + 2):
        a = N - i + 1
        ans = (ans + i * a + 1) % mod
    print(ans)

if __name__ == '__main__':
    main()
N, K = map(int, input().split())

count = 0
for i in range(K, N+2):
  count += ((N-i+1)*i+1)
  count %= 10**9+7
print(count)
N, K = map(int, input().split())

ans = 0


for i in range(K, N+2):
    mi = ((i-1)*i)//2
    ma = N*i-mi
    ans += ma-mi+1
    ans %= 10**9+7
    # print(mi, ma)

print(ans)
mod = 10**9+7
n, k = map(int, input().split())

ans = 0

for i in range(k, n+2):
    ans += i*(2*n-i+1)//2 - (i-1)*i//2 + 1
    ans %= mod

print(ans)
import math
n,k = map(int, input().split())
mod = 10**9+7
ans = 0
array = [i for i in range(n+1)]
first_sum = sum(array[:k])
latter_sum = sum(array[-k:])
for i in range(k,n+1):
    ans += (latter_sum - first_sum) + 1
    first_sum += array[i]
    latter_sum += array[-(i+1)]
    ans %= mod
ans += 1
print(ans % mod)
n, k = map(int, input().split())
a = 0
for i in range(k, n+2):
  a += i * -~(n - i) + 1
print(a % (10**9+7))
N, K = map(int, input().split())
number = [ i for i in range(0, N + 1)]


left = number[K - 1]
right = number[-K]
s_min = sum(number[0:K])
s_max = sum(number[-K:])
count = s_max - s_min + 1
for i in range(K + 1, N + 2):
    left += 1
    right -= 1
    s_min += left
    s_max += right
    count += s_max - s_min + 1
print(count % 1000000007)
def main():
    N, K = map(int, input().split())
    mod = 10**9 + 7
    r = 0
    for i in range(K, N+2):
        r += ((N + N-i+1) * i - i*(i-1))//2 + 1
        r %= mod
    return r
print(main())
N, K = [int(_) for _ in input().split()]

s = 0
e = 0
ans = 0

MOD = 10 ** 9 + 7

for i in range(N+1):
    s += i 
    e += N - i 
    if i + 1 >= K:
        ans += e - s + 1
        ans %= MOD
print(ans)
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    output=0
    for k in range(K,N+2):
        output+=(2*N-k+1)*k//2-k*(k-1)//2+1
        output%=10**9+7

    print(output)
main()
# coding: utf-8

# 14:35-14:48


def main():
    N, K = map(int, input().split())
    q = 10**9 + 7

    ans = 0
    for n in range(K, N+2):
        ans += n*(N-n+1) + 1
    
    return ans % q


print(main())
N, K = map(int, input().split())

print(int(((N*(N+1)*(N+2) - K*(K-1)*(3*N-2*K+4))/6 + N - K + 2)%1000000007))
N, K = map(int, input().split())
ans = 0
bigint = 10**9+7
for k in range(K,N+2):
    ans += N-k+2+(N-k+1)*(k-1)
    ans %= bigint
print(ans)
def main():
    n, k = (int(i) for i in input().split())
    num_sums = sum((n-j+1)*j + 1 for j in range(k, n+2)) 
    print(num_sums % (10**9 + 7))

main()
n,k=map(int,input().split())
MOD=(10**9)+7

ans=0
for i in range(k,n+2):
    min_sum=i*(i-1)//2
    max_sum=i*(n+(n-i+1))//2
#    print(i,min_sum,max_sum,max_sum-min_sum+1)
    ans=(ans+(max_sum-min_sum+1))%MOD
print(ans)
n, k = map(int,input().split())
mod = int(1e9)+7
# print(type(mod))
ans=0
for i in range(k,n+2):
	ans+=((n*i)-(i*(i-1))/2) - (i*(i-1))/2 + 1
	ans=ans%(mod)
print(int(ans))
n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    ma = (n+n-i+1)*i//2
    mi = (i-1)*i//2
    # print(ma, mi)
    add = ma-mi+1
    ans += add

print(int(ans % (10**9+7)))
from itertools import accumulate

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
f_acc = [0] + list(accumulate(list(range(n + 1))))
b_acc = [0] + list(accumulate(reversed(list(range(n + 1)))))
ans = 0
for i in range(k, n + 2):
    min_ = f_acc[i]
    max_ = b_acc[i]
    ans = (ans + max_ - min_ + 1) % MOD
print(ans)
n,k=map(int,input().split())

mod=10**9+7

ans=0
for i in range(k,n+2):
#  print(i,(i-1)*i//2, (n+1)*n//2)
  sigma1=(i-1)*i//2
  sigma2=(n-i)*(n-i+1)//2
  sigma3=n*(n+1)//2
#  print(i,sigma1,sigma3-sigma2)

  ans+=sigma3-sigma2-sigma1+1
  ans%=mod
print(ans)
p = 10**9+7
N,K = map(int,input().split())
cnt = 0
for i in range(N+1-K+1):
    cnt = (cnt+(K+i)*(N-K-i+1)+1)%p
print(cnt)
n,k = map(int,input().split())
s = 0
for i in range(k,n+2):
    s += i*(n*2+1-i)//2 - i*(i-1)//2 + 1
print(s%1000000007)
n, k = map(int, input().split())
cnt = [0] * (n + 1)
MOD = 10**9+7
l, r = 0, 0
for i in range(n + 1):
    l += i
    r += n-i
    #print(l, r)
    cnt[i] = (r - l + 1) % MOD
ans = 0
for i in range(k-1, n + 1):
    ans += cnt[i] % MOD

print(ans % MOD)
N, K = map(int, input().split())
mod = (10**9)+7

counter = 0
for k in range(K, N+1):
    counter += k * (N-k)
    counter += k+1
    counter = counter % mod

counter += 1 # k = N+1
counter = counter % mod

print(counter)
MOD = 1000000007
n, k = map(int, input().split())

n_li = list(range(n+1))

ans = 0

while(k <= n+1):
    p = (k - 1) * k / 2
    q = ((n + n - k + 1) * k) / 2

    ans += q - p + 1
    ans %= MOD
    k += 1

print(int(ans))
N, K = map(int, input().split())

a = 0

for i in range(K,N+2):
  a += i*(2*N-i+1)//2 - i*(i-1)//2 + 1
  
a = a % (10**9+7)
print(int(a))
n,m = map(int,input().split())

mod =10**9+7
sum = 0
min = 0
max = 0

for k in range(1,n+2):
    min += k-1
    max += n-(k-1)

    if k >= m:
        sum = (sum + max-min+1) % mod
print(sum)
mod = 1000000007
n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    ans += i*(n+1-i)+1
    ans = ans%mod
print(ans%mod)
N,K = map(int,input().split())

ans = 0
if(K <= N+1):
 for i in range(K, N+1 +1):
  tmp = i*(N-i+1)+1 % (10**9 + 7)
  ans += tmp
  ans = ans % (10**9 + 7)  
    
print(ans)
MOD = 10**9+7

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

min_list = [sum([i for i in range(K)])]
for i in range(K, N+1):
    min_list.append((min_list[-1]+i) % MOD)

max_list = [sum([N-i for i in range(K)])]
for i in range(K, N+1):
    max_list.append((max_list[-1]+N-i) % MOD)


count = 0
for i in range(len(min_list)):
    count = (count+(max_list[i]-min_list[i]+1)) % MOD

print((count) % MOD)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9

n, k = in_ints()

ans = 0
for p in range(k, n+2):
    ans = (ans + p*(n+1-p) + 1)%mod


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

mod = 10**9+7

ans = 0

for i in range(k,n+2):
    ans += (n + n - i + 1) * i // 2 - (i - 1) * i // 2 + 1
    ans %= mod
print(ans)
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7

N, K = map(int, readline().split())
N = N + 1

lower = None
upper = None
answer = 0
for k in range(K, N+1):
    if lower is None:
        lower = sum(range(k))
        upper = sum(range(N-k, N))
    else:
        lower += k - 1
        upper += N - k
    answer += (upper - lower + 1)
print(answer % MOD)