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: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())

print(sum(x - 1 for x in range(N, 0, -1)))

Submission status: Time Limit Exceeded

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

n=int(input())
ans=0
for i in range(n-1):
    ans+=i+1
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

M = 0

for i in range(1, N):
    M = M + i

print(M)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
M = 0
for i in range(N - 1):
    M += (i + 1) % (i + 2)
print(M)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque, Counter
import sys
import heapq
import math

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    # A, B = [int(a) for a in input().split()]
    # H = [int(a) for a in input().split()]
    # A = [
    #     [int(a) for a in input().split()]
    #     for _ in range(N)
    # ]

    print(sum(a for a in range(1, N)))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n == 1:
    print(0)
else:
    print(sum(range(1, n)))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for i in range(n-1):
    ans+=i+1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()

    if N == 1:
        print(0)
        return
    else:
        print(sum(range(N)))
        return

main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

print(sum([i for i in range(N)]))

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    N = int(input())
    print(sum([i for i in range(N)]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
output = 0
for i in range(1,N):
    output += i
print(output)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ct=0
for i in range(n):
    ct+=i
print(ct)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

A = [i for i in range(1, n+1)]
B = [i for i in range(2, n+1)]
B.append(1)

ans = 0
for a, b in zip(A, B):
    ans += a % b

print(ans)

Submission status: Time Limit Exceeded

Solution code:
"""
考え方

N-1までの値を合計した値が答え
"""

N = int(input())

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i != N:
            ans += i % (i+1)
    return ans
if __name__ == '__main__':
    print(main())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
for i in range(N):
    ans += i

print(ans)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
r = 0
for i in range(1,N+1):
    r += i%N

print(r)

Submission status: Memory Limit Exceeded

Solution code:
import numpy as np

N = int(input())

N_np   = 0

N_list = np.arange(1, int(N/4))
N_np   = N_np + np.sum(N_list)

N_list = np.arange(int(N/4), int(2*N/4))
N_np   = N_np + np.sum(N_list)

N_list = np.arange(int(2*N/4), int(3*N/4))
N_np   = N_np + np.sum(N_list)

N_list = np.arange(int(3*N/4), N)
N_np   = N_np + np.sum(N_list)


print(N_np)

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# ABC139 D

N=int(input())

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

Submission status: Accepted

Solution code:
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

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

    print(ans//2)

resolve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    # P=2,3,...N-1,N,1
    # i=1,2,...N-2,N-1,N
    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*(N+1)//2 - N)

Submission status: Accepted

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

N = int(input())

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

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:
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:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

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

Submission status: Accepted

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

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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


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

Submission status: Accepted

Solution code:
n=int(input())

if n==1: print(0); exit();
if n==2: print(1); exit();

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	for j in range(len(b)):
		carry = 0
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans


# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)

def main():
	N = input()
	print(
		bigint_divide(
			bigint_multiply(N, bigint_minus(N, 1))
			,2
		)
	)

main()

Submission status: Accepted

Solution code:
import sys
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush

sys.setrecursionlimit(10**6)
INF = 10**20

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(modsum)

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  if N==1:
    print(0)
    return
  ans = sum(range(1,N))
  print(ans)
main()

Submission status: Accepted

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import heapq


input = sys.stdin.readline
n = int(input())
result = n*(n-1)//2
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
print(a*(a-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(int((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:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    ans=((N)*(N-1))//2
    
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

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

main()

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N):
    n = N - 1
    print((n + 1) * n // 2)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N)

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    n -= 1
    ans = n*(n+1) //2
    print(ans)


main()

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

Submission status: Accepted

Solution code:
# 元の数列を次のように一つずらして順列を作るとMODSUMは大きくなりそう
# これが最大化どうかは証明できん
# A = {1,2,3,…,N}
# P = {2,3,4,…,1}
n = int(input())
print((n**2 - 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())
N=N-1
ans=(N+1)*N//2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


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


print(solve())

Submission status: Accepted

Solution code:
N = int(input())
#Mi=i%(i+1) (1<=i<N),
#   i%1     (i=N)

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

print(ans)

Submission status: Accepted

Solution code:
import sys

# 降順に並べた時が最大な気がする                                                
N = int(input())
print(N * (N-1) // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(int(answer))

Submission status: Accepted

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

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:
# 2020/08/16
# AtCoder Beginner Contest 139 - D

# Input
n = int(input())

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

# Output
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc139/tasks/abc139_d

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

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

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

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 bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()

# 規則性を見つける
# X mod P <= X-1
ans = N*(N-1)//2

print(ans)

Submission status: Accepted

Solution code:
from decimal import *

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

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
    print(0)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
#n = 10**9
n = int(input())
ans = 0
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:
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 = (n+1) * (n//2) - n
if n%2 == 1:
    ans += n//2 + 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(readline())

# 1 から N - 1までの和になる

def calc(A):
  return ((1 + A) * A) // 2

print(calc(N - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

print(m)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(int(result))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
"""求める最大の余りの合計は1〜N-1の合計に等しい"""
result = n*(n-1)//2
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

Solution code:
import heapq
t = 1
def max(a,b):
	if a > b:
		return a
	return b
def min(a,b):
	if a < b:
		return a
	return b

while t > 0:
	t -= 1
	# a,b = map(int,input().split())
	n = int(input())
	ans = (n-1)*(n)//2
	print(ans)
	# v = list(map(int,input().strip().split()))[0:n]
	# i = 0
	# ans = 0
	# while i < n:
	# 	j = i
	# 	while j+1 < n and v[j+1] <= v[j]:
	# 		j += 1
	# 	l = j-i+1
	# 	ans = max(ans,l)
	# 	i = j+1
	# print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

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

Submission status: Accepted

Solution code:
#5  [1,2,3,4,5]→[5,1,2,3,4]が最適解　等差数列の和の公式
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

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

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

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:
#!/usr/bin/env python3

N = int(input())

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

print(ans)

Submission status: Accepted

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

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

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

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)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def main():
    import sys

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




if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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