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,M=map(int,input().split())


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

else:
    n=0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
letters = input()

def kaibun_check(letters):
    count = 0
    if len(letters)%2 == 0 or len(letters)<1:
        return False
    for _ in range(len(letters)//2):
        count += 1
        if letters[count-1] != letters[-count]:
            return False
    return True

if kaibun_check(letters) and kaibun_check(letters[:(len(letters)-1)//2]) and kaibun_check(letters[(len(letters)+3)//2-1:]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations

def resolve():
    N, M = map(int, input().split())
    n = len(list(combinations(range(N), 2)))
    if M >= 2:
        m = len(list(combinations(range(M), 2)))
    else:
        m = 0
    return print(n+m)

Submission status: Wrong Answer

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

# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

(combinations_count(b+c, 2)-b*c)

Submission status: Wrong Answer

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,(100)+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: Wrong Answer

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*N)+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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

a = len(list(combinations(range(n),2)))

if (n == 2 and m == 0) or (n == 0 and m == 2):
    print(2)
    exit()

if m == 1:
    print(a + m -1)
    exit()
else:
    print(a + m)
    exit()

Submission status: Wrong Answer

Solution code:
import sys
X,Y = map(int,input().split())
if(X == 1 and Y == 1):
    print(0)
    sys.exit()
elif(Y == 1):
    print(int(X/2))
    sys.exit()
elif(X == 0 and Y ==2):
    print(1)
    sys.exit()
print(int((X * (X-1))/2 + Y))

Submission status: Wrong Answer

Solution code:
import math
e,o = map(int,input().split())
if e < 2:
    e_cases = 0
else:
    e_cases = math.factorial(e)/math.factorial(e-2)/2
if o < 2:
    o_cases = 0
else:
    o_cases = math.factorial(o)/math.factorial(o-2)/2
print(e_cases+o_cases)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a = []
b = []
for i in range(1,100):
    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: Wrong Answer

Solution code:
N, M = map(int, input().split())
a = []
b = []
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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(" ")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s1 = str(input())
s2 = ''
for i in range(len(s1)):
    s2 += s1[- i - 1]
if s1 != s2:
    print('No')
    exit()

t1 = s1[0 : ((len(s1)) - 1) // 2]
t2 = ''
for i in range(len(t1)):
    t2 += t1[- i - 1]
if t1 != t2:
    print('No')
    exit() 

u1 = s1[(len(s1) + 3) // 2 - 1:]
u2 = ''
for i in range(len(u1)):
    u2 += u1[- i - 1]
if u1 != u2:
    print('No')
    exit() 
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
X,Y = map(int,input().split())
if(X == 1 and Y == 1):
    print(0)
    sys.exit()
elif(Y == 1):
    print(int(X/2))
    sys.exit()
print(int((X * (X-1))/2 + Y))

Submission status: Wrong Answer

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

def fact(num):
    result = 1
    while num > 1:
        result *= num
        num -= 1
    return result

result += fact(M) / (fact(2) * fact(M-2))
result += fact(N) / (fact(2) * fact(N-2))

print(round(result))

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 *


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

Submission status: Wrong Answer

Solution code:
a, b=input().split()
a=int(a)
b=int(b)
if a<=1:
  k=b*(b-1)//2
  print(k)
elif b<=1:
  k=a*(a-1)//2
  print(k)
elif a<=1 and b<=1:
  print("0")
else:
  k=a*(a-1)*b*(b-1)//4
  print(k)

Submission status: Wrong Answer

Solution code:
gusu, kisu = input().split()
gusu = int(gusu) # 個数
kisu = int(kisu) # 個数
# 両者とも偶数から選べば偶数
total = int(gusu / 2.)

# 奇数どうしの足し算は全て偶数
total = total + int(kisu / 2.)

print(total)

Submission status: Wrong Answer

Solution code:
S=str(input())
N=len(S)
p=0
a=0
c=0
for i in range(int((N-1)/2)):
        if S[i]==S[-i-1]:
            p+=1
if p==(N-1)/2:
    for i in range(int((N-1)/4)):
        T=S[:int((N-1)/2)]
        if T[i]==T[-i-1]:
                a+=1
    if a==int((N-1)/4):
        for y in range(int((N-(N+3)/2)/2)):
            F=S[int((N+3)/2)-1:]
            if F[y]==F[-y-1]:
                c+=1
        if c==(int((N-(N+3)/2)/2)):
            print("yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
arr = list(map(int,input().rstrip().split()))
cou = 0
cou_n = 0
cou_m = 0
i =1
j =1
N = arr[0]
M = arr[1]
n =[]
m = []
while cou_n  != N:
    if i % 2 == 0:
        n.append(i)
        cou_n += 1
    i += 1

while cou_m != M:
    if j % 2 != 0 :
        m.append(j)
        cou_m +=1
    j += 1
f = n + m
# print(n)
# print(m)
f.sort()
print(f)
#start permutation
for i in range(len(f)):
    for j in range(i+1,len(f)):
        if ((f[i] + f [j]) % 2) == 0:
            cou +=1
print(cou)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

a = len(list(combinations(range(n),2)))
if m == 1:
    print(a + m -1)
else:
    print(a + m)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

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

n_comb = comb(N, 2)
m_comb = comb(M, 2)

output = int(n_comb) + int(m_comb)

print(output)

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 = list(map(int, input().split()))
N = a[0]
M = a[1]

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

Submission status: Wrong Answer

Solution code:
str = list(input())

def isKaibun(src):
  rev = src[:]
  rev.reverse()

  return src == rev


N = len(str)

def num(N):
  return N-1

s1 = num(1)
e1 = (num(N)-1) // 2 + 1
s2 = (num(N) + 3) // 2
e2 = num(N) + 1

if isKaibun(str) and isKaibun(str[s1:e1]) and isKaibun(str[s2:e2]):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
nb = 0
def combin(n, k):
    """Nombre de combinaisons de n objets pris k a k"""
    if k > n//2:
        k = n-k
    x = 1
    y = 1
    i = n-k+1
    while i <= n:
        x = (x*i)//y
        y += 1
        i += 1
    return x
if m > 1:
  nb = m + combin(n,2) 
elif m == 1 and n > 1:
  nb = combin(n, 2)
else:
  nb = 0
print(nb)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=0
if(n>=2):
  for i in range(n):
    s+=i
    
if(m==3 or m==2):
  s+=m
  
if(m>=4):
  for i in range(n):
    s+=m
print(s)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
num = int((n-1)/2)-1
for i in range(num):
  if s[i] != s[n-1-i]:
    print("No")
    exit()
    
num = int(num /2 -1)
for i in range(num):
  if s[i] != s[n-1-i]:
    print("No")
    exit()

num = int(len(s) * 0.5 - 1.5)
index = int((n + 3) /2 -1 )
for i in range(num):
  if s[index+i] != s[n-1-i]:
    print("No")
    exit()
   
  
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import factorial
even, odd = [int(x) for x in input().split()]
ways = (even * (even - 1)) // 2 + (factorial(odd) // 2)
print(ways)

Submission status: Wrong Answer

Solution code:
import math
from scipy.misc import comb

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

Submission status: Wrong Answer

Solution code:
a = list(input().split())
a1 = "".join(a)
c = reversed(a)
c1 = "".join(c)


def b():
    if len(a1) <= 5:
        return 0
    if a1 == c1:
        return 1
    else:
        return 0


if b() == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

odd_list = [x*2 for x in range(N)]
even_list = [2*y-1 for y in range(M)]

odd_num = 0

for i in range(N):
  for j in range(M):
    if (i + j) % 2 == 0:
      odd_num += 1

print(odd_num)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

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

n_comb = comb(N, 2)
m_comb = comb(M, 2)

output = int(n_comb + m_comb)

print(output)

Submission status: Wrong Answer

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

k = 0

if a%2 == 0:
  k = k + a*(a-1)/2
else:
  k = k
  
if b%2 == 0:
  k = k + b*(b-1)/2
else:
  k = k
  
print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
n,m=map(int,input().split())
N=cmb(n,2)
M=cmb(m,2)
if n == 1 and m != 1:
    print(M)
elif m == 1 and n != 1:
    print(N)
elif m == 1 and n == 1:
    print(0)
else:
    print(cmb(n,2)+cmb(m,2))

Submission status: Wrong Answer

Solution code:

def check_str( ss ):
  sslen = len(ss)
  
  ccnt = 0
  for c in ss:
    if( ss[0] == c ):
      ccnt+=1
  
  if( sslen == ccnt ):
    return False
  
  return (ss[:sslen//2] == ss[sslen//2+1:][::-1])
  
s = input()

slen = len(s)

if( not check_str( s ) ):
  print( "No" )
else:
#print(s[:slen//2])
#print(s[slen//2+1:][::-1])

  s1 =  s[:slen//2]
  s2 = s[slen//2+1:]
  
  
  if( (not check_str( s1 )) or (not check_str( s2 )) ):
    print( "No" )
  else:
    print( "Yes" )

#s1 = s[:len(s)-1]

#s1

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
nb = 0
def combin(n, k):
    """Nombre de combinaisons de n objets pris k a k"""
    if k > n//2:
        k = n-k
    x = 1
    y = 1
    i = n-k+1
    while i <= n:
        x = (x*i)//y
        y += 1
        i += 1
    return x
if m > 1:
  nb = m + combin(n,2) 
elif m == 1:
  nb = combin(n,2)
else:
  nb = 0
print(nb)

Submission status: Wrong Answer

Solution code:
import math
import string


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


n, m = map(int, input().split())
#print(n, m)
if n == 1:
    print(math.floor(m/2))
    exit()
if n == 0:
    print(m)
    exit()
a = nCr(n, 2)
print(a+m)

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
    while m > 2:
        e += m
        m -= 1
    print(e)
 
main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=N*(N-1)/2
b=M*(M-1)/2
if N<1.5 and M>1.5:
    print(int(b))
elif M<1.5 and N>1.5:
    print(a)
elif N<1.5 and N<1.5:
    print(int(0))
else:
    print(int(a+b))

Submission status: Wrong Answer

Solution code:
from math import factorial

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

result = 0
# 奇数は組み合わせ数
if M == 2:
    result += 1
if M > 2:
    result += int(factorial(M) / factorial(2) / factorial(M - 2))

# 偶数
if N == 2:
    result += 1
if N > 2:
    result += int(factorial(N) / factorial(2) / factorial(N - 2))

print(result)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=0
if(n>=2):
  for i in range(n):
    s+=i
    
if(m>=2):
  s+=m
  
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import string


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


n, m = map(int, input().split())
#print(n, m)
if n == 1:
    print(0)
    exit()
if n == 0:
    print(m)
    exit()
a = nCr(n, 2)
print(a+m)

Submission status: Wrong Answer

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

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())
if(n+m>=2 and n>=0 and n<=100 and m<=100 and m>=0):

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0

# 偶数
#if a != 0:
#    if a % 2 != 0:
#        a = a - 1

# 奇数


# 組み合わせ
nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
if a > 2:
    cnt = cnt + cmb(a, 2)

if b > 2:
    cnt = cnt + cmb(b, 2)
print(cnt)

Submission status: Wrong Answer

Solution code:
def checkPalindrome(str1, str2):
  for i in range(len(str1) // 2):
    if str1[i] != str2[i]:
      return False
  return True
    
s = input()
rs = ''.join(list(reversed(s)))
cri1 = checkPalindrome(s, rs)

s2 = s[:len(s) // 2]
rs2 = ''.join(list(reversed(s2)))
cri2 = checkPalindrome(s2, rs2)

s3 = s[len(s) // 2 + 1:len(s)]
rs3 = ''.join(list(reversed(s3)))
cri3 = checkPalindrome(s3, rs3)

if cri1 and cri2 and cri3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=N*N/4+M*M/4
b=N+M
if int(b)>2:
  print(int(a))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
s = str(input())

def check(text):
    n = len(text)
    if n == 1:
        return True

    left = int((n-1)/2)
    right = int((n+3)/2 - 1)
    if text[0:left] == text[right:n] and check(text[0:left]):
        return True
    return False

if check(s):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

ans = even + odd

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
##偶数+偶数(n+n)
n1 = n*(n-1)/2
##奇数+奇数(m+m)
m1 = m*(m-1)/2
##print
print(n1 + m1)

Submission status: Wrong Answer

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

print(oo + ee)

Submission status: Wrong Answer

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

num1=n*(n-1)*0.5
num2=m*(m-1)*0.5

print(num1+num2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
kai = []
kai2 = []
kai3 = []

for i in range(N):
  kai.append(S[i])

for i in range(0, int((N - 1) / 2)):
  kai2.append(S[i])

for i in range(int((N + 3) / 2) - 1, N):
  kai3.append(S[i])

rev = kai.reverse
rev2 = kai2.reverse
rev3 = kai3.reverse

if kai == rev:
  if kai2 == rev2:
    if kai3 == rev3:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

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

N1=(N*(N-1))/2
M1=(M*(M-1))/2

if N==0:
    print(M1)
elif M==0:
    print(N1)
else:
    print(M1+N1)

Submission status: Wrong Answer

Solution code:
def kaibun(str):
    return True if str == str[::-1] else False

s = input()
if not kaibun(s) :
    print('No')
    exit()
n = len(s)
n1 = (n - 1) // 2
if not kaibun(s[:n1]) :
    print('No')
    exit()
n2 = (n + 3) // 2 - 1
if not kaibun(s[n2:]) :
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

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

    print((n*(n-1)/2)+(m*(m-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:
from scipy.misc import comb

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

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

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
p = (n-1)//2
q = (n+3)//2 - 1
A = S[:p]
B = S[q:]
ans = 'Yes'
for i in range(len(S)):
    if S[i] != S[-i-1]:
        ans = 'No'
for i in range(len(A)):
    if A[i] != A[-i-1]:
        ans = 'No'
for i in range(len(B)):
    if B[i] != B[-i-1]:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

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

num1=n*(n-1)*0.5
num2=m*(m-1)*0.5

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=N*N/4+M*M/4
b=N+M
if int(b)>2:
  print(a)
else:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数入力
N, M  = map(int,input().split())

if N > 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M > 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))

Submission status: Wrong Answer

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

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

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

print(int(answer))

Submission status: Wrong Answer

Solution code:
import math
m,n=map(int,input().split())
dm,dn=0,0
if m>2:
    dm = math.factorial(m)//math.factorial(m-2)
if n>2:
    dn = math.factorial(n)//math.factorial(n-2)
print((dm+dn)//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:
a = list(map(int, input().split()))


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 1
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 1
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(int(a1() + b1()))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()
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


def main():
    N, M = MI()
    print(combinations_count(N, 2)+combinations_count(M, 2))
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

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

ans = comb(N,2) + comb(M,2)


print(int(ans))

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 and n !=0:
    a = cmb(n,2)
else:
    a = 0

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
from math import factorial
def bb(n,r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return int(a)

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

if m>1 and n>1:
    print(bb(n,2)+bb(m,2))
elif m>1 and n<=1:
    print(bb(m,2))
else:
    print(bb(n,2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 1
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 1
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(a1() + b1())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
a = list(map(int, input().split()))


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 1
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 1
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(a1() * b1())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import factorial

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

if N <= 1:
  a = 0
else:
  a = factorial(N) / 2 / factorial(N - 2)
  
if M <= 1:
  b = 0
else:
  b = factorial(M) / 2 / factorial(M - 2)
  
print(a+b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#偶数2
if a > 1 :
    answer += math.factorial(a) / (math.factorial(a - 2))

#奇数2
if b > 1:
    answer += math.factorial(b) / (math.factorial(b - 2))

print(int(answer))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

print(a)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
count=0
a=[]
for i in range(n):
    a.append(2)
for i in range(m):
    a.append(1)

for i in range(n+m-1):
    for j in range(i,n+m):
        if a[i]+a[j]%2==0:
            count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)

s2 = s[:int((n-1)/2)]
n2 = len(s2)


# 回文の判定
if s[:int((n-1)/2)] == s[int(int((n-1)/2) + 1):] and s2[:int((n2-1)/2)] == s2[int(int((n2-1)/2) + 1):]:
  print ("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
X,Y = map(int,input().split())
if(X == 1 or Y == 1):
    print(0)
    sys.exit()
print(int((X * (X-1))/2 + Y))

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

if N==0 and M==0:
  print(0)
else:
  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:
N, M = map(int, input().split())

if N == int(0):
    print(M*(M-1)/2)
elif M == int(0):
    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 = (int(x) for x in input().split())
a = int(comb(N, 2)) + int(comb(M, 2))
print(a)