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:
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): 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 SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

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

Submission status: Accepted

Solution code:
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
print(N*(N-1)//2)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
ans = 0
ans = (n-1) * (n) // 2

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin=sys.stdin

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
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())
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:
def resolve():

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

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# Problem D - ModSum

# input
N = int(input())

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

# output
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc139/tasks/abc139_d
# math
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# ans = 0
# for i in range(n):
#     ans += i
# print(ans)

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

Submission status: Accepted

Solution code:
num = int(input())

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

Submission status: Accepted

Solution code:


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


if __name__ == "__main__":
    submit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = (N-1) * N // 2
print(answer)
# 17

Submission status: Accepted

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

Submission status: Accepted

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

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.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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

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

Submission status: Accepted

Solution code:

n = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
from decimal import Decimal

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

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(0)
    exit()
ans = (1+(N-1))*(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())
if N==1:
  print(0)
  exit(0)
#a=[i for i in range(1,N)]
#print(sum(a))
if (N-1)%2==0:
  print(N*((N-1)//2))
else:
  print(N*((N-1)//2)+((N-1)//2)+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
D - ModSum
https://atcoder.jp/contests/abc139/tasks/abc139_d

"""
import sys


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


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

n = n-1

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

print(ans)
# print("{:.10f}".format(ans))

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math 
import bisect
import heapq
from collections import deque

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
a=int(input())
#_l=list(map(int,input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import collections
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
d,m = divmod(n,2)
if m != 0:
    print(n*d)

else:
    print(n*(d - 1) + d)

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

answer=0

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): 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 LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

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


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): 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 LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

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


if __name__ == '__main__':
	main()

Submission status: Accepted

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

from math import floor

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

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
# 1-nまでの k の和
def sigma1(n):
    return n * (n + 1) // 2
n = int(input())
print(sigma1(n-1))

Submission status: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = input()

b = int(a)

ans = 0

if b != 2:
    if b % 2 == 1:
        ans = b * ((b - 1) // 2)
    else:
        ans = b * ((b - 1) // 2) + (b // 2)
else:
    ans = 1

print(ans)

Submission status: Accepted

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

    ans = 0

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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 os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N = Scanner.int()
    print(N * (N - 1) // 2)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
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
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

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

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
from itertools import accumulate, permutations, combinations, product
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
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:


N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
#total=0
#l = list(range(2,n+1)) + [1]
#for i in range(n):
#    total+=(i+1)%l[i]
#print(total)
# 1+2+3+...+n-1
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:
def solve(n):
    return n * (n - 1) // 2

_n = int(input())
print(solve(_n))

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

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(inp):
    N = int(inp.readline().strip())

    r = (N * (N - 1)) // 2
    return int(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


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

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

Submission status: Accepted

Solution code:
a=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

    print(ans)

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

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
def main():
    sys.setrecursionlimit(10 ** 7)
    """inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
    eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
    dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]"""
    """for dx, dy in dd:
            nx = j + dx; ny = i + dy
                if 0 <= nx < w and 0 <= ny < h:"""
    def wi(): return list(map(int, sys.stdin.readline().split()))
    def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
    def ws(): return sys.stdin.readline().split()
    def i(): return int(sys.stdin.readline())
    def s(): return input()
    def s_list(): return list(input())
    def hi(n): return [i() for _ in range(n)]
    def hs(n): return [s() for _ in range(n)]#HeightString
    def mi(n): return [wi() for _ in range(n)]#MatrixInt
    def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
    def mip(n): return [wip() for _ in range(n)]
    def ms(n): return [ws() for _ in range(n)]
    def grid(n): return [s_list() for _ in range(n)]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


N = int(input())

print(solve(N))

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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())
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:
def main():
    '''
    N = aq + r (0 <= r <= a-1)よりΣrを最大にするのはr = a-1のとき
    '''
    N = int(input())
    print(N * (N - 1) // 2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# TLEになった
# A = [i for i in range(1, N)]
# print(sum(A))

#sum(N) = ((N+1)*N)/2なのでこちらで実施。
print((N * (N-1))//2)