Problem:


Score : 100 points

Problem Statement

We have N+M balls, each of which has an integer written on it.

It is known that:  

The numbers written on N of the balls are even.

The numbers written on M of the balls are odd.

Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.

It can be shown that this count does not depend on the actual values written on the balls.

Constraints

0 \leq N,M \leq 100

2 \leq N+M

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the answer.

Sample Input 1

2 1

Sample Output 1

1

For example, let us assume that the numbers written on the three balls are 1,2,4.

If we choose the two balls with 1 and 2, the sum is odd;

If we choose the two balls with 1 and 4, the sum is odd;

If we choose the two balls with 2 and 4, the sum is even.

Thus, the answer is 1.

Sample Input 2

4 3

Sample Output 2

9

Sample Input 3

1 1

Sample Output 3

0

Sample Input 4

13 3

Sample Output 4

81

Sample Input 5

0 3

Sample Output 5

3



Sample input:
2 1


Sample output:
1

Submission status: Accepted

Solution code:
s = input().split()
x = int(s[0])
y = int(s[1])

list = []
for i in range(x):
  list.append('n')
for i in range(y):
  list.append('m')
  
result = []
for i in range(len(list)):
  for j in range(i + 1, len(list)):
      result.append([list[i], list[j]])
      
count = 0
for i in range(len(result)):
  if result[i][0] == result[i][1]:
    count += 1

print(count)

Submission status: Accepted

Solution code:
def fact(n):
  fact=1
  for i in range(1,n+1): 
    fact = fact * i 
  return fact


x,y = input().split()
x = int(x)
y = int(y)
print((fact(x)//(2*fact(x-2))) + (fact(y)//(2*fact(y-2))))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
print(int((n*(n-1)/2)+(m*(m-1)/2)))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())

ans = round((a * (a - 1) / 2) + (b * (b - 1) / 2))
print(ans)

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

Solution code:
from math import factorial

def conb2(a):
    if a == 1:
        return 0
    else:
        return int(a*(a-1)/2)


if __name__ == "__main__":
    M, N = list(map(int, input().split()))
    print(conb2(M)+conb2(N))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
print(M*(M-1)//2 + N*(N-1)//2)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

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

Submission status: Accepted

Solution code:
#author : dokueki

import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    print(n*(n-1)//2+m*(m-1)//2)


if __name__ == "__main__":
    #IOE()
    main()

Submission status: Accepted

Solution code:
import math
n, m = map(int, input().split())
ans = n * (n - 1) / 2 + m * (m - 1) / 2
print(int(ans))

Submission status: Accepted

Solution code:


n, m = map(int, input().split())

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
sum1=(n*(n-1))//2
sum2=(m*(m-1))//2
print(sum1+sum2)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
from collections import deque

N=200005
inf=(1<<30)

def solve():
    n,m=map(int,input().split())
    ans1=n*(n-1)//2
    ans2=m*(m-1)//2
    print(ans1+ans2)
t=1
#t=int(input())
for case in range(t):
    solve()

Submission status: Accepted

Solution code:
def saiki(n):

    if n == 0:
        return 0
    else:
        return n + saiki(n - 1)

def number(n , m):

    ans = saiki(n) + saiki(m) - n - m

    return ans

def main():
    n , m = map(int , input().split())
    print(number(n , m))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
#Nは偶数。偶数２つの場合
n = 0
for i in range(1, N):
  n = n + i
 
#Mは奇数。奇数２つの場合
m = 0
for j in range(1, M):
  m = m + j
  
print("{}".format(n + m))

Submission status: Accepted

Solution code:
n, m=map(int, input().split())
print((n*(n-1)+m*(m-1))//2)

Submission status: Accepted

Solution code:
n, y = map(int, input().split())
answer = int(n*(n-1)/2 + y*(y-1)/2)
print(answer)

Submission status: Accepted

Solution code:
n, m = map(int, input().split(' '))
c = (n + m) * (n + m - 1) // 2 if n + m > 0 else 1
print (c - n * m)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=0
ans+=n*(n-1)/2
ans+=m*(m-1)/2
print(int(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
gu = n * (n-1) // 2
ki = m * (m-1) // 2
print(gu+ki)

Submission status: Accepted

Solution code:
n,m=[int(i) for i in input().split()]
print(n*(n-1)//2 + m*(m-1)//2)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
print(int(N * (N-1) / 2 + M * (M-1) / 2))

Submission status: Accepted

Solution code:
N, M = map( int, input().split() )

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

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
print(int(((n+m)*(n+m-1)/2-n*m)))

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    res = N*(N-1)//2 + M*(M-1)//2
    print(res)



if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
n = 0
m = 0

if N == 1:
  n = 0
  
else:
  n = N*(N-1)/2
  
if M == 1:
  m = 0

else:
  m = M*(M-1)/2

print(int(n + m))

Submission status: Accepted

Solution code:
import functools

@functools.lru_cache(maxsize=None)
def factorial(N):
    if N == 0:
        return 1
    if N == 1:
        return 1
    else:
        return N * factorial(N - 1)


def c(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(r) * factorial(n-r))


N, M = [int(x) for x in input().split()]

print(
    c(N, 2) + c(M, 2)
)

Submission status: Accepted

Solution code:
def choose(n, r):
    x, y = 1, 1
    for i in range(r):
        x *= n - i
        y *= i + 1
    return x // y


N, M = map(int, input().split())
ret = choose(N, 2) + choose(M, 2)
print(ret)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())

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

print(ans)

Submission status: Accepted

Solution code:
def combination(n, a, mod):
    x = 1
    y = 1
    for i in range(a):
        x = x * (n-i)%mod
        y = y * (a-i)%mod

        #x *= (n-i)
        #x %=mod
        #y *= (a-i)
        #y %=mod
    return x * pow(y, mod-2, mod)%mod

n, m = map(int, input().split())

ans = combination(n,2,pow(10,9)+7) + combination(m, 2, pow(10,9)+7)
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
X=N*(N-1)//2
Y=M*(M-1)//2
print(X+Y)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))

ans=0

if(N!=0) :
  ans += (N*(N-1))/2
if(M!=0) :
  ans += (M*(M-1))/2

print(int(ans))

Submission status: Accepted

Solution code:
def Conv(x):
    return x * (x - 1) // 2

N, M = map(int, input().split())
print(Conv(N) + Conv(M))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N,M = map(int,input().split())
ans=0
if N>1:
    ans+=int(N*(N-1)/2)
if M>1:
    ans+=int(M*(M-1)/2)
print(ans)

Submission status: Accepted

Solution code:
from math import factorial

N, M = map(int, input().split())

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

Submission status: Accepted

Solution code:
num = input("")
num = num.split(" ")
N = int(num[0])
M = int(num[1])
a = int(N*(N-1)/2) if N*(N-1) >= 0 else 0
b = int(M*(M-1)/2) if M*(M-1) >= 0 else 0
print(a + b)

Submission status: Accepted

Solution code:
from math import factorial
n, m = map(int, input().split())
ans = 0

def comb(n):
    return factorial(n) // (factorial(n - 2) * factorial(2))

if n > 1:
    ans += comb(n)
if m > 1:
    ans += comb(m)
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = 0
if n == 0 or n == 1:
    pass
else:
    ans += n*(n-1)//2
if m == 0 or m == 1:
    pass
else:
    ans += m*(m-1)//2
print(ans)

Submission status: Accepted

Solution code:
# N Mを受け取って

N,M = map(int,input().split())

ans = 0
# even + even
if N>0:
	ans += N*(N-1)/2
# odd + odd
if M>0:
	ans += M*(M-1)/2

print(int(ans))

Submission status: Accepted

Solution code:
N, M = map(int, input().split()) 
output = (N+M)*(N+M-1)//2-N*M
print(output)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = (n * (n-1) / 2) + (m * (m-1)/2)
print(int(ans))

Submission status: Accepted

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

N, M = [int(i) for i in input().split()]

cnt = 0
cnt += (N*(N-1))//2
cnt += (M*(M-1))//2
    
print(cnt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = N + M
all = A*(A-1)/2
inv = N*M
print( int(all - inv) )

Submission status: Accepted

Solution code:
even,odd =map(int,input().split())

tot = even+odd
num = int(tot*(tot-1)/2 - even*odd)
print(num)

Submission status: Accepted

Solution code:
n, m =map(int, input().split())
s = (n*(n-1)/2 + m*(m-1)/2)
s= int(s)
print(s)

Submission status: Accepted

Solution code:
#--------------------------------------------
#ライブラリ等
import sys
import math
from math import sqrt
input = sys.stdin.readline
#---------------------------------------------
X, Y = map(int, input().split())
M = (X*(X-1))
N = (Y*(Y-1))
L =(M+N)/2
print(int(L))

Submission status: Accepted

Solution code:
import math

N, M = map(int, input().split())

def tmp(a):
  if a == 0 or a == 1:
    return 0
  a = math.floor((a * (a - 1)) / 2)
  return a
print(tmp(N) + tmp(M))

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))

sum = 0

if N > 0:
    sum += N*(N-1)/2

if M > 0:
    sum += M*(M-1)/2

print(int(sum))

Submission status: Accepted

Solution code:
input = input().split()
N = int(input[0])
M = int(input[1])
answer = int(N * (N-1)/2 + M * (M-1)/2)
print(answer)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

# even+even
sum = N*(N-1)/2
# odd+odd
sum = sum + M*(M-1)/2

print(int(sum))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
print(N*(N-1)//2+M*(M-1)//2)

Submission status: Accepted

Solution code:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,M=map(int,input().split())
ans=0
if N>1:
  ans+=combinations_count(N,2)
if M>1:
  ans+=combinations_count(M,2)
print(ans)

Submission status: Accepted

Solution code:
def fact(n):
    if n < 0:
        return 0
    if n == 0:
        return 1
    if n == 1:
        return 1
    return n * fact(n-1)

def combination(n, k):
    if n < k:
        return 0
    return fact(n) / ( fact(n-k) * fact(k))

n, m = [int(x) for x in input().split()]
answer = int(combination(n, 2) + combination(m, 2))
print(answer)

Submission status: Accepted

Solution code:
n, m = map( int, input().split() )
print((n*(n-1))//2 + (m*(m-1))//2)

Submission status: Accepted

Solution code:
inp = input().split()
res = 0
for i in inp:
  res += int(i)*(int(i)-1)/2
print(int(res))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M = map(int, readline().split())
print(N * (N - 1) // 2 + M * (M - 1) // 2)

Submission status: Accepted

Solution code:
q=input()
w,e=map(int,q.split())
y=w*(w-1)//2;
u=e*(e-1)//2;
print (y+u)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
print((n*(n-1))//2 + (m*(m-1))//2)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
if N <= 1:
  N = 1
if M <= 1:
  M = 1
print(int(N*(N-1)/2+M*(M-1)/2))

Submission status: Accepted

Solution code:
"""
Author: guiferviz
Time: 2020-03-27 14:59:20
"""

import math


def c(n, r):
    if r > n:
        return 0
    return math.factorial(n) / ( math.factorial(r) * math.factorial(n - r) )


def main():
    n, m = map(int, input().split())
    print(int(c(n, 2) + c(m, 2)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from math import factorial

line = input()
N, M = (int(s) for s in line.split(' '))

total = 0
if N > 1:
  total += factorial(N) / factorial(N - 2) / 2
if M > 1:
  total += factorial(M) / factorial(M - 2) / 2

print(int(total))

Submission status: Accepted

Solution code:
def ols(): return input()
def oli(): return map(int, input().split())
def olai(): return list(map(int, input().split()))
def olas(): return list(input().split())
def mlai(L): return [int(input()) for _ in range(L)]
def mlas(L): return [input() for _ in range(L)]

n, m = oli()
print(n*(n-1)//2 + m*(m-1)//2)

Submission status: Accepted

Solution code:
import math

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

n, m = map(int, input().split())

if not 0 <= n <= 100 and 0 <= m <= 100 and 2 <= n + m:
    print('Unsupported...')  
if n >= 2:
    n_comb = combinations_count(n, 2)
else:
    n_comb = 0
if m >= 2:
    m_comb = combinations_count(m, 2)
else:
    m_comb = 0
    
print(n_comb + m_comb)

Submission status: Accepted

Solution code:
m, n = list(map(int, input().split()))
res = m*(m-1)//2 + n*(n-1)//2
print(res)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
print(int((a*(a-1)/2)+(b*(b-1)/2)))

Submission status: Accepted

Solution code:
N, M = map(int,input().split())

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

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

print(int(ans))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
sumn,summ = 0,0
for i in range(n-1,0,-1):
  sumn += i
for j in range(m-1,0,-1):
  summ += j
print(sumn+summ)

Submission status: Accepted

Solution code:
import math
n, m = map(int, input().split())
# 組み合わせの全通り
all_pattern = math.factorial(n+m) // (math.factorial(n+m - 2) * math.factorial(2))
print(all_pattern - n*m)

Submission status: Accepted

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

from sys import stdin, stdout

n, m = map(int, input().split())

if (n == 1 and m == 1):
    print (0)
else:
    even = int((n-1)*(n/2))
    odd = int((m-1)*(m/2))
    print (even+odd)

Submission status: Accepted

Solution code:
import math
import itertools
N,M=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N<=1:
    if M<=1:
        print(0)
    else:
        b = combinations_count(M, 2)
        print( b)
else:
    if M<=1:
        a = combinations_count(N, 2)
        print(a )
    else:
        a = combinations_count(N, 2)
        b = combinations_count(M, 2)
        print(a + b)

Submission status: Accepted

Solution code:
import math

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

N, M = map(int, input().split())

print(combinations_count(N, 2) + combinations_count(M, 2))

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.buffer.readline
readints = lambda: list(map(int, sys.stdin.buffer.read().split()))

n, m = readints()

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

Submission status: Accepted

Solution code:
import math


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


N, M = map(int, input().split())

if N >= 2 and M >= 2:
    print(combinations_count(N, 2) + combinations_count(M, 2))
elif N >= 2:
    print(combinations_count(N, 2))
elif M >= 2:
    print(combinations_count(M, 2))
else:
    print(0)

Submission status: Accepted

Solution code:
#A
NM = input().split(' ')
N = int(NM[0])
M = int(NM[1])
print(int((N+M)*(N+M-1)/2 - N*M))

Submission status: Accepted

Solution code:
from scipy.misc import comb
n, m = map(int, input().split())
# nC2+mC2を求めればよい
print(comb(n, 2, exact=True) + comb(m, 2, exact=True))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p = n * (n - 1) / 2 + m * (m - 1) / 2
print(int(p))

Submission status: Accepted

Solution code:
N,M=map(int, input().split())
t=N*(N-1)//2
l=M*(M-1)//2
if t<0:
  t=0
if l<0:
  l=0
print(t+l)

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
k=(s[0]*(s[0]-1)+s[1]*(s[1]-1))/2
print(int(k))

Submission status: Accepted

Solution code:
[N, M] = list(map(int, input().split()))

def main():
  #偶数+ 偶数
  ans1 = ans12(N)
  #奇数+ 奇数
  ans2 = ans12(M)
  ans = int(ans1 + ans2)
  print(ans)

def ans12(x):
  if x > 1:
    return (x * (x - 1)) / 2
  else:
    return 0

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n,m=map(int, input().split())

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

Submission status: Accepted

Solution code:
import math
def comb(n, r):
    if(n>=r):
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
    else:
        return 0
        
m,n = map(int, input().split())
ans = comb(m, 2) + comb(n, 2)
print(ans)

Submission status: Accepted

Solution code:
def cmb(n,k):
  x,y=n,k
  for i in range(1,k):
    x*=n-i
    y*=k-i
  return x//y

n,m=[int(x) for x in input().split()]
N=cmb(n,2) if n>=2 else 0
M=cmb(m,2) if m>=2 else 0
print(N+M)

Submission status: Accepted

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

n, m = map(int, input().split())

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

print(int(ans))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
print(int((N*(N-1) + M*(M-1))/2))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
a=N*(N-1)/2
b=M*(M-1)/2
print(int(a+b))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
print((n-1)*n//2 + (m-1)*m//2)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
X = int(N*(N-1)/2 + M*(M-1)/2)
print(X)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
print(x * (x - 1) //2 + y*(y-1)//2)

Submission status: Accepted

Solution code:
N, M = (int(x) for x in input().split())
ans = 0
if N >= 1:
    ans += N * (N-1) // 2
if M >= 1:
    ans += M * (M-1) // 2
    
print(ans)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
print(int(n*(n-1)/2 + m*(m-1)/2))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = max(0,n*(n-1)//2) + max(0,m*(m-1)//2)
print(ans)

Submission status: Accepted

Solution code:


n, m = map(int, input().split(" "))

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

print(int(res))

Submission status: Accepted

Solution code:
N,M=(int(x) for x in input().split())

k = N + M

if N >= 0 and M <=100 and N+M >=2: 
    int((N + M) * (N + M - 1) / 2 - (N * M))
    print(int(k * (k - 1) / 2 - (N * M)))

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
n = (N*(N-1))/2
m = (M*(M-1))/2
A=int(n+m)
print(A)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
A = int((N + M) * (N + M - 1) / 2 - (N * M))
print(A)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())

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

Submission status: Accepted

Solution code:
import math
n,m = map(int,input().split())
cnt = 0
if n >= 2:
  cnt = math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if m >= 2:
  cnt = cnt + math.factorial(m) // (math.factorial(m - 2) * math.factorial(2))
print(cnt)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
ans1 = ((n) * (n - 1)) // 2
ans2 = ((m) * (m - 1)) // 2
print(ans1 + ans2)

Submission status: Accepted

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

def fact(n):
    ans = 1
    for i in range(1,n+1): ans*=i
    return ans

def main():
    n, m = map(int, r().strip().split())
    print((fact(n)//(2*fact(n-2)))+(fact(m)//(2*fact(m-2))))

main()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
print(int(n*(n-1)/2 + m*(m-1)/2))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
brojac = 0

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

for i in range(m-1):
    brojac += m - (i+1)

print(brojac)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
 
print(n*(n-1)//2+m*(m-1)//2)

Submission status: Accepted

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


def main():
    import sys
    input = sys.stdin.readline

    n, m = map(int, input().split())
    ans = 0
    ans += max(0, n * (n - 1) // 2)
    ans += max(0, m * (m - 1) // 2)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

n,m = map(int, input().split())

even = [i for i in range(2, 333, 2)]

odd = [i for i in range(1, 333, 2)]


seq = []


for i in range(n):
    seq.append(even[i])

for i in range(m):
    seq.append(odd[i])



cnt = 0

for v1, v2 in itertools.combinations(seq,2):
    tmp = int(v1) + int(v2)
    if tmp % 2 == 0:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N, M = input().split()
N, M = int(N), int(M)
if N < 2:
  print(int(M*(M-1)/2))
elif M < 2:
  print(int(N*(N-1)/2))
else:
  print(int(N*(N-1)/2 + M*(M-1)/2))

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
cnt=0
for i in range(n):
    for j in range(n-i-1):
        cnt+=1
for i in range(m):
    for j in range(m-i-1):
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
t=list(map(int,input().split()))
n=t[0]
m=t[1]

Rt=int((n*(n-1)+m*(m-1))/2)

print(Rt)

Submission status: Accepted

Solution code:
a = input().split()
N = int(a[0])
M = int(a[1])

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())

if N != 0 and M != 0:
  answer = N*(N-1)/2 + M*(M-1)/2
  print(int(answer))
elif N == 0:
  answer = M*(M-1)/2
  print(int(answer))
else:
  answer = N*(N-1)/2
  print(int(answer))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
print(n * ~-n // 2 + m * ~-m // 2)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
print(int((a[0]*(a[0]-1)+a[1]*(a[1]-1))/2))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
print(N*(N-1)//2+M*(M-1)//2)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

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

print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = n*(n-1)/2 + m*(m-1)/2
print(int(a))

Submission status: Accepted

Solution code:
s = input()

N, M= [int(si) for si in s.split()]

def func(N, M):
    a = 0

    if N>1:
        a += N*(N-1)/2

    if M>1:
        a += M*(M-1)/2
    print(int(a))
    
func(N, M)

Submission status: Accepted

Solution code:
import sys

try:
	nums = list(map(int, input().split()))
	N, M = nums[0], nums[1]
except:
	print("整数を入力")
	sys.exit()

if (N < 0 or 100 < N) or (M < 0 or 100 < M):
	print("NとMはそれぞれ0以上100以下")
	sys.exit()
if N + M < 2:
	print("N + Mは2以上")
	sys.exit()


def keisan(num):
	# 組み合わせの数をcntでカウント
	cnt = 0
	while not num == 0:
		copy_num = num
		while not (copy_num - 1) == 0:
			copy_num -= 1
			cnt += 1
		num -= 1
	return cnt

sum = keisan(N) + keisan(M)
print(sum)

Submission status: Accepted

Solution code:
n,m = map(int,input().split(' '))
kakuritu = ((n+m)*(n+m-1))/2
kisuu = m*n
print(int(kakuritu-kisuu))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = n*(n-1)//2 + m*(m-1)//2
print(l)

Submission status: Accepted

Solution code:
m,n = map(int,input().split())
print(max([0,m*(m-1)//2])+max([0,n*(n-1)//2]))

Submission status: Accepted

Solution code:
N ,M = map(int, input().split())

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

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]

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

print(int(a+b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  inputNumEven, inputNumOdd = map(int, input().split())
  #print(inputNumEven, inputNumOdd)
  
  if inputNumEven < 0:
    inputNumEven = 0
  if inputNumOdd > 100:
    inputNumOdd = 100
    
  result = inputNumEven*(inputNumEven-1)/2 + inputNumOdd*(inputNumOdd-1)/2
    
  
  return print(int(result))

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
# 奇数同士 or 偶数同士なので
print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())

print(int(a*(a-1)/2 + b*(b-1)/2))

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))

ans = 0
ans += N * (N-1) // 2 if N!=1 else 0
ans += M * (M-1) // 2 if M!=1 else 0

print(ans)

Submission status: Accepted

Solution code:
li = input().split()
li[0] = int(li[0])  
li[1] = int(li[1])  
  
print( int(li[0]*(li[0]-1)/2 + li[1]*(li[1]-1)/2 ))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
print((N*~-N+M*~-M)//2)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

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

if ans < 0:
    print(ans)
else:
    print(ans)

Submission status: Accepted

Solution code:
def pattern(n,m):
    count = (n*(n-1))/2 + (m*(m-1))/2
    print(int(count))
n,m = [int(x) for x in input().split()]
pattern(n,m)

Submission status: Accepted

Solution code:
def main():
    N,M = map(int,input().split())
    print(N*(N-1)//2 + M*(M-1)//2)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math


n, m = map(int, input().split())


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


if n > 1:
    num_1 = combinations_count(n, 2)
else:
    num_1 = 0

if m > 1:
    num_2 = combinations_count(m, 2)
else:
    num_2 = 0

print(num_1 + num_2)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
 
print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
n_combi=n*(n-1)/2
m_combi=m*(m-1)/2
ans=n_combi+m_combi
print(int(ans))

Submission status: Accepted

Solution code:
n,m= map(int, input().split())

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
 
print(n*(n-1)//2+m*(m-1)//2)

Submission status: Accepted

Solution code:
import math

# 組み合わせ算出
def combinations_count(n, r):
    if n == 1:
        return 0
    if n == 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if __name__ == '__main__':
    a,b=map(int,input().split())
    # 偶数を2回引く
    e_2 =  combinations_count(a,2)
    # 奇数を２回引く引
    o_2 = combinations_count(b, 2)
    print(e_2 + o_2)

Submission status: Accepted

Solution code:
n, q = list(map(int, input().split()))
ans = 0

if n > 1:
    ans = ans + int(n*(n-1)/2)
if q > 1:
    ans = ans + int(q*(q-1)/2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X, Y = input().split()

X2 = int(X) * (int(X)-1) / 2
Y2 = int(Y) * (int(Y)-1) / 2

answer = X2 + Y2

print(int(answer))

Submission status: Accepted

Solution code:
import sys

n, m = input().strip().split()
n, m = [int(n), int(m)]
ans = n * (n-1) // 2 + m * (m-1) // 2

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import math
 
N, M = map(int, input().split())
 
def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
print(comb(N, 2)+comb(M, 2))

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
ans = n * (n - 1) // 2 + m * (m - 1) // 2
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=int(N*(N-1)/2)+int(M*(M-1)/2)
print(A)

Submission status: Accepted

Solution code:
import math
n,m = map(int, input().split())

def c(s,t):
    if s == 0 or s == 1:
        return 0
    return math.factorial(s)/(math.factorial(s-t)*math.factorial(t))

print(int(c(n,2)+c(m,2)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
#偶数、奇数
#偶数になるのは偶偶、奇奇のみ
print((n*(n-1) + m*(m-1))//2)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(i) for i in input().split()]
#template
#issueから始める
N,M = inputlist()
print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split(' ')))
print((N**2-N)//2 + (M**2-M)//2)

Submission status: Accepted

Solution code:
ans=0

n,m=map(int,input().split())
if n > 1:
	for i in range(1,n):
		ans += i

if m > 1:
	for i in range(1,m):
		ans += i

print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
print(int((n+m)*(n+m-1)/2-n*m))

Submission status: Accepted

Solution code:
a,b = input().split()
a = int(a)
b = int(b)


S = a*(a-1)/2
F = b*(b-1)/2
if a<1.9 and b<1.9:
  print(0)
elif a<1.9 and b>1.9:
  print(int(F))
elif a>1.9 and b<1.9:
  print(int(S))
elif a>1.9 and b>1.9:
  print(int(S+F))

Submission status: Accepted

Solution code:
a,b = input().split()
a = int(a)
b = int(b)
A = a-1
B = b-1

S = a*A/2
F = b*B/2
if a<1.9 and b<1.9:
  print(0)
elif a<1.9 and b>1.9:
  print(int(F))
elif a>1.9 and b<1.9:
  print(int(S))
elif a>1.9 and b>1.9:
  print(int(S+F))

Submission status: Accepted

Solution code:
a,b = input().split()
a = int(a)
b = int(b)
A = a-1
B = b-1
X = a*A
Y = b*B
S = X/2
F = Y/2
if a<1.9 and b<1.9:
  print(0)
elif a<1.9 and b>1.9:
  print(int(F))
elif a>1.9 and b<1.9:
  print(int(S))
elif a>1.9 and b>1.9:
  print(int(S+F))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ans = max(N*(N-1)//2,0) + max(M*(M-1)//2,0)
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
count = 0
if m >= 2:
  count += m*(m-1)/2
if n >= 2:
  count += n*(n-1)/2
print(int(count))

Submission status: Accepted

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

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

N, M = map(int, input().split())
print(N * (N - 1) // 2 + M * (M - 1) // 2)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
print(int((a*(a-1)/2)+(b*(b-1)/2)))

Submission status: Accepted

Solution code:
num1,num2 = map(int,input().split())

print(num1 * (num1 - 1) // 2 + num2 * (num2 - 1) // 2)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = (a*(a-1))/2
d = (b*(b-1))/2
print(round(c+d))