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: Time Limit Exceeded

Solution code:
# coding: utf-8
N = int(input())

res = sum(range(N))

print(res)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
sum = 0
for i in range(1, num):
#    if i == num:
#        pass
#    else:
    sum += i % (i+1)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
tmp = 0
for i in range(N):
    tmp += i
print(tmp)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

result = 0
max_result = 0
for idx in range(2, n+1):
  block_num, mod_ = divmod(n, idx)
  result = tosa(idx-1) * block_num + tosa(mod_)
  if max_result < result:
    max_result = result
    
print(int(max_result))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
I = [x%(x+1) for x in range(1,N+1)]
ans = sum(I) - N
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
if N==1:
	ans=0
else :
	a=range(1,N)
	ans=sum(a)
print(ans)

Submission status: Time Limit Exceeded

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

N = int(input())
a[0] = N
a[1] = 0
for i in range (1,a[0]):
  a[1] = a[1] + i
print(a[1])

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
sum = 0
for i in range(a):
    sum += i
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
array = [i for i in range(1, N+1)]
num = 0

for i in range(1, N):
    num += array[i-1] % array[i]

print(num)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
sum=0
for i in range(N):
    sum+=i
if N==1:
    print(0)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = [(elem + 1) for elem in range(n)]

if len(lst) == 1:
    print(0)
else:
    print(sum(lst[:-1]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
I = [x for x in range(1,N+1)]
P = [x+1 for x in range(1,N)]
P.append(1)
M = [x % y for (x,y) in zip(I,P)]
print(sum(M))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

s = [i for i in range(N)]
print(sum(s))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
C=0
for i in range(N):
	C+=i
print(C)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#El Patron
#EASY MATH
A = int(input())

print(sum(range(1, A + 1)) - A)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
m = []
for i in range(1, N):
    m.append( i % (i+1) )
print(sum(m))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
I = [x for x in range(1,N+1)]
P = [x for x in range(1,N+1)]
del P[0]
P.append(1)
M = [x % y for (x,y) in zip(I,P)]
print(sum(M))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
sum = 0
for i in range(1, num+1):
    if i == num:
        sum += i % 1
    else:
        sum += i % (i+1)
print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

mod = (N-1)*N/2
for i in range(1,N+1):
    if N%i == N:
        break

print(int(mod+N-i))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

P = np.array([i for i in range(1,int(input())+1)])

M = np.sum(np.array([divmod(i, P[i])[1] for i in range(len(P))]))

print(M)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

N_list = np.array(range(N))

N_np   = np.sum(N_list)

print(int(N_np))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
N = int(N)
if not(1 <= N and N <= 10**9):
    exit()
ans = 0

if N % 2 == 0:
    for i in range(int(N/2)):
        ans += N+1
    ans -= N
else:
    for i in range(int(N/2)):
        ans += N
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

N_list = np.array(range(N))

N_np   = np.sum(np.array(N_list))

print(int(N_np))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

total=[ a for a in range(N) ]

print(sum(total))

Submission status: Time Limit Exceeded

Solution code:
a = int(input())

ans = 0
for i in range(1,a):
  ans += i
  
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

N_list = [i+1 for i in range(N-1)]

N_np   = np.sum(np.array(N_list))

print(int(N_np))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Nlist = []
for i in range(N):
    Nlist.append(i+1)
Nlist
print(sum(Nlist)-N)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
total = 0
for i in range(1, N):
  total += i

print(total)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math

# 標準入力をスペースで区切って、intに変換 listに収納
int_list  = [int(x) for x in stdin.readline().rstrip().split()]

N = int_list[0]

total = 0
for i in range(N):
    total+=i

print(total)

Submission status: Time Limit Exceeded

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]))
kekka = 0
for i in range(1, n):
    kekka += i

print(kekka)

Submission status: Time Limit Exceeded

Solution code:
from itertools import accumulate
n = int(input())
a = list(accumulate(range(n)))
print(a[-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

P = np.array([i for i in range(1,int(input())+1)])

M = np.sum(np.array([i % P[i] for i in range(len(P))]))

print(M)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
if n % 2:
    temp = int((1 + n-1) * ((n-1) / 2))
else:
    temp = int((1 + n-1) * ((n-1) // 2) + -(-n // 2))
for i in range(1, n):
    if n % (i+1) > i:
        temp += n-i
print(temp)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

total=0
for i in range(N):
    total=total+i

print(total)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
listN = np.array([i+1 for i in range(n)])
listM = np.array([j+2 for j in range(n-1)]+[1])
print(np.sum(listN%listM))

Submission status: Time Limit Exceeded

Solution code:
n = []
a = []
num = int(input())
for i in range(num):
    n.append(i+1)
    a.append(i+1)
a.pop(0)
a.append(1)
sum = 0
for c,d in zip(n, a):
    sum+= c % d
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(sys.stdin.readline())
print(sum(n + 1 for n in range(N - 1)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
total = 0
for i in range(1, N):
  total += i
  
print(total)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

N_list = [i+1 for i in range(N)]


sum = 0

for i in range(0, len(N_list), 1):
    sum = sum + i

print(sum)

Submission status: Time Limit Exceeded

Solution code:
def D():
    n = int(input())
    S = [i for i in range(1, n+1)]
    ans = 0
    # for i in range(1, n+1):
    #     m = 0
    #     s = [i for i in range(1, n+1)]
    #     for j in range(len(s)):
    #         m = max(m, s[0]%i)
    #         del s[0]

    #     print(i, m)
    #     ans += m
    ans = n*(n-1)//2
    print(ans)
D()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
j = 0
for i in range(1,N):
    j += i
print(j)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(input())

ans = sum([i for i in range(1,n)])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = input()
N = int(N)
if not(1 <= N and N <= 10**9):
    exit()

# n_list = []
# num = 1
# for i in range(N):
#     n_list.append(i+1)
#     num = num * (i+1)

ans = 0
# i = 0
# for i in range(num):
#     print(i+1)
#     P = []

# print(n_list)



# ans = 0

# tmp = n_list.pop(0)
# n_list.append(tmp)
# print(n_list)

# for i in range(len(n_list)):
#     print((i+1)%n_list[i])
#     ans += (i+1) % n_list[i]

for i in range(N):
    ans += i+1
ans -= N

# P = []
# for i in n_list:
#     P.insert(0, i)

# print(P)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = list(x for x in range(1, int(input()) + 1))
p = [max(n)]
p.extend(n)

m = []
ans = 0

for i in range(len(n)):
  m.append(p[i] % (i+1))

for i in range(len(n)):
  ans += m[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = []
l1 = []
for i in range(1, N):
    l.append(i)
    l1.append(i + 1)
l.append(N)
l1.append(1)
m = 0
for i in range(len(l)):
    m += l[i] % l1[i]
print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 0
for i in range(n):
  a += i
print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

print(sum(range(1, n + 1)) - n)

Submission status: Time Limit Exceeded

Solution code:
def main(): 
    n = int(input())

    sum = 0

    for i in range(1, n):
        sum += i

    print(sum)



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Mmax = 0
for i in range(N-1):
    Mmax += i+1

print(Mmax)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

total = 0
for i in range(1, n+1):
    if i == n:
        break
    total += i % (i+1)
print(total)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
cnt=0
if n==1:
  print(0)
else:
  for i in range(1,n):
    cnt+=i%(i+1)
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

mod = 0
for i in range(1,N):
    M = i%(i+1)
    mod += M
print(mod)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(i for i in range(1, n+1))
p = a.copy()
p.append(p[0])
p.pop(0)
c = 0
for i in range(n):
    c += a[i] % p[i]
print(c)

Submission status: Time Limit Exceeded

Solution code:
N = input()
N = int(N)
if not(1 <= N and N <= 10**9):
    exit()

n_list = []
num = 1
for i in range(N):
    n_list.append(i+1)
    num = num * (i+1)

ans = 0
# i = 0
# for i in range(num):
#     print(i+1)
#     P = []

# print(n_list)



# ans = 0

tmp = n_list.pop(0)
n_list.append(tmp)
# print(n_list)

for i in range(len(n_list)):
    ans += (i+1) % n_list[i]

# P = []
# for i in n_list:
#     P.insert(0, i)

# print(P)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
for i in range(n):
  ans+=i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0

if N == 1:
  print(ans)
  exit()

for i in range(N-1):
  ans = ans + i + 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
sum = 0
for i in range(N):
  sum += i
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
listN = np.array([i+1 for i in range(n)])
listM = np.array([j+2 for j in range(n-1)]+[1])
print(sum(listN%listM))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

cnt = 0

for c in range(n) :
    cnt += c
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

c = list()
for n in range(1, N+1):
    c.append(n)

d = c[:]
del d[0]
d.append(1)

cont = 0
for e, f in zip(c, d):
    mod = e % f
    cont += mod


print(cont)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
N = int(input())

P = [i+1 for i in range(N)]

res = 0
for i in range(N-1):
    res += (i+1) % P[i+1]

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

myans = 0

for i in range(N):
    myans += i
    
print(myans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=[i for i in range(1,int(input())+1)]
p=n[1:] 
p.append(n[0])

count=0
for i in range(len(n)):
    count+=n[i]%p[i]
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

temp = [i+1 for i in range(1, N)]
ans = sum(temp[:-1])
ans += 1 % temp[-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
ans=0
for i in range(N-1):
	ans+=i+1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
b=int((a-1)*a/2)
c=[]
c.append(b)
for i in range(1,int(a/2)):
    if i<a%(i+1):
        c.append(b+(a%(i+1)-i))
print(max(c))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

ans = 0
for y in range(1, N):
    ans += y

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0
if n>1:
    for i in range(n):
        ans+=i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
for i in range(N):
  ans += i%(i+1)
  if i == N-1:
    ans += i%1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = [i for i in range(1, N+1)]
print(sum(L)-max(L))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
count=0
for i in range(N-1):
    count+=i+1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sum = 0
for i in range(n):
  sum += i
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
list1=[]
count2=1
ans_sum=[]
#list2=list(0 for _ in range(n))
for i in range(n):
    list1.append(i+1)
for i in range(n):
    count=count2
    ans=[]
    for j in range(n):
        ans.append(list1[j]%count)
        if count==n:
            count=1
        else:
            count+=1
        #print(ans)
    count2+=1
    ans_sum.append(sum(ans))
print(max(ans_sum))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 0
for i in range(n):
    res += i
print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
listN = [i+1 for i in range(n)]
listM = [j+2 for j in range(n-1)]
listM.append(1)
ans = [x%y for (x,y) in zip(listN,listM)]
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
print(sum(range(N)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

res = 0

for i in range(N,1,-1):
    res += (i-1) % i

print(res)

Submission status: Time Limit Exceeded

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

sum = 0

for i in range(N-1):
    sum += (i + 1)

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = [i for i in range(1,n+1)]
num.append(1)
ans = 0
for j in range(1,n+1):
  ans += j%num[j]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

P = np.array([i for i in range(1,int(input())+1)])

M = sum(np.array([i % P[i] for i in range(len(P))]))

print(M)

Submission status: Time Limit Exceeded

Solution code:
print(sum([x for x in range(1, int(input()))]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list1 = [i for i in range(1, N + 1)]

list2 = list1[1:]

list2.append(1)

zipped = list(zip(list1, list2))

sum = 0

for t in zipped:
  mod = t[0] % t[1]
  sum = sum + mod
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 0
for i in range(1, n, 1):
    res += i
print(res)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        ans += i - 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list = [i+1 for i in range(N)]
sum = 0

for i in range(1,N):
  sum += i

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sum = 0

for i in range(1,n):
  sum += i
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
#D - ModSum
N=int(input())
M=0
for i in range(1,N):
    M+=i%(i+1)
print(M)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
listN = [i+1 for i in range(n)]
listM = [j+2 for j in range(n-1)]
listM.append(1)
ans = 0
for k in range(n-1):
    ans += listN[k]%listM[k]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

x = [i + 1 for i in range(N)]

print(sum(x) - N)

Submission status: Time Limit Exceeded

Solution code:
F = [0, 0, 1]
    
while True:
    try:
        N = int(input())
        
        if N > len(F) - 1:
            for i in range(len(F), N+1):
                F.append(F[i-1] + i - 1)
        
        print(F[N])
    except:
        break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = 0
cur = 1
while(True):
  if cur >= N:
    break
  s += cur
  cur += 1
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0

for i in range(1, N):
    ans += i

print(ans)

Submission status: Time Limit Exceeded

Solution code:

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


N = int(input())

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: Time Limit Exceeded

Solution code:
n_2 = int(input())

c = 0
for j in range(1,n_2+1):
    c += j
    
print(c - n_2)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
alist = [i+1 for i in range(a)]
# blist = []
current = 2
blist = [i+2 for i in range(a-1)]
blist.append(1)
#
ans = 0
for i in range(a):
    # print( alist[i] % blist[i])
    ans += alist[i] % blist[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
num = np.array(range(1,n+1))
tmp = num.copy()
num = np.delete(num, 0)
num = np.append(num, 1)
print(sum(tmp % num))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A= []
for i in range(N-1):
    A.append(i+2)

A.append(1)

count = 0

for i in range(N):
    count += (i+1)%A[i]

print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list = [i+1 for i in range(N)]
sum = 0

for i in range(1,N+1):
  if i == N:
    sum += i%1
  else:
    sum += i%list[i]

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
a = np.array(list(i for i in range(1, n+1)))
p = a.copy()
p = np.append(p, a[0])
p = np.delete(p, 0)
print(sum(a % p))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0

def add(n):
    if n%2 == 0:
        return sum(range(1,n))
    else:
        p = (n // 2 ) + 1
        return (n % p) + sum(range(1,n)) - (p-1)

print(add(n))

Submission status: Time Limit Exceeded

Solution code:

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


N = int(input())

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: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

ans = int(((1 + N)*N/2) - N)


for i in range(1, N):
    if i < N%i:
        ans -= i
        ans += N%i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

P = [i for i in range(1,N+1)]

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

print(M)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

num_list = [i+1 for i in range(n)]

print(sum(num_list) - n)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

P = [(x + 2) for x in range(N-1)] + [1]
M = [i % P[i-1] for i in range(N)]
print(sum(M))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=0
for i in range(n):
  x=x+i
print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = 0
for i in range(1, N):
  s += i
print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
M=0
for i in range(N-1):
  M+=(i+1)
print(M)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
if n == 1:print(0);exit()
sum = 0
for i in range(0,n-1):
  sum += i+1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

N = int(input())

M_sum = 0
M_sum = sum(range(1, N))
M_sum += N % 1
print(M_sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())

max = 0
for _ in range(1,N):
    max = max + _
print(max)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = [n for n in range(1, N)]

print(sum(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

n1 = int(input())
if n1 == 1:
    print(0)
else:
    a1 = 0
    for i in range(1, n1):
        a1 += i
    print(a1)

Submission status: Time Limit Exceeded

Solution code:
import sys
inputs = sys.stdin.readlines()

N = int(inputs[0])

s = 0
for i in range(1, N+1):
    s += i
print(s-N)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = [n for n in range(1, N)]

sum = 0
for i, e in enumerate(l):
    sum += e % (e+1)

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mod = 0
if N == 1:
  print(0)
else:
  print(sum(range(2,N))+1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans=0

for i in range(N):
  ans+=i
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n_2 = int(input())

max_amaries = []

for j in range(1,n_2+1):
    if j == n_2:
        print(sum(max_amaries))
    max_amari = j % (j+1)
    max_amaries.append(max_amari)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

num_list = [i+1 for i in range(n)]

best_ans = 0

for i in range(n - 1):
  best_ans += num_list[i] % num_list[i + 1]

print(best_ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0

for i in range(1, N):
    ans += i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def D():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        m = 0
        s = [i for i in range(n)]
        for j in range(len(s)):
            m = max(m, s[0]%i)
            del s[0]

        ans += m
    print(ans)
D()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

result = 0
for i in range(N):
    result += i

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

N = int(input())

M_sum = 0
for i in range(1, N):
    M_sum  += i

M_sum += N % 1
print(M_sum)

Submission status: Time Limit Exceeded

Solution code:


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

from collections import deque

N = int(input())
p = deque()
for i in range(N):
    p.append(i+1)

x = p.popleft()
p.append(x)

#p = [2,3,4,5,6,7,8,9,10,11,12,13,1]

#print(p)
count = 0
for i in range(N):
    count += (i+1) % p[i]

print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mod = 0
if N == 1:
  print(0)
else:
  for i in range(1,N+1):
    if i == 1:
      mod += 1
    elif i == N:
      mod += 0
    else:
      mod += i
  print(mod)

Submission status: Time Limit Exceeded

Solution code:
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
A = [i for i in range(1, N+1)]
sum = sum(A)
print(sum-N)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
count = 0
if 1 <= n <= 10 ** 9:
    for i in range(n - 1):
        count += i + 1
    print(count)
else:
    print('hoge!')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 0
for i in range(N):
    ans += i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
r = 0
for i in range(1,N):
    r += i
print(r)

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
n = int(input())

answer = 0

for i in range(1,n):
	answer += i
print(answer)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 0

def add(n):
    if n%2 == 0:
        return sum(range(1,n))
    else:
        p = (n // 2 ) + 1
        return (n % p) + sum(range(p,n)) + add(p-1)

print(add(n))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
if N == 1:
  print("0")
else:
  ans = 0
  for i in range(N):
    ans += i
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
answer = 0
print(sum([ i % (i + 1) for i in range(1, N)]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input().strip())
ans = 0
for i in range(n):
    ans = ans + i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(1,n):
    ans+=i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
print(sum([_ for _ in range(int(input()))]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

num_list = [i+1 for i in range(n)]

div_list = num_list[1:]
div_list.append(num_list[0])

best_ans = 0

for i in range(n):
  best_ans += (num_list[i] % div_list[i])


print(best_ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
if N == 1:
  print("0")
else:
  nums = [i for i in range(1,N)]
  print(sum(nums))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n == 1:
    print(0)
else:
    print(sum(range(n)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

N = int(input())
p = []
for i in range(N):
    p.append(i+1)

x = p.pop(0)
p.append(x)
#p.reverse()

#p = [2,3,4,5,6,7,8,9,10,11,12,13,1]

#print(p)
count = 0
for i in range(N):
    count += (i+1) % p[i]

print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = 0

for i in range(n):
    num = num + i

print(num)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
sum = 0
for i in range(N):
    sum += i
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = [i for i in range(1,n+1)]
tmp = num.copy()
ans = 0
for j in range(n):
  if j==0:
    num.pop(0)
    num.append(1)
  ans += tmp[j]%num[j]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

arr = [i+1 for i in range(N)]
if N == 1:
    print(0)
else:
    print((1+(N-1))*(N-1)//2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
print(sum(i for i in range(N)))

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
print(sum([i for i in range(N)]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

print(sum([i for i in range(N)]))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
count=0
for i in range(n):
  count=count+i
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N =int(input())
m = 0
for i in range(N):
    m += i

print(m)