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: Wrong Answer

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if n != 1:
    a = cmb(n,2)
else:
    a = 0

if m != 1:
    b = cmb(m,2)
else:
    b = 0
print(a + b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split(" "))
result = 0
print(n,m)
if n > 1:
    for i in range(n):
        result += n-1
        n -= 1
if m > 1:
    for t in range(m):
        result += m-1
        m -= 1
print(result)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
N,M = (int(x) for x in input().split())
a = comb(N, 2) + comb(M, 2)
print(a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,M = inputMap()

	if N < 2 and M < 2:
		print(0)
		sys.exit()

	ans = 0
	if N > 1:
		ans += cmb(N, 2)
	if M > 1:
		ans += -(-M // 2) + 1

	print(ans)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# special thanks :
#  https://nagiss.hateblo.jp/entry/2019/07/01/185421
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(math.sqrt(n) * (1 + 1e-10)))

# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

print(even + odd)

Submission status: Wrong Answer

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


if N!=0:
  for i in range(1,N+1):
    l_n.append(i*2)
else:
  l_n.append(0)


if M!=0:
  now=1
  for i in range(M):
    l_n.append(now)
    now+=2
else:
  l_n.append(0)

now=0
cnt=0

for i in range(len(l_n)):
  for j in range(len(l_n)):
    if i<j:
      
      now=l_n[i]+l_n[j]
      if now%2==0:
        cnt+=1
      
print(cnt)

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    n -= 1
    e = 0
    while n > 0:
        e += n
        n -= 1
    if m <= 1:
        print(e)
    else:
        print(e + m)


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a=0
b=3
answer = 0

#偶数2
if a != 0:
    answer += math.factorial(a) / (math.factorial(a - 2)*2)

#奇数2
if b != 0:
    answer += math.factorial(b) / (math.factorial(b - 2)*2)

print(int(answer))

Submission status: Wrong Answer

Solution code:
x, y = map(int, input().split())
result_x = 0
result_y = 0
if x > 1:
    result_x = 0
    for i in range(x):
        result_x = result_x + i

if x > 1:
    result_y = 0
    for i in range(y):
        result_y = result_y + i


print(result_x + result_y)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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



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

else:
    n=0

if M>=2:
    m=(M*(M-1))/2

else:
    m=0

print(n+m)

Submission status: Wrong Answer

Solution code:
import itertools
N,M=map(int,input().split())
c=0
for (a,b) in itertools.combinations(list(range(2,101,2))[:N]+list(range(1,100,2))[:M],2):
    c += 1 if (a+b)%2==0 else 0
print(c)

Submission status: Wrong Answer

Solution code:
import math 
def ncr(m,n):
    return((math.factorial(m))/((math.factorial(n))*(math.factorial(m-n))))
nm=list(map(int,input().split()))
if(nm[0]<2 and nm[1]>=2):
    print(ncr(nm[1],2))
elif(nm[0]>=2 and nm[1]<2):
    print(ncr(nm[0],2))
elif(nm[0]<2 and nm[1]<2):
    print(0)
else:
    print(int(ncr(nm[0],2)+ncr(nm[1],2)))

Submission status: Wrong Answer

Solution code:
import math

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

if M % 2 != 0:  
    print(int(math.factorial(N + M) / (math.factorial(2) * math.factorial(N + M - 2))) - N * M)
else:
    print(int(math.factorial(N + M) / (math.factorial(2) * math.factorial(N + M - 2))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if N < 2 and N < 2:
    print(0)
elif M < 2:
    print(comb(N,2))
elif N < 2:
    print(comb(M,2))
else:
    print(comb(N,2) + comb(M, 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [0]*n
b = [1]*m
ans = a+b
count = 0
for i in range(0,n+m):
    for j in range(i+1,n+m):
        if (ans[i]+ans[j])%2==0:
            count += 1
            print(ans[i],ans[j],i,j)
print(count)

Submission status: Wrong Answer

Solution code:

from math import factorial

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

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

if M > 2 and N >2:
    sum_n = combinations_count(M, 2) + combinations_count(N, 2)

elif M > 2:
    sum_n = combinations_count(M, 2)

elif N > 2:
    sum_n = combinations_count(N, 2)

else:
    sum_n = 0

print(sum_n)

Submission status: Wrong Answer

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

if N>1 and M>1:
  k=(M*(M-1)+N*(N-1))//2
  print (k)
elif N==1:
  print ((M*(M-1))//2)
else:
  print ((N*(N-1))//2)

Submission status: Wrong Answer

Solution code:
# 200322 A

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
n, m = map(int, input().split())
print(int(comb(n,2)+comb(m,2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
def combi(n,r):
    if n < r:
        return 0
    return math.factorial(n) // math.factorial(r) * math.factorial(n-r)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = int(i[0])
m = int(i[1])

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

print(p)

Submission status: Wrong Answer

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

n=0
m=0

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

if M>=2:
    m=(M*(M-1))/2

print(n+m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
val = input().split(' ')
n = int(val[0])
m = int(val[1])

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

print(result)

Submission status: Wrong Answer

Solution code:
n,m=list(map(int,input().split()))
x=0
if n<2 and m<2:
    x=0
elif n<2 :
    x=m*(m-1)/2
elif m<2:
    x=n*(n-1)/2
else:
    x=m*(m-1)/2+n*(n-1)/2
print(x)

Submission status: Wrong Answer

Solution code:
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    even = (N * (N - 1)) // 2
    odd = 0 if M == 1 else M
    print(even + odd)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import factorial

N, M = [int(i) for i in input().split()]
ans = 0
if N > 1:
    ans += int(factorial(N) / factorial(2) / factorial(N - 2))
if M > 1:
    ans += int(factorial(M) / factorial(2) / factorial(M - 2))

print(ans)

Submission status: Wrong Answer

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


def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = tmp(n) if n > 1 else 0
    ans_m = tmp(m) if m > 1 else 0
    ans = ans_n + ans_m
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
data = input().split(" ")

N = int(data[0])
M = int(data[1])

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

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

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

n = N
r = 2
if n -r >= 0:
    a = factorial(n) / factorial(r) / factorial(n - r)
else:
    a = 0

n = M
r = 2
if n -r >= 0:
    b = factorial(n) / factorial(r) / factorial(n - r)
else:
    b = 0

print(int(a)+int(b))

Submission status: Wrong Answer

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

if n <= 2:
  n_even = 0
else:
  n_even = n * (n-1) / 2
if m <= 2:
  m_even = 0
else:
  m_even = m * (m-1) / 2

even = n_even + m_even
print(int(even))

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
N,M = (int(x) for x in input().split())
a = int(comb(N, 2) + comb(M, 2))
print(a)

Submission status: Wrong Answer

Solution code:
def solve():
    a, b = list(map(int, input().split()))
    
    if a == 0 and b == 0:
        print(0)
        return
    
    if a == 0:
        ans = b * (b - 1) // 2
        print(ans)

    if b == 0:
        ans = a * (a - 1) // 2
        print(ans)
    
    ans = a * (a - 1) // 2
    ans += b * (b - 1) // 2
    print(ans)
    return

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb


N, M = map(int, input().split())
result = 0
if N >= 2:
    result += comb(N, 2)
if M >= 2:
    result += comb(M, 2)
print(int(result))

Submission status: Wrong Answer

Solution code:
M,N=map(int,input().split())
def fact(n):
	s=1
	for i in range(2,n):
		s=s*i
	return s

def conb(n,r):
	return fact(n)//(fact(r)*fact(n-r))

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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
N, M = map(int, input().split())
print(comb(N, 2) + comb(M, 2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

C = N * (N - 1) / 2 + M * (M - 1) / 2
print(str(C))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if (N == 0 or N == 1) and (M == 0 or M == 1):
    print(0)
if (N == 0 or N == 1) and M != 0 and M != 1:
    print(M*(M-1)//2)
if N != 0 and N != 1 and (M == 0 or M == 1):
    print(N*(N-1)//2)
else:
    print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

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

print(int(comb(N, 2) + comb(M, 2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
if N <= 1:
	answer = 0
else:
	answer = int(N/2)

print(answer)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N >=2:
    odd = (N*(N-1))/2
else:
    odd = 0
if M >= 2:
    even = (M*(M-1))/2
else:
    even = 0
print(odd+even)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

n=0
m=0

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

if M>1:
    m=(M*(M-1))/2

print(n+m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 偶偶　奇奇

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[0]<=1:
  n=0
else:
  n=a[0]*(a[0]-1)/2

if a[1]<=1:
  m=0
else:
  m=a[1]*(a[1]-1)/2
 
print(n+m)

Submission status: Wrong Answer

Solution code:
L, R = map(int,input().split())
sum = L+R
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

aaa = cmb(L,2) + cmb(R,2)
print(aaa)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

#from scipy.special import comb

def main():
    n, m = map(int, input().split(" "))
    ans = comb(n, 2) + comb(m, 2)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = n * (n - 1) if n > 1 else 0
    ans_m = m * (m - 1) if m > 1 else 0
    ans = ans_n + ans_m
    return ans


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a[1]==1:
  m=0
else:
  m=a[1]*(a[1]-1)/2
 
print(n+m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

n,m = map(int,input().strip().split())
if n<=1 and m <=1:
    print(0)
if n <= 1:
    print(ncr(m,2))
elif m <= 1:
    print(ncr(n,2))
else:
    print(ncr(m,2) + ncr(n,2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

Submission status: Wrong Answer

Solution code:
a = [int(i) for i in input().split()]

x= a[0] * (a[0]-1) * (1/2)

x+= a[1] * (a[1]-1) * (1/2)

print(x)

Submission status: Wrong Answer

Solution code:
import math

f = math.factorial


def comb(n, r):
    if n - r < 0:
        return 0
    else:
        return int(f(n) / f(r) / f(n - r))


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

Submission status: Wrong Answer

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

print(a)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
b = a[0]+a[1]

c = ((a[0]*(a[0]-1))+(a[1]*(a[1]-1)))/2
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
N,M = map(int,input().split())
even = comb(N,2)
odd = comb(M,2)
print(int(even + odd))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# 整数の入力
N, M = list(map(int, input().split()))

output = (N*(N-1))/2 + (M*(M-1))/2

###########　出力
print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import factorial


def f(n, r):
    return int(factorial(n) / factorial(r) / factorial(n - r))


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

res = 0

if N >= 2:
    res += f(N, 2)

if M >= 2:
    res += f(M, 2)

print(res)

Submission status: Wrong Answer

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

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

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split(' '))
if n >= 2:
    ret_n = n * (n - 1) / 2
else:
    ret_n = 0

if m >= 2:
    ret_m = m * (m - 1) / 2
else:
    ret_m = 0

print(ret_n + ret_m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = k[0] * (k[0] -1) / 2
m = k[1] * (k[1] -1) / 2

print(l + m)

Submission status: Wrong Answer

Solution code:
guu, ki = map(int, input().split())

print(guu*(guu-1)/2 + ki*(ki-1)/2)

Submission status: Wrong Answer

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

if n == 1 and m ==1:
    print(0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n * m - m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(M*M + N*N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
Q = N*(N-1)*0.5
P = M*(M-1)*0.5
print(P+Q)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
inp=input().split()
n=int(inp[0])
m=int(inp[1])
arr=[]
pares=0
impares=0
count=1
nums=0
while len(arr)<(m+n):
    if count%2==0 and pares<n:
        arr.append(count)
        pares+=1
    elif count%2!=0 and impares<m:
        arr.append(count)
        impares+=1
    count+=1
sums=[]
for x in arr:
   for y in arr:
        if(x+y)%2==0 and [x,y] not in sums and [y,x] not in sums and x!=y:
            nums+=1
            sums.append([x,y])

print(nums)

Submission status: Time Limit Exceeded

Solution code:
import time
time.sleep(3)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
N -= 1
M -= 1
Nans = 1
while(True):
    if N == 1:
        break
    Nans += N
    N -= 1
Mans = 1
while(True):
    if M == 1:
        break
    Mans += M
    M -= 1
print(Nans+Mans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
a = []
b = []
if M == 0:
    for i in range(1,(2*N)+1):
        if i%2==0 and i>0:
            a.append(i)
elif N == 0:
    for i in range(1,(2*M)+1):
        if i%2==1:
            b.append(i)
else:
    for i in range(1,(2**N)+1):
        if i%2==0 and i>0:
            a.append(i)
        else:
            b.append(i)
c = a[:N] + b[:M]
l = []
num = 1
for i in range(len(c)-1):
    for j in range(num,len(c)):
        res = c[i] + c[j]
        l.append(res)
    num+=1

k=[i for i in l if i%2==0]
print(len(k))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
a = [j for j in range((2**N)+1) if j%2==0 and j>0]
b = [j for j in range((2**M)+1) if j%2==1]
A = a[:N]
B = b[:M]
c = A + B
l = []
num = 1
for i in range(len(c)-1):
    for j in range(num,len(c)):
        res = c[i] + c[j]
        l.append(res)
    num+=1

k=[]
for i in l:
    if i%2==0:
        k.append(i)
print(len(k))

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
c=0
while a>1 or b>1:
  if (a-2)>1 or (b-2)>1:
    a=a-2
    b=b-2
    c=c+1
print(c)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
c=0
while a>0 or b>0:
  if (a-2)>0 or (b-2)>0:
    a=a-2
    b=b-2
    c=c+1
print(c)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    # nは偶数、mは奇数
    # n+mから2つ選ぶ選び方は
    # n:m = 0:2 和は 偶数、選び方はmC2
    # n:m = 1:1 和は 奇数 （今回はこれは含めない）
    # n:m = 2:0 和は 偶数、選び方はnC2
    cnt = 0
    if m >= 2:
        cnt += m * (m -1) // 2
    if n >=2:
        cnt += n * (n -1) // 2
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N,M=map(int,input().split())
def C(x):
    if x>=2:
        return math.factorial(x)//(math.factorial(x-2)*2)
    else:
        return 0
print(C(N)+C(M))