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:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
import heapq
from collections import deque

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""


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

    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

N = int(input())

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

print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
 
N = int(input())
print(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())
ans = (1+(N-1))*(N-1)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import numpy as np
N = int(input())
#n = np.array([i + 1 for i in range(N)])
ans = 0

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

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# D - ModSum
N = int(input())

# 一番大きい並び方は{1, 2, 3, ..., n} → {n, 1, 2, 3, ..., n-1}
modSum = N * (N - 1) // 2

print(modSum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# abc139/abc139_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    n = N - 1
    print((n * (1 + n)) >> 1)
    return

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# from math import factorial
# from collections import defaultdict, deque
#  from heapq import heappush, heappop

# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]
# Ss = ["".join(sorted(input())) for _ in range(N)]

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

count = 0

#for i in range(N):
#    count += i

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

m = N-1

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
# 2019/09/01

n=int(input())

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

Submission status: Accepted

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


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


if __name__ == "__main__":
    n = int(input())
    print(main(n))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#double underscore makes a class variable or a class method private
mod = 1000000007
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
n=ii()
print(((n)*(n-1))//2)

Submission status: Accepted

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

import sys

n= int(sys.stdin.readline())
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())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    sum_p = sum(range(N))
    print(sum_p)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N = input(int)
    print(((N - 1) + 1) * (N - 1) // 2)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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


N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

N = int(input())
# for i in range(N):
#     sum = 0
#     ans = 0
#     for j in itertools.permutations(range(i)):
#         for t, k in enumerate(j):
#             sum += (t+1)%(k+1)
#         ans = max(ans, sum)
#         sum=0
#     print(i, ans)

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

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(sys.stdin.readline().strip())

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


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:
  M = N //2 
  print(M*(N-1))
else:
  M = (N-1) //2
  print(M*N)

Submission status: Accepted

Solution code:
import collections as c
ip = lambda : map(int, input().split())
# ##############
mod = 1e9+7
N = int(input())
ans = N*(N-1)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

if n%2==1:
    neko=int((n-1)/2)
    ans=neko*n
    print(ans)

Submission status: Accepted

Solution code:
# しらんけど
# ふつうにこれやったらTLEなったのでアレする
# n = int(input())
# print(sum(range(n)))

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(a)

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(input()) - 1
    ans = 0

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

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()

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

if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(s)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter

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

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import math

n = int(stdin.readline().rstrip())
ans = n*(n-1)//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())
ans = N * (N + 1) // 2 - N
print(ans)

Submission status: Accepted

Solution code:
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)

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


if __name__ == '__main__':
  solve()

Submission status: Accepted

Solution code:
n1 = int(input())

r1 = (n1 * (n1 - 1)) // 2

print(r1)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(c)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC139
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:
import sys

input = sys.stdin.readline


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


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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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())

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

Submission status: Accepted

Solution code:
import decimal
n = int(input())
print(decimal.Decimal(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

def main():
    input = sys.stdin.readline
    N = int(input())
    ans = (N-1) * N // 2

    return ans


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Accepted

Solution code:
from sys import stdin

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

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

input = lambda: stdin.readline()[:-1]
main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(100001)
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
m = (1 + (N-1)) * (N-1) // 2
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect


mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

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

print(ans) 


'''
1 0
2 1
3 3
4 6
5 10
6 15
7 21
8 28
9 36
10 45
11 55
12 66
13 78
'''

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 math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


# @mt
def slv(N):
    return (N**2 - N)//2


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    if N == 1:
        print(0)
        return
    print(((1+(N-1))*(N-1))//2)
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())
t=n-1
ans=t*(t+1)
print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()

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

Submission status: Accepted

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


def solve(N: int):
    res = N*(0+(N-1)) // 2
    print(res)
    return


# Generated by 1.1.4 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-1)*n // 2)

Submission status: Accepted

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

Submission status: Accepted

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



resolve()

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

Submission status: Accepted

Solution code:

N = int(input())


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys, math; from collections import deque; readline=sys.stdin.readline;

N = int(readline())

ans = (N - 1) * N // 2 if N >= 2 else 0
print(ans)

Submission status: Accepted

Solution code:
N=int(input())

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

print(s-N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

# {1, 2, ..., N}
# {P1, P2, ..., Pn}　として {2, 3, ..., N, 1} を選べる

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

Submission status: Accepted

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