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

Z = 10**9 + 7
X = 0


#     a = list(range(i))
#     b = list(range(N + 1 - i, N + 1))
#     X = X + (sum(b) - sum(a) + 1)

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

print((X + 1)%Z)

import math

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

Z = 10**9 + 7
X = 0


#     a = list(range(i))
#     b = list(range(N + 1 - i, N + 1))
#     X = X + (sum(b) - sum(a) + 1)

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

print(math.floor((X + 1)%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):
from itertools import permutations, combinations

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

ans = 0
_list = list(range(N+1))
_list.sort(reverse = True)
h = _list[0]
l = 0
cnt = 0

if N == K == 1:
    print(2)
    exit()
for i in range(1, N+1):
    h += _list[i]
    cnt += 1
    l += cnt
    print(i , h , l)
    if i >= K-1:
        ans += h - l + 1

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

from itertools import permutations, combinations

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

ans = 0
_list = list(range(N+1))
_list.sort(reverse = True)
h = _list[0]
l = 0
cnt = 0

if N ==1 and K == 1:
    print(2)
    exit()
for i in range(1, N+1):
    h += _list[i]
    cnt += 1
    l += cnt
    print(i , h , l)
    if i >= K-1:
        ans += h - l + 1

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

from itertools import permutations, combinations

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

ans = 0
_list = list(range(N+1))
_list.sort(reverse = True)
h = 0
l = 0
cnt = -1

for i in range(N+1):
    h += _list[i]
    cnt += 1
    l += cnt
    if i >= K-1:
        ans += h - l + 1
        
print(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):
p = 10 ** 9 + 7
n, k = map(int, input().split())
n += 1
upper = 1
lower = 1
for i in range(1, n - k + 1):
    upper *= n - i + 1
    upper %= p
    lower *= i
    lower %= p
print(upper * pow(lower, p - 2, p) % p)


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

ans = 0
for i in range(n + 1, k - 1, -1):
    ans += i * n - i * (i - 1) + 1
    ans %= p
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):
data = input().split()
N = int(data[0])
K = int(data[1])
e = [n for n in range(N+1)]
print(e)
count = 0
for k in range(K,N+2):
    count += 2 * N - k * (k-1)
print(count//(10**9+7))

data = input().split()
N = int(data[0])
K = int(data[1])
e = [n for n in range(N+1)]
count = 0
for k in range(K,N+2):
    count += k * N - k * (k-1) + 1
print(count%(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 = list(map(int, input().split()))
N = NK[0]; K = NK[1]

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

print(result)


NK = list(map(int, input().split()))
N = NK[0]; K = NK[1]
 
result = 0
for i in range(K,N+2):
    result += i*(N-i+1) +1
    result = result%1000000007
 
print(result)

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 itertools

n, k = map(int, input().split())
arr = [i for i in range(n+1)]

a = 0
for i in range((n+1)-(k-1)):
    tmp = set()
    for group in itertools.combinations(arr, i+k):
        tmp.add(sum(group))
    print(tmp)
    a += len(tmp)

print(a)

import numpy as np

n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7
arr = np.arange(n+1)
a = np.cumsum(arr)
b = np.cumsum(arr[::-1])

for i in range(k, n+1+1):
    ans += b[i-1] - a[i-1] + 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):
n,k=map(int,input().split())
a=0
while k<=n+1:
    b=1
    s=1
    for t in range(k):
        b*=(t+1)
        s*=(n+1-t)
    a+=s/b
    k+=1
print(a)

n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(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):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
c=n1()
ab=[(x[0],x[1]) for x in n3(n-1)]

import networkx as nx
G = nx.Graph()

G.add_nodes_from(range(1,n+1))
G.add_edges_from(ab)

path=[[x] for x in range(1,n+1)]
for i in range(1,n+1):
    path.extend(list(nx.all_simple_paths(G, source=i, target=[x for x in range(i+1,n+1)])))
path_color = [[c[x-1] for x in line] for line in path]
dict_color={i:0 for i in range(1,n+1)}
for x in path_color:
    for i in set(x):
        dict_color[i]+=1
for i in dict_color:
    print(dict_color[i])


def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()

down=[0]*(n+1)
up=[0]*(n+1)
up[0]=n
ans=0 if k>1 else n+1
for i in range(1,n+1):
    down[i]=down[i-1]+i
    up[i]=up[i-1]+(n-i)
    if i>=k-1:
        ans+=up[i]-down[i]+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):
def sum_part(N, k):
  return k*(2*N-k+1)/2-k*(k-1)/2+1
  
N, K = map(int, input().split())
ans = 0
for k in range(K,N+2):
  ans += sum_part(N, k)
  
print(ans)

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

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


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

Verdicts: Wrong Answer

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):
from scipy.special import comb
a, b = map(int, input().split())
 
def coun(x, y):
  a = comb(x, y, exact=True)
  return a
 
if(a+1== b):
  print(1)
else:
  count = 0
  for i in range(a-b+2):
    count += coun(a+1,i+b)
  print(count)

a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i-1)/2
  max = a*(a-1)/2 - (a-i)*(a-i-1)/2
  return max - min + 1

count = 0
for i in range(a-b+2):
  count += cal(a+1,i+b)
print(count % mod)

a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i-1)/2
  max = a*(a+1)/2 - (a-i)*(a-i+1)/2
  return max - min + 1

count = 0
for i in range(a-b+2):
  count += cal(a,i+b)
print(count % mod)


a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i-1)/2
  max = a*(a-1)/2 - (a-i)*(a-i-1)/2
  return max - min + 1

count = 0
for i in range(a-b+2):
  count += cal(a,i+b)
print(count % mod)


a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i-1)/2
  max = a*(a-1)/2 - (a-i)*(a-i+1)/2
  return max - min + 1

count = 0
for i in range(a-b+2):
  if(a < i+b):
  	count += cal(a+1,i+b)
  else:
    count += 1
print(count % mod)


a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i+1)/2
  max = a*(a+1)/2 - (a-i)*(a-i+1)/2
  return max - min + 1

count = 0
for i in range(a-b+1):
  count += cal(a,i+b)
print(count % mod)

a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i-1)/2
  max = a*(a+1)/2 - (a-i)*(a-i+1)/2
  return max - min + 1

count = 0
for i in range(a-b+2):
  if(a < i+b):
  	count += cal(a,i+b)
  else:
    count += 1
print(count % mod)


from math import factorial
a = factorial(n) / factorial(r) / factorial(n - r)
a, b = map(int, input().split())

def count(x, y):
  a = factorial(x) / factorial(y) / factorial(x - y)
  return a

if(a+1== b):
  print(1)
else:
  count = 0
  for i in range(a-b+2):
    count += count(a,i+b)
  print(count)
  

from math import factorial
a, b = map(int, input().split())
 
def count(x, y):
  a = factorial(x) / factorial(y) / factorial(x - y)
  return a
 
if(a+1== b):
  print(1)
else:
  count = 0
  for i in range(a-b+2):
    count += count(a,i+b)
  print(count)

a, b = map(int, input().split())
mod = pow(10,9) + 7

def cal(a,i):
  min = i*(i-1)/2
  max = a*(a-1)/2 - (a-i)*(a-i-1)/2
  return max - min + 1

count = 0
for i in range(a-b+2):
  count += cal(a+1,i+b)
print(int(count % mod))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

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

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

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

N, K = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
tmp = 0
for i in range(K-1):
  tmp += i
for i in range(K, N + 2):
  tmp += i - 1
  ans += i * N - tmp * 2 + 1
  ans = 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):
from typing import NoReturn


def my_sum(start: int, end: int):
    if start < 0:
        return my_sum(1 - start, end)
    elif start > 1:
        return my_sum(1, end) - my_sum(1, start - 1)
    else:
        return end * (end + 1) // 2


def main() -> NoReturn:
    n, k = map(int, input().split())  # type: int, int

    p: int = 10 ** 9 + 7

    answer = 0

    for i in range(k, n + 2):
        min_val: int = my_sum(0, i)
        max_val: int = my_sum(n - i + 1 , n)
        answer += max_val - min_val + 1

    print(answer % p)


if __name__ == '__main__':
    main()


from typing import NoReturn


def main() -> NoReturn:
    n, k = map(int, input().split())  # type: int, int

    p: int = 10 ** 9 + 7

    answer = 0

    for i in range(k, n + 1):
        min_val: int = sum(range(i))
        max_val: int = sum(range(n - i + 1, n + 1))
        answer += max_val - min_val + 1

    print(answer % p)


if __name__ == '__main__':
    main()


from typing import NoReturn


def my_sum(start: int, end: int):
    if start < 0:
        return my_sum(1 - start, end)
    elif start > 1:
        return my_sum(1, end) - my_sum(1, start - 1)
    else:
        return end * (end + 1) // 2


def main() -> NoReturn:
    n, k = map(int, input().split())  # type: int, int

    p: int = 10 ** 9 + 7

    answer = 0

    for i in range(k, n + 2):
        min_val: int = my_sum(0, i - 1)
        max_val: int = my_sum(n - i + 1 , n)
        answer += max_val - min_val + 1

    print(answer % p)


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):
N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, i+8):
#        print (i, j)
        number = int(str(N[i:j]))
#        if number%2019 == 0:
#            count +=1
#            break
#            print (i, j)
#T = int(N)//2019
#
#for t in range (T):

#    length = len(str(den))
#    sum_length = len(N)


#            count +=1

print (count

N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, i+8):
#        print (i, j)
        number = int(str(N[i:j]))
        if number%2019 == 0:
            count +=1
            break


print (count)

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

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

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

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):
	miin=i*(i-1)/2
	maax=i*(2*n-i+1)/2
	ans+=maax-miin+1
print(int(ans)%10**9+7)

n,k=map(int,input().split())
ans=0
for i in range(k,n+2):
	miin=i*(i-1)/2
	maax=i*(2*n-i+1)/2
	ans+=maax-miin+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):
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n, aii):
    dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

    for x in range(1, n+1):
        ai, i = aii[x-1]
        dp[x][0] = dp[x-1][0] + ai * (i-x+1)
        dp[0][x] = dp[0][x-1] + ai * (n-x-i)

    for s in range(1, n+1):
        for x in range(1, s):
            y = s - x
            ai, i = aii[s-1]
            dp[x][y] = max(dp[x-1][y] + ai * (i-x+1),
                           dp[x][y-1] + ai * (n-y-i))

    res = 0
    for x in range(n+1):
        if dp[x][n-x] > res:
            res = dp[x][n-x]
    return res


if __name__ == "__main__":
    n = i1num()
    a = inums()
    aii = sorted([(a[i], i)for i in range(n)], reverse=True)
    print(solve(n, aii))


def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n, k):
    m = 10**9+7
    res = 0
    for i in range(k, n+2):
        res += n*i - i*i + i + 1
    return res % m


if __name__ == "__main__":
    n, k = inums()
    print(solve(n, k))


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

pattern = 0

for i in range(k, n + 2):
    min = (0 + i - 1) // 2 * i
    print("min",min)
    max = ((n - i) + (1 + n)) // 2 * i
    print("max",max)
    pattern += max - min + 1
    
pattern %= 10 ** 9 + 7

print(pattern)

import itertools
import math
from functools import reduce

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

#set obj
#cnt = 0

sum_list = set()

for i in range(k, n + 1):
    
    for pattern in list(itertools.combinations(range(n + 1), i)):
        #print(pattern)
        result = reduce(lambda a, b : a + b + math.pow(10, 100), pattern, 0)
        #result = reduce(lambda a, b : a + b + 100, pattern, 0)
        #result = reduce(lambda a, b : a + b, pattern, 0)
        #print(result)
        sum_list.add(result)
    #cnt += len(sum_list)
    #print(sum_list)
    

print(len(sum_list) + 1)
#print(sum_list)

# + 1




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

pattern = 0

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

print(pattern)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n,x,y=map(int,input().split())
x-=1
y-=1
a=[]
for i in range(n):
  a.append(0)
for i in range(n):
  for j in range(n-i):
    p=min(abs(j-i),abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
    a[p]+=1
for i in range(n-1):
  print(str(a[i+1]))

n,x,y=map(int,input().split())
x-=1
y-=1
a=[]
for i in range(n):
  a.append(0)
for i in range(n-1):
  for j in range(n-i):
    j=n-1-j
    p=min(abs(j-i),abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
    a[p]+=1
for i in range(n-1):
  print(str(a[i+1]))

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
N, X, Y= map(int, input().split(' '))
 
node = []
for k in range(1, N+1):
    for v in range(k, N+1):
       node.append(min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1]))

for i in range(1, N+1):
    print(node.count(i))
   

N, X, Y= map(int, input().split(' '))
 
array=[None]*N
for i in range(N):
    array[i]=0
    
for k in range(1, N+1):
    for v in range(k, N+1):
       array[min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1])] += 1 

for i in range(1, N):
    print(array[i])
   

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):


from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())

start = list(range(0, N-1)) + list(range(1, N)) + [X, Y] 
end = list(range(1, N)) + list(range(0, N-1)) + [Y, X]
cost = [1] * len(start)

graph = csr_matrix((cost, (start, end)))
lengths = dijkstra(graph, directed = False)
c = Counter(lengths.astype(np.int64).reshape(-1))
for k in range(1, N):
    print(c[k])



from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())

start = list(range(0, N-1)) + list(range(1, N)) + [X, Y] 
end = list(range(1, N)) + list(range(0, N-1)) + [Y, X]
cost = [1] * len(start)

graph = csr_matrix((cost, (start, end)))
lengths = dijkstra(graph, directed = False)
c = Counter(lengths.astype(np.int64).reshape(-1))
for k in range(1, N):
    print(c[k]//2)




from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())

start = list(range(0, N-1)) + list(range(1, N)) + [X-1, Y-1] 
end = list(range(1, N)) + list(range(0, N-1)) + [Y-1, X-1]
cost = [1] * len(start)

graph = csr_matrix((cost, (start, end)))
lengths = dijkstra(graph, directed = False)

c = Counter(lengths.astype(np.int64).reshape(-1))
for k in range(1, N):
    print(c[k]//2)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
s=input()
l=len(s)
q=int(input())
cnt=1

for _ in range(q):
	a=list(input().split())
	if len(a)==1:
		cnt*=(-1)
	else:
		if cnt==1:
			if a[1]=="1":
				s=a[2]+s
			else:
				s=s+a[2]
		else:
			if a[1]=="1":
				s=s+a[2]
			else:
				s=a[2]+s
				
if cnt==-1:
	s=s[::-1]
	
print(s)

n,x,y=map(int,input().split())
d=[0]*(n-1)

for i in range(n-1):
	for j in range(i+1,n):
		d[min(j-i-1,abs(x-1-i)+abs(y-1-j))]+=1
		
for i in range(n-1):
	print(d[i])

Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n, x, y = map(int, input().split())
L = []
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            length = j-i-(y-x-1)
        elif x < i < y and x < j < y:
            a = j-i
            b = (j-x)+(i-y)+1
            if a < b:
                length=a
            else:
                length=b
        elif x < i < y and j >= y:
            length = j-y
            a = y-i
            b = (i-x)+1
            if a < b:
                length+=a
            else:
                length+=b
        elif x < j < y and i <= x:
            length = x-i
            a = j-x
            b = (y-j)+1
            if a < b:
                length+=a
            else:
                length+=b
        else:
            length = j-i
        L.append(length)
for k in range(1, n):
    if k == 2:
        print(len([l for l in L if l==k])+1)
    else:
        print(len([l for l in L if l==k]))

n, x, y = map(int, input().split())
result = [0]*n
for i in range(1, n):
    for j in range(i+1, n+1):
        a = j - i
        b = abs(i-x) + abs(j-y) + 1
        c = abs(i-y) + abs(j-x) + 1
        result[min(a,b,c)] += 1
for r in result[1:]:
    print(r)

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n, x, y = map(int, input().split())
lis = [0]*(n-1)
print(lis)
for i in range(1, n):
    for j in range(i+1, n+1):
        lis[min([j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)])-1] += 1
for i in range(n-1):
    print(lis[i])

n, x, y = map(int, input().split())
lis = [0]*(n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        lis[min([j-i, abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)])-1] += 1
for i in range(n-1):
    print(lis[i])

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
N,X,Y = map(int,input().split())
length = [0]*(N+1)
for i in range(1,N+1):
  for j in range(i,N+1):
    ans = min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(X-j)+1+abs(Y-i))
    length[ans] += 1
for i in range(1,N+1):
  print(length[i])

N,X,Y = map(int,input().split())
length = [0]*(N+1)
for i in range(1,N+1):
  for j in range(i,N+1):
    ans = min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(X-j)+1+abs(Y-i))
    length[ans] += 1
for i in range(1,N):
  print(length[i])

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

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

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = min(j-i,abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
            print(ans,i,j)
            dict[ans] +=1
            
print(dict)


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

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = min(j-i,abs(x-i)+abs(j-y)+1)
            print(ans,i,j)
            dict[ans] +=1
            
for i in range(n-1):
     print(dict[i+1])

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

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = min(j-i,abs(x-i)+abs(j-y)+1)
            dict[ans] +=1
            
for i in range(n-1):
     print(dict[i+1])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n,x,y = map(int, input().split())
ans = [0]*n
for i in range(0 , n):
  for j in range(i+1 ,n+1):
    ans= ans(min(abs(j-i), abs(x-i), abs(y-j)+1)+1
    
for i in range(1,n):
  print(ans[i])

n,x,y = map(int, input().split())
ans = [0]*n
for i in range(1 , n):
  for j in range(i+1 ,n+1):
    ans[min(abs(j-i),abs(x-i)+abs(y-j)+1)]+=1
    
for i in range(1,n):
  print(ans[i])

Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype=int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X, Y] = 1
lil[Y, X] = 1
shortest = scipy.sparse.csgraph.floyd_warshall(lil)
for i in range(N-1):
    print(np.count_nonzero(shortest == i))

import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype = int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X-1, Y-1] = 1
lil[Y-1, X-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
ans = np.bincount(lil2.ravel(), minlength = N) // 2
for i in range(1,N):
    print(ans[i])

Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

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

ans_list = [0]*(n)
for i in range(1, n+1):
    for j in range(1, n+1):
        if i>j:
            min_dis = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i)+1+abs(j-x))
            ans_list[min_dis] += 1

for i, value in enumerate(ans_list):
    print(value)

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

ans_list = [0]*(n)
for i in range(1, n+1):
    for j in range(i+1, n+1):
            min_dis = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i)+1+abs(j-x))
            ans_list[min_dis] += 1

for i in range(1, len(ans_list)):
    print(ans_list[i])

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

fr,to,w=[],[],[]

for i in range(n-1):
  fr.append(i)
  to.append(i+1)
  w.append(1)

fr.append(x-1)
to.append(y-1)
w.append(1)

g=csr_matrix((w, (fr, to)), shape=(n, n))

ans_l=[]



d=dijkstra(g,directed=False).astype(int)
ans_l=np.bincount(d.ravel(), minlength=n)//2

print(*ans_l[1:], sep='\n')



from collections import Counter

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

x-=1
y-=1

dist=[]
for i in range(n-1):
  for j in range(i+1,n):
    dist.append(min(j-i,abs(i-x)+1+abs(j-y)))

c=Counter(dist)
for i in range(1,n):
  print(c[i]

from collections import Counter

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

x-=1
y-=1

dist=[]
for i in range(n-1):
  for j in range(i+1,n):
    dist.append(min(j-i,abs(i-x)+1+abs(j-y)))

c=Counter(dist)
for i in range(1,n):
  print(c[i]

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,x,y=nii()
x-=1
y-=1
ans=[0 for i in range(n)]

for i in range(n-1):
  for j in range(i+1,n):
    dist1=j-i
    dist2=abs(i-x)+1+abs(j-y)
    dist=min(dist1,dist2)
    ans[dist]+=1

for i in ans[1:]:
  print(i)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
N, X, Y=map(int,input().split())
List=[]
i=1
for j in range(2,N+1):
  while 0<i<j<=N:
    List.append(min([abs(j-i), abs(X-i)+abs(Y-j)+1]))
    i+=1  
  else:
    j+=1  
    i=1
List.sort()

import collections
c=collections.Counter(List)
Newlist=list(c.values())
for p in Newlist:
  print(p)

N, X, Y=map(int,input().split())
List=[]
i=1
for j in range(2,N+1):
  for i in range(1,j):
    List.append(min([abs(j-i), abs(X-i)+abs(Y-j)+1]))

List.sort()

import collections
C=collections.Counter(List)

for p in range(1,N):
  if p in C.keys():
    print(C[p])
  else:
    print(0)

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
from collections import deque
from collections import Counter
N, X, Y = map(int, input().split())

res = deque()

for x in range(1, N):
    for y in range(x + 1, N+1):
        res.append(min([abs(x-y), 1 + abs(X-x) + abs(Y-y)))
resd = Counter(res)

for i in range(1, N):
    if i in resd.keys():
        print(resd[i])
    else:
        print(0)

from collections import deque
from collections import Counter
N, X, Y = map(int, input().split())

res = deque()

for x in range(1, N):
    for y in range(x + 1, N+1):
        res.append(min(abs(x-y), 1 + abs(X-x) + abs(Y-y)))
resd = Counter(res)

for i in range(1, N):
    if i in resd.keys():
        print(resd[i])
    else:
        print(0)

Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
K = int(input())
l = [i for i in range(1,10)]

def func(x):
    y = x%10
    if y == 0:
        return [x*10,x*10+1]
    elif y == 9:
        return [x*10+8,x*10+9]
    else:
        return [x*10+y-1,x*10+y,x*10+y+1]

li1 = l[:]
li2 = []
if K < 10:
    print(K)
else:
    while True:
        for i in li1:
            a = func(i)
            li2.extend(a)
        l.extend(li2)
        if len(l) >=K:
            break
        else:
            li1 = li2[:]
            li2 = []
    print(l[K-1])



N,X,Y = map(int,input().split())
l = [0]*N

for i in range(1,N):
    for j in range(i+1,N+1):
        a = min(abs(i-j),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
        l[a] += 1

[print(i) for i in l[1:]]


Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
print(sorted([1,3,2]))
print(sorted([1,3,2],reverse=True))

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

ans = [0]*(n)
for i in range(1,n):
  for j in range(i+1,n+1):
    ans[min(j-i,abs(i-x)+1+abs(y-j))]+=1




for i in range(1,n):
  print(ans[i])

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(j-y)),abs(y-i)+1+abs(j-x)-1]+=1
for i in range(n-1):
    print(ans[i])


n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))-1]+=1
for i in range(n-1):
    print(ans[i])

Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
def warshal_floyd(m, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                c_ij = m[i][j]
                c_ikj = m[i][k] + m[k][j]
                m[i][j] = min(c_ij, c_ikj)
    return m


def main():
    from collections import Counter
    n, x, y = map(int, input().split())
    m = [[float("Inf")] * n for _ in range(n)]
    for i in range(n):
        m[i][i] = 0
    for i in range(n - 1):
        m[i][i + 1] = 1
        m[i + 1][i] = 1

    m[x - 1][y - 1] = 1
    m[y - 1][x - 1] = 1

    wm = warshal_floyd(m, n)

    mm = sum(m, [])
    c = Counter(mm)
    ans = ''
    for i in range(1, n):
        d = c.get(i)
        if d is None:
            ans += "0\n"
        else:
            ans += str(d // 2) + '\n'
    print(ans)


if __name__ == '__main__':
    main()


def main():
    n, x, y = map(int, input().split())
    m = [0] * (n - 1)
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            p = min([abs(i - j), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x)])
            m[p - 1] += 1

    ans = "\n".join(map(str, m))
    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Time Limit Exceeded

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(n):
    for j in range(i+1,n):
     dis=min(abs(i-j),abs(x-i)+1+abs(y-j))
     ans[dis]+=1
for i in ans:
    print(i)


n,x,y=map(int,input().split())
ans=[0]*n
for i in range(n):
    for j in range(i):
     dis=min(abs(i-j),abs(x-i)+1+abs(y-j))
     ans[dis]+=1
for i in ans:
    print(i)


n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
     dis=min(abs(i-j),abs(x-i)+1+abs(y-j))-1
     ans[dis]+=1
for i in ans:
    print(i)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
l=[0] * (n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        index=min(abs(y-j)+abs(x-i)+1,j-i)-1
        #print(index+1)
        l[index]=l[index]+1
for i in range(len(l)):
    print(l[i])


n,x,y=[int(i) for i in input().split()]
l=[0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        index=min(abs(y-j)+abs(x-i)+1,j-i)-1
        #print(index+1)
        l[index]=l[index]+1
for i in range(len(l)):
    print(l[i])


Verdicts: Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
n,x,y = map(int, input().split())
max_dis = 0
ans = [0]*n
for i in range(1, n):
    for j in range(i+1,n+1):
        ans[min(abs(i-j), (abs(x-i)+1 +abs(y-j)))] +=1
print(*ans, sep="\n")

n,x,y = map(int, input().split())
max_dis = 0
ans = [0]*n
for i in range(1, n):
    for j in range(i+1,n+1):
        ans[min(abs(i-j), (abs(x-i)+1 +abs(y-j)))] +=1
print(*ans[1:], sep="\n")

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

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


dic = {}

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        if v in dic:
            dic[v] += 1
        else:
            dic[v] = 1


for i in range(1, N):
    print(dic[i])


N, X, Y = map(int, input().split())

dic = defaultdict(int)

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        dic[v] += 1


for i in range(1, N):
    print(dic[i])


N, X, Y = map(int, input().split())


dic = {}

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        if v in dic:
            dic[v] += 1
        else:
            dic[v] = 1


for i in range(1, N):
    if i in dic:
        print(dic[i])
    else:
        print(0)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

Submission attempts (in order):
# D - Line++

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
cnt = [0] * N

for i in range(N):
    for j in range(i+1,N):
         tmp = min(j-i, abs(i-X)+abs(j-Y)+1)
         cnt[tmp] += 1

for k in range(1, N):
    print(cnt[k])

print(cnt)

# D - Line++

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
cnt = [0] * N

for i in range(N):
    for j in range(i+1,N):
         tmp = min(j-i, abs(i-X)+abs(j-Y)+1)
         cnt[tmp] += 1

for k in range(1, N):
    print(cnt[k])

Verdicts: Wrong Answer

Accepted
Problem: We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:    * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.   * There is an edge between Vertex X and Vertex Y.  For each k=1,2,...,N-1, solve the problem below:    * Find the number of pairs of integers (i,j) (1 \leq i < j \leq N) such that the shortest distance between Vertex i and Vertex j in G is k.

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

LI = [0 for _ in range(n-1)]
for i in range(1,n):
	for j in range(i+1, n+1):
		dis = min((j-i), (abs(j-y)+abs(i-x)+1))
		print([i, j, dis])
		LI[dis-1] += 1

for i in range(n-1):
	print(LI[i])

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

LI = [0 for _ in range(n-1)]
for i in range(1,n):
	for j in range(i+1, n+1):
		dis = min((j-i), (abs(j-y)+abs(i-x)+1))
		LI[dis-1] += 1

for i in range(n-1):
	print(LI[i])

Verdicts: Wrong Answer

Accepted