TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
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
  # print('{},{},{}'.format(i, mmin, mmax))

  k = 10**9 + 7
  print(a%k)

    
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))

    
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2


import numpy as np

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

a = 1
for i in range(k, n + 1):
  mmin = summ(i)
  mmax = summ(n, n - i)
  m = mmax - mmin
  a += m
  
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)
  mmax = summ(n, n - i)
  m = mmax - mmin
  a += m

print(a)

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))

    
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2


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))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k=map(int,input().split())






# 

ans=0
for m in range(k,n+1):
    print((m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 ))
    ans+= (m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 )
print(int(ans+1))

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






# 

ans=0
for m in range(k,n+1):
    ans+= (m*(2*n+(m-1)*-1)/2 - m*(2*0+(m-1))/2 + 1 )
print(int((ans+1)%(10**9+7)))


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k=map(int,input().split())
L=list(range(n+1))

cnt=0
ans=0

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


for i in range(k,n+2):
    print(i,calc(i))
    cnt+=calc(i)
    

print(cnt)

n,k=map(int,input().split())
L=list(range(n+1))

cnt=0
ans=0

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


for i in range(k,n+2):
    cnt+=calc(i)
    cnt%=(10**9+7)
    

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
  print(s%10**9+7)

N ,K =(int(x) for x in input().split(' '))

s = 0

for a in range(K,N+2) :
  
  SUM1 = sum([x for x in range(0,a)])
  SUM2 = sum([x for x in range(N-a+1, N+1)])
  
  s = s + SUM2 - SUM1 + 1
  
  print(s)
  
  

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

a = (n-k+2)*(((k+n+1)*(n+1))+2)//2
b = (((n+1)*(n+2)))*(2*n+3)//6
c = (((k-1)*k))*(2*k-1)//6

print((a-b+c)%(10**9+7))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
s_1 = 0
s_2 = 0
s_3 = 0
mod = 1000000007
ans = 0
for i in range(k, n + 2):
    s_1 = (n + n + 1 - i) * i / 2
    s_2 = (0 + i - 1) * i / 2
    s_3 += s_1 + 1 - s_2
ans = s_3 % 1000000007
print('{:g}'.format(ans))


n, k = map(int, input().split())
s_1 = 0
s_2 = 0
s_3 = 0
mod = 1000000007
ans = 0
for i in range(k, n + 2):
    s_1 = (n + n + 1 - i) * i // 2
    s_2 = (0 + i - 1) * i // 2
    s_3 += s_1 + 1 - s_2
ans = s_3 % 1000000007
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
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 latgest -smallest + 1

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

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)


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)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
i,j= list(map(int, input().split()))
n=i+1
nCr = j
sum=0
print(nCr)
for r in range(n):
    nCr_1 = nCr * (n - r) // (r + 1)
    nCr = nCr_1
    sum+=nCr_1
print(sum%(10**9+7))

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

i,j= list(map(int, input().split()))
n=i+1
nCr = j
sum=0
from scipy.special import comb

for k in range(j,n+1):
    sum+=comb(n, k, exact=True)
print(sum%((10**9)+7))


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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
print(1)

N,K = map(int,input().split())
A = 0
while K < N +2:
    min = K/2*(K-1)
    max = K/2*(2*N-K +1)
    A += max - min + 1
    K+= 1
print(int(A % (10**9 +7) ))




Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K = map(int, input().split())
 
if K==N+1:
    print(1)
elif K==N:
    print(N+2)
else:
    
    zentori=[]
    for i in range(2**(K-1),2**(N+1)):
        
        baai=[]
        for j in range(N+1):
            if i<2**j+2**(K-1):
                continue
            if (i>>j) & 1:
                baai.append(j)
        if len(baai)>=K:
            zentori.append((sum(baai),len(baai)))
    
    setzentori=set(zentori)
    print(int(len(setzentori)%(10**9+7)))


N, K = map(int, input().split())
 
if K==N+1:
    print(1)
elif K==N:
    print(N+2)
else:
    def tousawa(shokou, makkou, kosu):
        return int((shokou+makkou)*kosu/2)
    
    ans=0
    for i in range(K,N+2):
        ans+=tousawa(N-i+1,N,i)-tousawa(0,i-1,i)+1
    print(int(ans%(10**9+7)))


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n, k = list(map(int, input().split()))

mod = 1000000009

sn = (n*(n+1)*(n+2)/6 +n+1)% mod
sk = ((k-1)*k*(3*n-2*k+4)/6 +k-1)% mod

snk = (sn - sk)% mod

print(snk)

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

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

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

import math

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

mod = 10**9 +7

sn = (n*(n+1)*(n+2)/6 +n+1)% mod
sk = ((k-1)*k*(3*n-2*k+4)/6 +k-1)% mod

snk = math.floor((sn - sk)% mod)

print(snk)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k = map(int,input().split())

mod = 10**9 + 7

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

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

mod = 10**9 + 7

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K=map(int,input().split())
ans=0
for k in range(K,N+2):
  ans+=k*(k-1)//2 - k*(2*N+3-k)//2 +1
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):





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




possible = 0


for selected in range(K, N + 1):
    
    minFraction = sum(range(selected))

    
    maxFraction = sum(range(N + 1 - selected, N + 1))

    
    possible += maxFraction - minFraction + 1

print(possible)



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




possible = 0


def sumRange(first, last):
    count = last - first + 1
    return (first + last) * count / 2




for selected in range(K, (N + 1) + 1):
    
    minFraction = sumRange(0, selected - 1)

    
    maxFraction = sumRange(N - selected + 1, N)

    
    possible += maxFraction - minFraction + 1

print(possible)



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




possible = 0


def sumRange(first, last):
    count = last - first + 1
    return int((first + last) * count / 2)




for selected in range(K, (N + 1) + 1):
    
    minFraction = sumRange(0, selected - 1)

    
    maxFraction = sumRange(N - selected + 1, N)

    
    possible += maxFraction - minFraction + 1


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



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

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


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

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


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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
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())
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))


Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K=map(int,input().split())
M=N+1
L=K-1
print((M*(M*M+5)/6 + L*(L*L*2+L*3-5-M*(L+1)*3)/6)%(10**9+7))

N,K=map(int,input().split())
M=N+1
L=K-1
print(M*(M*M+5)/6 + L*(L*L*2+L*3-5-M*(L+1)*3)/6%10**9+7)

MAX_NUM = 10**6 + 1
MOD = 10**9+7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

n,k=map(int,input().split())
ans=0
for r in range(k,n+2):
    ans+=combinations(n+1,r)-r
print(ans)

N,K=map(int,input().split())
M=N+1;L=K-1
print((M**3+5*M+2*L**3+3*(1-M)*L**2-(5+3*M)*L)/6%1000000007)

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;
int main() {
    long long N, K;
    cin >> N >> K;
    long long M = N+1, L = K-1;
    long long res = M*(M*M+5)/6 + L*(L*L*2+L*3-5-M*(L+1)*3)/6;
    cout << res%MOD << endl;
}

N,K=map(int,input().split())
M=N+1
L=K-1
print((M*(M*M+5)/6+L*(L*L*2+L*3-5-M*(L+1)*3)/6)%(10**9+7))

N,K=map(int,input().split())
M=N+1
L=K-1
print(M*(M*M+5)/6 + L*(L*L*2+L*3-5-M*(L+1)*3)/6%(10**9+7))

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
#!/usr/bin/env python3

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

mod = 10**9+7




low_lim = (((1+k) % mod) * (k % mod)) % mod // 2
up_lim = (((1+n) % mod)*(n % mod) % mod)//2

num = low_lim-up_lim

print(num % mod)


#!/usr/bin/env python3

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

mod = 10**9+7

ans = 0
for k_ in range(k, n+2):
    low_lim = (0+(k_-1))*k_//2
    up_lim = ((n-k_+1)+n)*k_//2
    
    ans += up_lim - low_lim + 1






print(ans % mod)


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):


def main():
    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()

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()

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K = map(int, input().split())
 
c = 0
for i in range(K, N + 1 + 1):
    ma = ((N + N - (i - 1)) * i) / 2
    mi = ((0 + i - 1) * i) / 2
    c += int(ma - mi + 1)
 	c %= (10 ** 9 + 7)
print(c)

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

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

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

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:27:49 2020

@author: arute
"""


from sys import stdin

import time
import numpy as np
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
M = int(temp[1])


probs = np.zeros(1).astype("int64")

for i,m in enumerate(range(M,N+2)):
    
    if i == 0:
        small = np.sum(np.arange(m))
        #
        large = np.sum(np.arange(N+1-m,N+2))
    else:
        small = (small+m-1).astype("int64")
        large = (large + (N+1-m)).astype("int64")
    
    probs = probs + (large - small + 1)

print(int(probs%(1e9+7)))


# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:27:49 2020

@author: arute
"""


from sys import stdin

import time
import numpy as np
import math



def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
M = int(temp[1])


probs = np.zeros(1).astype("int64")

for i,m in enumerate(range(M,N+2)):
    
    if i == 0:
        small = np.sum(np.arange(m))
        #
        large = np.sum(np.arange(N+1-m,N+1))
    else:
        small = (small+m-1).astype("int64")
        large = (large + (N+1-m)).astype("int64")
    probs = probs + (large - small + 1)

print(int(probs%(1e9+7)))


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K = map(int,input().split())
print(-(1/3)*N*(N**2 - 3*N - 1) - N*K +(1/3)*(K-1)*(K-2)*(K-3))

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K = map(int, input().split())
MOD = 10**9+7

fact = [0] * (N+2)
fact[0] = fact[1] = 1

def comb_init():
	global fact
	for i in range(2, N+2):
		fact[i] = i * fact[i-1]

def comb(n, r):
	global fact
	x = fact[n] % MOD
	y = pow(fact[r], -1, MOD)*pow(fact[n-r], -1, MOD)
	return (x*y)%MOD

ans = 0
comb_init()
for i in range(K, N+2):
	ans += comb(N+1, i)
	ans %= MOD
print(ans%MOD)

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

fact = [0] * (N+2)
fact[0] = fact[1] = 1

def comb_init():
	global fact
	for i in range(2, N+2):
		fact[i] = i * fact[i-1]

def comb(n, r):
	global fact
	x = fact[n] % MOD
	y = pow(fact[r], -1, MOD)*pow(fact[n-r], -1, MOD)
	return (x*y)%MOD

ans = 0
comb_init()
for i in range(K, N+2):
	ans += comb(N+1, i)
print(ans%MOD)


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
	ans %= MOD
print(ans%MOD)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K=map(int,input().split())
def wa(N,K):
    return (N+1)*K-K**2
d=0
for i in range(K,N+1):
  d=d+wa(N,i)
print((d+1)%(10**9+7))


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


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k=map(int,input().split())

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

result = 0
for j in range(k, n+2):
    result += cmb(n,j,p)

print(result)
    

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

res=0
for i in range(k,n+2):
  mae=i*(i-1)//2
  ushiro=i*(2*n-i+1)//2
  res+=ushiro-mae+1
  res%=10**9+7
print(res)

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
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)


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()

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()

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
M = int(input())
K = int(input()) 

sum = 0

for j in range(K,M+2):
    temp = j*(M-j+1) + 1
    if temp > (10^9 + 7):
        temp = temp%(10^9 + 7)
    sum += temp

print(sum)

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

sum = 0

for j in range(K,M+2):
    temp = j*(M-j+1) + 1
    if temp > (10**9 + 7):
        temp = temp%(10**9 + 7)
    sum += temp
if sum > 10**9+7:
    sum = sum%(10**9+7)

print(sum)

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n, k = map(int, input().split())
M = (n+1)*(1/2)*(n+1)*(n+2)-(1/6)*(n+1)*(n+2)*(n*2+3)+n+1
m = (n+1)*(1/2)*(k-1)*k-(1/6)*(k-1)*k*(2*k-1)+k-1
ans = M-m
print(ans%(1000000007))

n, k = map(int, input().split())
M = (n+1)*(1/2)*(n+1)*(n+2)-(n+1)*(n+2)*(n*2+3)*(1/6)+n+1
m = (n+1)*(1/2)*(k-1)*k-(k-1)*k*(2*k-1)*(1/6)+k-1
ans = M-m
print(int(ans%(1000000007)))

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k = (int(x) for x in input().split())
M = 10**9+7
s = 0

for i in range(n-k):
    ad = 1 + i*(n-i+1)
    s += ad
    if s >= M:
        s -= N
        
print(s)

n,k = (int(x) for x in input().split())
M = 10**9+7
s = 0

for i in range(n+2-k):
    ad = 1 + (n+1-k-i)*(k+i)
    s += ad


        
print(s%M)

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):

def answer(N:int,K:int) -> int:
    counter = 0
    for i in range(K,N+2):
        counter += i*(N - K + 1) + 1
    return counter % (10**9 + 7)



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

if __name__ == '__main__':
   main()



def answer(N:int,K:int) -> int:
    l = [i for i in range(N+1)]
    counter = 0
    for i in range(K,N+2):
        counter += i*(N - i + 1) + 1

    return counter % (10**9 + 7)



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

if __name__ == '__main__':
   main()


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n, k = map(int, input().split())

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

print(ans)


using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    long long ans = 0;

    for (int i = k; i <= n+1; ++i){
        ans += i * (n - i + 1) + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

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

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

print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
import numpy as np

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
ref = np.array(list(range(n + 1)), dtype='int64')

max_sum = np.sum(ref[-k + 1:])
min_sum = np.sum(ref[:k - 1])
ans = 0

print('min, max = ', min_sum, max_sum, max_sum - min_sum)
for i in range(k, n + 2):
    min_sum += ref[i - 1]
    max_sum += ref[-i]
    ans += max_sum - min_sum + 1
    ans %= MOD

print(ans)


import numpy as np

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
ref = np.array(list(range(n + 1)), dtype='int64')

max_sum = np.sum(ref[-k + 1:])
min_sum = np.sum(ref[:k - 1])
if k == 1:
    max_sum = min_sum = 0
ans = 0

for i in range(k, n + 2):
    min_sum += ref[i - 1]
    max_sum += ref[-i]
    ans += max_sum - min_sum + 1
    ans %= MOD

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K = map(int, input().split())



def calc(x):
    a = x * (x - 1) // 2
    b = (2 N - x + 1) * x // 2
    return a - b + 1


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

tot /= 10 ** 9 + 7

print(tot)


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




def calc(x, N):
    a = x * (x - 1) // 2
    b = (2 * N - x + 1) * x // 2
    return b - a + 1


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

aa = tot % (10 ** 9 + 7)

print(aa)


Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K = map(int, input().split())


#20000100000










#0,1
#0,2
#0,3=1,2= 3,0/2,1
#0,4=1,3
#0,5=1,4/2,3
#0,6=1,5/2,4
#0,7=1,6/2,5/3,4 =4,3/5,2/6,1/7,0


#0,1,2 003
#0,1,3
#0,1,4=0,2,3
#0,1,5=0,2,4=2,1,3
#1,3,6 = 6,4,0 = 5,3,2


#0111 1011 1101 1110

#11100
#11010






#######################################################################
#https://note.nkmk.me/python-math-factorial-permutations-combinations/
from functools import lru_cache
from operator import mul
from functools import reduce

@lru_cache(maxsize=100000000)
def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
#######################################################################

ans = 0

for i in range(K,N+2):
    Ni_comb = combinations_count(N+1,i)
    print(i,Ni_comb)
    ans += Ni_comb

print(ans)

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


#20000100000








ans = 0

for i in range(K,N+2):
    comb_min = (0+i-1)*i//2 #sum(all_num[0:i])
    comb_max = (N+N-i+1)*i//2 #sum(all_num_inv[0:i])
    #print(i,comb_min,comb_max)
    comb_num = comb_max - comb_min + 1
    ans += comb_num
    ans %= MOD_BY
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k = map(int,input().split())
mod = 10**9+7
answer = 0

for i in range(k,n+2):
  max_value = sum(range(n-i,n+1))
  lowest_value = sum(range(0,i+1))
  answer = answer + max_value - lowest_value + 1

print(answer % mod)

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

for i in range(k,n+1):
  max_value = sum(range(n-i+1,n+1))
  lowest_value = sum(range(1,i+1))
  answer = answer + max_value - lowest_value + 1
 
print(answer % mod)

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

for i in range(k,n+1):
  max_value = sum(range(n-i+1,n+1))
  lowest_value = sum(range(0,i))
  answer = answer + max_value - lowest_value + 1

print(answer % mod)

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

for i in range(k,n+2):
  max_value = sum(range(n-i,n))
  lowest_value = sum(range(0,i))
  answer = answer + max_value - lowest_value + 1

print(answer % mod)


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

for i in range(k,n+1):
  max_value = sum(range(n-i+1,n+1))
  lowest_value = sum(range(1,i+1))
  answer = answer + max_value - lowest_value + 1
 
print(answer % mod)


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

for i in range(k,n+1)

max_value = sum(range(n-i+1,n+1))
lowest_value = sum(range(1,i+1))
 
answer = answer + max_value - lowest_value + 1
 
print(answer % mod)

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

for i in range(k,n+2):
  max_value = sum(range(n-i+1,n+1))
  lowest_value = sum(range(1,i+1))
  answer = answer + max_value - lowest_value + 1

print(answer % mod)

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

max_value = sum(range(1,n+1))
lowest_value = sum(range(1,k+1))

answer = max_value - lowest_value + 1

print(answer % mod)

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

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

print(answer % mod)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):

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


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

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
MOD = 10**9+7

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


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

    t = (N-k+1)*k
    cnt += t
    cnt %= MOD
print(cnt)

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)

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K=map(int,input().split())
N = N+1
a = N - K
ans = 0

MM = 10**9 +7

for i in range(K,K+a):
  start = int( ( (i)*(i-1)/2 ) % MM )
  fin = int( ( (N+(N-1)-i)*(i)/2+1 ) % MM )
  ans = int( ( ans + (fin - start) ) % MM )
  print(fin,start)
if N == K:
  ans = ans + 1
print(ans)


N,K=map(int,input().split())
N = N+1
a = N - K
ans = 0

MM = 10**9 +7

for i in range(K,K+a):
  start = int( ( (i)*(i-1)/2 ) % MM )
  fin = int( ( (N+(N-1)-i)*(i)/2+1 ) % MM )
  ans = int( ( ans + (fin - start) ) % MM )

ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
def touSum(a,l):
    return int(((l-a+1)*(a+l))/2)

N,K = map(int,input().split())
maxSum = touSum(1,N)
print(maxSum)
con = 0
for i in range(K,N+1+1):
    #print(str(i)+":"+str(touSum(1,i-1))+":"+str(touSum((1+N)-i,N)))
    if touSum(1,i-1)>maxSum:
        print(con)
        break
    else:
        con += touSum((1+N)-i,N) -touSum(1,i-1)+1
print(con%(10**9+7))

def touSum(a,l):
    return int(((l-a+1)*(a+l))/2)

N,K = map(int,input().split())
maxSum = touSum(1,N)
#print(maxSum)
con = 0
for i in range(K,N+1+1):
    #print(str(i)+":"+str(touSum(1,i-1))+":"+str(touSum((1+N)-i,N)))
    if touSum(1,i-1)>maxSum:
        print(con)
        break
    else:
        con += touSum((1+N)-i,N) -touSum(1,i-1)+1
print(con%(10**9+7))

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

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

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


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N,K=map(int,input().split())
n=[i for i in range(N+1)]
mod=10**9+7141421 35623

min_value=[0]*(N+1)
max_value=[0]*(N+1)
min_value[0]=0
max_value[0]=N
for i in range(1,N+1):
  min_value[i]=min_value[i-1]+n[i]
  max_value[i]=max_value[i-1]+n[-(i+1)]

ans=0
for i in range(K-1,N+1):
  ans+=max_value[i]-min_value[i]+1
  ans%=mod
print(ans)

N,K=map(int,input().split())
n=[i for i in range(N+1)]
mod=10**9+7

min_value=[0]*(N+1)
max_value=[0]*(N+1)
min_value[0]=0
max_value[0]=N
for i in range(1,N+1):
  min_value[i]=min_value[i-1]+n[i]
  max_value[i]=max_value[i-1]+n[-(i+1)]

ans=0
for i in range(K-1,N+1):
  ans+=max_value[i]-min_value[i]+1
  ans%=mod
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n, k = map(int, input().split())

a = 0

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

ans = a % (10**9+7)
print(ans)

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

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

ans = a % (10**9+7)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K=map(int,input().split())
print(((N+1)*(N+K+1)*(N-K+2)/2+N-K+2-(N+1)*(N+2)*(2*N+3)/6+(K-1)*K*(2*K-1)/6)%(10**9+7))

N, K=map(int,input().split())
print(int(((N+1)*(N+K+1)*(N-K+2)/2+N-K+2-(N+1)*(N+2)*(2*N+3)/6+(K-1)*K*(2*K-1)/6)%(10**9+7)))

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
# -*- coding: utf-8 -*-
import numpy as np
import itertools
import time
n, k = list(map(int, input().split()))

result = 0
for _k in range(k, n + 2):
    
    min_value = ((_k-1)+1)*(_k-1)/2
    max_value = (n + n - (_k-1)) * (_k)/2
    # print(min_value, max_value)
    result += max_value - min_value + 1
print(result)


# -*- coding: utf-8 -*-
import numpy as np
import itertools
import time
n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
result = 0
for x in range(k, n + 2):

    
    min_value = x*(x-1)//2
    max_value = (n + n-x+1)*x//2
    # print(min_value, max_value)
    result += max_value - min_value + 1
print(int(result) % MOD)


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K = map(int, input().split())

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

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

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


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n, k = map(int, input().split())
total = 0
for i in range(k, n+2):
  total += i(n+1-i) + 1
  total %= 10**9 + 7
print(total)

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


Verdicts: Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
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+1):
  L = i * (i - 1) / 2
  R = n * i - i * (i - 1) / 2
  ans += R - L + 1
print(ans)

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))

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
import numpy as np 

a = input()
N,K = np.array(a.split()).astype(int)

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

res = 0
for i in range(K, N+1+1):
    l = b_sum(0,i-1)
    r = b_sum(N-i+1, N)
    res += r-l+1
    print(r-l+1)
print(res)



import numpy as np 

a = input()
N,K = np.array(a.split()).astype(int)

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

res = 0
for i in range(K, N+1+1):
    l = b_sum(0,i-1)
    r = b_sum(N-i+1, N)
    res += r-l+1
mod = 10**9 + 7
print(res%mod)



Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


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

    g1 = [1, 1]  
    g2 = [1, 1]  
    inv = [0, 1]  計算用テーブル

    if n+1 == k:
        print(1)
        exit()

    for i in range(2, n + 2):
        g1.append((g1[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inv[-1]) % mod)

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

    print(ans % mod)


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


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

    g1 = [1, 1]  
    g2 = [1, 1]  
    inv = [0, 1]  計算用テーブル

    if n+1 == k:
        print(1)
        exit()

    for i in range(2, n + 2):
        g1.append((g1[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inv[-1]) % mod)

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

    print(ans)


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

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

    print(ans % mod)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
import itertools
def main():
    N,K = map(int, input().split())
    MOD = pow(10,9)+7

    
    
    
    
    
    
    
    
    

    ans  = 0
    for m in range(K,N+2):
        ans += (N-m+1)*m%MOD
    print(ans%MOD)


main()


import itertools
def main():
    N,K = map(int, input().split())
    MOD = pow(10,9)+7

    
    
    
    
    
    
    
    
    

    ans  = 0
    for m in range(K,N+2):
        ans += ((N-m+1)*m+1)%MOD
    print(ans%MOD)


main()


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
n,k=map(int,input().split())
count=0
for i in range(n+1):
    if i<k:
        continue
    elif i>=k:
        mini=i*(i-1)//2
        a=n*(n+1)//2
        b=(n-i)*(n-i+1)//2
        maxi=a-b
        total=maxi-mini+1
        count+=total
print(count%(10**9+7))
        

n,k=map(int,input().split())
count=0
for i in range(n+2):
    if i<k:
        continue
    elif i>=k:
        mini=i*(i-1)//2
        a=n*(n+1)//2
        b=(n-i)*(n-i+1)//2
        maxi=a-b
        total=maxi-mini+1
        count+=total
ans=count%(10**9+7)
print(ans)
        

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

def sum(a,b):
    i=0
    i = (a + b)*(b - a + 1)/2
    return i

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(s % 10**9+7)

list = input().split()
N = list[0]
K = list[1]
i = K
s = 0

def sum(a,b):
    i=0
    for p in range(b-a+1):
        i+= a + p
    return i

print(sum(1,5))

for i =< N + 1:
    s += sum(N-i+1,N) - sum(0,i-1)
    i += 1
print(s)
    

list = input().split()
N = list[0]
K = list[1]
i = K
s = 0

def sum(a,b):
    i=0
    for p in range (b-a+1):
        i += a + p
    return i

for i =< N + 1:
    s = s + sum(N-i+1,N) - sum(0,i-1)
    i += 1
print(s)

list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

def sum(a,b):
    i=0
    i = (a + b)*(b - a + 1)/2
    return i

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(s % (10**9+7))

N, K = map(int,input().split())
i = K
s = 0

def sum(a,b):
    i=0
    for p in range(b-a+1):
        i+= a + p
    return i

print(sum(1,5))

for i =< N + 1:
    s += sum(N-i+1,N) - sum(0,i-1)
    i += 1
print(s)

list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

def sum(a,b):
    i=0
    i = (a + b)*(b - a + 1)/2
    return i

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(s)

list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

def sum(a,b):
    i=0
    i = (a + b)*(b - a + 1)/2
    return i

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(int(s % (10**9+7)))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
INF = 10 ** 9 + 7
N, K = map(int, input().split())

l = []
ans = 0

for i in range(N+1):
  l.append(i)

mx = l[N]
mn = 0
print(l)
for i in range(K, N+2):
  s = 0
  mx += l[N-i+1]
  mn += l[i-1]
  ans += (mx - mn + 1) % INF

print(ans % INF)


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

ans = 0
mx = 0
mn = 0

for i in range(N+1):
  mx += N-i
  mn += i
  if i + 1 >= K:
    ans += (mx - mn + 1) % INF

print(ans % INF)


Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
N, K = map(int, input().split())

print(((N*(N+1)*(N+2) - K*(K-1)*(3*N-2*K+4))/6 + N - K + 2)%1000000007)

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))

Verdicts: Wrong Answer

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
mod = 10**9+7
n, k = map(int, input().split())

ans = 0

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

print(ans%mod)




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

ans = 0

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

print(ans)



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

ans = 0

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

print(ans%mod+1)




Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.  We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Submission attempts (in order):
#input
N, K = map(int, input().split())

#output
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)

#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)

Verdicts: Runtime Error

Accepted