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):
# coding: utf-8
# Your code here!
import numpy as np
#import math
import itertools


#N= int(input())
N, K = map(int, input().split())
l = [i for i in range(N+1)]

count = 0
if K == N+1:
    max_sum = np.sum(l)
    print(max_sum)
else:
    max_sum = np.sum(l[-K+1:])
if K == 1:
    min_sum = 0
else:
    min_sum = np.sum(l[:K-1])
    print(min_sum)
#print(l)
print(N, K)

for k in range(K,N+2):
    max_sum += l[-k]
    min_sum += l[k-1]
    count += (max_sum-min_sum+1)%((10**9)+7)
    
print(count%((10**9)+7))
#count = 0
#for k in range(K, N+1):
#    count += 
#141421 35623

# coding: utf-8
# Your code here!
import numpy as np
#import math
import itertools


#N= int(input())
N, K = map(int, input().split())
l = [i for i in range(N+1)]

count = 0
if K == N+1:
    max_sum = np.sum(l[1:])
elif K == 1:
    max_sum = 0
else:
    max_sum = np.sum(l[-K+1:])

if K == 1:
    min_sum = 0
else:
    min_sum = np.sum(l[:K-1])

#print(max_sum)
#print(min_sum)
#print(l)

for k in range(K,N+2):
    max_sum += l[-k]
    min_sum += l[k-1]
    
    count += (max_sum-min_sum+1)%((10**9)+7)
    
print(count%((10**9)+7))
#count = 0
#for k in range(K, N+1):
#    count += 
#141421 35623

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())
cnt = [0]*(N-K+2)

cnt_all = 0
mod = 1000000007

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

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

print(cnt_all % mod)

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] = (i+1)*(N-i)

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

print(cnt_all % mod)


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

Verdicts: 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
MOD = 10**9+7
for i in range(k, n+2):
    maxim = (i - 1) * i // 2
    minim = (n + n - i + 1) * i // 2
    ans += (maxim - minim + 1)
    ans %= MOD
print(ans)

n, k = map(int, input().split())
ans = 0
MOD = 10**9+7
for i in range(k, n+2):
    
    maxim = (n + n - i + 1) * i // 2
    minim = (i - 1) * i // 2
    ans += (maxim - minim + 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):
a,b=(int(x) for x in input().split())
z=0
for i in range(b,a+2):
  z=(z+(a-i+1)*i+1)%(1e9+7)
print(z)

a,b=(int(x)for x in input().split())
z=0
while b<=a+1:z=(z+(a-b+1)*b+1)%(10**9+7);b+=1
print(z)

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):
    tmpans = 0
    s1 = (0+i-1)*i/2
    s2 = (n-i+1 + n)*i/2
    tmpans = s2-s1+1
    ans += tmpans
print(max(1,ans%(10**9+7)))

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

for i in range(k,n+2):
    tmpans = 0
    s1 = (0+i-1)*i//2
    s2 = (n-i+1 + n)*i//2
    tmpans = s2-s1+1
    ans += tmpans
print(max(1,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):
def main(N=None, K=None):
    if not N:
        N = int(input())
        K = int(input())
    ans = (K-N-2)*(2*K*K-K*(N+2)-N*N-N-6)//6
    ans %= 10**9+7
    print(ans)
    return ans


if __name__ == "__main__":
    
    
    
    main()


def main(N=None, K=None):
    if not N:
        N, K = map(int, input().split())
    ans = (K-N-2)*(2*K*K-K*(N+2)-N*N-N-6)//6
    ans %= 10**9+7
    print(ans)
    return ans


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())
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
    K+= 1
diff = diff % mod
print(int(diff))


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

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

ans = 0

for i in range(K,N+2):
  Min = i*(i-1)/2
  Max = i*(2*N-i+1)/2
  ans += Max-Min+1
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 = i*(2*N-i+1)/2
  ans += Max-Min+1
print(int(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):
import itertools
n = int(input())
k = int(input())
l = list(range(n+1))
ad = 0
for i in list(range(k,n+2)):
        l2 = list(itertools.combinations(l,r=i))
        se = set([sum(j) for j in l2])
        ad += len(se)
print(ad)


mport itertools
n,k = map(int,input().split())
l = list(range(n+1))
ad = 0
for i in list(range(k,n+2)):
        l2 = list(itertools.combinations(l,r=i))
        se = set(map(sum,l2))
        ad += len(se)
print(ad)

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)

Verdicts: 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())
mod = 1000000007
sum = 0
for i in range(k, n + 2):
    tempSum1 = (n * (n + 1)) / 2
    tempSum2 = ((n - i) * (n - i + 1)) / 2
    tempSum3 = (i * (i - 1)) / 2
    sum += (tempSum1 - tempSum2 - tempSum3 + 1) % mod
print(sum % mod)

n, k = map(int, input().split())
mod = 1000000007
sum = 0
for i in range(k, n + 2):
    tempSum1 = (n * (n + 1)) / 2
    tempSum2 = ((n - i) * (n - i + 1)) / 2
    tempSum3 = (i * (i - 1)) / 2
    sum += (tempSum1 - tempSum2 - tempSum3 + 1) % mod
print(int(sum % 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):
a = list(map(int,input().split()))
n = a[0]
k = a[1]

count = 0


b=n+1-k+1
keisu=[0]*b
for i in range(b):
  keisu[i]=k+i


for i in keisu:
  mn = (i-1)*i/2
  mx = (2*(n-i+1)+(i-1))*i/2
  count += mx-mn+1
  
print(count%(10^9+7))

a = list(map(int,input().split()))
n = a[0]
k = a[1]

count = 0


b=n+1-k+1
keisu=[0]*b
for i in range(b):
  keisu[i]=k+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))

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()))
s=0
for i in range(k,n+2):
	s+=i*(2*n-i+1)+1
print(s%(1000000007))

n,k,s=list(map(int,input().split())),0
for i in range(k,n+2):
	s+=i*(n+n-(i-1))//2+1-(i*(i-1))//2
print(s%(1000000007))

n,k,s=input(),input(),0
for i in range(k,n+2):
	s+=i*(n+n-(i-1))//2+1-(i*(i-1))//2
print(s%(1000000007))

n,k=list(map(int,input().split()))
for i in range(k,n+2):
	s+=i*(n+n-(i-1))//2+1-(i*(i-1))//2
print(s%(1000000007))

n,k=list(map(int,input().split()))
s=0
for i in range(k,n+2):
	s+=i*(n+n-(i-1))/2+1-(i*(i-1))/2
print(s%(1000000007))

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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):
from scipy.special import comb
N, K = tuple(map(int, input().split()))

result = 0
k = K
while k <= N + 1:
    result += comb(N, k, exact=True)
    k += 1

print(result)



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

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

    
    sum_min = ((0 + k - 1) * k) / 2

    
    
    total += int(sum_max - sum_min + 1)

print(total % (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 = (int(x) for x in input().split())
for i in range(k,n+2):
    base = n*i -(i*(i-1)) +1
#    print(base)
    res = res+ base

resu = res%1000000007

print(resu)

n,k = (int(x) for x in input().split())
res = 0
for i in range(k,n+2):
    base = n*i -(i*(i-1)) +1
    res = res+ base
resu = res%1000000007
print(resu)

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

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

def check(n,k):
    sum_min = (k-1)*k/2
    sum_max = n*(n+1)/2 - (n-k)*(n-k+1)/2
    
    sum_pattern = sum_max - sum_min + 1
    return sum_pattern


cnt = 0
for i in range(K,N+1):
    c = check(N,i)
    cnt = (cnt + c) % (10**9+7)
    
print(cnt+1)


# -*- coding: utf-8 -*-

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

def check(n,k):
    sum_min = (k-1)*k/2
    sum_max = n*(n+1)/2 - (n-k)*(n-k+1)/2
    
    sum_pattern = sum_max - sum_min + 1
    return sum_pattern


cnt = 0
for i in range(K,N+1):
    c = check(N,i)
    cnt = (cnt + c) % (10**9+7)
    
print(int(cnt+1))


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 math
import itertools

N, K = map(int, input().strip().split())
L = math.pow(10, 10)

values = [0] * (N + 1)
for i in range(N + 1):
    values[i] = i

amount = 0
for comb_no in range(K, N + 2):
    possible_values = set()
    for combination in itertools.combinations(values, comb_no):
        possible_values.add(sum(combination))
    print(len(possible_values))

import math
import itertools

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

all_combination = 0
for num in range(K, N + 2): 
    min = (0 + num - 1) * num / 2
    max = (N - (num - 1) + N) * num / 2
    possiblility = (int(max) - int(min) + 1)
    all_combination += possiblility

print(all_combination % (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):
print(1)
N, K  = map(int, input().split())


print(N)
print(K)


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

print(K,N)


mod = 1000000000+7

z=0
for x = range(K, N+2):
  for y = range(0,x):
    z += (N-y) - y + 1
    z %= mod
#
print(z)


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

mod = 1000000000+7

z=0
for x = range(K, N+2):
  for y = range(x):
    z += (N-y) - y + 1
    z %= mod
#
print(z)


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)



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

  z = (z + zz) % mod
  zz += (N-x+1) - (x-1)
  zz = zz % mod
#
print(z)



Verdicts: Wrong Answer

Runtime Error

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):
n,k=map(int,input().split())
print(((n+1)*(n+1+k)*(n-k+2)//2-(n+1)*(n+2)*(2*n+3)//6+k*(k-1)*(2*k-1)//6)%(10**9+7))

n,k=map(int,input().split())
print(((n+1)*(n+1+k)*(n-k+2)//2-(n+1)*(n+2)*(2*n+3)//6+k*(k-1)*(2*k-1)//6+(n-k+2))%(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 = [int(INPUT) for INPUT in input().strip().split(' ')]

total_num = 0

for k in range(K, N + 2):
    Min = sum(range(k - 1))
    Max = sum(range(N - (k - 1), N + 1))
    num = Max - Min + 1
    total_num += num

print(total_num)

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 = (N - (k - 1)) * k + 1
    total_num += num

print(int(total_num % (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())
mod = 10 ** 9 + 7
premin = 0
premax = 0
ans = 0
list = [i for i in range(n + 1)]
for x in range(n + 2):
    if x < k: continue
    if k < x: ans += pre
    premin = sum(list[0 : x])
    premax = sum(list[n + 1 - x : n + 1])
    ans += (premax - premin + 1) % mod
print(ans)

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 + 2):
    premin = sum(list[x])
    premax = sum(list[n + 1 - x])
    if x < k: continue
    ans += (premax - premin + 1)
    if ans >= mod: ans %= mod
print(ans)


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)


Verdicts: 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())
mod=10**9+7
ans=0
for i in range(k,n+2):
  ans+=((2*n-i+1)*i//2-i*(i-1)//2)%mod
print(ans)

n,k=map(int,input().split())
mod=10**9+7
ans=0
for i in range(k,n+2):
  ans+=(2*n-i+1)*i//2-i*(i-1)//2+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())

Ans = [0]*(N+2)
Sum_Ans = 0

def solution(N,K,Ans,Sum_Ans):
    for i in range(K,N+2):
        
        #min[i] = i*(i - 1) / 2
        Ans[i] = i*(N - i + 1)
        
        Sum_Ans += Ans[i]
    
    print(Sum_Ans%(10**9 + 7))

solution(N,K,Ans,Sum_Ans)

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

Ans = [0]*(N+2)
Sum_Ans = 0

def solution(N,K,Ans,Sum_Ans):
    for i in range(K,N+2):
        
        #min[i] = i*(i - 1) / 2
        Ans[i] = i*(N - i + 1) + 1
        
        Sum_Ans += Ans[i]
    
    print(Sum_Ans%(10**9 + 7))

solution(N,K,Ans,Sum_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 resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]

    res = 0
    if K <= N:
        for i in range(K, N+1):
            a = (i-1)*i//2
            c = N-i
            b = N*(N+1)//2 - c*(c+1)//2
            print(a, b)
            res += b - a +1
    res += 1
    print(res)

if __name__ == "__main__":
    resolve()


def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]

    res = 0

    for i in range(K, N+2):
        a = (i-1)*i//2
        c = N-i
        b = N*(N+1)//2 - c*(c+1)//2
        # print(a, b)
        res += b - a +1

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

if __name__ == "__main__":
    resolve()


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 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
from collections import Counter
import math
import pprint
from functools import reduce


def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))


N, K= [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
go = 0

for i in range(K,N+2):
    ans_= (i*(N-i+1) + 1) % 1000000007
    ans += ans_
    go += 1
    

print(go,ans%1000000007)

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
from collections import Counter
import math
import pprint
from functools import reduce


def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))


N, K= [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
go = 0

for i in range(K,N+2):
    ans_= (i*(N-i+1) + 1) % 1000000007
    ans += ans_
    go += 1
    

print(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 = map(int, input().split())
import math
import itertools



def cal(num, r, count):

    for v in itertools.combinations(range(num), r):
        count[sum(v)] += 1
    real_count = 0
    for i in count:
        if i>0:
            real_count += 1

    return real_count

total = 0
while K<=N+1:
    count = [0]*1000000000
    total += cal(N+1, K,count)
    K+=1

total = total % (10**9+7)
print(total)


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

min = K*(K-1)/2
max = K*(2*N-K+1)/2


sum=0
for k in range(K,N+2):
    min = k*(k-1)/2
    max = k*(2*N-k+1)/2

    sum+=(int(max-min+1))
print(sum%(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())

s = int(((N+1)*((N+1)**2 + 5))/6 -((K-1)*((K-1)**2 + 5))/6)

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

N,M = map(int,input().split())
 
s = 0
 
for i in range(K,N+2):
  s += i*N +1 - i*(i -1)

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

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

s = 0

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

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

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

Verdicts: Wrong Answer

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):
#D 
inp = input().split(' ')
N = int(inp[0])
K = int(inp[1])

(int((N+1)*((N+1)*(N+2) - K*(K-1))/2.0 - ((N+1)*(N+2)*(2*N+3) - (K-1)*K*(2*K-1))/6.0) + (N+1+1-K)) % (int(10**9) + 7)

#D 
inp = input().split(' ')
N = int(inp[0])
K = int(inp[1])

print((int((N+1)*((N+1)*(N+2) - K*(K-1))/2.0 - ((N+1)*(N+2)*(2*N+3) - (K-1)*K*(2*K-1))/6.0) + (N+1+1-K)) % (int(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):
import itertools

line=input()
n,k=map(int,line.split())
s=set(list(range(n+1)))
sums=list()
while k!=(n+2):
     koko=list()
     sub=list(itertools.combinations(s,k))
     #print(sub)
     for val in sub:
          soso=0
          for i in val:
               soso+=(i+(10**100))
               soso=(soso%(10**9))
          if soso not in sums:
               sums.append(soso)
          
               
          
     
     
     
     k+=1
print(len(sums))


line=input()
n,k=map(int,line.split())
sums=0
while k!=(n+2):
     if k==1:
          mini=0
     if k>=2:
          mini=(((k)*(k-1))/2)#%((10**9)+7)
     maxi=( (((n+1)*(n)) - ((n+1-k)*(n-k)) )/2  )#%((10**9)+7)
     sums+=(maxi-mini+1)
     sums=sums%((10**9)+7)
     k+=1
print(int(sums))

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 += 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
    ans %= 10**9+7
    # print(p, m, ans)
print(ans % 10**9+7)

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)

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):
S = input()
l = len(S)

a = 0
count = 0

for i in range(l):
    a = int(S[l-i-1])
    for j in range(i+1,l):
        if int(S[l-j-1]) != 0:
            a += int(S[l-j-1])*10**(j-i)
            if j-i > 2:
                if a % 2019 == 0:
                    count += 1
            
print(count)

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

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 main():
    n, k =map(int, input().split())
    res = 0

    for left in range(n):
        num = 0
        right = left + k
        res += (right - left)
    
    print(res %(10 ** 9))

if __name__ == '__main__':
    main()
        

def main():
    ans = 0
    n, k = map(int, input().split())
    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))
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=int(input())
l=list(map(int,input().split()))

ans=[0]*n

for i in l:
    ans[i-1]+=1

for j in ans:
    print(j)

n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
    mini=i*(i-1)//2
    maxi=mini+i*(n-i+1)
    ans+=int(maxi-mini+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 = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
for k in range(K, N + 2):
    ans = (ans + k * (2 * N - k + 1) / 2 - (k - 1) * k / 2 + 1)
    ans %= MOD
print(ans)


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


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


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


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):
import itertools

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

ans = 0

for k in range(K, N):
  ans += len(set(map(sum, itertools.combinations(range(N), k))))

print(ans%(10000000000+7)

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

ans = 0
mod = pow(10,9)+7

for k in range(1, K+1):
  ans += sum(range(N-k+1, N+1)) - sum(range(0, k))
  
  
print(ans % mod)

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

ans = 0

for k in range(1, K+1):
  ans += sum(range(N-k+1, N+1)) - sum(range(0, k))
  
  
if ans > 0:
  print(ans)
else:
  print(1)

import itertools

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

ans = 0

for k in range(K, N):
  ans += len(set(map(sum, itertools.combinations(range(N), k))))

print(ans)

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


## sum(range(N-k+1, N+1))
## k*((N+1-k)+N)/2

## sum(range(0, k))
## k*(0+k-1)/2

Verdicts: Runtime Error

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

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


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

sum = 0
for i in range(k, n+2):
    min_sum = i * (i-1) / 2
    max_sum = i * (2 * n - i + 1) / 2
    sum += max_sum - min_sum + 1
print(int(sum % (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):
import numpy as np


mod = 10 ** 9 + 7

n, k = map(int, input().split())
k_np = np.arange(k, n + 2, dtype=np.int64)
low = ((k - 1) * k) // 2
high = n * k_np - low
cnt = high - low + 1
print(cnt.sum() % mod)


import numpy as np


mod = 10 ** 9 + 7

n, k = map(int, input().split())
k_np = np.arange(k, n + 2, dtype=np.int64)
low = (k - 1) * k // 2
high = n * k_np - low
cnt = high - low + 1
print(cnt.sum() % mod)


def main():
    n, k = map(int, input().split())
    mod = 10**9+7
    if n - k == -1:
        print(1)
    else:
        ans = (n+2*k) * (n-k+1) * (n-k+2) // 6 + n - k + 2
        print(ans%mod)
if __name__=="__main__":
    main()


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 np

N,K = map(int,input().split())
p = 10**9+7
Nlist = []
ReNlist =[]
Ans = 0
for i in range(N+1):
    Nlist.append(i)
    ReNlist.append(N-i)
Nlist = np.array(Nlist).cumsum
ReNlist = np.array(ReNlist).cumsum
for i range(K,N+1):
    Ans += ReNlist[K-1]-Nlist[K-1]
    Ans = Ans % p
print(Ans)


import numpy as np

N,K = map(int,input().split())
p = 10**9+7
Nlist = []
ReNlist =[]
Ans = 0
for i in range(N+1):
    Nlist.append(i)
    ReNlist.append(N-i)
Nlist = np.array(Nlist).cumsum()
ReNlist = np.array(ReNlist).cumsum()
for i in range(K,N+1):
    Ans += ReNlist[i-1]-Nlist[i-1] +1
    Ans = Ans % p
print(Ans+1)


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):
import numpy as np
from numba import jit

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

ary = np.array([i for i in range(n+1)])
print(ary)

@jit
def lr(l,r): 
    return (l+r)*(r-l+1)//2

ans = 0
for j in range(k,n+2):
    l = lr(0, j-1)
    r = lr(n+1-j, n)
    ans += r-l+1
    ans %= 10**9+7
    
print(ans)


import numpy as np
from numba import jit

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

tmp=[]
for i in range(n+1):
    tmp.append(i)
ary = np.array(tmp)
#print(ary)

@jit
def lr(l,r): 
    return (l+r)*(r-l+1)//2

ans = 0
for j in range(k,n+2):
    l = lr(0, j-1)
    r = lr(n+1-j, n)
    ans += r-l+1
    ans %= 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())

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

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

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

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

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

Verdicts: 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 i in range(k, n+2):
  minsum = sum(range(0, i))
  maxsum = sum(range(n+1-i ,n+1))
  print(i,minsum, maxsum)
  ans += maxsum - minsum + 1

print(ans)

N, K = map(int, input().split())
mod = 10**9 + 7
count = 0
for n in range(K, N+2):
  maxSum = (n*(N + N-n+1))//2
  minSum = (n*(n-1))//2
  count += maxSum - minSum + 1
  count %= mod

print(count)

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
MOD = 10**9+7

for k in range(K, N+2):  
  upper = k*(2N-(k-1))//2
  lower = k*(k-1)//2
  ans += upper - lower + 1
  ans %= MOD
print(ans)

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

for k in range(K, N+2):  
  upper = k*(2*N-(k-1))//2
  lower = k*(k-1)//2
  ans += upper - lower + 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())
ans = 0
mod = 10 ** 9 + 7
l=1
r=n
for i in range(k):
  ans += (r - l + 1) % mod
  ans %= mod
  l += i + 2
  l %= mod
  r += n - i - 1
  r %= mod
print(ans)

n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7
l=0
r=n
for i in range(n+1):
  if i >= k-1:
    ans += (r - l + 1) % mod
    ans %= mod
  l += i + 1
  l %= mod
  r += n - i - 1
  r %= 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=list(map(int,input().split()))
src=[n for n in range(N+1)]
t=sum(src[-K+1:])
m=sum(src[:K-1])-1
if m < 0:
  m=0
ans=0
for n in range(N+2-K):
  t+=src[-K-n]
  m+=src[K+n-1]
  a=t-m
  ans+=a
print(ans%(10**9+7))

N,K=list(map(int,input().split()))
ans=0
for k in range(K,N+2):
  M=k*N-k*(k-1)//2
  m=k*(k-1)//2
  ans+=M-m+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):
import numpy as np

n,k=map(int,input().split())
sum=0
k=k+1

for i in range(k,n+2):
  #print(i,(i+1)*n-i*(i+1)+1)
  sum=sum+i*n-i*(i-1)+1
  
print(int(sum)%(10e9+7))	

import numpy as np

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

for i in range(k,n+2):
  #print(i,i*n-i*(i-1)+1)
  sum=sum+i*n-i*(i-1)+1
  
#print(int(sum))
print(int(int(sum)%(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(sum(1+i*(n-i+1)for i in range(k,n+2))%(1e9+7))

n,k=map(int,input().split())
print((n-k+2)*((-k-~n)*(n+2*k)+6)//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):
n,k = map(int,input().split())
cnt = 0
for i in range(k,n+2):
    cnt += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1
print(cnt % (10 ** 9 + 7))

n,k = map(int,input().split())
cnt = 0
for i in range(k,n+2):
    cnt += n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - i * (i - 1) / 2 + 1
print(int(cnt % (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())

def C(N, p):
  min_p = p * (p - 1) // 2
  max_p = p * (2 * N - p + 1) // 2
  return max_p - min_p + 1

ans = 0
for i in range(K, N + 1):
  ans += C(N, i)
  
print(ans)

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

def C(N, p):
  min_p = p * (p - 1) // 2
  max_p = p * (2 * N - p + 1) // 2
  return max_p - min_p + 1

ans = 0

for i in range(K, N + 2):
  ans += C(N, i) % 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())
wa=0
for i in range(N+1-K):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa+1


wa=wa+1
wa=wa%(10**9+7)
print(wa)


N,K=map(int,input().split())
wa=0
for i in range(N+1-K):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa+1

wa=wa+1 
print(wa)


N,K=map(int,input().split())
wa=0
for i in range(N+1-k+1):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa
    
print(wa)


N,K=map(int,input().split())
wa=0
for i in range(N+1-K):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa+1
    wa%=10**9+7

wa=wa+1
print(wa)


N,K=map(int,input().split())
wa=0
for i in range(N+1-K):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa+1


wa=wa+1
wa=wa%(10**9+7)
print(int(wa))


Verdicts: Wrong Answer

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):
n,k = map(int, input().split())

ans = 0
for i in range(k, n+2):
    print(i)
    smin = int(0.5*i+(2*0+(i-1)*1))
    smax = int(0.5*(n+2-i)+(i-1)*1)
    s = smax - smin
    ans+=s
    ans%=7+10**9
print(ans)


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

ans = 0
for i in range(k, n + 2):
    # print(i)
    smin = int(0.5 * i * (2 * 0 + (i - 1) * 1))
    smax = int(0.5 * i * (2 * (n + 1 - i) + (i - 1) * 1))
    s = smax - smin + 1
    # print("s", s)
    ans += s
    ans = ans % (7 + 10 ** 9)
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
def f(n):
  return n*(n-1)//2
ans=0
for i in range(k,n+2):
  a=f(n+1)-f(n-k-i)-f(k+i)+1
  ans+=a%mod
print(ans%mod)

n,k=map(int,input().split())
mod=10**9+7
def f(n):
  mod=10**9+7
  return (n*(n+1)//2)%mod
ans=0
for i in range(k,n+2):
  a=f(n)-f(n-i)-f(i-1)+1
  ans+=(a%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())
 
m = 10 ** 9 + 7
  
ans = 1
x = 1
for a in range(1,K+1):
  x *= (N + 2 - a) * a
  x //= a
  ans += x
  ans %= m
 
print(ans)

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

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

ans = 0

for i in range(K, N + 2):
  M = (2*N - i + 3) * i // 2
  m = i * (i+1) // 2
  ans += M - m + 1
  ans %= mod
  
print(ans)


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):
    ans += (2*n-k+1)*k//2-(k+1)*k//2+1
    ans %= MOD
print(ans % MOD)


n, k = map(int, input().split())
MOD = 10**9+7
ans = 0
for i in range(k, n+2):
    ans += (2*n-i+1)*i//2-(i-1)*i//2+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):
#amari = (10**100)%(10**9+7)
def sm(i):
    tmpp = 0
    for j in range(i):
        tmpp += j
    return tmpp,j

def bi(i,N):
    tmpp = 0
    for j in range(i):
        tmpp += N-j

    return tmpp,N-j

def main():
    N,K = map(int,input().split())
    ans = 0
    
    for i in range(K,N+2,1):
        if i == K:
            small,numsmall = sm(i)
            big,numbig = bi(i,N)
            print(numsmall,numbig)
        else:
            small += numsmall+1
            numsmall += 1
            big += numbig - 1
            numbig -= 1
        ans += big - small + 1

    return (ans%(10**9+7))

print(main())


#amari = (10**100)%(10**9+7)
def sm(i):
    tmpp = 0
    for j in range(i):
        tmpp += j
    return tmpp,j

def bi(i,N):
    tmpp = 0
    for j in range(i):
        tmpp += N-j

    return tmpp,N-j

def main():
    N,K = map(int,input().split())
    ans = 0
    
    for i in range(K,N+2,1):
        if i == K:
            small,numsmall = sm(i)
            big,numbig = bi(i,N)
            #print(numsmall,numbig)
        else:
            small += numsmall+1
            numsmall += 1
            big += numbig - 1
            numbig -= 1
        ans += big - small + 1

    return (ans%(10**9+7))

print(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 = list(map(int, input().split()))
ans = 0
sum_n = (n+1)*n/2

for i in range(k, n+2):
    tmp_b = (i)*(i-1)/2
    tmp_a = sum_n - (n-i+1)*(n-i)/2
    ans += tmp_a - tmp_b + 1
print(ans)

n,k = list(map(int, input().split()))
ans = 0
sum_n = (n+1)*n/2

for i in range(k, n+2):
    tmp_b = (i)*(i-1)/2
    tmp_a = sum_n - (n-i+1)*(n-i)/2
    ans += tmp_a - tmp_b + 1
    print(tmp_a - tmp_b + 1)
print(ans)

n,k = list(map(int, input().split()))
ans = 0
sum_n = (n+1)*n/2

for i in range(k, n+2):
    tmp_b = (i)*(i-1)/2
    tmp_a = sum_n - (n-i+1)*(n-i)/2
    ans += tmp_a - tmp_b + 1
print(int(ans)%(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())
MOD = 10**9+7
def resolve():
    ans = 0
    for i in range(K, N+2):
        ans += calc(i)
    print(ans%MOD)

def calc(i):
    minv = i * (i-1) // 2
    maxv = minv + i * (N - i + 1)
    print(minv, maxv)
    return maxv-minv+1

if __name__ == '__main__':
    resolve()

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

def calc(i):
    minv = i * (i-1) // 2
    maxv = minv + i * (N - i + 1)
    return maxv-minv+1

if __name__ == '__main__':
    resolve()

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):
#!/usr/bin/python3
# -*- coding: utf-8 -*-


import numpy as np
from itertools import accumulate


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

n = range(N+1) #  + 10**100
# print((n + 10**100)%(10**9+7))

if K >= N:
    print(1)
    exit(0)

print(n)

combi = np.array(range(N+1-(K-1)))+K
print(combi)
S = 0

minsum = list(accumulate(n))

maxsum = list(accumulate(n[::-1]))

for c in combi:
    # S += len(set(np.sum(np.array(list(itertools.combinations(n, c))),axis=1)))
    # itertools.combinations(n, c)
    min_num = (minsum[c-1]-1) % 1000000007
    max_num = maxsum[c-1] % 1000000007
    # print(min_num, max_num)
    S += (max_num-min_num)
    S %= 1000000007
print(S)



#!/usr/bin/python3
# -*- coding: utf-8 -*-


import numpy as np
from itertools import accumulate


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

n = range(N+1)
# print((n + 10**100)%(10**9+7))

if K > N:
    print(1)
    exit(0)

combi = np.array(range(N+1-(K-1)))+K
S = 0

minsum = list(accumulate(n))

maxsum = list(accumulate(n[::-1]))

for c in combi:
    # S += len(set(np.sum(np.array(list(itertools.combinations(n, c))),axis=1)))
    # itertools.combinations(n, c)
    min_num = (minsum[c-1]-1) % 1000000007
    max_num = maxsum[c-1] % 1000000007
    # print(min_num, max_num)
    if (max_num-min_num) < 0:
        S += ((max_num-min_num) + 1000000007)
    else:
        S += (max_num-min_num)
    S %= 1000000007
print(S)



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


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)


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

MAX = (N+1)*(N+2)//2
MIN = (K-1)*(K)//2

print((MAX-MIN)/10**9+7)

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

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

def sigma(N, k):
  a = (k*(k+1)*(2*k+1)//6)%(10**9+7)
  b = (k*(k+1)//2)%(10**9+7)
  c = k
  return -a + (N+1)*b + c

print((sigma(N,N+1)-sigma(N, K-1))%(10**9+7))

Verdicts: Wrong Answer

Wrong Answer

Accepted