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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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()
    ans = N * (N-1) // 2
    print(ans)

main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

#sum[i,1,N-1][i] = N*(N-1)/2

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import fractions
N = int(input())
print(N*(N-1)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def sum(n):
    return ((n + 1) * n) // 2


n = int(input())
print(sum(n - 1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input().strip())
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())
print( (n-1)*n//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    print(n*(n-1)//2)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	M = N-1
	ans = (1+M)*M//2
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())

from decimal import Decimal
ret = Decimal(n/2)*Decimal(n-1)
print(int(ret))

Submission status: Accepted

Solution code:
n = int(input())
ans = (n*(n-1))//2  #int((n*(n-1))/2)だとnが大きいとき誤差が出る
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

calc_N =  N-1

if calc_N % 2 == 1:
    O = calc_N // 2
    output = (1+calc_N) * O + O + 1
else :
    O = calc_N // 2
    output = (1+calc_N) * O
    
print(output)

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = n*(n+1) // 2 -n
print(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:
a = int(input())
sub = a*(a-1)//2
print(sub)

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calculate(n):
    return n * (n-1) // 2

N = int(input())
print(calculate(N))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019-11-17 20:44:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n = int(sys.stdin.readline().rstrip())
    ans = (1 + (n - 1)) * (n - 1) // 2
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Submission status: Accepted

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

else:
    sum = int((n-1)/2)
    sum = sum * n

print(int(sum))

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    print(sum_of_arithmetic_progression(1, 1, N - 1))


if __name__ == '__main__':
    main()

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()) 
print(int(n*(n-1)//2))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return


# B
def B():
    a, b = LI()
    print(-(-(b - 1) // (a - 1)))
    return


# C
def C():
    N = I()
    H = LI()
    ans = 0
    cnt = 0
    for i in range(1, N):
        if H[i - 1] >= H[i]:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    print(ans)
    return


# D
def D():
    N = I()
    print(N * (N - 1) // 2)
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    D()
    return


# Solve
if __name__ == "__main__":
    D()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

wa = (n+1)*(n//2)
if n % 2 == 1:
    wa+=(n+1)//2

print(wa-n)

Submission status: Accepted

Solution code:
from sys import stdin
n=int(stdin.readline().rstrip())
print((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())
ans=(n**2-n)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

print(N ** 2 - 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()) - 1
#okokokok
print((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())
# test line
# test line
# test line
print((n*(n-1))//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int):
    answer = (N-1)*N//2
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N = I()
ans = int(0)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    print((n-1) * (1 + n - 1) // 2)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def pa(an):
	return (an)*(an+1) //2

n = int(input())
print(pa(n-1))

Submission status: Accepted

Solution code:
n=int(input())
print(((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(int((n-1)*n//2))

Submission status: Accepted

Solution code:
from sys import stdin

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

Submission status: Accepted

Solution code:
n  = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
print(int(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(((n-1)*n)//2)

Submission status: Accepted

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

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())
print((n - 1)*n//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left 

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()

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

if  __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

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

Submission status: Accepted

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

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 == 1:
    print(0)

elif N == 2:
    print(1)

else:
    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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

# input
N = int(input())

# solve & output
print(N * (N - 1) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = int(input())

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

Submission status: Accepted

Solution code:
#ABC139 D - ModSum

N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

#一つずらしが余りの最大になりそう
#答えは1からN-1までを足した数

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
# import math
# import numpy as np
# from functools import lru_cache

args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False

# sys.setrecursionlimit(10000)

#### input
N = int(input())
# a, b = map(int, input().split())
# a = list(map(int, input().split()))
# a = list(map(lambda x: int(x)*(-1), a))  # 各要素を-1倍


# n = int(input())
# t = [int(input()) for i in range(n)]
if em: sys.stdin = open('/dev/tty')

#### function
# @lru_cache(maxsize=10000)

#### process

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

# I = [i for i in range(1, N+1)]
# P = [i for i in range(2, N+1)]
# P.append(1)

# rems = [I[i] % P[i] for i in range(0, len(I))]
# print(sum(rems))

# if em: embed()

## heapsort, O(NlogN)
# import heapq
# heapq.heapify(A)
# min = heapq.heappop(A)
# heapq.heappush(A, new_element)

Submission status: Accepted

Solution code:

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

N -= 1

print('%d' % (N * (N + 1) // 2))

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


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

Submission status: Accepted

Solution code:
a=int(input());print(a*a-a>>1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

n-=1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1%P1 + 2%P2 + 3%P3 + ... + N%PN の最大値
# 1~N-1までの総和を超える値xがあるとする
# N*(N-1)/2 < x < N*(N+1)/2

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

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
print ( a * (a-1) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys

n = int(input())
print(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())

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

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    return n*(n-1)/2


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return

#B
def B():
    a, b = LI()
    ans = 0
    b -= 1
    while b > 0:
        b -= a - 1
        ans += 1
    print(ans)

    return

#C
def C():
    n = II()
    h = LI()
    i = 0
    ans = 0
    while i < n:
        down = i+1
        while down < n:
            if h[down - 1] >= h[down]:
                down += 1
            else:
                break
        ans = max(ans, down - i - 1)
        i = down
    print(ans)
    return

#D
def D():
    n = II()
    print(n * (n - 1) // 2)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    D()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
if n > 1:
  ans = (n * (n-1)) // 2

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
print((a-1)*(a)//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 * (n-1) // 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###############################################################################################################################################

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

Submission status: Accepted

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

#単入力
n=int(input())
print(n*(n-1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

print(sum(range(n)))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from itertools import accumulate


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
 
print(int(N*(N-1)//2))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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