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

Solution code:
N = int(input())
print('{}'.format(int((N * (N - 1)) // 2 )))

Submission status: Accepted

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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    return (n,)


def solve(n):

    # result = int((n-1)*n*0.5)
    result = (n-1)*n//2

    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)


if __name__ == '__main__':

    main()

Submission status: Accepted

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

n = int(input())
print(sum(range(1,n)))

Submission status: Accepted

Solution code:
n = int(input())

ans = (n * (n-1)) // 2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
if n>1:
    ans=((n-1)*n)//2 
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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()
sum = N*(1+N)//2
print(sum-N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

a = N/2
b = int(N/2)
if not(N%2 == 0):
    Mmax = N*b
elif N%2 == 0:
    Mmax = N*(b-1) + b



print(Mmax)

Submission status: Accepted

Solution code:
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    N = np.int64(input())
    #print(N)
    #ans = np.int64((1 + (N - 1)) / 2 * (N - 1))
    ans = (1 + (N - 1)) * (N - 1) // 2
    print(int(ans))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
#print(round(N*(N-1)/2))
if N%2 == 0:
    print(int(N/2)*(N-1))
else:
    print(int((N-1)/2)*N)

Submission status: Accepted

Solution code:
N = int(input())

N = N -1

mysum = ((N*(N+1))//2)

print(mysum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

out = (N-1) * N // 2
print(int(out))

Submission status: Accepted

Solution code:
def solve(N):
    return (N * (N - 1)) // 2
 
 
if __name__ == '__main__':
    N = int(input())
 
    answer = solve(N)
    print(int(answer))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
if n==1:
  print(0)
else:
  s=(n*(n-1))//2
  print(int(s))

Submission status: Accepted

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)

# for i in range(1, 10 ** 7):
#     mt = (N * (N+1)) // 2 - N
#     tsk = (N - 1) * N // 2

#     if mt != tsk:
#         print("values are not correct! @ N {}, mt {}, tsk,{}".format(i, mt, tsk))

sum = (N * (N+1)) // 2 - N
#sum = (N * (N+1)) / 2 - N

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
print('{}'.format((N*(N-1)//2)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())
print(n*(n-1)//2)

Submission status: Accepted

Solution code:
import math

N = int(input().split()[0])

# if (N - 1) % 2 == 0:
#     ans = int(N * ((N - 1) / 2))
# else:
#     mean_v = math.floor((N - 1) / 2) + 1
#     ans = int(N * math.floor((N - 1) / 2))
#     ans += mean_v

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import math
N = int(input())
print(math.floor((N*(N-1)//2)))

Submission status: Accepted

Solution code:
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)
n = ip()
print((n-1)*n//2)

Submission status: Accepted

Solution code:
# coding: utf-8
import math

if __name__ == "__main__":
    N = int(input())
    print(int(((N-1)*N)//2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"

inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N=I()
    print(int(N*(N-1)//2))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

if __name__ == "__main__":
    N = int(input())
    print(int(((N-1)*N)//2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
  print(0)
elif N == 2:
  print(1)
else:
  print(int(N * (N-1) // 2))

Submission status: Accepted

Solution code:
N = int(input())

MM = ( N*(N-1) )//2

print(int(MM))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    print(int(n*(n-1)//2))

Submission status: Accepted

Solution code:
N=int(input())
print('{}'.format(N*(N-1)//2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
x= n-1

a = x*n
print(a//2)

Submission status: Accepted

Solution code:
N=int(input())

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

print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

# sum = (N-2)*(N+1)/2 + 1
sum = (N-2)*(N+1)//2 + 1

if N == 1:
    sum = 0
elif N ==2:
    sum = 1

print(int(sum))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

answer = (N-1)*N//2
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
ans = (n*(n-1))//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
sum = 0
sum = (a-1)* a // 2
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
ans = ((N-1)*N)//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

x = int((N - 1) * N // 2)

print(x)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(n  * (n - 1) // 2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n = int(input())
    ans = n*(n-1)//2
    print(ans)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
def sol(n):
    if n <= 0: return 0
    if n == 1:
        return 0
    if n == 2:
        return 1
    x = n - 1
    if x % 2 == 0: # even
        return ((x + 1) * int(x/2))
    else: # odd
        return ((x + 1) * int(x/2)) + int((x+1)/2)



n = int(input().strip())
print (sol(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from decimal import *
N = int(input())

print(int(Decimal(Decimal(N-1)/2*Decimal(N))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input().strip())
ans = (n*(n-1))//2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

sum = (N - 1) * N // 2

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a, b = divmod((n - 1) * n, 2)
print(a)

Submission status: Accepted

Solution code:


N = int(input())
# if N == 1:
#     print("0")
#     exit()
ans = (N-1)*N//2
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x= n-1

a = x*n
print(int(a//2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = ((n-1)*n)//2

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
#(1,2,...,N)に対してP=(2,3,...,N,1)が最善

sum = int((N-1)*N//2)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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)

#sum = int((N * (N+1)) / 2 - N)
#sum = (N * (N+1)) / 2 - N

#print(sum)

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
print(((n-1)*n)//2)

Submission status: Accepted

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

ans = int(n*(n-1)//2)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n= int(input()) -1
cout = (n*(2+n-1))//2
print(cout)

Submission status: Accepted

Solution code:
N= int(input())

n= N-1

sum = (n*N)//2

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
S = int(input())
total=10*6
if(S%2==1):
    total=S*((S-1)//2)
else:
    total=(S-1)*((S-2)//2)+(S-1)

print(total)

Submission status: Accepted

Solution code:
def p_d():
    N = int(input())

    print(N * (N - 1)//2)
    
if __name__ == '__main__':
    p_d()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

sum = ((n - 1) * n) // 2

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans=0
ans = (n-1)*(n)//2
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
if N==0:
    print(0)
else:
    ret=int(N*(N-1)//2)
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from pprint import pprint

def solve(n):
    # print(int((n-1) * n / 2))
    print((n-1) * n // 2)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    solve(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

N = int(input())

# 初項1, 等差1, 項数Nの等差数列の和の公式：1/2n{2a+(n-1)d}

N -= 1

calc =  N * (N+1) // 2

print(calc)

Submission status: Accepted

Solution code:
from decimal import Decimal
N =Decimal(input())
print(N*(N-1)/2)

Submission status: Accepted

Solution code:
print((lambda n: n*(n-1)//2)(int(input())))

Submission status: Accepted

Solution code:
n = int(input())

ans = n*(n-1)//2 

print(ans)

Submission status: Accepted

Solution code:
import sys


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


def main():
    N = int(input())
    ret = 0
    for i in range(1, N):
        ret += i
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
if n%2 != 0:
  ans = n*((n-1)//2)
else:
  ans = n*((n//2)-1) + n//2

print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
if N % 2 == 0:
    print(N*(N//2)-N//2)
else:
    print(N*(N//2))

Submission status: Accepted

Solution code:
from decimal import *

N = int(input())
# if N == 1:
#     print("0")
#     exit()
ans = Decimal((Decimal(N-1) * Decimal(N) / 2))
print(int(ans))

Submission status: Accepted

Solution code:

n = int(input())
if n % 2 == 0:
        print(int(((n-1)+1)*((n-1)//2) + ((n-1)//2+1)))
else:
        print(int(((n-1)+1)*((n-1)//2)))

Submission status: Accepted

Solution code:
N = int(input())

def summation(num):
    factor = divmod(num, 2)
    return (int(num / 2) * (1 + num)) + (factor[0] + 1) * factor[1]

tmp = int(summation(N))
print(tmp - N)

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
count=N*(N-1)//2
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
n=n-1
sum=(n*(n+1))//2
print(int(sum))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

if (n%2)==0:
  ans = int(n/2)
  ans = (n-1)*ans
else:
  ans = (int)((n-1)/2)
  ans = n*ans

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
print(n * (n-1) // 2)

Submission status: Accepted

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

if N % 2 == 0:
    i = int(N/2)
    ans = (N+1) * i
    ans -= N
else:
    i = int(N/2)
    ans = N * i

    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def solve(N):
    n = N - 1
    return (n * (n+1)) // 2


if __name__ == '__main__':
    N = int(input())

    ans = solve(N)

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    if n % 2 == 0:
        print(int((n/2))*(n-1))
    else:
        print(n*int((n-1)/2))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
if N%2==1:
    n=int((N-1)/2)
    X=N*n
else:
    n=int((N/2)-1)
    M=int(N/2)
    X=N*n+M
print(int(X))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
from decimal import Decimal


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

    if n == 1:
        print(0)
        return

    # print(int(n ** 2 - n))
    # print((n ** 2 - n) / 2)
    # print(n * (n - 1))
    # print(n * (n - 1) / 2)
    ans = int(Decimal(n * (n - 1)) / 2)
    print(ans)
    # print(ans * 2)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = (n-1) * n // 2

print(int(ans))

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
one_of_N = 0
other_N = 0

if N % 2 == 0:
  one_of_N = int(N / 2)
  other_N = N - 1
else:
  one_of_N = int((N - 1) / 2)
  other_N = N
  
result = (one_of_N * other_N)
print('{}'.format(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if N % 2 == 0:
    ans = int((N/2)) * (N-1)
else:
    ans = int((N-1)/2) * N
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from decimal import *
N=int(input())
getcontext().prec = 15000
ans=(Decimal(N)*Decimal(N-1))/2
print((Decimal(ans)))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
# data = getInputListInt()

if n % 2 == 0:
    ans = int(n / 2)
    ans = int(ans  * (n - 1))
else:
    ans = int((n - 1) / 2)
    ans = int(ans * n)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print("0")
else :
    print(N* (N - 1) //2)

Submission status: Accepted

Solution code:
N=int(input())-1
sum=(N*(N+1))//2
if N==0:
    print(0)
else:
    print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

if n == 2:
    print(1)
    sys.exit()

# temp1 = (n-1) // 2
# temp2 = 2 + n - 2
#ans = ((n-1) / 2) * (2 + (n - 2))
ans = (n-1) * (2 + (n - 2))
ans = ans // 2
#ans = temp1 * temp2

#print(ans)
print(int(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000) 

n = int(input())
print(n*(n-1)//2)

Submission status: Accepted

Solution code:
n = int(input())
        
ans = ((n - 1) * (n)) // 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = int()
d = n-1
print((d*(d+1)//2))

Submission status: Accepted

Solution code:
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n = int(input())
    ans = n*(n+1)//2-n
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import decimal

N = decimal.Decimal(input())
print(N * (N - 1) / 2)

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
print(int((N - 1) * N // 2))

Submission status: Accepted

Solution code:
import sys
INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

N = int(input())

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

print(ans)

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
#coding: utf-8
from decimal import Decimal
n = int(input())
n = n-1
answer = 0

if n % 2 == 0:
	answer = (Decimal(n)+Decimal(1))*(Decimal(n)/2)
else:
	answer = Decimal(n)*((Decimal(n)-Decimal(1))/2) + Decimal(n)

print(int(round(answer,0)))

Submission status: Accepted

Solution code:
N = int(input())


#1からN-1までの和

if N == 1:
  print(0)
elif N == 2:
  print(1)
else:
  print((N-1)*(N)//2)

Submission status: Accepted

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

N = int(input())
total = sum(range(1, N))
  
print(total)

Submission status: Accepted

Solution code:
n = int(input())
if n%2:
    p = ((n-1)//2)*n
    print(int(p))
else:
    p = (n//2)*(n-1)
    print(int(p))

Submission status: Accepted

Solution code:
n = int(input())
num = n-1
if(num%2==1):
    ans= num//2 +1
    ans*=num
else:
    ans = (num-1)//2 +1
    ans*= (num-1)
    ans+=num
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n%2==0:
  even = n
  odd = n-1
else:
  even = n-1
  odd = n
even_2 = int(even/2)

print(even_2*odd)

Submission status: Accepted

Solution code:
N=int(input())-1
if N%2==0:
	print(int(N/2)*(N+1))
else:
  	print((N)*int((N+1)/2))

Submission status: Accepted

Solution code:
n = int(input())
ans = (n-1)*(1+n-1)//2
print(ans)

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = (n*(n-1))//2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 0:
  ans = int(n / 2) * (n-1)
else:
  ans = int((n-1)/2) * (n)

print(ans)

Submission status: Accepted

Solution code:


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


N = int(input())

# まず等差数列の和
n = N-2
count = (n*(4+(n-1)))//2

#print(count)

# 最終項
count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0

if (n-1)%2 == 0 :
    cnt = ((n-1)//2) * (n)
else :
    cnt = ((n-1)//2) * (n) + n//2

print(cnt)

Submission status: Accepted

Solution code:

n = int(input())

if n % 2:
    print(n * (n - 1) // 2)
else:
    print(n * (n // 2 - 1) + n // 2)

Submission status: Accepted

Solution code:
def D():
    n = int(input())
    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: Accepted

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

N = int(input())

n = N - 1
if bool(n%2):
    ans = (n//2) * (n) + n
else:
    ans = (n//2) * (n+1)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
 
N = int(input())

if N%2 != 0:
    ans = N*((N-1)//2)
else:
    ans = N*((N-2)//2)+(N-1)//2+1
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

if n%2==0:
  ans = int(n/2)
  ans = ans*(n-1)
else:
  ans = int((n-1)/2)
  ans = ans*n

print(ans)

Submission status: Accepted

Solution code:
def main(n):
    print(n * (n - 1) // 2)

if __name__ == '__main__':
    n = int(input())
    main(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input()) - 1
    if N > 1:
        print(int(N * (1 + N) // 2))
    else:
        print(int(N))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

dst = N * (N-1) // 2
print(dst)

Submission status: Accepted

Solution code:
N = int(input())
if N % 2 == 1:
    print(N*((N - 1)//2))
else:
    print(N*((N - 1)//2) + (N - 1)//2 + 1)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func():
    N = int(input())
    sum = 0
    for i in range(1, N + 1):
        sum += i

    print(sum-N)


if __name__ == '__main__':
    func()