peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N=int(input())
alp="abcdefghij"
S=[""for i in range(N)]

def gen(cnt,rem):
    if rem==0:
        print("".join(S))
    else:
        for i in range(min(N,cnt+2)):
            S[N-rem]=alp[i]
            gen(i,rem-1)            

S[0]="a"
gen(0,N-1)
# Judge status: Accepted
def med(l):
	t = len(l)
	if t%2:
		return l[t//2]
	else: return (l[t//2]+l[t//2-1])/2

n = int(input())
a = []
b = []
for i in range(n):
	x,y = map(int,input().split())
	a+=[x]
	b+=[y]
a.sort()
b.sort()

if n%2==0:
	print(int((med(b)-med(a))*2)+1)
else:
	print(med(b)-med(a)+1)
# Judge status: Accepted
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


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

if k == 10:
    print(len(str(n)))
else:
    print(len(Base_10_to_n(n,k)))
# Judge status: Accepted
#  ABC 067: A – Sharing Cookies
a, b = [int(s) for s in input().split()]
print('Possible' if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else 'Impossible')
# Judge status: Wrong Answer
N = int(input())
l = [int(x) for x in input().split()]
ans = 1
wa = sum(l)
kosuu = 1 - l[0]
flag = 0
for i in range(1,N):
    if  flag == 0:
        kosuu = kosuu * 2
    if kosuu >= wa:
        flag = 1
        kosuu = wa
    ans += kosuu
    kosuu = kosuu - l[i]
    wa = wa-l[i]
    if kosuu <= 0:
        print(-1)
        exit()
if kosuu*2 < l[N]:
    print(-1)
else:
    print(ans+l[N])
# Judge status: Accepted
s = input()
ans = 0
cache = 0
for c in s:
    if c in ["A", "C", "G", "T"]:
        cache += 1
    else:
        if cache > ans:
            ans = cache
            cache = 0
if cache > ans:
    ans = cache
print(ans)
# Judge status: Accepted
import sys

readline = sys.stdin.readline
N = int(readline())
CSF = []
for i in range(N-1):
    CSF.append(tuple(map(int, readline().split())))
for i in range(N):
    time = 0
    for c, s, f in CSF[i:N-1]:
        if time < s:
            time = s
        else:
            time = (time+f-1)//f*f
        time += c
    print(time)
# Judge status: Accepted
#from collections import Counter
#= int(input())
#= map(int, input().split())
N, R = map(int, input().split())
if N >= 10:
    print(R)
else:
    R += 100 * (10 - N) 
    print(R)
# Judge status: Accepted
A,B,C=map(int,input().split())
print('Yes' if A+B>=C else 'No')
# Judge status: Accepted
#51 C - Many Medians
N = int(input())
X = list(map(int,input().split()))
Xsrt = sorted(X,reverse = False)
XL = set(Xsrt[:N//2])
XR = set(Xsrt[N//2:])

ans = []
for x in X:
    if x in XR:
        ans.append(Xsrt[N//2-1])
    elif x in XL:
        ans.append(Xsrt[N//2])
for a in  ans:
    print(a)
# Judge status: Accepted

S = int(input())

mod = 10 ** 9 + 7

X = [1] * S

for i in range(1, S):
  X[i] = X[i - 1] * i % mod

ans = 0

for i in range(1, S // 3 + 1):
  ans += X[S - 2 * i - 1] * pow(X[i - 1] * X[S - 3 * i] % mod, mod - 2, mod) % mod
  ans %= mod

print(ans)
# Judge status: Accepted
# A - Airport Bus
# https://atcoder.jp/contests/agc011/tasks/agc011_a

n, c, k = map(int, input().split())
T = [int(input()) for _ in range(n)]

T.sort()

ans = 1
cnt = 0
st = T[0]
for t in T:
  cnt += 1
  if t - st > k or cnt > c:
    ans += 1
    st = t
    cnt = 1

print(ans)
# Judge status: Accepted
from sys import stdin
s = stdin.readline().rstrip().split()
n, r = int(s[0]), int(s[1])

if 10-n >= 0:
    print(r+100*(10-n))
else:
    print(r)
# Judge status: Accepted
n, a, b = map(int, input().split())
mod = 10**9 + 7
def c(x):
  out = 1
  for i in range(min(x, n-x)):
    out *= n-i
    out *= pow(i+1, mod-2, mod)
    out %= mod
  return out
ans = pow(2, n, mod) -1 -c(a)-c(b)
ans %= mod
print(ans)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

if N < 2:
    print(0)
    exit()

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        if L[i] == L[j]:
            continue

        for k in range(j + 1, N):
            if (L[i] != L[k]) and (L[j] != L[k]) and (L[i] + L[j] > L[k]) and (L[j] + L[k] > L[i]) and (
                    L[k] + L[i] > L[j]):
                cnt += 1

print(cnt)
# Judge status: Accepted
k = int(input())
a,b = map(int,input().split())

found = False

for i in range(a,b+1):
	if i % k == 0:
		found = True
		break

if found:
	print("OK")
else:
	print("NG")
# Judge status: Wrong Answer
s=list(input())
s[0:3]=["2","0","1","8"]
print("".join(s))
# Judge status: Accepted
ab = input()
n = int(ab.replace(" ", ""))
for i in range(1000):
    if i * i == n:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
import math

n, d = map(int, input().split())
X = []

def dis(a, b):
  t = 0
  for i in range(d):
    t += (a[i] - b[i])**2
  t = t**(0.5)
  return t
C = []
for i in range(n):
  X.append(list(map(int, input().split())))
for i in range(n-1):
  for j in range(i+1, n):
    C.append(dis(X[i], X[j]))
ans = 0
for i in C:
  if int(i) == math.ceil(i):
    ans += 1
print(ans)
# Judge status: Accepted
N = int(input())
S = list(input())
data = [0] * (N + 2)
cnt = 0
for i in range(N):
    if S[i] == "#":
        cnt += 1
    data[i + 1] = cnt
data[-1] = cnt
ans = float("inf")
for i in range(N + 1):
    turn = data[i] + N - i - data[-1] + data[i]
    if ans > turn:
        ans = turn
print(ans)
# Judge status: Accepted
def resolve():
	n = int(input())
	div4 = 0
	div2 = 0
	divn = 0
	for i in list(map(int, input().split())):
		if i % 4 == 0:
			div4 += 1
		else:
			if i % 2 == 0:
				div2 += 1
			else:
				divn += 1
	if div2:
		divn += 1
	if div4 + 1 >= divn:
		print('Yes')
	else:
		print('No')
resolve()
# Judge status: Accepted
for i in range(int(input()), 1000):
  if i//100 == (i//10)%10 == i%10:
    print(i)
    break
# Judge status: Wrong Answer
import numpy as np
import sys

n, k = map(int, input().split())
dp = np.full(n, 10005, dtype=int)
h = np.array([int(x) for x in input().split()])
dp[0] = 0
for i in range(n):
	j = 0
	while i - j >= 0 and j <= k:
		dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
		j += 1
print(dp[n - 1])
# Judge status: Accepted
n=int(input())
a=[int(input()) for _ in range(n)]+[0]

ans=0
cnt=0

for aa in a:
    if aa==0:
        ans+=cnt//2
        cnt=0
    else:
        cnt+=aa

print(ans)
# Judge status: Accepted
import re
s,t=input().replace(*"?."),input()
l,m,*c=len(s),len(t)
for i in range(l-m+1):
 if re.match(s[i:i+m],t):c+=(s[:i]+t+s[i+m:]).replace(*".a"),
print(c and min(c)or"UNRESTORABLE")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print("Yes" if c==b or c==a or c==a+b else "No")
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
*P, = map(int, input().split())
*Q, = map(int, input().split())
*R, = map(int, input().split())
P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
print(sum(sorted(P + Q + R, reverse=True)[:X + Y]))
# Judge status: Wrong Answer
from bisect import bisect_left, bisect_right
n = int(input())
alis = sorted(list(map(int, input().split())))
blis = list(map(int, input().split()))
clis = sorted(list(map(int, input().split())))
ans = 0
for b in blis:
    up = bisect_right(alis, b)
    down = n - bisect_left(clis, b)
    ans += up*down
print(ans)
# Judge status: Accepted
X,Y=map(int,input().split())

ans=0
while X<=Y:
    X*=2
    ans+=1
print(ans)
# Judge status: Accepted
n = input()
int_n = int(n)
# len(n)桁のうち、オール9、もしくは1つを除いて9、が答え候補。候補を全探索

le = len(n)
nines = 10 ** le - 1
if nines == int_n:
    print(le*9)
    exit()

ans = 0

for i in range(le):
    for dif in range(1, 10):
        candi = nines - dif * 10 ** i
        if 9 * le - dif >= ans and candi <= int_n:
            ans = 9 * le - dif

print(ans)
# Judge status: Accepted
n = int(input())
numlist = []
i = 2
ans = 0

while i * i <= n + 1:
    count = 0
    while n % i == 0:
        count += 1
        n //= i
    i += 1
    if count != 0:
        numlist.append(count)
if n != 1:
    numlist.append(1)

while len(numlist) != 0:
    i = 1
    a = numlist.pop(0)
    while a - i >= 0:
        a -= i 
        i += 1
        ans += 1
print(ans)
# Judge status: Wrong Answer
def resolve():
    n = input()
    ln = list()
    for i in range(10):
        ln.append(0)
    
    for c in n:
        num = int(c)
        ln[num] += 1
    
    ans = ""
    for i in range(10):
        if ln[i] >= 3:
            ans = "Yes"
            break
    if ans == "Yes":
        print("Yes")
    else:
        print("No")
resolve()
# Judge status: Accepted
a,b = map(int, input().split())
for i in range(1,10000):
  if i*8//100 == a:
    if i*10//100 == b:
      print(i)
      break
else:
  print(-1)
# Judge status: Accepted
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    l, r, d = map(int, input().split())
    print(r // d - (l - 1) // d)
resolve()
# Judge status: Accepted
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans = 0
for v in [7,56,73,84,146,273,292,448]:
  ans |= f&v==v;
print('Yes' if ans else 'No')
# Judge status: Wrong Answer
N=int(input())
A=int(input())
N//=500
if A<N:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
 
ans = A[0]
for i in range(1, N-1):
    ans += A[(i+1)//2]
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split())) + [-1]
m = 1000
s = 0
for i in range(N):
    if A[i+1]>A[i]:
        n = m//A[i]
        s += n
        m %= A[i]

    if A[i+1]<A[i]:
        m += s*A[i]
        s = 0

print(m)
# Judge status: Wrong Answer
k, R, a = int(input()), 7, -1
for i in range(1, k+10):
    if not R:
        a = i
        break
    R = (R * 10 + 7) % k
print(a)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n+1)

i = n
while i > 0:
    cnt = 0
    for j in range(1, n):
        if i * j  > n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(n+1):
    if ans[i] == 1:
        print(i)
# Judge status: Accepted
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]

s_A = sorted(A)

cost = 0
bought = 0
for n in range(N):
  if bought + s_A[n][1] < M:
    bought += s_A[n][1]
    cost += s_A[n][0]*s_A[n][1]
  else:
    cost += s_A[n][0]*(M-bought)
    break
    
print(cost)
# Judge status: Wrong Answer
K, S = map(int, input().split())
count = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if S == x+y+z:
            count += 1

print(count)
# Judge status: Accepted
n,x = map(int,input().split())
l = list(map(int,input().split()))
d = 0
count = 1
for i in range(n):
    d += l[i]
    if d <= x:
      count += 1
    else:
      print(count)
      exit()
print(count)
# Judge status: Wrong Answer
a = list(map(int, input().split()))
print("YES" if a[0]== a[2] == 5 and a[1] == 7 else "NO")
# Judge status: Wrong Answer
o = list(input())
e = list(input())
w = [a + b for a, b in zip(o, e)]
print(*w, sep='')
# Judge status: Accepted
import math

x = int(input())
y = (x*360)//math.gcd(x,360)//x
print(y)
# Judge status: Accepted
n = int(input())
a = int(input())
print("Yes" if n%500 <= a else "No")
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))
if N == 1:
    print('Yes')
    exit()
if N == 2:
    if H[0] - H[1] > 1:
        print('No')
        exit()
    else:
        print('Yes')
        exit()
for i in range(N-1,0,-1):
    if H[i] < H[i-1]:
        H[i-1] -= 1
    if H[i] < H[i-1]:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
a, b = map(int, input().split())
num = 1
for i in reversed(range(1, min(a, b)+1)):
    if a % i == 0 and b % i == 0:
        a = a / i
        b = b / i
        num = i
        break

print(int(a*b*num))
# Judge status: Wrong Answer
A, B, K = map(int, input().split())
if A>=K:
    A = A - K
    print(A,B)
else:
    A = 0
    B = max(0,B-(K-A))
    print(A,B)
# Judge status: Accepted
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
x,y=map(int,input().split())
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))

if (A.index(1)+1)>=K and (N-A.index(1))>=K:
  ans=-(-A.index(1))//(K-1)-(-N+A.index(1)+1)//(K-1)
else:
  ans=1-(-N+K)//(K+1)
print(ans)
# Judge status: Wrong Answer
import  math
x=math.pi

r=int(input())
print(int((r*r*x)/x))
# Judge status: Accepted
dish=[int(input()) for i in range(5)]
dish_s=[(dish[i]+9)//10 for i in range(5)]
dish_d=[dish[i]%10 for i in range(5)]
sum=0
for i in range(5):
  sum+=dish_s[i]
m=0
for i in range(5):
  if dish_s[i]*10-dish[i]>m:
    m=dish_s[i]*10-dish[i]  
print(sum*10-m)
# Judge status: Accepted
n=int(input())
hoge=list(map(int,input().split()))
d0,d2,d4=0,0,0
for i in range(n):
  if(hoge[i]%4==0):
    d4+=1
  elif(hoge[i]%2==0):
    d2+=1
  else:
    d0+=1
if(d2!=0):
  d0+=1  
if(d0-d4>1):
  print("No")
else:
  print("Yes")
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())
Q, R = divmod(n, 2)
ans = Q*min([8*q, 4*h, 2*s, d]) + R*min([4*q, 2*h, s])
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
if N % 2 == 1:
    for a, b in zip(range(1, M+1), range(2*M, M, -1)):
        print(a, b)
else:
    for a, b in zip(range(1, M+1), range(M+1, 0, -1)):
        if a < b:
            print(a, b)
        else:
            break

    for a, b in zip(range(M+3, 2*M+2), range(2*M+2, M, -1)):
        if a < b:
            print(a, b)
        else:
            break
# Judge status: Accepted
import math
n,k=map(int, input().split())
a=list(map(int, input().split()))
right=max(a)
left=0
def cutable(a,x):
    count=0
    for i in a:
        count+=math.ceil(i/x)-1
    return count<=k
while right>left+1:
    mid=(right+left)//2
    if cutable(a,mid):
        right=mid
    else:
        left=mid
print(right)
# Judge status: Accepted
n,k = map(int, input().split())
al = list(map(int, input().split()))

ok, ng = 10**9+1, 0
while abs(ok-ng) > 1:
    mid = (ok+ng) // 2
    # mid = (ok+ng) / 2
    cnt = 0
    for a in al:
        a_cnt = (a-1)//mid
        cnt += max(0,a_cnt)

    if cnt <= k:
        ok = mid
    else:
    	ng = mid

print(ok)
# Judge status: Wrong Answer
S = input()
T = input()
if S in T and len(S) == len(T)-1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
k = int(input())
now = k
r = 0
for i in range(1, k + 100):
    r = (r * 10 % k + 7) % k
    if r==0:
        print(i)
        exit()
print(-1)
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
x=int(input())
l=make_divisors(x)
ll=[(i,i-j) for i in range(200) for j in l]
for a,b in ll:
  if a**5-b**5==x:
    print(a,b)
    break
# Judge status: Accepted
a = int(input())
s = input()
if a>=3200:
    print(s)
else:
    print("red")
# Judge status: Wrong Answer
a,b=map(int,input().split())
if (a+b)%2==0:
    if a+b<19:
        print("Yay!")
    else:
        print(":(")
else:
    if a+b<15:
        print("Yay!")
    else:
        print(":(")
# Judge status: Accepted
n=int(input())
a=int(input())
if n%500<=a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
count = {}
max_count = 0
for _ in range(N):
  s = input()
  if s not in count:
    count[s] = 0
  count[s] += 1
  max_count = max(max_count, count[s])

longest = []
for s, c in count.items():
  if c == max_count:
    longest.append(s)

longest.sort()
for s in longest:
  print(s)
# Judge status: Accepted
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()
    s = 0
    for i in range(1, n+1):
        m = n // i
        l = (m*(m+1)) // 2
        s += i*l
    return s


if __name__ == "__main__":
    print(main())
# Judge status: Wrong Answer
s = input()

if s[-1] == 's':
  print(s[0:-1] + 'es')
else:
  print(s + 's')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ans = 0
A.sort()
a=0
b=0
c=1

for i in range(N-1):
  if A[i] == A[i+1]:
    a += 1
    b += 1
    c += 1
  else:
    if ans < a:
      ans = a
    a = b
    a += 1
    b = c
    b += 1
    c = 1
    
print(ans)
# Judge status: Accepted
LI = lambda: list(map(int, input().split()))

N = int(input())
D = [LI() for _ in range(N)]


def main():
    m = 0
    x = 0
    for a, b in D:
        if a == b:
            x += 1
            m = max(m, x)
        else:
            x = 0
    ans = "Yes" if m >= 3 else "No"
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))

col = [0 for _ in range(9)]
for a in A:
  if a >= 3200:
    col[8] += 1
    continue
  col[a//400] = 1
  
ans_min = sum(col[:-1])
if ans_min == 0 and col[-1] != 0:
  ans_min = 1
print(ans_min, sum(col))
# Judge status: Accepted
n,x = map(int,input().split())
l = list(map(int, input().split()))

ans = 1
tmp = 0
for i in l:
    tmp += i
    if(tmp > x):
        break
    ans += 1
print(ans)
# Judge status: Wrong Answer
n=input()
print('Yes' if n.count(n[0])==3 or n.count(n[1])==3 else 'No')
# Judge status: Wrong Answer
s = int(input())

a = []

for i in range(1000000):
    if s % 2:
        s = 3*s +1
    else:
        s = s//2
    if s in a:
        print(i+1)
        break
    a.append(s)
# Judge status: Wrong Answer
n = int(input())
lis = list(map(int, input().split()))
odd_flag = 0
count = 0

while odd_flag == 0:
    for i in range(0, n):
        if lis[i] % 2 == 0:
            lis[i] = lis[i]/2
            count += 1/n
        else:
            odd_flag = 1

ans = int(count)


print(ans)
# Judge status: Wrong Answer
input()
s = input()

m = 0
ans = 0
for q in s:
    d = 1 if q == "I" else -1
    if m < m + d:
        ans = m + d
    m = m + d

print(0 if ans < 0 else ans)
# Judge status: Accepted
import math
n,d = map(int, input().split())

cnt = 0
for i in range(n):
  x,y = map(int, input().split())
  temp = (x**2) + (y**2)
  ans = math.sqrt(temp)
  if ans <= d:
    cnt += 1

print(cnt)
# Judge status: Accepted
import heapq

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]
B = sorted(B, key = lambda x: x[1])[::-1]

heapq.heapify(A)
cnt = 0
for i in range(M):
    for _ in range(B[i][0]):  heapq.heappush(A, max(heapq.heappop(A), B[i][1]))
    cnt += B[i][0]
    if cnt >= N:  break
print(sum(A))
# Judge status: Accepted
from math import pi
R = int(input())
print(R*2*pi)
# Judge status: Wrong Answer
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print((math.ceil(a/10)+math.ceil(b/10)+math.ceil(c/10)+math.ceil(d/10)+math.ceil(e/10))*10)
# Judge status: Accepted
a,b,c,d,e = map(int, input().split())
ans = 15 - sum([a,b,c,d,e])
print(ans)
# Judge status: Accepted
from collections import deque

def main():
  n,k=map(int,input().split())
  s=input()
  # maked group
  t=[]
  t.append(s[0])
  x=s[0]
  for i in range(1,n):
    if x!=s[i]:
      t.append(s[i])
      x=s[i]
  #print(t)
  
  j=0
  t=deque(t)
  while j<k:
    if len(t)<=2:
      print(n-1)
      exit(0)
    t.popleft()
    t.popleft()
    j+=1
    
  print(n-1-(len(t)-1))

  
if __name__=='__main__':
  main()
# Judge status: Accepted
import math
n, k = list(map(int,input().split()))
a = list(map(int,input().split()))

def lte_k(x, len_list):
    counter = 0
    for item in len_list:
        counter += math.ceil(item / x) - 1
    return counter <= k

def binary_search():
    low = 0
    high = max(a)

    while low < high-1:
        mid = (low + high) // 2
        guess = lte_k(mid, a)
        if guess:
            high = mid
        else:
            low = mid
    return high

print(binary_search())
# Judge status: Accepted
M,N = list(map(int,input().split()))
A = list(map(int,input().split()))
A.append(M+A[0])
dis = 0
for i in range(N):
    if A[i+1]-A[i] >= dis:
        dis = A[i+1]-A[i]
print(M-dis)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

x = [int(x) for x in input().split()]
for i in range(5):
    if x[i] == 0:
        print(i + 1)
        sys.exit()
# Judge status: Accepted
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)
elif n <= 1:
    print(ncr(m,2))
elif m <= 1:
    print(ncr(n,2))
else:
    print(ncr(m,2) + ncr(n,2))
# Judge status: Wrong Answer
s = input()


s1 = s[0:len(s)//2]
s2 = s[len(s)//2+1:len(s)]

print(s1, s2)
def reverse(s): 
    return s[::-1]

def isPalindrome(s): 
    rev = reverse(s) 
  
    if (s == rev): 
        return True
    return False

if isPalindrome(s1):
    if isPalindrome(s2):
        if s1==s2:
            print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    N,M,K = map(int,input().split())
    if K == 0 or K == N*M:
        return ('Yes')
    ans_dict = {}
    ans_dict[K] = False
    for i in range(N):
        for j in range(M+1):
            ans_dict[i*M + (N-i-i)*j] = True
    if ans_dict[K] == True:
        return('Yes')
    else:
        return('No')

print(main())
# Judge status: Wrong Answer
# B - Checkpoints
def main():
    n, m = map(int, input().split())
    a_b = [input().split() for i in range(n)]
    c_d = [input().split() for i in range(m)]

    for i in range(m):
        temp = []
        for j in range(n):
            temp.append(abs(int(a_b[j][0])-int(c_d[i][0]))+abs(int(a_b[j][1])-int(c_d[i][1])))
        else:
            print(temp.index(min(temp))+1)


        
if __name__ == '__main__':
    main()
# Judge status: Accepted
S,M=map(int,input().split())
if S<(M//2):
  if (M-2*S)<4:
    print(S)
  else:
    print(S+((M-2*S)//4))
else:
  print(M//2)
# Judge status: Accepted
N=int(input())
S=[input() for j in range(N)]

A=set(S)
print(len(A))
# Judge status: Accepted
# unihernandez22
# https://atcoder.jp/contests/abc166/tasks/abc166_e
# hashing, math, implementation
n = int(input())
a = list(map(int, input().split()))

x = []
y = {}

for i, elem in enumerate(a):
    x.append(i+a[i])
    y[i-a[i]] = y.get(i-a[i], 0) + 1

ans = 0

for i in x:
    ans += y.get(i, 0)

print(ans)
# Judge status: Accepted
s = str(input())
ans = [0 for _ in range(len(s)+1)]
for i in range(len(s)):
    if(s[i] == '<'):
        ans[i+1] = ans[i]+1
for i in range(len(s),0,-1):
    if(s[i-1] == '>'):
        ans[i-1] = max(ans[i-1],ans[i]+1)
print(sum(ans))
# Judge status: Wrong Answer
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
counter_list = []
for i in range(N):
    if a_list.count(i) > 0:
        counter_list.append(a_list.count(i))

counter_list.sort()

count = 0
for i in range(len(counter_list) - K):
    count += i

print(count)
# Judge status: Accepted
def main():
    x, y, a, b, c = list(map(int, input().split()))
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))
    P = sorted(P, reverse = True)[:x]
    Q = sorted(Q, reverse = True)[:y]
    ans = sorted(P + Q + R, reverse = True)
    print(sum(ans[:x + y]))

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c = map(int,input().split())
if a+b+c >= 22:
  print('bust')
else:
  print('win')
# Judge status: Wrong Answer
r,g,b=map(int,input().split())
R=str(r)
G=str(g)
B=str(b)
l=(R+G+B)
L=int(l)
if L%4==0:
    print('YES')
else:
    print('No')
# Judge status: Accepted
n=int(input())
A=[]
for i in range(n):
    A.append(int(input()))
c=1
count=-1
for i in range(1,n+1):
    c=A[c-1]
    if c==2:
        count=i
        break
print(count)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print(min(b%a,c))
# Judge status: Wrong Answer
L=int(input())
L1=(L//3)
L2=L%3
while L2>=10**-8:
    L1+=(L2/3)
    L2=(L2/3)

print(float(L1**3))
# Judge status: Wrong Answer
a=input()
print(a)
print(a[0:3])