Problem:


Score : 400 points

Problem Statement

For an integer N, we will choose a permutation \{P_1, P_2, ..., P_N\} of \{1, 2, ..., N\}.

Then, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.

Find the maximum possible value of M_1 + M_2 + \cdots + M_N.

Constraints

N is an integer satisfying 1 \leq N \leq 10^9.

Input

Input is given from Standard Input in the following format:

N

Output

Print the maximum possible value of M_1 + M_2 + \cdots + M_N.

Sample Input 1

2

Sample Output 1

1

When the permutation \{P_1, P_2\} = \{2, 1\} is chosen, M_1 + M_2 = 1 + 0 = 1.

Sample Input 2

13

Sample Output 2

78

Sample Input 3

1

Sample Output 3

0



Sample input:
2


Sample output:
1

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    N = int(input())
    ans = (1 + (N - 1)) / 2 * (N - 1)

    if N <= 1e07:
      a = np.arange(start=1, step=1, stop=N+1)
      if N %2 == 1:
        bol = (a % ((N+1)/2) >= a)
        ans += np.sum((a % ((N+1)/2)[bol] - a[bol])
      else:
        bol = (a % (N/2) >= a)
        ans += np.sum((a % (N/2)[bol] - a[bol])
       
      #print(a[bol])
      #print(bol)
      #print(np.any(bol))
      #if np.any(bol):
      #print((N % a)[bol])
      #print(((N % a)[bol]))
      #print(a[bol])
      #ans += np.sum((N % a)[bol] - a[bol])

    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
print(sum(range(1, N))

Submission status: Runtime Error

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

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

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

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n=  int(sys.stdin.readline())
import numpy as np
l=np.arange(1,n+1)
p=np.arange(2,n)
if n ==1:
    print(0)
else:
    print(sum(p)+1)

Submission status: Runtime Error

Solution code:
a = int(input())
result = 0
if a mod 2 == 0:
  print(a * a / 2)
else:
  print(a * (a - 1) / 2)


print(result)

Submission status: Runtime Error

Solution code:
N = int(input())
NL = list(range(1,N+1))
I = list(range(1,N+1))
M = []
ans = 0

import itertools
P_NL = list(itertools.permutations(NL))

for i in range(len(P_NL)):
    for v in range(N):
        M.append(P_NL[i][v] % I[v])
        if sum(M) >= ans:
            ans = sum(M)
print(ans)

Submission status: Runtime Error

Solution code:
# D - ModSum
import numpy as np
N = int(input())

N_1 = np.array(list(range(1, N+1)))
P_1 = np.array(list(range(2,N+1)))
P_1 = np.append(P_1, 1)

ans = sum(N_1 % P_1)
print(ans)

Submission status: Runtime Error

Solution code:
print(sum(list(range(int(input()))))

Submission status: Runtime Error

Solution code:
import numpy as np
a = np.zeros(2,dtype = "int64")

a[0] = int(input())

def func(i):

  if(i == 1): 
    return 1
  return i + func(i - 1)

print(func(a[0]-1))

Submission status: Runtime Error

Solution code:
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int,input().split())))

output = 0
memo = [0] * N
newmemo = [0] * N
owari = [0] * N
flag = 0
while flag < N:
    ng = 0
    for i in range(N):
        check = A[i][memo[i]]-1
        if i==A[check][memo[check]]-1:
            if memo[i] < N-2:
                newmemo[i]+=1
            elif (memo[i] == N-2) and (owari[i]==0):
                owari[i] = 1
                flag += 1
            else:
                continue
        else:
            ng += 1
    if ng == N:
        output = -1
        break
    memo = newmemo[:]
    output += 1

print(output)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

if __name__ == '__main__':
    N = int(input())
    S = 0
    last = N
    if N == 1:
        print(0)
        exit(0)
    if N == 2:
        print(1)
        exit()
    if N == 3:
        print(5)
        exit()

    while True:
        save = 0
        num = 0
        for n in range(1,int(np.ceil(np.sqrt((last+1))))):
            val = last % n
            if val > save:
                save = val
                num = n
        else:
            S += save + np.sum(np.arange(num,last))
            last = num-1
            if num <= 2:
                break
    if N%2==0:
        S-=1
    print(S)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
print(sum(np.arange(n)))

Submission status: Runtime Error

Solution code:
n=int(input())
if n==1:
  print(0)
if n==2:
  print(1)
else:
  ans=1
  for i in range(3,n+1):
    ans+=(i-1)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
C=[0]*(N-1)
for i in range(N-1):
	C[i]=i+1
print(sum(C))

Submission status: Runtime Error

Solution code:
n=list(range(1,int(input())+1))

print(sum(n[:len(n)-1]))

Submission status: Runtime Error

Solution code:
N=int(input())
H=[0]*N
for i in range(N):
  H[i]=N%(i+1)-i
print(max(H)+int(N*(N-1)/2))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
sum(np.arange(n))

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 1:
  print(0)

print((N-1)(N)/2)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(range(N))
#a[0] = a[-1]
Mmax = sum(a)

print(Mmax)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(range(1,n+1))
summax=0
for i in range(len(a)):
    for j in range(len(a)-1, i, -1):
        sum=0
        for k,v  in enumerate(a):
            sum += (k % int(v))
        if sum > summax: summax=sum
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]

print(summax)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000) 

n = int(input())
li1 = list(range(n))
print(sum(li1))

Submission status: Runtime Error

Solution code:
N=input()
print(N*(N-1)/2)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    N = int(input())
    ans = (1 + (N - 1)) / 2 * (N - 1)

    a = np.arange(start=1, step=1, stop=N+1)
    bol = (N % a >= a)
    #print(bol)
    #print(np.any(bol))
    #if np.any(bol):
    #print((N % a)[bol])
    #print(np.sum((N % a)[bol] - a))
    ans += np.sum((N % a)[bol] - a[bol])

    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""

from collections import defaultdict
import sys
import time
import logging



def deco(func):
    def wrapper(*args, **kwargs):
        s = time.time()
        #print('--start--')
        ret = func(*args, **kwargs)
        logging.debug('--end in %f --' % (time.time() - s))
        return ret

    return wrapper


def sol_wrong(n):
    if n <= 0: return 0
    dp = [0] * (n+1)

    dp[1] = 0
    if n == 1:
        return dp[n]
    if n == 2:
        return 1
    if n == 3:
        return 3
    # dp[2] = 1
    # dp[2] = 3
    # dp[4] = 5

    for i in range(3, n+1):
        dp[i] = dp[i-2] + i

    return dp[n]


def sol_lte():
    if n <= 0: return 0
    dp = [0] * (n+1)
    dp[1] = 0
    if n == 1:
        dp[1] = 0
        return dp[1]
    if n == 2:
        dp[2] = 1
        return dp[2]
    dp[2] = 1
    for i in range(3, n+1):
        dp[i] = dp[i-1] + i - 1
    return dp[i]


def sol(n):
    if n <= 0: return 0
    dp = [0] * (n+1)
    dp[1] = 0
    if n == 1:
        return 0
    if n == 2:
        return 1
    dp[2] = 1

    x = n - 1
    if x % 2 == 0: # even
        return ((x + 1) * int(n/2))
    else: # odd
        return ((x + 1) * int(n/2)) + int((n+1)/2)



do_submit = True
#do_submit = False
if do_submit:
    logging.basicConfig(level=logging.ERROR, format="%(message)s")
else:
    logging.basicConfig(level=logging.DEBUG, format="%(message)s")

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [[x.strip() for x in line.split()] for line in lines]
    n, k = parsed_lines[0]
    n = int(n)
    k = int(k)
    S = parsed_lines[1][0]
    return (n, k, S)


if not do_submit:
    n, k, S = input_parse("""
    14 2
    11101010110011
    """)
    print(sol(n, k, S))

    n, k, S = input_parse("""
    5 1
    00010
    """)
    print(sol(n, k, S))

    n, k, S = input_parse("""
    1 1
    1
    """)
    print(sol(n, k, S))


else:
    # str = ""
    # str += input().strip() + "\n"# n, k
    # str += input().strip() # S
    # n, k, S = input_parse(str)
    n = int(input().strip())
    print (sol(n))

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())

N_list = np.arange(1, N)

N_np   = np.sum(N_list)

print(N_np)

Submission status: Runtime Error

Solution code:
n = int(input())
li1 = list(range(n))
print(sum(li1))

Submission status: Runtime Error

Solution code:
N = int(input())

l = list(range(1,N+1)) 
I = list(range(1,N))
l.pop(0)

print(sum([x % y for (x,y) in zip(I, l)]))

Submission status: Runtime Error

Solution code:
from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
if n == 1:
    print(0)
else:
    a = list(range(1, n))
    b = list(accumulate(a))
    print(max(b))

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools
N=int(input())

IS=np.array(list(range(1,N+1)))

countmax=0
for ISP in itertools.permutations(IS):
    countmax=max(sum(IS%list(ISP)),countmax)

print(countmax)

Submission status: Runtime Error

Solution code:
import numpy as np

a = int(input())
h = np.array(list(range(1,a+1)))
h2 = h[::-1]
temp = int(0)
index_val = int(0)
max_mod = int(0)
sum_mod = int(0)

for value in h2:
  for index in range(len(h)):
    if h[index]!=0:
      temp = value % h[index]
      if temp > max_mod:
        max_mod = temp
        index_val = index
  sum_mod += max_mod
  max_mod = 0
  temp = 0
  np.put(h,index_val,0)

if a==1:
  print(0)
else:
  print(sum_mod+1)

Submission status: Runtime Error

Solution code:
N = int(input())
Ns = list(range(1,N+1))[::-1]
print(sum([Ns[i+1] % n for i,n in enumerate(Ns) if len(Ns)>i+1]))

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())

N_list = np.arange(1, N)

N_np   = np.sum(N_list)

print(int(N_np))

Submission status: Runtime Error

Solution code:
from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
if n == 1:
    print(0)
else:
    a = list(range(1, n))
    b = list(accumulate(a))
    print(b[-1])

Submission status: Runtime Error

Solution code:
N = int(input())
Ns = list(range(1,N+1))[::-1]
sum([Ns[i+1] % n for i,n in enumerate(Ns) if len(Ns)>i+1])

Submission status: Runtime Error

Solution code:
print(sum(range(1, N)))

Submission status: Runtime Error

Solution code:
from sys import stdin
from itertools import accumulate#累積和

n = int(stdin.readline().rstrip())
if n == 1:
    print(0)
else:
    a = list(range(1, n))
    b = list(accumulate(a))
    print(b[-1])

Submission status: Runtime Error

Solution code:
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""

from collections import defaultdict
import sys
import time
import logging



def deco(func):
    def wrapper(*args, **kwargs):
        s = time.time()
        #print('--start--')
        ret = func(*args, **kwargs)
        logging.debug('--end in %f --' % (time.time() - s))
        return ret

    return wrapper


def sol_wrong(n):
    if n <= 0: return 0
    dp = [0] * (n+1)

    dp[1] = 0
    if n == 1:
        return dp[n]
    if n == 2:
        return 1
    if n == 3:
        return 3
    # dp[2] = 1
    # dp[2] = 3
    # dp[4] = 5

    for i in range(3, n+1):
        dp[i] = dp[i-2] + i

    return dp[n]


def sol_lte():
    if n <= 0: return 0
    dp = [0] * (n+1)
    dp[1] = 0
    if n == 1:
        dp[1] = 0
        return dp[1]
    if n == 2:
        dp[2] = 1
        return dp[2]
    dp[2] = 1
    for i in range(3, n+1):
        dp[i] = dp[i-1] + i - 1
    return dp[i]


def sol(n):
    if n <= 0: return 0
    dp = [0] * (n+1)
    dp[1] = 0
    if n == 1:
        return 0
    if n == 2:
        return 1
    dp[2] = 1
    for i in range(3, n+1):
        x = i - 1
        if x % 2 == 0: # even
            dp[i] = ((x + 1) * int(n/2))
        else: # odd
            dp[i] = ((x + 1) * int(n/2)) + int((n+1)/2)
    return dp[i]



do_submit = True
#do_submit = False
if do_submit:
    logging.basicConfig(level=logging.ERROR, format="%(message)s")
else:
    logging.basicConfig(level=logging.DEBUG, format="%(message)s")

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [[x.strip() for x in line.split()] for line in lines]
    n, k = parsed_lines[0]
    n = int(n)
    k = int(k)
    S = parsed_lines[1][0]
    return (n, k, S)


if not do_submit:
    n, k, S = input_parse("""
    14 2
    11101010110011
    """)
    print(sol(n, k, S))

    n, k, S = input_parse("""
    5 1
    00010
    """)
    print(sol(n, k, S))

    n, k, S = input_parse("""
    1 1
    1
    """)
    print(sol(n, k, S))


else:
    # str = ""
    # str += input().strip() + "\n"# n, k
    # str += input().strip() # S
    # n, k, S = input_parse(str)
    n = int(input().strip())
    print (sol(n))

Submission status: Runtime Error

Solution code:
N = int(input())
N_list = list(range(1,N,1))
mod = sum(N_list)
print(mod)

Submission status: Runtime Error

Solution code:
N = int(input())
r = range(N)
l = list(r)

print(sum(l))

Submission status: Runtime Error

Solution code:
N=int(input())
H=[0]*N
for i in range(N):
  H[i]=N*(N-1)/2 - i + N%(i+1)
print(int(max(H)))

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    N = int(input())
    ans = (1 + (N - 1)) / 2 * (N - 1)

    a = np.arange(start=1, step=1, stop=N+1)
    bol = (N % a > a)
    #print(bol)
    #print(np.any(bol))
    if np.any(bol):
        ans += np.sum((N % a)[bol] - a)

    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
a = int(input())

for i in range(a - 1):
  result = result + i + 1

print(result)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(range(N))
a[0] = a[-1]
a.pop(-1)
Mmax = sum(a)

print(Mmax)

Submission status: Runtime Error

Solution code:
n = int(input())

print((n-1)(n-2)/2)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [0] * n
c = 0
for i in range(1, n+1):
    x = i + 1 if i < n else 1
    c += i % x
print(c)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    N = int(input())
    ans = (1 + (N - 1)) / 2 * (N - 1)

    a = np.arange(start=1, step=1, stop=N+1)
    bol = (N % a > a)
    if np.any(bol):
        ans += np.sum((N % a)[bol] - a)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n=list(range(1,int(input())+1))
p=n[1:]
count=0
for i in range(len(p)):
    count+=(n[i]%p[i])
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
print(sum(list(range(1,n))))

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())

# n_list = np.arange(1, n + 1)
# m_list = np.zeros(n)
# m_list[:-1] = n_list[1:]
# m_list[-1] = n_list[0]

n_l = np.arange(1, n + 1)

res = np.cumsum(n_l) 

print(int(res[-2]))

Submission status: Runtime Error

Solution code:
n=list(range(1,int(input())+1))
p=n[1:]
count=0
for i in range(len(n)-1):
    count+=n[i]%p[i]
print(count)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

#N = 2
N = int(input())

M_sums = []
for balls in itertools.permutations(range(1, N+1), N):
    a = np.array(balls)
    b = np.arange(1, N+1)
    #print(a)
    #print(b)
    #print(a%b)
    M_sum = np.sum(a%b)
    M_sums.append(M_sum)
    #print(M_sum)
    
    #print("=======")
print(max(M_sums))

Submission status: Runtime Error

Solution code:
n=int(input())
ls=[None]*n
ls2=[None]*n
for i in range(n):
  ls[i]=i+1
  ls2[i]=i+2
ls2[-1]=1
ans = 0
for i in range(n):
  ans += ls[i]%ls2[i]
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import numpy

#N = 2
N = int(input())

M_sums = []
for balls in itertools.permutations(range(1, N+1), N):
    a = np.array(balls)
    b = np.arange(1, N+1)
    #print(a)
    #print(b)
    #print(a%b)
    M_sum = np.sum(a%b)
    M_sums.append(M_sum)
    #print(M_sum)
    
    #print("=======")
print(max(M_sums))

Submission status: Runtime Error

Solution code:
n = int(input())
lst = list(range(n))
print(sum(lst))

Submission status: Runtime Error

Solution code:
N = int(input())
r = range(N)
l = list(r)
sum = 0

for i in l:
  sum += l[i]

print(sum)

Submission status: Runtime Error

Solution code:
from collections import deque
N = int(input())
Ns = list(range(1,N+1))[::-1]
P = deque(Ns)
P.rotate(1)
print(sum(n % p for p,n in zip(P,Ns)))

Submission status: Runtime Error

Solution code:
print((N-1)/2 * N)

Submission status: Runtime Error

Solution code:
from collections import deque
N = int(input())
Ns = list(range(1,N+1))[::-1]
P = deque(Ns)
P.rotate(1)
sum(n % p for p,n in zip(P,Ns))

Submission status: Runtime Error

Solution code:
import numpy as np

a = int(input())
h = np.array(list(range(1,a+1)))
h2 = h[::-1]
temp = int(0)
index_val = int(0)
max_mod = int(0)
sum_mod = int(0)

for value in h2:
  for index in range(len(h)):
    temp = value % h[index]
    if temp > max_mod:
      max_mod = temp
      index_val = index
  sum_mod += max_mod
  max_mod = 0
  np.put(h,index_val,0)

if a!=1:
  print(sum_mod+1)
else:
  print(0)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())

n_list = np.arange(1, n + 1)
m_list = np.zeros(n)
m_list[:-1] = n_list[1:]
m_list[-1] = n_list[0]

kekka = 0
amari = n_list % m_list
print(int(sum(amari)))

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())
Ns = list(range(1, N + 1))

print(sum(Ns[i] for i in range(N - 1)))

Submission status: Runtime Error

Solution code:
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""

from collections import defaultdict
import sys
import time
import logging



def deco(func):
    def wrapper(*args, **kwargs):
        s = time.time()
        #print('--start--')
        ret = func(*args, **kwargs)
        logging.debug('--end in %f --' % (time.time() - s))
        return ret

    return wrapper


def sol_wrong(n):
    if n <= 0: return 0
    dp = [0] * (n+1)

    dp[1] = 0
    if n == 1:
        return dp[n]
    if n == 2:
        return 1
    if n == 3:
        return 3
    # dp[2] = 1
    # dp[2] = 3
    # dp[4] = 5

    for i in range(3, n+1):
        dp[i] = dp[i-2] + i

    return dp[n]


def sol(n):
    if n <= 0: return 0
    dp = [0] * (n+1)
    dp[1] = 0
    if n == 1:
        dp[1] = 0
        return dp[1]
    if n == 2:
        dp[2] = 1
        return dp[2]
    dp[2] = 1
    for i in range(3, n+1):
        dp[i] = dp[i-1] + i - 1
    return dp[i]



do_submit = True
#do_submit = False
if do_submit:
    logging.basicConfig(level=logging.ERROR, format="%(message)s")
else:
    logging.basicConfig(level=logging.DEBUG, format="%(message)s")

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [[x.strip() for x in line.split()] for line in lines]
    n, k = parsed_lines[0]
    n = int(n)
    k = int(k)
    S = parsed_lines[1][0]
    return (n, k, S)


if not do_submit:
    n, k, S = input_parse("""
    14 2
    11101010110011
    """)
    print(sol(n, k, S))

    n, k, S = input_parse("""
    5 1
    00010
    """)
    print(sol(n, k, S))

    n, k, S = input_parse("""
    1 1
    1
    """)
    print(sol(n, k, S))


else:
    # str = ""
    # str += input().strip() + "\n"# n, k
    # str += input().strip() # S
    # n, k, S = input_parse(str)
    n = int(input().strip())
    print (sol(n))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
print(np.sum(np.arange(1, N, dtype='int32')))

Submission status: Runtime Error

Solution code:
n = int(input())
ns = list(range(1, n+1))
ns_ = ns[1:] + [ns[0]]

total = 0
for i in range(n):
    total += ns[i] % ns_[i]
print(total)

Submission status: Runtime Error

Solution code:
N = int(input())

l = []
l1 = []
for i in range(1, N + 1):
    l.append(i)
for i in range(2, N + 1):
    l1.append(i)
l1.append(1)

m = []
for i in range(len(l)):
    m.append(l[i] % l1[i])
pirnt(sum(m))

Submission status: Runtime Error

Solution code:
N = int(input())


def sum_ms(ps):
    n = len(ps)
    result = 0
    for j in range(n):
        i = j + 1
        result += i % ps[j]
    return result


ps = list(range(2, N + 1))
ps.append(1)
print(sum_ms(ps))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
narray = np.arange(1,N+1)
P = np.hstack((narray , narray))
ans = 0
A = []
for i in range(N):
  for l in range(N):
    ans += narray[l] % P[i+l]
  A.append(ans)
  ans = 0
print(max(A))

Submission status: Runtime Error

Solution code:
def func():
    N = int(input())
    serial = list(range(1, N + 1))

    print(sum(serial)-N)


if __name__ == '__main__':
    func()

Submission status: Runtime Error

Solution code:
N = int(input())


def ms(ps):
    n = len(ps)
    result = []
    for j in range(n):
        i = j + 1
        result.append(i % ps[j])
    return result


ps = list(range(2, N + 1))
ps.append(1)
print(sum(ms(ps)))

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit

n = int(input())
a = np.array(list(i for i in range(1, n + 1)))

@jit
def main():
    p = a.copy()
    p = np.append(p, a[0])
    p = np.delete(p, 0)
    print(sum(a % p))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())

N_list = list(range(1,N+1,1))
N_list.reverse()

mod = 0
for i in range(len(N_list)):
	print(i+1,'%',N_list[i] ,'=' ,(i+1) % N_list[i])
	mod += (i+1) % N_list[i]

print(mod)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    n_list = list(range(1, n + 1))

    rev_list = n_list[:]

    rev_list.insert(0, n_list[-1])
    rev_list.pop(len(rev_list) - 1)

    ans = 0
    for i, r in enumerate(rev_list):
        ans += r % n_list[i]

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
list = list(range(1,N+1))
ans = 0
for i in range(N)[::-1]:
    max = 0
    for j in list:
        remove = 0
        rem = i % j
        if max <= rem:
            remove = j
            max = rem
    list.remove(remove)
    ans += max

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
list_N=np.array(list(range(1,N)))
print(int(np.sum(list_N)))

Submission status: Runtime Error

Solution code:
import sys
import itertools

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())
l=list(range(1,N+1))
m=list(itertools.permutations(range(1,N+1)))
le=len(m)
a=0
ans=0

for j in range(le):
	for i in range(N):
		a+=l[i]%m[j][i]
		
	if a>ans:
		ans=a
	a=0

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
ar = np.arange(1, N)
total = np.sum(ar)
print(total)

Submission status: Runtime Error

Solution code:
n = int(input())
dp = [0] * (n+1) 
for i in range(2,n+1):
  dp[i] = dp[i-1]+(i-1)
print(dp[-1])

Submission status: Runtime Error

Solution code:
import numpy as np
x = np.arange(int(input()))
print(np.sum(x))

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main(void){
    // Your code here!
    int num;
    scanf("%d",&num);
    int list[num];
    for(int i=1;i<=num;i++){
        list[i-1] = i;
    }
    //int mod;
    //int maxi=0;
    //int maxn=0;
    //int eli[num];
    /*for (int i=0;i<num;i++){
        eli[i] = 0;
    }
    int count=0;
    for(int i=num;i>0;i--){
        maxn = 0;
        maxi = 0;
        for(int j=0;j<num;j++){
            if(eli[j]==1){
                continue;
            }
            mod = i % list[j];
            if (mod > maxn){
                maxn = mod;
                maxi = j;
            }
        }
        count += maxn;
        eli[maxi] = 1;
        //printf("%d mod %d = %d\n",i,maxi+1,maxn);
    }*/
    unsigned int c =0;
    for(int i=num;i>0;i--){
        if(i-1==0){
            break;
        }
        c += i-1;
    }
    printf("%u",c);
}

Submission status: Runtime Error

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################


count = 0
for i in range(N):
    if i == (N-1):
        count += (i+1) % (1)
    else:
        count += (i+1) % (i+2)

print(count)

Submission status: Runtime Error

Solution code:
N = int(input())

data = list(range(N))
for i in range(len(data)):
  data[i] = data[i] + 1

max_num = 0
count_num = 0
out = 0
for i in range(len(data)):
  for k in range(len(data)):
    if count_num == 0:
      tmp = k % data[i]
      if max_num < tmp:
        max_num = tmp
        count_num = k
    else:
      if k != count_num:
        tmp = k % data[i]
        if max_num < tmp:
          max_num = tmp
          count_num = k
    out = out + max_num      

print(out)

Submission status: Runtime Error

Solution code:
n = int(input())
return sum(range(n))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
lst1 = np.array([list(range(1,n))])

if n==1:
  print(0)
else:
  print(lst1.sum())

Submission status: Runtime Error

Solution code:
n = int(input())


a = list(range(1, n))

print(sum(a))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
print(np.sum(np.arange(N)))

Submission status: Runtime Error

Solution code:
n = int(input())
ans = [0] * n
for i in range(1,n):
  ans[i - 1] = i   
print(sum(ans))

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main(void){
    // Your code here!
    int num;
    scanf("%d",&num);
    int list[num];
    for(int i=1;i<=num;i++){
        list[i-1] = i;
    }
    //int mod;
    //int maxi=0;
    //int maxn=0;
    //int eli[num];
    /*for (int i=0;i<num;i++){
        eli[i] = 0;
    }
    int count=0;
    for(int i=num;i>0;i--){
        maxn = 0;
        maxi = 0;
        for(int j=0;j<num;j++){
            if(eli[j]==1){
                continue;
            }
            mod = i % list[j];
            if (mod > maxn){
                maxn = mod;
                maxi = j;
            }
        }
        count += maxn;
        eli[maxi] = 1;
        //printf("%d mod %d = %d\n",i,maxi+1,maxn);
    }*/
    int c=0;
    for(int i=num;i>0;i--){
        if(i-1==0){
            break;
        }
        c += i-1;
    }
    printf("%d",c);
}

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main(void){
    // Your code here!
    int num;
    scanf("%d",&num);
    int list[num];
    for(int i=1;i<=num;i++){
        list[i-1] = i;
    }
    //int mod;
    int maxi=0;
    int maxn=0;
    int eli[num];
    /*for (int i=0;i<num;i++){
        eli[i] = 0;
    }
    int count=0;
    for(int i=num;i>0;i--){
        maxn = 0;
        maxi = 0;
        for(int j=0;j<num;j++){
            if(eli[j]==1){
                continue;
            }
            mod = i % list[j];
            if (mod > maxn){
                maxn = mod;
                maxi = j;
            }
        }
        count += maxn;
        eli[maxi] = 1;
        //printf("%d mod %d = %d\n",i,maxi+1,maxn);
    }*/
    int c=0;
    for(int i=num;i>0;i--){
        if(i-1==0){
            break;
        }
        c += i-1;
    }
    printf("%d",c);
}

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())
Ns = list(range(1, N + 1))
Ps = list(Ns[i + 1] for i in range(0, N - 1))
Ps.extend([Ns[0]])
#print(Ns)
#print(Ps)
mod_sum = sum(Ns[i] % Ps[i] for i in range(len(Ns)))
print(mod_sum)
#print()

Submission status: Runtime Error

Solution code:
N = int(input()
print(int(((N-1)*N)/2))

Submission status: Runtime Error

Solution code:
n = int(input())
lst1 = list(range(1,n))
#lst2 = list(range(2,n+1))
#lst2.append(1)
#lst3 = list(range(2,n+1))
#del lst3[lst3.index(n//2+1)]
#lst3.append(n//2+1)
m_sum = sum(lst1)
#m_sum2 = sum(list(map(lambda x,y,:x%y, lst1, lst3)))
if n==1:
  print(0)
else:
  print(m_sum)

Submission status: Runtime Error

Solution code:
n = int(input())

a = list(range(1, n+1))
b = a[1:]+[1]
ans = 0

for i in range(n):
    ans += a[i] % b[i]

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
ans = [0] * n
for i in range(1,n):
  ans[i] = i
   
print(sum(ans))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    int64_t ans;
    ans = N * (N - 1) / 2;
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
n = int(input())+1
l1 = range(1,n+1)
l2 = list(l1[1:n-1])
l2.append(1)
total = 0
for a,b in zip(l1,l2):
    total += a%b
print(total)

Submission status: Runtime Error

Solution code:
from itertools import accumulate

n = int(input())

ans = list(accumulate(range(1, n)))[-1]
print(ans)

Submission status: Runtime Error

Solution code:

import numpy as np

n = int(input())
p = np.array(list(range(2, n + 1)) + [1])
mod = p - 1

print(sum(mod[:n-1]))

Submission status: Runtime Error

Solution code:
N = int(input())
P = list(range(1, N))
sum= 0

P.remove(1)
P.append(1)

for i in range(N):
  M = i % P[i]
  sum += M
  
print(sum)

Submission status: Runtime Error

Solution code:
N=int(input())
l=list(range(1,N))
s=[0]*N
for i in range(N-1):
    s[i+1]=s[i]+l[i]
print(s[N-1])

Submission status: Runtime Error

Solution code:
n1 = int(input())
if n1 == 1:
    print(0)
else:
    n2 = list(range(1, n1+1))
    n2.reverse()
    a1 = sum(n2[1:(len(n2))])
    print(a1)

Submission status: Runtime Error

Solution code:
n = int(input)
print(sum([i for i in range(n)]))

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())
Ns = list(range(1, N + 1))

Ps = list(Ns[i + 1] for i in range(0, N - 1))
Ps.extend([Ns[-1]])
#print(Ns)
#print(Ps)
mod_sum = sum(Ns[i] % Ps[i] for i in range(len(Ns)))
print(mod_sum)

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
list_N=list(range(1,N+1))
P=[list_N[-1]]
P.extend(list_N[:-1])

ret=np.sum(np.array(P)%np.array(list_N))
print(ret)

Submission status: Runtime Error

Solution code:
N = int(input())

P = list(range(1,N+1))
M = P[1:]
M.append(1)

ans = 0
for i in range(N):
  ans += P[i]%M[i]
  
print(ans)