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

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# 1,2,...n-1の総和がmax
result=n*(n-1)//2
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

# import itertools

num = int(input())

# イテレーションせずに求めます
rtn = num * (num-1) //2
print(int(rtn))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input().strip())

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

Submission status: Accepted

Solution code:
import math
n = int(input())

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

Submission status: Accepted

Solution code:
# D - ModSum

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

Submission status: Accepted

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

MOD = 10 ** 9 + 7

N = int(input())

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

print(ans)

Submission status: Accepted

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

N = int(input())

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    t = 0
    for i in range(1, n):
        t += i
    print(t)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
N = [int(s) for s in raw_input().split(" ")][0]
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())
a=(1+N-1)*(N-1)//2
print(a)

Submission status: Accepted

Solution code:
# encoding: utf-8

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((1+N)*N//2-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((1 + (N - 1)) * (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:
while True:
    try:
        N = int(input())
        print(N*(N-1)//2)
    except EOFError:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:

def calc(n):
    return (1 + n - 1) * (n-1) // 2


n = int(input())
r = calc(n)
print(r)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() 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)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


print(sum(range(I())))

Submission status: Accepted

Solution code:
def read_input():
	N = int(raw_input())
	return N

def f(N):
	return N*(N-1)/2


#################### main ####################

#t0 = time.clock()
N = read_input()
print f(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:
n = int(input()) - 1
print(int(n*(n+1)//2))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

n = int(input())
print(solve(n))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
result = num * (num - 1) // 2
##  初項0, 公差1, 項数numの等差数列の和= num(2a + (num - 1)d)/2
print(int(result))

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


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 -*-
# 整数の入力
n = int(input())
count = (n - 1) * n // 2
print("{}".format(count))

Submission status: Accepted

Solution code:
size = int(input().rstrip("\n"))
print(size * (size-1) // 2)

Submission status: Accepted

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

a = int(input())
answer = a*(a-1)//2

print(int(answer))

Submission status: Accepted

Solution code:
N = int(input())
#なぜかｗA
#ans = (((N+1)*N) / 2) - N
#ans = (((N-1)*N) / 2)
#ans = int(ans)
ans = (((N+1)*N) // 2) - N
 

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input()) - 1
#print(N)
print("{}".format(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(n*~-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())

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

Submission status: Accepted

Solution code:
n = int(input())


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
ans = (pow(n,2) - n) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(string):
    n = int(string)
    return str(n * (n - 1) // 2)


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 解説動画より
# 分子/分母 で 分子<分母の時　分子がそのまま余りとなり余りは最大値となる
# ちなみに最後の数は、1で割ることになり、余りは０
# だから N-1までの和をとればよい 
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:
num = int(input())
print(int(num * (num -1) // 2))

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+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()
print(n*(n-1)//2)

Submission status: Accepted

Solution code:
n=int(input())

#1～n-1までの数列の和
print((n-1)*n//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=int(input())
#N=list(map(int,input().split()))
ans=(S-1)*S//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = raw_input()
A = int(A)

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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


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

Submission status: Accepted

Solution code:
from decimal import Decimal
n=int(input())

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

print(int(Decimal(a)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

print(res)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




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

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools





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




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return

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

def main():
    N = int(input())
    if (N==1):
        print(0)
    else:
        print(gau(N-1))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

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

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:
# -*- coding: utf-8 -*-

import sys
import copy
import math

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(*[n*(n-1)//2 for n in [int(input())]])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

#りゅうせいの解答2 不正解2つあり
# N = int(input())
#
# mod_sum = int(N*(N-1)/2)
# print(mod_sum)

# りゅうせいの解答1　実行時間超過
#  N = int(input())
#
# P_list = []
# M_list = []
#
#
# for i in range(N):
#     if i == N-1:
#         P_list.append(1)
#
#     else:
#         P_list.append(i+2)
#
#
# for i in range(N):
#     M_list.append((i+1) % P_list[i])
#
# print(sum(M_list))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# @Author: WA_King
# @Date:   2019-04-03 19:35:31
# @Last Modified by:   lcw
# @Last Modified time: 2019-09-02 13:56:36
a=int(input())
print(a*(a-1)//2)

Submission status: Accepted

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

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

    # O(N)じゃ間に合わない

    """
    i   = 1 2 3 4 5 6 7 8
    P_i = 2 3 4 5 6 7 8 1

    ↑これが最大値なのでは？
    つまり、
    ・P_i = i + 1
    ・P_N = 1
    にすると、1 ~ N-1の和が答えになる。
    """
    ans = (1+(N-1))*(N-1)//2
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(N):
    return N * (N - 1) // 2



if __name__ == '__main__':
    N = int(input())
    ans = solve(N)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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


if __name__ == '__main__':
    d()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

M = 0

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


print(int(M))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
if n ==1:
    print(0)
elif n == 2:#なぜ？
    print(1)
else:
    print(n*(n-1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n = ni()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print N*(N-1)//2

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

n = N - 1

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

Submission status: Accepted

Solution code:
n=int(input());print n*~-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())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

num = 0

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

print(num)

Submission status: Accepted

Solution code:
N = int(input())

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

print(output)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

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())
 
print(n * (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(int((n-1)*n//2))
"""
if n==1:
    print(0)
else:
    plist=list(range(1,n+1))
    qlist=list(range(2,n+1))
    qlist.append(1)
    parray=np.array(plist)
    qarray=np.array(qlist)
    rarray=parray%qarray
    sm=rarray.sum()
    print(sm)
"""

Submission status: Accepted

Solution code:
n =int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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