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:
# ABC139d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

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

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    # A, B = [int(a) for a in input().split()]
    # H = [int(a) for a in input().split()]
    # A = [
    #     [int(a) for a in input().split()]
    #     for _ in range(N)
    # ]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

i  = lambda: int(input())

N = i()

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

Submission status: Accepted

Solution code:

N = int(input())

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())

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

Submission status: Accepted

Solution code:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n=int(input())
    print((n-1)*n//2)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from sys import stdin,stdout
I = lambda : map(int,stdin.readline().split())
import math

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

Submission status: Accepted

Solution code:
from sys import stdin

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

print(wa)

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
n = int(input())

print((n*(n-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:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
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 [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  return (n-1)*n//2

# main()
print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
print((n - 1) * n // 2)

Submission status: Accepted

Solution code:
import sys

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


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    N = II()
    print(sum(range(N)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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



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 = int(0)

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())
print (N * (N - 1) >> 1)

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# 1からnまでの等差数列の和
def get_sum(n): return (1+n)*n//2

N = INT()

print(get_sum(N-1))

Submission status: Accepted

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


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


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
n=int(input());print((n*(n-1))//2)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    Solution().main()

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = (n-1)*n//2
    print(ans)
   
    
if __name__ =="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
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 II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


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

solve()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    res = N*(N-1)//2
    return str(res)

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

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

if __name__=='__main__':
    code()

Submission status: Accepted

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

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

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 sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N=int(input())
print(sum(range(N)))

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:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


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

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


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ABC139D
import sys

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  1 20:24:52 2019

@author: Yamazaki Kenichi
"""

N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from fractions import Fraction
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 [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 _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

N = _I()

"""
並び替えた後あまりを計算する
まずは貪欲的に考える
大きい方からあまりが最大になるものをマッチングする
しかしこれだと10**9なので絶対間に合わない
gcdとかいきてきそう
そもそもあまりが
1,2,...Nを割っていく
Nを割ってN余ることはない。
8 % 9は8になる。
ひとつずつずらしていくか
そうすると、1/2n n+1がなりたつ
"""

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

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    count = 0
    for nn in range(1, N):
        count += nn
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)

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

main()

Submission status: Accepted

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, = gi()
print((n * (n - 1)) // 2)

Submission status: Accepted

Solution code:
N = int(input())

t = N - 1

print(t * (t + 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:
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
print(n*(n-1)//2)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    return (n * (n - 1)) // 2


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
ser = None
m = 0
def main():
    global ser
    N = int(input()) - 1
    print(N * (N+1) // 2)
main()

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

#from itertools import permutations

n = int(input())
#a,b = [int(i) for i in readline().split()]
#lr = [[int(i)-1 for i in readline().split()] for _ in range(q)]
"""
L = list(range(1,n+1))
ans = 0
for i in permutations(L):
    res = 0
    for j in range(n):
        res += (j+1)%i[j]
    ans = max(ans,res)    
"""

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
print((N-1)*(2*1+(N-2)*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())
if N == 1:
    print(0)
else:
    print(N * (N - 1) // 2)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()


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

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    print(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())

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

Submission status: Accepted

Solution code:
#import sys
#input = sys.stdin.readline
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:
    a = 0
else:
    a = (N)*(N-1)//2
print(a)

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int):
    print(N*(N-1)//2)
    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:
n = int(raw_input())
print  n * (n-1) / 2

Submission status: Accepted

Solution code:
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())

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

    print(ans)

sol()

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    n = ii()
    
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        ans = (n*(n-1))//2
        print(ans)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

m = N-1

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

if n == 1:
    print(0)
    exit()
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())
print((1 + N - 1) * (N - 1) // 2)

Submission status: Accepted

Solution code:
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def getlist():
	return list(map(int, input().split()))

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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int):
    ret = (N - 1) * N // 2
    print(ret)
    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:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
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)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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

#B
def B():
    a,b = LI()
    for i in range(10000):
        if 1+i*a-i >= b:
            print(i)
            return
    return

#C
def C():
    n = I()
    a = LI()
    ans = 0
    r = 1
    for l in range(n):
        if r == l:
            r += 1
        while r < n and a[r-1] >= a[r]:
            r += 1
        ans = max(ans, r-l-1)
    print(ans)
    return

#D
def D():
    n = I()
    print(n*(n-1)>>1)
    return

#E
def E():

    return

#F
def F():

    return

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

Submission status: Accepted

Solution code:
N = input()

print N*(N-1)/2

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    ans = ((N-1)*N//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:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
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())

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

sum = (n*(n-1))//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())

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time

sys.setrecursionlimit(10**7)
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 pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n = I()
    r = (n-1) * n // 2

    return r


print(main())

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N = int(sys.stdin.readline())

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

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:
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import re

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()

print N * (N - 1) / 2

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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