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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n = int(input())

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

Submission status: Accepted

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

# import itertools
# n = int(input())

# test_list = list(range(1, n+1))

# ans = 0
# ans_list = []
# ans_score = []
# for i in itertools.permutations(test_list, n):
#     # print(i)
#     ans_tmp = 0
#     for j in range(len(i)):
#         ans_tmp += (j+1) % i[j]
#     ans_score.append(ans_tmp)
#     ans_list.append(i)
#     # print(ans_tmp)

#     ans = max(ans_tmp, ans)

# print("ans:", ans)
# for i in range(len(ans_list)):
#     if ans_score[i] == ans:
#         print(ans_list[i])

n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC139
# D
# ModSum

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
from math import ceil
N = int(input())
n = N -1
if n == 1:
    ans = 1
elif n%2 != 0:
    ans = (1+n)*(n//2) + ceil(n/2)
else:
    ans = (1+n)*(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())

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

Submission status: Accepted

Solution code:
n = int(input())
print(sum(range(1, n)))

Submission status: Accepted

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

# In[21]:


P = int(input())


# In[22]:


# i_list = list(range(1, P+1))
# p_list = i_list[1:]
# p_list.append(i_list[0])

# # print(i_list, p_list)

# ans = 0
# for i in range(P):
#     ans += i_list[i]%p_list[i]
# print(ans)

# ans = sum(range(1,P))
ans = P*(P-1)//2
print(ans)


# In[ ]:

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import heapq
import collections
import itertools
import bisect
mod = 10 ** 9 + 7
N = int(input())

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

Submission status: Accepted

Solution code:
from math import ceil


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

if __name__ == "__main__":
  main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    print((N*(N-1))//2)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
print(N*(N-1)//2)

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def solve():
    n = II()

    ans = tsum(1, n-1)
    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
print(N*(N-1)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# D - ModSum

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:
import math

n = int(input())

_sum = (n**2 + n) // 2

print(_sum - n)

Submission status: Accepted

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n=int(readline())

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

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

Submission status: Accepted

Solution code:
import sys, heapq

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


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

if __name__ == '__main__':
    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:
import sys
from io import StringIO
import unittest

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

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

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """13"""
        output = """78"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
from sys import stdin
import math
import fractions
import heapq

n = int(stdin.readline().rstrip())

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 0:
    result = N // 2
    result = result * (N - 1)
elif N % 2 == 1:
    result = (N - 1) // 2
    result = result * N

print(result)

Submission status: Accepted

Solution code:
import math

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

n = int(input())
print(main(n))

Submission status: Accepted

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

Submission status: Accepted

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

n = ii()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    q4()

Submission status: Accepted

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

# D - ModSum
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# ABC139 D - ModSum

#import itertools
N = int(input())
print(N * (N - 1) // 2)
"""
P = [i + 1 for i in range(N)]

for v in itertools.permutations(P, N):
    val = 0
    for i in range(N):
        val += (i + 1) % v[i]
    if val == 78:
        print(v, val)
"""

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
# D: 1 2 ... n-1 n
# P: 2 3 ... n   1
# M: 1 2 ... n-1 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:
n=int(input())
suu=n*(n-1)//2
print(suu)
w=[1,2,3,4]

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
ans = (n - 1) * n // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


# Generated by 1.1.6 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:
import sys
input = sys.stdin.readline().rstrip


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 初期入力
N = int(input())

#N_list =[i for i in range(1,N+1)]
N_list_sum =N*(N+1)//2
ans =N_list_sum -N
print(ans)

Submission status: Accepted

Solution code:
def myAnswer(N:int) -> int:
   N -=1
   return N * (N + 1) // 2

def modelAnswer():
   return
def main():
   N = int(input())
   print(myAnswer(N))
if __name__ == '__main__':
   main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os, sys, re, math

N = int(input())

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

print(s)

Submission status: Accepted

Solution code:
N = int(input())
ret = (1 + N) * N // 2 - N 
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)

Submission status: Accepted

Solution code:
n = int(input())
#答えが違う
#print(int(n*(n-1)/2))  # 合わない...
#print(int(n*(n-1)//2))  # 合わない...
print(n*(n-1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

m_sum = 0
print(int(n*(n-1)//2))

Submission status: Accepted

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

n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

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

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

Submission status: Accepted

Solution code:
n=int(input())
#n,p=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

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

print(ans)

Submission status: Accepted

Solution code:
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(input())
  ans = 0
  if N==1:
    ans = 0
  else:
    ans = (N-1) * N//2
  print(ans)
  
if __name__ == '__main__':
  main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''Haha this is python? How could you tell, Sherlock?'''

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:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


# def gen_counter(stop=10):
#     index = 1
#     while True:
#         if stop < index:
#             break
#         yield index
#         index += 1


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


# arr = np.arange(1, N + 1)
# t_arr = np.append(arr[1:], arr[0])
# print(sum(arr % t_arr))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())


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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    t = (1 + n) * n // 2
    print(t - n)

Submission status: Accepted

Solution code:
N = int(input())

def kaidan(k):
    return k * (k + 1) // 2

print(kaidan(N-1))

Submission status: Accepted

Solution code:
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""
import math
n=int(input())
ans=n*(n-1)//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())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = (N - 1) * N // 2
    # X % K の最大値は K-1
    # 1,2,3,...,Nで割った余りの最大値は
    # 0,1,2,...,N-1
    # 1,2,...,Nを
    # 2,3,...,N,1で割ることで
    # 余りは1,2,...,N-1,0となり、
    # 最大値を達成できる
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
#1,2,3,...,Nまでの順列の合計
#実はN(N+1)//2で表せる
def sigma(n):
    return n*(n+1)//2

print(sigma(n-1))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

N=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin,setrecursionlimit
import string
setrecursionlimit(10 ** 7)
n = int(stdin.readline().rstrip())
print(n*(n-1)//2)