Harryxun/stf_run huggingface dataset:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

def mCn(m,n):
    return math.factorial(m)//(math.factorial(n)*math.factorial(m-n)) % mod
#modに対応して高速なコンビネーションが求められる
# 階乗 & 逆元計算
n = 10**5
factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))

def combinations_count(n,r):
    if n-r < 0:
        return 0
    return factorial[n]*inverse[r]*inverse[n-r]%mod


ans = 0
for i in range(1,M):
    ans += (M-i)*N**2*i*(combinations_count(M*N-2,K-2))
    if ans > mod:
        ans = ans % mod

for i in range(1,N):
    ans += (N-i)*M**2*i*(combinations_count(M*N-2,K-2))
    if ans > mod:
        ans = ans % mod

print(ans)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

def mCn(m,n):
    return math.factorial(m)//(math.factorial(n)*math.factorial(m-n)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N1 = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N1 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(1,M):
    ans += (M-i)*N**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

for i in range(1,N):
    ans += (N-i)*M**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

print(ans)
a,b =input.split()

b = int(b*100)

print((a*b)//100)

### FIXED CODE ###

a,b =input().split()
a = int(a)
b = b.replace('.','')
print(a*int(b)//100)
a,b,c=map(int,input().split())
n=c-a-b
if　n**2 > 4*a*b:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = list(input())
score = 0
for i in range(k):
    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    else:
        score += s
 
for i in range(k, len(t)):
    if t[i] != t[i-k]:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        else:
            score += s
    else:
        t[i] = ""
 
print(score)
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = list(input())
score = 0
for i in range(k):
    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    else:
        score += s

for i in range(k, len(t)):
    if t[i] != t[i-k]:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        else:
            score += s
    else:
        t[i] = ""

print(score)

### FIXED CODE ###

n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = list(input())
score = 0
for i in range(k):
    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    else:
        score += s
 
for i in range(k, len(t)):
    if t[i] != t[i-k]:
        if t[i] == "r":
            score += p
        elif t[i] == "s":
            score += r
        else:
            score += s
    else:
        t[i] = ""
 
print(score)
s = str(input())
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] or s[3] == s[4]:
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

s = str(input())
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
    print('Bad')
else:
    print('Good')
s=input()
t=input()
n=len(s)-len(t)+1
lst=[]
for i in range(n):
    tot=0
    ss=s
    for j in range(len(t)):
        if ss[i+j]==t[j] or ss[i+j]=="?":
            tot+=1
    if tot==len(t):
        for j in range(len(t)):
            ss[i+j]=t[j]
        ss=ss.replace("?","a")
        lst.append(ss)
lst.sort()
print(lst[0] if len(lst)!=0 else "UNRESTORABLE" )

### FIXED CODE ###

s=input()
t=input()
n=len(s)-len(t)+1
lst=[]
for i in range(n):
    tot=0
    ss=s
    for j in range(len(t)):
        if ss[i+j]==t[j] or ss[i+j]=="?":
            tot+=1
    if tot==len(t):
        ss=list(ss)
        t=list(t)
        for j in range(len(t)):
            ss[i+j]=t[j]
        ss="".join(ss)
        t="".join(t)
        ss=ss.replace("?","a")
        lst.append(ss)
lst.sort()
print(lst[0] if len(lst)!=0 else "UNRESTORABLE" )
import math
n = int(input())
M = list(map(int, input().split()))
X = [math.abs(x) for x in M]
print(sum(X) - min(X)*2)

### FIXED CODE ###

import math
n = int(input())
M = list(map(int, input().split()))
p = [q < 0 for q in M].count(True)
X = [abs(x) for x in M]
if p % 2 == 0:
    print(sum(X))
else:
    print(sum(X) - min(X)*2)
H,W,M = map(int,input().split())

horizontal = [[i,0] for i in range(H)]
vertical = [[i,0] for i in range(W)]
table = [[0]*W for _ in range(H)]

for i in range(M):
    h,w = map(int,input().split())
    h -= 1
    w -= 1
    table[h][w] = 1
    vertical[w][1] += 1
    horizontal[h][1] += 1

vertical.sort(key=lambda x:-x[1])
horizontal.sort(key = lambda x:-x[1])

h_max = horizontal[0][1]
v_max = vertical[0][1]
    
for i in range(H):
    if horizontal[i][1]<h_max:
        break
for j in range(W):
    if vertical[j][1]<v_max:
        break

flag = False
for h in horizontal[:i]:
    for v in vertical[:j]:
        if table[h[0]][v[0]] == 0:
            print(h,v)
            flag = True
            break
    if flag:
        break

if flag:
    print(h_max+v_max)
else:
    print(h_max+v_max-1)

### FIXED CODE ###

H,W,M = map(int,input().split())

horizontal = [[i,0] for i in range(H)]
vertical = [[i,0] for i in range(W)]
table = {}

for i in range(M):
    h,w = map(int,input().split())
    h -= 1
    w -= 1
    table[(h,w)] = True
    vertical[w][1] += 1
    horizontal[h][1] += 1

vertical.sort(key=lambda x:-x[1])
horizontal.sort(key = lambda x:-x[1])

h_max = horizontal[0][1]
v_max = vertical[0][1]
    
for i in range(H):
    if horizontal[i][1]<h_max:
        i -= 1
        break
for j in range(W):
    if vertical[j][1]<v_max:
        j -= 1
        break

flag = False
for h in horizontal[:i+1]:
    for v in vertical[:j+1]:
        if table.get((h[0],v[0]))==None:
            flag = True
            break
    if flag:
        break

if flag:
    print(h_max+v_max)
else:
    print(h_max+v_max-1)
n, y = map(int, input().split())
ans = 0
for i in range(n+1):
    for j in range(n-i+1):
        if (10000*i + 5000*j +1000(n-i-j)) ==y:
            print(i, j, n-i-j)
        else:
            print('-1 -1 -1')

### FIXED CODE ###

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

for i in range(n+1):
    for j in range(n-i+1):
        if 10000 * i + 5000 * j + 1000 * (n-i-j)==y:
            print(i, j, n-i-j)
            exit()
print("-1 -1 -1")
import itertools
n=int(input())
A=[]
for i in range(n):
  A.append(list(map(int,input().split())))
  
def kaijo(x):
  if x==1:
    return x
  return x*kaijo(x-1)

def dist(x,y):
  return ((A[x][0]-A[y][0])**2+(A[x][1]-A[y][1])**2)**(1/2)

DIST=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
  for j in range(n):
    DIST[i][j]=dist(i,j)
    
ans=[]   
for Q in itertools.permutations(n):
  t=0
  for i in range(n-1):
    t+=DIST[i][i+1]
  ans.append(t)
print(sum(ans)/kaijo(n))

### FIXED CODE ###

#n個の都市を好きな都市から出発してすべての都市を１度だけ訪れる最短時間
#全ての都市の組i,jについてi,jを結ぶ道がある

import itertools
n=int(input())
A=[]
for i in range(n):
  A.append(list(map(int,input().split())))
  
def kaijo(x):
  if x==1:
    return x
  return x*kaijo(x-1)

def dist(x,y):
  return ((A[x][0]-A[y][0])**2+(A[x][1]-A[y][1])**2)**(1/2)

DIST=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
  for j in range(n):
    DIST[i][j]=dist(i,j)
    
ans=[]   
for Q in itertools.permutations([i for i in range(n)]):
  t=0
  for i in range(n-1):
    t+=DIST[Q[i]][Q[i+1]]
  ans.append(t)
  
print(sum(ans)/kaijo(n))
A,B,C,D,E,F=map(int, raw_input().split())
noudo=int(float(E)/(100+E)*100)

a=[]
for i in range(noudo):
	for j in range(noudo):
		#print i,j
		if i*C+D*j<=noudo:
			a.append(i*C+D*j)

b=[]
cnt=F/100
for i in range(cnt):
	for j in range(cnt):
		if i*100+j*100<=F and i*100+j*100!=0:
			b.append(i*100+j*100)


noudo=float(E)/(100+E)*100
max_noudo=0
for i in a:
	for j in b:
		t_noudo=float(i)/(i+j)*100
		if t_noudo>max_noudo:
			max_noudo=t_noudo
			ans=i,j

print ans[0],ans[1]




### FIXED CODE ###

# -*- coding: utf-8 -*-
A,B,C,D,E,F=map(int, raw_input().split())
#print A,B,C,D,E,F

sugar_list=[0]*(F+1)
i=0
while i <= F :
	for j in range(F):
		val=C*i+D*j
		if val > F:
			break
		elif val <= F:
			sugar_list[val]=1
	i+=1

#print "# Sugar"
#print sugar_list

#Water
water_list=[0]*(F/100+1)
#print water_list
loop_cnt=F/100+1

i=0
while i <= loop_cnt:
	for j in range(loop_cnt):
		val=A*i+B*j
		if val > F/100:
			break
		else:
			#print i,j,val
			water_list[val]=1
	i+=1

#print "# Water"
#print water_list

max_noudo=float(E)/(100+E)
#print max_noudo


hwm=0
water_ans=A*100
sugar_ans=0
for i in range(1,len(water_list)):
	for j in range(len(sugar_list)):
		if water_list[i]*sugar_list[j]==1 and i*100+j<=F and j<=i*E:
			if float(j)/(i*100+j)>hwm:
				hwm=float(j)/(i*100+j)
				water_ans=i*100
				sugar_ans=j
				

print water_ans+ sugar_ans, sugar_ans
N,A,B=map(int,input().split())
ans=0
if A>=N:
  ans=N
elif A<N<=A+B:
  ans=A
elif N>A+B:
  num=int(N/(A+B))
  ans=num*A+N-(A+B)*num
  if n-(A+B)*num>=A:
    ans=(num+1)*A
print(ans)



### FIXED CODE ###

N,A,B=map(int,input().split())
num=N//(A+B)
rest=min(N%(A+B),A)
ans=num*A+rest
print(ans)
from collections import defaultdict

def bellman_ford(V, E, s):
    '''
    Input:
        V = list(range(N))
        E = {i: defaultdict(int) for i in range(N)}
        s (in V) : start vertex
    Output:
        dist: the list of the minimum cost from s to arbitrary vertex v in the given graph
    '''
    INF = float('inf')
    N = len(V)
    dist = [INF]*N
    dist[s] = 0
    for n_iterations in range(N):
        updated = [False]*N
        for v in V:
            d = dist[v]
            if d != INF:
                for u, c in E[v].items():
                    temp = d + c
                    if dist[u] > temp:
                        updated[u] = True
                        dist[u] = temp
                        prev[u] = v
        if sum(updated) == 0: # the minimum costs are already stored in dist
            break
    else: # the above loop is not broken if and only if there exists a negative cycle
        if updated[N-1]: return None
        else: return dist
    return dist

N, M = map(int, input().split())
E = {i: defaultdict(int) for i in range(N)}
for _ in range(M):
    a, b, c = map(int, input().split())
    E[a-1][b-1] = -c
V = list(range(N))
dist = bellman_ford(V, E, 0)
if dist is None:
    print('inf')
else:
    print(-dist[N-1])

### FIXED CODE ###

from collections import defaultdict

def bellman_ford(V, E, s):
    '''
    Input:
        V = list(range(N))
        E = {i: defaultdict(int) for i in range(N)}
        s (in V) : start vertex
    Output:
        dist: the list of the minimum cost from s to arbitrary vertex v in the given graph
    '''
    INF = float('inf')
    N = len(V)
    dist = [INF]*N
    dist[s] = 0
    for n_iterations in range(N):
        updated = [False]*N
        for v in V:
            d = dist[v]
            if d != INF:
                for u, c in E[v].items():
                    temp = d + c
                    if dist[u] > temp:
                        updated[u] = True
                        dist[u] = temp
        if sum(updated) == 0: # the minimum costs are already stored in dist
            break
    else: # the above loop is not broken if and only if there exists a negative cycle
        if updated[N-1]: return None
        else: return dist
    return dist

N, M = map(int, input().split())
E = {i: defaultdict(int) for i in range(N)}
for _ in range(M):
    a, b, c = map(int, input().split())
    E[a-1][b-1] = -c
V = list(range(N))
dist = bellman_ford(V, E, 0)
if dist is None:
    print('inf')
else:
    print(-dist[N-1])
N = int(input())
alist = map(int, input().split())
alist.sort()
alist.reverse()
score_a = sum(alist[::2])
score_b = sum(alist[1::2])
print(score_a - score_b)

### FIXED CODE ###

N = int(input())
alist = list(map(int, input().split(" ")))
alist.sort()
alist.reverse()
score_a = sum(alist[::2])
score_b = sum(alist[1::2])
print(score_a - score_b)
l=[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
print( l[int(input())+1])

### FIXED CODE ###

print([1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51][int(input())-1])
n = int(input())
lis = list(map(int, input().split()))
lis2 = sorted(lis)
m1 = lis2[n/2-1]
m2 = lis2[n/2]

c = 0
for i in range((m1+1), (m2+1)):
    c += 1
print(c)


### FIXED CODE ###

n = int(input())
lis = list(map(int, input().split()))
lis2 = sorted(lis)
m1 = lis2[n//2-1]
m2 = lis2[n//2]

c = 0
for i in range((m1+1), (m2+1)):
    c += 1
print(c)
h,w=map(int,raw_input().split())
print("%d %d"%(h*w,h*2+w*2))

### FIXED CODE ###

h,w=map(int,raw_input().split())
print("%d %d"%(h*w,h*2+w*2))
from math import factorial

def count_pattern(n, r):
    if r == 0:
        return 1
    else:
        a = factorial(n) // factorial(r) // factorial(n - r)
    return int(a)

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

for i in range(k):
    pick_count = i + 1

    blue_pattern =  count_pattern(k - 1, pick_count - 1)
    red_pattern = count_pattern(n - k + 1 , pick_count)
    total_pattern = blue_pattern * red_pattern
    print (int(total_pattern % (10 ** 9 + 7)))


### FIXED CODE ###

from math import factorial

def count_pattern(n, r):
    if r == 0:
        return 1
    elif n < r:
        return 0
    else:
        a = factorial(n) // factorial(r) // factorial(n - r)
    return int(a)

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

for i in range(k):
    pick_count = i + 1

    blue_pattern =  count_pattern(k - 1, pick_count - 1)
    red_pattern = count_pattern(n - k + 1 , pick_count)
    total_pattern = blue_pattern * red_pattern
    print (int(total_pattern % (10 ** 9 + 7)))
N = int(input())
Hlist = list(map(int, input().split()))

H1 = Hlist[0]
H2 = Hlist[1]

ans = 1
if H2 >= H1:
    ans += 1

for i in range(2, N):
    if Hlist[i] >= H1 and Hlist[i] >= H2 and Hlist[i] >= Hlist[i-1]:
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
H = list(map(int, (input().split())))
c = 0
nax = 0
for i in range(N):
    nax = max(nax, H[i])
    if H[i] == nax:
        c += 1
print(c)
import math

n = int(input())

for i in range(0, n):
    a = int(input())
    b = int(input())
    if int(math.log10(a + b)) + 1 > 80:
        print("overflow")
    else :
        print(a + b)

### FIXED CODE ###

n = int(input())

for i in range(0, n):
    a = int(input())
    b = int(input())
    if len(str(a + b)) > 80:
        print("overflow")
    elif len(str(a)) > 80:
        print("overflow")
    elif len(str(b)) > 80:
        print("overflow")
    else :
        print(a + b)
n, m, x = map(int, input().split())
trainlist = {}
for i in range(m):
    a, b = map(str, input().split())
    k = "".join([a.zfill(2), "-", b.zfill(2)])
    if k in trainlist:
        trainlist[k] = trainlist[k] + 1
    else:
        trainlist[k] = 1
        
for i in range(x):
    s, t = map(int, input().split())
    ans = 0
    for w in trainlist:
        if s <= int(w[0])*10+int(w[1]) and int(w[3])*10+int(w[4]) <= t:
            ans += trainlist[w]
    print(ans)

### FIXED CODE ###

n, m, q = map(int, input().split())
ans = [[0]*n for _ in range(n)]
for i in range(m):
  l, r = map(int, input().split())
  ans[l-1][r-1] += 1

for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans[i][j] += ans[i][j-1]
for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans [i][j] += ans[i+1][j]

for _ in range(q):
  p, q = map(int, input().split())
  print(ans[p-1][q-1])
N, M = map(int, input().split())
A = list(set(map(int, input().split())))

### 解説より、
while not any(x % 2 for x in A):
    A = [i // 2 for i in A]
 
if not all(x % 2 for x in A):
    print(0)
    exit()
### ###

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)

ans = A[0]
for i in range(1, N):
    ans = lcm(ans, A[i])
    
print((M // ans + 1) // 2)

### FIXED CODE ###

import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]
 
def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
LCM=A[0]
for i in range(1,N):
    LCM=lcm(LCM,A[i])
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)
s=str(input())
q=int(input())

right=[]
left=[]
flag=0

for i in range(q):
    a = input()
    if int(a[0]) == 1:
        if flag == 0:
            flag=1
        else:
            flag=0
    else:
        if int(a[2]) == 1:
            if flag == 0:
                left.append(0,a[4])
            else:
                right.append(a[4])
        elif int(a[2]) ==2:
            if flag ==0:
                right.append(a[4])
            else:
                left.append(0,a[4])

right_result="".join(right)
left_result="".join(left)

if flag==0:
    print(str(left_result[::-1]+s+right_result))
else:
    print(str(right_result[::-1]+s[::-1]+left_result))


### FIXED CODE ###

s=str(input())
q=int(input())

right=[]
left=[]
flag=0

for i in range(q):
    a = input()
    if int(a[0]) == 1:
        if flag == 0:
            flag=1
        else:
            flag=0
    else:
        if int(a[2]) == 1:
            if flag == 0:
                left.append(a[4])
            else:
                right.append(a[4])
        elif int(a[2]) ==2:
            if flag ==0:
                right.append(a[4])
            else:
                left.append(a[4])

right_result="".join(right)
left_result="".join(left)

if flag==0:
    print(str(left_result[::-1]+s+right_result))
else:
    print(str(right_result[::-1]+s[::-1]+left_result))
N = int(input())
if N % 2 ==0:
  print(N/2)
 
else:
  ptint(1+N/2)

### FIXED CODE ###

N = int(input())
if N % 2==0:
  print(int(N/2))
  
else:
  print(int((N/2)+1))
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [False] * n
now = 0
count = 0
history = [1]
flag = True

while b[now] == False:
  history.append(a[now])
  b[now] = True
  count += 1
  if count >= k:
    print(a[now])
    flag = False
    break
  if a[now]-1 == now:
    print(a[now])
    flag = False
    break
  now = a[now]-1
  
if flag == True:
  if now != 0:
    k -= now + 1
    history = history[now+1:]
  history.pop()
  print(history[k % len(history)])


### FIXED CODE ###

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [-1] * (n+1)
now = 1
history = []

while b[now] == -1:
  b[now] = len(history)
  history.append(now)
  now = a[now-1]

c = len(history) - b[now]
l = b[now]

if k < l:
  print(history[k])
else:
  k -= l
  k %= c
  print(history[l+k])
n = input()
s = 0
for i in n:
    s += n[i]

print(["No","Yes"][n%s == 0])

### FIXED CODE ###

n = int(input())
s = 0
for i in str(n):
    s += int(i)
print("Yes" if n%s == 0 else "No")
N = int(input())
H = list(map(int, input().split()))
for i in range(N):
    if H[i] > H[max(N - 1, i + 1)] + 1:
        print("No")
        exit()
    if i > 0:
        if H[i] < max(H[:i]) - 1:
            print("No")
            exit()
print("Yes")


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
M = 0
for i in range(1, N):
    M = max(M, H[i - 1])
    if H[i] < M - 1:
        print("No")
        exit()
print("Yes")
n = int(input())
nums = [int(i) for i in input().split()]
ans = 0
while Ture:
  if [i for i in nums if i % 2 == 1]:
    break
  nums = [ i//2 for i in nums]
  ans += 1
print(ans)


### FIXED CODE ###

s = input()
print(s.count("1"))
s = input()
a = 'YAKI'
ans = 0
for i in range(4):
    if s[i] == a[i]:
        ans = 1
    else:
        break
if ans == 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
a = 'YAKI'
ans = 0
if len(s) >= 4:
    for i in range(4):
        if s[i] == a[i]:
            ans = 1
        else:
            ans = 0
            break
if ans == 1:
    print('Yes')
else:
    print('No')
n,k= map(int,input().split())
td=[]
for i in range(n):
    td.append(list(map(int,input().split())))
td.sort(key=lambda x:x[1],reverse=True)
select=td[:k]
cat=list(set([tdi[0] for tdi in select]))
noselect=list(filter(lambda x: x[0] not in cat,td[k:]))
noselect.sort(key=lambda x:x[0])
noselect02=[]
noselect02.append(noselect[0])
for no in noselect[1:]:
    if no[0] != noselect[-1][0]:
        noselect.append(no)
        continue
    if no[1] > noselect[-1][1]:
        noselect[1]=no[1]

rs = sum([tdi[1] for tdi in select])+len(set([tdi[0] for tdi in select]))**2
for i in range(1,min(k,len(noselect)+1)):
    t = select[:-i]
    t[k-i:k-i] = noselect[:i]
    r = sum([tdi[1] for tdi in t])
    r += len(set([tdi[0] for tdi in t]))**2
    if rs < r:
        rs = r
print(rs)

### FIXED CODE ###

n,k= map(int,input().split())
td=[]
for _ in range(n):
    td.append(list(map(int,input().split())))
td.sort(key=lambda x:x[1],reverse=True)
NEW=[1]*(n+1)
x=0
y=0
TOP=[]
SUB=[]
A=[]
for tdi in td[:k]:
    if NEW[tdi[0]]==1:
        NEW[tdi[0]]=0
        TOP.append(tdi[1])
        y+=1
    else:
        A.append(tdi[1])
    x+=tdi[1]
    
for tdi in td[k:]:
    if NEW[tdi[0]]==1:
        SUB.append(tdi[1])
        NEW[tdi[0]]=0
ans=x+y**2
for i in range(min(k-1,len(A),len(SUB))):
    x -= A.pop()
    x += SUB[i]
    y += 1
    ans = max(ans,x+y**2)
print(ans)
H,K=map(int,input().split())
 
ln=list(map(int,input().split()))
 
sum=0

if K!=0:
	ln.sort(reverse=True)
	for A in range(K):
		ln[A]=0
 
for A in ln:
  sum+=A
 
print(sum)

### FIXED CODE ###

H,K=map(int,input().split())
 
s=list(map(int,input().split()))
 
sum=0

s.sort(reverse=True)

if K>=len(s):
  for A in range(len(s)):
    s[A]=0

else:
  for A in range(K):
    s[A]=0



for A in s:
  sum+=A
 
print(sum)
import math
A, B = map(int, input().split())
gcd = math.gcd(A, B)
ans = 1
for i in range(2, min(gcd, 1000000)):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
print(ans)

### FIXED CODE ###

import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)
N = int(input())
    A = list(map(int, input().split()))
    s = [0] * (N + 2)
    for i in range(N + 1):
        s[i + 1] = s[i] + A[i]
    node, leaf = 1, 1
    for d in range(1, N + 1):
        if leaf < A[d]:
            print(-1)
            break
        leaf = min((leaf - A[d - 1]) * 2, s[N + 1] - s[d])
        if leaf < A[d]:
            print(-1)
            break
        node += leaf
    else:
        print(node)

### FIXED CODE ###

N = int(input())
A_leaf = list(map(int, input().split()))
if N == 0:
    print(1 if A_leaf[0] == 1 else -1)
    exit()
s = [0]*(N+2)
for i in range(1, N+2):
    s[i] = s[i-1] + A_leaf[i-1]
node = [1]*(N+1)
for i in range(1, N+1):
    node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i])
    if node[i] < A_leaf[i]:
        print(-1)
        exit()
else:
    print(sum(node))
a=int(input())
b=int(input())
if a%2==0 or b%2==0:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

l = list(map(int, input().split()))
a=l[0]
b=l[1]
if a%2==0 or b%2==0:
    print("No")
else:
    print("Yes")