peterverebics/CodeNet_Python_118 huggingface dataset:
N, K = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7

def sum_num(n):
    return (n*(n+1))//2

for k in range(K, N+1):
    min_sum = sum_num(k-1)
    max_sum = sum_num(N) - sum_num(N-k)
    # print(k, min_sum, max_sum)
    ans += max_sum - min_sum + 1

ans += 1
ans %= mod
print(int(ans))
n, k = map(int,input().split())
 
ans = 0
for select in range(k, n + 2):
    min_ = select * (select - 1) / 2
    max_ = select * (2 * n - select + 1) / 2
    ans += (max_ - min_ + 1)
print(int(ans % (10**9 + 7)))
n, k = map(int, input().split())
ans = 0

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

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

for i in range(k, n+2):
    total += i*n - (i-1)*i +1

print(total%(10**9+7))
n,k = map(int,input().split())
count = 0
for i in range(k, n+2):
    min_num = int((i-1) * i /2)
    max_num = int(i*(2*n-i+1)/2)
    count += (max_num - min_num+1)
print(count % (10**9 + 7))
def resolve():
    n, k = map(int, input().split())
    Mod = 1000000007
    ans = 0
    for i in range(n - k + 2):
        j = i + k
        start = j * (j - 1) / 2
        final = (n * 2 - j + 1) * j / 2
        add = final - start + 1
        ans = (ans + add) % Mod
    print(int(ans))

resolve()
mod=10**9+7
x=[0]+[0]
for i in range(1,2*10**5+10):
  x.append((x[-1]+i)%mod)

ans=0


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


for i in range(k,n+2):
  ans+=(i*(n+n+1-i)//2)-x[i]+1
  ans%=mod
  
print(ans)
def coun(n,r):
    return n*r+1+r-r**2

def sigma(func,frm,too):
    result=0
    for i in range(frm,too+2):
        #print(i)
        result=result+func(too,i)
        #print(result)
    print(result%mod)

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

sigma(coun,k,n)
def main():
    MOD = 10**9 + 7
    n, k = map(int, input().split())
    ans = 0
    for x in range(k, n+2):
        ans +=  (n+2)*(n+1)//2 - (n-x+2)*(n-x+1)//2 - (x+1)*x//2 + 1
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()
n,k = map(int,input().split())
li = [i for i in range(0,n+1)]
#print(li)
#[0,1, 2, 3]
tmp = 0
def exc(n):
    return (n)*(n+1)//2

for i in range(k,n+2):
    #print(i,li[n-i+1:],li[:i],sum(li[n-i+1:]) - sum(li[:i]))
    #tmp += sum(li[n-i+1:]) - sum(li[:i]) + 1
    mi = exc(i-1)
    ma = exc(n) - exc(n-i)
    #print(i,mi,ma,ma - mi + 1)
    tmp += ma - mi + 1
print(tmp%(10**9+7))
from math import factorial
n, k = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

def s(n, m=0): # m~nの総和
    global mod
    return (n * (n+1) // 2 - (n-m) * (n-m+1) // 2) % mod

sm = 0
for i in range(k, n+1):
    sm = (sm + s(n, i) - s(i-1, i-1) + 1) % mod

print((sm+1) % mod)
import math
n, k = map(int,input().split())
total = 0
mod = 10**9+7
max_value = (n*(n+1)) //2
for a in range(k,n+1):
    high = (max_value-(n-a)*(n-a+1)//2)
    low = (a*(a-1)) //2
    total += high - low + 1
total += 1 # k = n+1
print(total%mod)
n,k=map(int,input().split())
cnt=0
p=10**9+7
for i in range(k,n+2):
  cnt+=1+(i*(2*n-i+1))//2-(i*(i-1))//2
  if cnt>=p:
    cnt%=p
print(cnt)
N, K = map(int,input().split())
count = 0
base_t = 0
for i in range(1, N+2):
    base_t += i
    if i>=K:
        count += ((N+1)-i)*i+1
print(count % (10**9+7))
n,k = map(int,input().split(" "))

sum = 0
for i in range(k,n+2):
    maxsum = (2*n-i+1)*i/2
    minsum = (i-1)*i/2

    num = maxsum-minsum +1
    sum += num
    sum = sum % (10**9+7)

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

list = list(range(N+1))
t = 10**9+7
result = 0

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

print(result%t)
n,k=map(int,input().split())
r=[0]
l=[0]
ans=0
INF=10**9+7
for i in range(n+1):
    a=r[i]+i
    b=l[i]+n-i
    r.append(a)
    l.append(b)
#print(r)
#print(l)

for i in range(k,n+2):
    min_wa=r[i]
    max_wa=l[i]
    ans+=max_wa-min_wa+1
    
print(ans%INF)
#!/usr/bin/env python3
n, k = map(int, input().split())
# 選ぶ数が違う時絶対に違う
# 1..N の中で和が同じにならない組み合わせを引いたらいい
# 解説AC  k ... n+1 について最大、最小をとってその間は全部作れる
ans = 0
mod = 10 ** 9 + 7
for i in range(k, n + 2):
    mi = (i - 1) * i // 2
    ma = (2 * n - i + 1) * i // 2
    # print(i, (ma - mi + 1))
    ans += (ma - mi + 1) % mod
print(ans % mod)
n,k=map(int,input().split())
s=0
for i in range(k,n+2):
    s+=i*(n-i+1)+1
print(s%1000000007)
import numpy
N, K  = map(int, input().split(' '))
right = 0
s = 0
for i in range(K, N+2):
    mi = (i-1)*i/2
    ma = (2*N-i+1)*i/2
    s += (ma - mi) + 1
print(int(s%(1e9+7)))
n, k = map(int, input().split())
mod = 10**9+7
ans = 0
for i in range(k, n+1):
  ans += ((i*(2*n-i+1))//2 - (i*(i-1))//2 + 1) % mod
ans += 1
print(ans % mod)
n,k=map(int,input().split())
count=0
for i in range(k,n+2):
    count+=i*(n-i+1)+1
print(count%(10**9+7))
N, K = map(int, input().split())
ans = 0
for i in range(K, N+2):
    ans += i * (N+1-i) + 1
print(ans % (10**9+7))
import sys
N,K=map(int, sys.stdin.readline().split())
mod=10**9+7
ans=0
for k in range(K,N+2):
    max_n=(N+(N-k+1))*k/2
    min_n=(k-1)*k/2
    ans+=max_n-min_n+1
print ans%mod
n, k = map(int, input().split())
MOD = 1e9+7

def s(i,n):
    s1 = (2 * i * i)
    s2 = (3 * n * (i+1)) 
    s3 = 8

    d = (s2 + s3 - s1)

    ans = ( int((i * d)/6 + 0.5) )
    
    return ans

ans = int(s(n+1,n) - s(k-1,n)) % MOD
if ans < 0:
    ans += MOD

print(int(ans))
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    mod = 10 ** 9 + 7

    res = 0

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

    print(res)



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

        ans %= p

    print(ans)


if __name__ == '__main__':
    main()
import itertools


def main():

    N, K = map(int, input().split())
    mod = 1000000007
    s = list(itertools.accumulate(range(0, N+1)))

    ans = 1
    for k in range(K, N+1):
        ans = (ans + s[N] - s[N-k] - s[k-1] + 1) % mod

    print(ans)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
l = [int(i) for i in range(n + 1)]
lr = l[::-1]

if k == n + 1:
    print(1)
else:
    ans = 1
    mod = 10**9 + 7
    left = sum(l[:k])
    right = sum(lr[:k])
    # print(left)
    # print(right)
    for i in range(n - k + 1):
        ans += right - left + 1
        ans %= mod
        left += l[k + i]
        right += lr[k + i]
    print(ans)
N, K = map(int, input().split())

count = 0
for p in range(K, N+2):
    count += p * (N - p + 1) + 1
    
print(count % (10**9 + 7))
import sys
import itertools
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N,K=nm()

mod=10**9+7
ans=0

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

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

MOD = 10**9 + 7
def f(t):
  return (N-t+1)*t+1

ans = 0
for i in range(K, N+2):
  ans += f(i)
  ans %= MOD
print(ans)
#input
N, K = map(int, input().split())

#output
mod = pow(10, 9) + 7
answer = 0
for i in range(K, N+2):
    answer += ((N*(N+1)//2)  - ((N-i)*(N-i+1)//2) - (i*(i-1)//2) + 1) % mod

print(answer % mod)
N, K = map(int, input().split())
num = list(range(N+1))
count = 0
base_minimum = sum([i for i in num[:K]])
base_maximum = sum([i for i in num[-K:]])
count += base_maximum - base_minimum + 1

for k in range(K, N+1):
    base_minimum += num[k]
    base_maximum += num[-k-1]
    count += base_maximum - base_minimum + 1
    
print(int(count%(1e9+7)))
N,K = map(int,input().split())

# from scipy.special import comb
# a = comb(n, r)

MOD = 10**9 + 7
ans = 0
for k in range(K,N+2):
    # print(k)
    right = (N+N-k+1)*k // 2
    left = (k-1)*k // 2 
    ans += right - left + 1
    ans %= MOD
    # print(ans)
    # ans += comb(N+1, k, exact=True)
    # print(ans)


print(ans)
n,k = map(int,input().split())
total = 0
for i in range(k,n+2):
    m = i*(i-1)//2
    M = i*n-(i*(i-1))//2
    total += M - m + 1
print(total % (10**9 + 7))
def solve():
  N, K = map(int, input().split())
  mod = 10**9+7
  ans = 0
  for k in range(K,N+2):
    ans += (N+N-k+1)*k//2-k*(k-1)//2+1
    ans %= mod
  return ans
print(solve())
mod = 1e9+7
n, k = list(map(int, input().split()))
count = 0
for i in range(k, n+2):
    count += i*(2*n-i+1)//2 - (i*(i-1)//2-1)
print(int(count%mod))
#D
N, K = map(int, input().split())
count=0
for i in range(K,N+2):
    min_a=(i-1)*i/2
    max_a=(N+(N-i+1))*i/2
    count+=max_a-min_a+1
print(int(count)%(10**9+7))
N,K = map(int,input().split())


sum = 0
for k in range(K,N+2):
    # sum(arr[0:0+k]), sum([l-,l])
    s1 = ((0 + k-1) * k) // 2
    s2 = (((N - k + 1) + N) * k) // 2
    sum = sum + (s2 - s1 + 1)

print(sum % (1000000000 + 7))
n, k = map(int, input().split())

ans = 0

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

print(ans % (10**9+7))
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    ans+=1+(i*(n+n-i+1)- i*(i-1))/2
if ans>10**9+7: ans%=10**9+7
print(int(ans))
N,K=map(int,input().split())
ans=0
mod=(10**9)+7
def ABC(N,K):
    mod=(10**9)+7
    a=((K-1)*K)//2
    b=(K*(2*N-K+1))//2
    s=b-a+1
    return s%mod

for i in range(K,N+2):
    ans+=ABC(N,i)

print(ans%mod)
#abc163  Sum of Large Numbers
n, k = map(int, input().split())
def Funmy(a, N):
    return (8+3*a*N + 3*N -2*a*a)*a/6

total =Funmy(n+1,n) -Funmy(k-1,n)
m = 7 + 10**9
output = (total)%m
print(int(output))
n,k = map(int,input().split())
ans = 0
mod = 10**9+7
for i in range(k,n+2):
    M = n*(n+1)//2-(n-i)*(n-i+1)//2
    m = (i-1)*(i)//2
    ans += M-m+1
    ans %= mod
print(ans)
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
mod = 10**9+7

ans = 0
for i in range(K, N+2):
    ans += (N+(N-i+1))*i//2-(i*(i-1)//2)+1
    ans %= mod
print(ans)
N, K = map(int, input().split())
l = []
cmin = 0
cmax = 0
for i in range(K, N+2):
  cmin = 0
  cmax = 0
  cmin = i * (i-1) / 2
  cmax = (2*N - i + 1) * i / 2
  dif = cmax - cmin + 1
  l.append(dif)
print(int(sum(l)%(10**9 + 7)))
if __name__ == '__main__':
    a,b= map(int,input().split())
    maxnum =0
    minnum =0
    diff = 10**9 +7
    ans = 0

    for i in range(b,a+2):
        max = (i * (2*a+1-i)) / 2
        min = (i* (i - 1) / 2)
        ans += max-min+1
        ans = ans % diff
    print(int(ans))
N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    sum_min = 1/2*K*(K-1)
    sum_max = 1/2*K*(2*N-K+1)
    diff += sum_max - sum_min+1
    K+= 1
diff = diff % mod
print(int(diff))
MOD = 10**9 + 7
def mySum(a, b):
    return (a + b) * (b - a + 1) // 2 % MOD

N, K = list(map(int, input().split()))
l = mySum(N-K+1, N) - mySum(0, K-1) + 1
res = l
for i in range(K, N+1):
    l = l - i + (N-i)
    res += l
    res %= MOD
print(res)
N, K = map(int, input().split())

mod = 10**9+7
res = 1
l = K*(K-1)//2
r = l+(N-K+1)*K
for i in range(K, N+1):
    res += r-l+1
    res %= mod
    l += i
    r += N-i
print(res)
N, K = map(int, input().split())
MOD = 1000000007

min_ = sum([i for i in range(K)])
max_ = sum([i for i in range(N, N - K, -1)])

right = K - 1
left = N - (K - 1)

cnt = 0
for k in range(K, N + 2):
    cnt += max_ - min_ + 1

    right += 1
    left -= 1

    min_ += right
    max_ += left

print(cnt % MOD)
nk = input()
nk = nk.split()
[n,k] = nk
n, k = int(n), int(k)
ans = 0
for s in range(k, n + 2):
    temp = s*(n-s+1) + 1
    ans += temp
    if(ans > 1000000007):
        ans = ans % 1000000007
print(ans)
N,K = list(map(int, input().split()))

ans = 0

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

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

goukei = 0
for j in range(k,n+2):
    goukei += ((2*n-j+1)*(j)/2) - ((j-1)*j/2) + 1
    
print(int(goukei % (1e9 + 7)))
n, k = map(int, input().split())
ans = 0

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

print(ans % (10**9+7))
mod = pow(10, 9) + 7

def main():
    N, K = map(int, input().split())
    ans = 0
    for k in range(K, N+2):
        #ans += sum(range(N+1-k, N+1)) - sum(range(0, k)) + 1
        ans += (N*(N+1))//2 - ((N-k)*(N-k+1))//2 - ((k-1)*k)//2 + 1
        ans %= mod
    print(ans%mod)


if __name__ == "__main__":
    main()
mod = 1000000007

def sum_(a, b):
    return int((a+b)*(b-a+1)/2)

def main():
    args = input().rstrip().split(' ')
    N, K = int(args[0]), int(args[1])
    
    Ans = 0
    for i in range(K, N+2):
        sum_b = sum_(0, i-1)
        sum_u = sum_(N-i+1, N)
        Ans += (sum_u-sum_b)+1
        Ans = Ans % mod
    print(Ans)
    
if __name__ == "__main__":
    main()
N,K = map(int, input().split())

i = K
S = 0
while i < N+1:
    S = S + (N+1-i)*i+1
    i = i + 1
S = S + 1

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

def sm(mn :int, mx :int) -> int:
    n = mx - (mn - 1)
    return int((mx + mn) * (n / 2))

cnt = 0
for i in range(k, n+2):
    mn, mx = sm(0, i-1), sm(n-(i-1), n)
    cnt += mx - (mn-1)
    cnt = cnt % BASE
print(cnt)
n, k = map(int, input().split())
a = [i for i in range(n+1)]
mod = 10**9+7
ans = 0
for i in range(k, n+2):
  L = i * (i - 1) / 2
  R = n * i - i * (i - 1) / 2
  ans += R - L + 1
  ans %= mod
print(int(ans))
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    for k in range(K, N + 2):
        a = k * (k - 1) // 2
        b = k * (2 * N - (k - 1)) // 2
        ans = (ans + (b - a + 1)) % P

    print(ans)


if __name__ == "__main__":
    main()
N,K = map(int, input().split())
MOD = 10**9+7
def count(N, K):
    min =K*(K-1)/2
    max = (N-K+1)*K+min
    count_num = max-min+1
    K = K +1
    while K <=N+1:
        min = min + K-1
        max = max + N-K+1
        count_num = count_num + max-min+1
        K=K+1
    return count_num

print(int(count(N,K)%MOD))
import sys
input=sys.stdin.readline

# n=int(input())
# A=list(map(int,input().split()))
mod=1000000007
n,k=map(int,input().split())
n+=1
ans=0
l=0
r=0
for i in range(k):
    l+=i
posl=k-1
for i in range(n-k,n):
    r+=i
posr=n-k


while l!=r:
    ans+=r-l+1
    ans%=mod
    posl+=1
    l+=posl
    posr-=1
    r+=posr
print(ans+1)
def f(n,k):
  return (n+1)*(n+k+1)*(n-k+2)//2+k*(k-1)*(2*k-1)//6-(n+1)*(n+2)*(2*n+3)//6+n-k+2

n,k=map(int,input().split())
print(f(n,k)%1000000007)
import sys
N, K = map(int, sys.stdin.readline().split())
cnt = 0
while K <= N+1:
  cnt += (2*N-K+1)*K//2 - (K-1)*K//2 + 1
  K += 1
print(cnt%(10**9+7))
n,k = map(int,input().split())

ans = 0
mod = 10**9 + 7

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

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

ans = 0
for k in range(K, N + 2):
    MIN = (k - 1) * k // 2 % MOD
    MAX = (2 * N - k + 1) * k // 2 % MOD
    ans += MAX - MIN + 1
    ans %= MOD

print (ans)
n, k = map(int, input().split())
mod = 10 ** 9 + 7
a = [i for i in range(n + 1)]
b = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(1, n + 1):
    b[i] = b[i - 1] + a[i]
a.reverse()
c[0] = a[0]
for i in range(1, n + 1):
    c[i] = c[i - 1] + a[i]
ans = 0
for i in range(n + 1):
    if i + 1 >= k:
        ans += (c[i] - b[i] + 1)
        ans %= mod
print(ans)
mod = 1000000007
N, K = map(int, input().split())

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

r = 1

for i in range(K, N+1):
	up = S[N]-S[N-i]
	low = S[i-1]
	r = (r+(up-low+1))%mod

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

mod = 10**9+7 #出力の制限

res = 0
for i in range(K, N+2):
    ma = (2*N-i+1)*i/2
    mi = (i-1)*i/2
    res += (ma-mi+1)%mod

print(int(res%mod))
import numpy as np
from itertools import combinations
n,K = map(int,input().split())
num_ls = [i for i in range(n+1)]
csum_num_ls = list(np.cumsum(num_ls))
mod = 1000000007

ans = 0
for k in range(K,n+1):
    smallest = csum_num_ls[k-1]
    biggest = csum_num_ls[-1] - csum_num_ls[-k-1]
    ans_k = biggest - smallest + 1
    ans += ans_k
    ans %= mod
ans += 1
print(ans)
MOD=10**9+7

N,K=map(int,input().split())
ans=0
ans+=N-K+2
ans+=(N+1)*(N+1+K)*(N-K+2)//2
ans%=MOD
ans-=(N+1)*(N+2)*(2*N+3)//6
ans%=MOD
ans+=K*(K-1)*(2*K-1)//6
ans%=MOD
print(ans)
import sys
input = sys.stdin.readline
from collections import *
from math import *

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

for i in range(K, N+2):
    c = ((2*N-i+1)*i)//2-i*(i-1)//2+1
    ans += c
    ans %= MOD

print(ans)
from sys import stdin
input = stdin.readline


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

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

  print(sum_ % 1_000_000_007)


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

MOD = 10**9+7
n += 1
ans = 0
for i in range(k, n+1):
    p = i*(2*n - (i-1)) // 2
    m = i*(2 + i-1) // 2
    ans += p - m + 1
print(ans % MOD)
N, K = map(int, input().split())
ans = 0
for i in range(K,N+2):
    ans += N*i -i**2 +i +1
print(ans%(10**9 + 7))
n, k = map(int, input().split())
res = 0
divnum = 10 ** 9 + 7
for i in range(k, n + 2):
  res += i * (n - i + 1) + 1
  res %= divnum
print(res)
N,K = map(int, input().split())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7) +1)
MODULO = 10**9+7
n, k = map(int, input().split())


ans = 0
for num_add in range(k, n+2):
	min_res = (0 + num_add-1) * num_add // 2
	max_res = (n-num_add+1 + n) * num_add // 2
	ans += (max_res - min_res + 1) % MODULO
	ans %= MODULO
	# print("ans", ans)

print(ans)
import sys

input = sys.stdin.readline

P = 10 ** 9 + 7


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

    ans = 0
    for k in reversed(range(1, (N+1)+1)):
        a = (N + (N-k+1))*k//2
        b = k*(k-1)//2
        ans += a - b + 1
        ans %= P

        if k == K :
            break

    print(ans)


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

for i in range(k, n+2):
  # 最小の和: 0 -> i-1 まで
  s_min = i * (i-1) // 2
  # 最大の和: n-i+1 -> n まで
  s_max = (n+1) * n // 2 - (n-i+1) * (n-i) // 2
  # とりうる個数
  s_count = s_max - s_min + 1
  # 答えに追加
  ans = (ans + s_count) % div

print(ans)
MOD = int(1e9+7)
def main():
    n,k = map(int,input().split())
    ans = 0
    for i in range(k,n+2):
        # min_sum = sum(range(i))
        min_sum = i*(i-1)//2
        # max_sum = sum(range(n,n-i,-1))
        max_sum = (2*n-i+1)*(i)//2
        # print(min_sum,max_sum)
        ans = (ans + (max_sum-min_sum+1))%MOD
    print(ans)
    return

if __name__ == "__main__":
    main()
MOD = 10**9 + 7
N, K = map(int, input().split())

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

MOD = 10 ** 9 + 7

count = 0	
for i in range(K, N + 2):
    count += (((2 * N - i + 1) - (i - 1)) * i // 2 + 1) % MOD
    
count %= MOD
print(count)
N,K = map(int,input().split())
lis = []
for k in range(K,N+2):
    lis.append((N-k+1)*k+1)

print(sum(lis)%(10**9+7))
n, k = map(int, input().split())
cnt = 0
MOD = 1000000007
for i in range(k, n+2):
    left = i*(i-1)//2
    right = i*(2*n-i+1)//2
    add = right - left + 1
    cnt = (cnt+add)%MOD
print(cnt)
N, K = map(int, input().split(" "))
mod = 10 ** 9 + 7
ans = 0
for k in range(K, N + 2):
    ans += (k * (2 * N + 1 - k) // 2) - (k * (k - 1) // 2) + 1
    ans %= mod
print(ans)
mod=pow(10,9)+7
n,k=map(int,input().split())
mini,maxi=-1,-1
ranges=[[0,0]]
ans=0
for i in range(k,n+2):
    mini=(i*(i-1))//2
    maxi=((i)*(n+n-i+1))//2
    ans += (maxi-mini+1)%mod
    ans=ans%mod

print(ans)
N, K = [int(s) for s in input().split(" ")]
res = 0
for i in range(K, N + 2):
  res += (N - i + 1) * i + 1
  #print res, i, (N - i + 1) * i + 1
print(res % 1000000007)
n,k = map(int,input().split())
su = 0
mod = 10**9+7
for i in range(k,n+2):
  a = i*(i-1)//2
  b = i*(2*n+1-i)//2
  su += b-a+1
 # print(a,b,su)
  su %= mod
print(su)
n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7

n_min = sum([i for i in range(0, k-1)])
n_max = sum([n - i for i in range(0, k-1)])

for i in range(k-1, n+1):
  n_min += i
  n_max += n - i
  ans += n_max - n_min + 1
    
print(ans % mod)
def II(): return int(input())
def MI(): return map(int, input().split())
N,K=MI()
ans=0
MOD=10**9+7
for i in range(K,N+2):
  x=(N+1-i)*i+1
  ans+=x
  ans%=MOD
print(ans)
n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    a=0.5*i*(i-1)
    b=0.5*n*(n+1)-0.5*(n-i)*(n-i+1)
    ans+=int(b-a+1)


print(ans%(10**9+7))
n,k=map(int,input().split())
# 累積和！max-min+1
csl=[]
sum=0
for i in range(n+1):
	sum+=i
	csl.append(sum)
#3 2
#[0, 1, 3, 6]
# 0 1 2 3
cnt=0
for i in range(k,n+1):
	max=csl[n]-csl[n-i]
	min=csl[i-1]
	#初めの数も含むの+1
	cnt+=(max-min+1)
	cnt%=(10**9+7)
#0~nまで全選択の+1
print(cnt+1)
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

ans = 0
for i in range(K, N + 2):
    ans += (N + N - i + 3) * i // 2 - i * (i + 1) // 2 + 1
    ans %= MOD
print(ans)
n, k = [int(_) for _ in input().split()]

ans = 0
for i in range(k, n+2):
    ans += (((n + (n-i+1)) * i) / 2) - ((i-1) * i) / 2 + 1
    ans = ans % (10**9+7)
print(int(ans))
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N,K = LI()
ans = 0
for i in range(K,N+2):
    ans = (ans + (N*i - (i-1) * i // 2) - i*(i-1) // 2 +1) % MOD
print (ans)
n,k = [int(i) for i in input().split(' ')]
s = 0
for i in range(k,n+2):
    s += i*n - (i*i) + i + 1
    
print(s%(10**9+7))
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

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


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

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

total_num = 0

for k in range(K, N + 2):
    # Min = sum(range(k))
    # Max = sum(range(N - (k - 1), N + 1))
    # # print("%s~%s" % (Min, Max))
    # num = Max - Min + 1
    num = (N - (k - 1)) * k + 1
    total_num += num

print(int(total_num % (1e9+7)))
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
MOD = 10**9 + 7

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


if __name__ == '__main__':
    main()
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

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

ans = 0
for i in range(k, n+2):
    min = i * ( 0 + i-1) / 2
    max = i * ( (n+1 - i) + n) / 2
    ans += int(max - min + 1)

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

mod = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    # 等差数列の和 項数*(初項+末項)/2
    min = i * (0 + (i - 1)) // 2
    max = i * ((n - (i - 1)) + n)  // 2
    ans += (max - min) + 1
    ans %= mod
    
print(ans)
n,k=map(int,input().split())
left=right=ways=0
for i in range(n+1):
  left += i
  right += n-i
  if i >= k -1:
    ways += max(right -left +1, 0)
print(int(ways%(1e9+7)))
n, k = map(int, input().split())
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 %= 10**9 + 7

print(ans)
N,K = map(int,input().split())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

for i in range(K,N+2):
    cnt[i-K] = i*N - i*(i-1) + 1

for i in range(N-K+2):
    cnt_all += cnt[i]

print(cnt_all % mod)
n, k = map(int, input().split())
print((((-2 + k - n)*(-6 + 2* k**2 - n - n**2 - k*(2 + n)))//6)%(10**9+7))