Problem:


Score : 400 points

Problem Statement

For an integer N, we will choose a permutation \{P_1, P_2, ..., P_N\} of \{1, 2, ..., N\}.

Then, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.

Find the maximum possible value of M_1 + M_2 + \cdots + M_N.

Constraints

N is an integer satisfying 1 \leq N \leq 10^9.

Input

Input is given from Standard Input in the following format:

N

Output

Print the maximum possible value of M_1 + M_2 + \cdots + M_N.

Sample Input 1

2

Sample Output 1

1

When the permutation \{P_1, P_2\} = \{2, 1\} is chosen, M_1 + M_2 = 1 + 0 = 1.

Sample Input 2

13

Sample Output 2

78

Sample Input 3

1

Sample Output 3

0



Sample input:
2


Sample output:
1

Submission status: Accepted

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

N=int(input().rstrip('\n'))
print((N-1)*N//2)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    if n == 1:
        print(0)
        sys.exit()
    ans = (n*(n-1))//2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(n):
    ans += i

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 14, 2020 11:34:55 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


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

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


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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

    # for i in range(n-1):
    #     ans += i+1

    # print(ans)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

# i を P[i] = i+1 で割る (i=1,..., N-1)が最大

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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



if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

n = k()
if n== 1:
    print(0)
    sys.exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
print((n-1)*n//2)
#並び替えるの意味があまりよくわからない、深く考える必要はないと思われる

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

n = int(input())

count = 0
for i in range(1,n):
    count += i

print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
13
'''

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

N = int(stdin.readline())
ans = solve(N)
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)

# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


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




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)

# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


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




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# abc139_d.py
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())
if n == 1 :
    print(0)
elif n == 2 :
    print(1)
else :
    print(n*(n-1)//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    n -= 1
    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-n)//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 * (N-1)) // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
import bisect

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

    N = int(input())

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

main()

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

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

Submission status: Accepted

Solution code:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:


n=int(input())

ans=0
#for i in range(1,n):
#    ans+=i%(i+1)
#
#ans+=n%1

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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

    print(sum_up_to_n(N - 1))
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ABC139D

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
print(a*(a-1)//2)

Submission status: Accepted

Solution code:
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
if a%2==0:
  b=a//2
  print(b*(a-1))
else:
  b=(a-1)//2
  print(a*b)

Submission status: Accepted

Solution code:
#139D

#ここから試験用コード
'''
import itertools

for N in range(1,13):
    l = [i for i in range(1,N+1)]

    ans = 0
    ans_permutation = list()

    for permutation in itertools.permutations(l, N):
        temp_ans = 0
        permutation = [0] + list(permutation)
        for i in range(1,N+1):
            temp_ans += i%permutation[i]

        if ans <= temp_ans:
            if ans < temp_ans:
                ans_permutation = list()
            ans = temp_ans    
            ans_permutation.append(list(permutation)[1:])

    print(N,ans,ans_permutation)
    
#試験用コードの結果
# 1  0 [[1]]
# 2  1 [[2, 1]]
# 3  3 [[1, 3, 2], [2, 3, 1]]
# 4  6 [[2, 3, 4, 1]]
# 5 10 [[1, 3, 4, 5, 2], [2, 1, 4, 5, 3], [2, 3, 4, 5, 1]]
# 6 15 [[2, 3, 4, 5, 6, 1]]
# 7 21 [[1, 3, 2, 5, 6, 7, 4], [1, 3, 4, 5, 6, 7, 2], [2, 3, 1, 5, 6, 7, 4], [2, 3, 4, 5, 6, 7, 1]]
# 8 28 [[2, 1, 4, 5, 6, 7, 8, 3], [2, 3, 4, 5, 6, 7, 8, 1]]
# 9 36 [[1, 3, 4, 5, 6, 7, 8, 9, 2], [2, 3, 4, 1, 6, 7, 8, 9, 5], [2, 3, 4, 5, 6, 7, 8, 9, 1]]
#10 45 [[2, 3, 4, 5, 6, 7, 8, 9, 10, 1]]

#いずれにも最初は2,3...、最後は1となるパターンがある
#上記パターン時は ((N-1)+1)*(N-1)/2 が答え。
'''
N = int(input())
print(N*(N-1)//2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N=int(input())

# 1 2 3 4 5
# 2 3 4 5 1

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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
if n <= 2:
  ans = 1%n
else:
  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())

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

Submission status: Accepted

Solution code:
from decimal import Decimal


n = int(input())

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

Submission status: Accepted

Solution code:
# ans

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())

    #N, Q = map(int, input().split())

    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
# nums = [i for i in range(1, N + 1)]
if (N - 1) % 2 == 0:
    print(N * ((N - 1) // 2))
else:
    # 12 =>
    print(N * ((N - 1) // 2) + (N // 2))

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

Submission status: Accepted

Solution code:
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    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())

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

ans = sum - n

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N =int(input())



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

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
14min 05sec
"""
# 実験したら規則性が見えた。

#import itertools
#
#def test():
#    for i in range(1, ):
#        N = i
#        #N = int(input())
#        N_list = list(range(1, N+1))
#
#        answer = 0
#        for P_list in itertools.permutations(N_list):
#            answer = max(
#                answer,
#                sum([N_list[i] % P_list[i] for i in range(N)])
#            )
#        print(i, answer)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

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

Submission status: Accepted

Solution code:
N = int(input())

S = sum(range(1,N))

print(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N=int(input())
#print(sum([i for i in range(S)]))
"""
if s%2==0:
  ans=(1+s)*(s/2)
else:
  ans=(1+s)*int(s/2)+(int(s/2)+1)
"""
print(int(N*(N-1)//2))

Submission status: Accepted

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
n -= 1

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

Submission status: Accepted

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    if N == 1:
        print(0)
        exit()

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())

ans = N * int(N - 1)

ans = ans // 2

print(ans)

Submission status: Accepted

Solution code:
#abc139d

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

# i % i+1 = i が最善, あまりは 1 〜 N-1 
print(N*(N-1)//2)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    ans = (N-1) * N // 2
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N = ri()
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(raw_input())
print (n-1)*n/2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()

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

print(ans)

Submission status: Accepted

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


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#2245
#import numpy as np

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


if __name__ == "__main__":
	main()

Submission status: Accepted

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

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())
# 1,2,3,...Nについて 2,3,4,....N,1で割ったあまりの和を考えると、 1からNまでの和となる。
#よって　出力は N(N-1)//2
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:
a = int(input())
print(int(a*(a-1)//2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from itertools import permutations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

if (N -1) % 2 == 0:
  ans = N*(N-1)//2
else:
  ans = N*(N-2)//2 + 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((1+N)*N//2-N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
参考
https://qiita.com/DaikiSuyama/items/ddb4544ee5df2f8d45c7
1～Nをある数で割った余りの合計を最大値にするためには、
2～Nで1～N-1を割ればよい（最後のNは1で割る）
以下の通り、余りは1～Nとなる
1 mod 2 = 1
2 mod 3 = 2
3 mod 4 = 3
…
（N-1) mod N = N-1
N mod 1 = N
https://mathwords.net/1karannowa
1～Nまでの和を求める公式
'''

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
n = int(input())
if(n%2==0):
    print((n + 1) * (n // 2) - n)
else:
    print((n + 1) * ((n-1) // 2) +(n+1)//2- n)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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