Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit("4000000")
def knap(n,w,weight,value,dp):
  #  print(n,":",w,":",len(dp),":",len(dp[n]))
    if dp[n][w]!=-1:
        return dp[n][w]
    if n==0:
        dp[n][w]=0
        return 0
    if w==0:
        dp[n][w]=0
        return 0
    if w-weight[n]<0:
        tmp2=knap(n-1,w,weight,value,dp)
        dp[n][w]=tmp2
        return tmp2
    tmp1=knap(n-1,w-weight[n],weight,value,dp)+value[n]
    tmp2=knap(n-1,w,weight,value,dp)
    if tmp1>tmp2:
        dp[n][w]=tmp1
        return tmp1
    else:
        dp[n][w]=tmp2
        return tmp2
        

n,W=map(int,input().split())
weight=[0]
value=[0]
for i in range(n):
    a,b=map(int,input().split())
    weight.append(a)
    value.append(b)
dp=[[-1]*(W+1)]*(n+1)
print(knap(n,W,weight,value,dp))



### FIXED CODE ###

N,W=map(int,input().split())
w=[]
v=[]
maxV=0
for i in range(N):
    a,b=map(int,input().split())
    if maxV<b:
        maxV=b
    w.append(a)
    v.append(b)
#dp[n個目のアイテムまでで][V以上を達成する]=最小のw
#dp[0][v]=inf ゼロ個でｖは無理なので
#dp[0][0]=0と初期化する
#だからiの時dp[i][v]=min(dp[i-1][v],dp[i-1][V-v[i-1]]+w[i])である<-i-1なのはvとかにはゼロ個とかないので
#V-v[i]<0ならば、とれないので前者になるね！！
#これをi=0(は初期化でする)->nまでおこない、各iについてはとりうる最大のValueを考えるが
#これは最大で各アイテムについて最大のVがあってこれにアイテム数Nを掛けたものである
#つまりdpのサイズはdp[0->N][0->maxV*N]をとればよい

dp=[[float("inf") for i in range(maxV*(N+1))] for j in range(N+1)]
dp[0][0]=0

for i in range(1,N+1):
    for val in range(maxV*N+1):
        tmp1=dp[i-1][val]#とらない
        if val-v[i-1]<0:#この時、iこめの価値がおおきいので、これをとるだけで達成してしまう
            tmp2=w[i-1]#i=1の時、dp[0][val]=inf
        else:#i=1の時val-v[0]>0で無限になるので
            tmp2=dp[i-1][val-v[i-1]]+w[i-1]#
        res=min(tmp1,tmp2)
        dp[i][val]=res
#ここでW以下となるvalの最大値をたんさくする
max=0
for value in range(len(dp[N])):
    if dp[N][value]<=W:
        if value>max:
            max=value
print(max)
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) == 1:
                count[j] += 1
        a += rieki[j][count[j]]
    
    if ans < a : ans = a 
print("{}".format(ans))
                

### FIXED CODE ###

N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))
x, n = map(int, input().split())
if n == 100:
    print("")
elif n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
nums = [n for n in range(1, 101) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])

### FIXED CODE ###

x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
    exit()
nums = [n for n in range(-1, 102) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])
S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]
	count += 1

print(count)

### FIXED CODE ###

S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]:
    count += 1

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


### FIXED CODE ###

r = int(input())
d = 3*(r**2)
print(d)
s=input()
if(len(s)>9):
    print("NO")
    quit()
i=0
for c in "AKIHABAR":
    if(s[i]==c):
        i+=1
    else:
        if(c=="A"):
            continue
        else:
            print("NO")
            quit()
print("YES")

### FIXED CODE ###

s=input()
if(len(s)>9):
    print("NO")
    quit()
i=0
for c in "AKIHABAR":
    if(len(s)==i):
      print("NO")
      quit()
    if(s[i]==c):
        i+=1
    else:
        if(c!="A"):
            print("NO")
            quit()
print("YES")
def main():
    n = int(input())
    a_list = []
    for _ in range(n):
        a = int(input())
        a_list.append(a)

    for i in a_list:
        if i == max(a_list):
            a_list.sort()
            print(a_list[-2])
        else:
            print(max(a))

main()

### FIXED CODE ###

def main():
    n = int(input())
    a_list = []
    for i in range(n):
        a = int(input())
        #[タグ、値]
        a_list.append([i,a])

    ans = sorted(a_list, key=lambda x:x[1])
    #print(ans)

    #print("-"*75)
    for i in range(n):
        #if 値 == max(ans)
        if a_list[i][1] == ans[-1][1]:
            #ansの最後から二番目の値
            print(ans[-2][1])
        else:
            print(ans[-1][1])

main()
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cntA = [0] * (N + 1)
cntB = [0] * (N + 1)
for i in range(N):
    cntA[A[i]] += 1
    cntB[B[i]] += 1
nums = [(cntA[i], cntB[i], i) for i in range(1, N+1)]
nums.sort(key=lambda p: p[0] + p[1], reverse=True)
a = deque()
b = deque()
c = deque(list(range(N)))
ansa = [0] * N
ansb = [0] * N
for x, y, n in nums:
    if x == y == 0:
        break
    if x + y > len(a) + len(b) + len(c):
        print('No')
        exit()
    if x + y <= len(c):
        for i in range(x):
            ansa[c[0]] = n
            b.append(c[0])
            c.popleft()
        for i in range(y):
            ansb[c[0]] = n
            a.append(c[0])
            c.popleft()
    else:
        m = x - len(a)
        if m > 0:
            for i in range(m):
                ansa[c[0]] = n
                b.append(c[0])
                c.popleft()
            x -= m
        m = len(c)
        for i in range(m):
            ansb[c[0]] = n
            a.append(c[0])
            c.popleft()
        y -= m
        for i in range(x):
            ansa[a[0]] = n
            a.popleft()
        for i in range(y):
            ansb[b[0]] = n
            b.popleft()
ans = []
for i in range(N):
    ans.append((ansa[i], ansb[i]))
ans.sort()
print('Yes')
print(*[p[1] for p in ans])

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cntA = [0] * (N + 1)
cntB = [0] * (N + 1)
for i in range(N):
    cntA[A[i]] += 1
    cntB[B[i]] += 1
nums = [(cntA[i], cntB[i], i) for i in range(1, N+1)]
nums.sort(key=lambda p: p[0] + p[1], reverse=True)
a = deque()
b = deque()
c = deque(list(range(N)))
ansa = [0] * N
ansb = [0] * N
for x, y, n in nums:
    if x == y == 0:
        break
    if x + y > len(a) + len(b) + len(c):
        print('No')
        exit()
    if x + y <= len(c):
        for i in range(x):
            ansa[c[0]] = n
            b.append(c[0])
            c.popleft()
        for i in range(y):
            ansb[c[0]] = n
            a.append(c[0])
            c.popleft()
    else:
        ra = x - len(a)
        rb = y - len(b)
        if ra > 0:
            for i in range(ra):
                ansa[c[0]] = n
                b.append(c[0])
                c.popleft()
            x -= ra
        if rb > 0:
            for i in range(rb):
                ansb[c[0]] = n
                a.append(c[0])
                c.popleft()
            y -= rb
        while len(c):
            if x:
                ansa[c[0]] = n
                b.append(c[0])
                x -= 1
            else:
                ansb[c[0]] = n
                a.append(c[0])
                y -= 1
            c.popleft()
        for i in range(x):
            ansa[a[0]] = n
            a.popleft()
        for i in range(y):
            ansb[b[0]] = n
            b.popleft()
ans = []
for i in range(N):
    ans.append((ansa[i], ansb[i]))
ans.sort()
print('Yes')
print(*[p[1] for p in ans])
import itertools
N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
s=0
o=0
for i in range(Q):
    u,v,x,y=map(int,input().split())
    a.append(u)
    b.append(v)
    c.append(x)
    d.append(y)
for k in range(M):
    l=list(itertools.combinations(range(k+N), N))
    for x in l:
        s=0
        h=[]
        for i in range(N):
            h.append(x[i]-i)
        for i in range(Q):
            if h[a[i]]-h[b[i]]==c[i]:
                s+=d[i]
    if o<s:
        o=s
print(o)


### FIXED CODE ###

import itertools
N,M,Q=map(int,input().split())
v=[[] for _ in range(Q)]
o=0
for i in range(Q):
    v[i]=list(map(int,input().split()))
l=list(itertools.combinations(range(M-1+N), N))
for x in l:
    s=0
    a=[]
    for i in range(N):
        a.append(x[i]-i+1)
    for i in range(Q):
        if a[v[i][1]-1]-a[v[i][0]-1]-v[i][2]==0:
            s+=v[i][3]
    if s>o:
        o=s
print(o)
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    for i in range(K):
        x,y,z=B+C,C+A,A+B
        A,B,C=x,y,z
        t=(A-B)
        if abs(t)>10**18:print("Unfair");return
    print(t)
    
#%%submit!    
resolve()

### FIXED CODE ###

#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    
    k=K%2
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    if k%2:t=(-1)*t
    print(t)
    #print(A,B,C)


#%%submit!
resolve()
import numpy as np
N = int(input())
n = [x for x in range(1, N+1)]
m = n[1:]
m.append(n[0])
n = np.array(n)
m = np.array(m)
x = n % m
print(sum(x))

### FIXED CODE ###

*A, = input()
*B, = input()
ans = 0
if A[0] == B[0]:
  ans += 1
if A[1] == B[1]:
  ans += 1
if A[2] == B[2]:
  ans += 1
print(ans)
N=int(input())
d=[0]*N
d=map(int,input().sort())
res=0

for i in range(N-1):
    for j in range(N-i):
        res+=d[i]*d[j]

print(res)

### FIXED CODE ###

N=int(input())
d=list(map(int,input().split()))
res=0

for i in range(N-1):
    for j in range(N-i-1):
        #d[i+1]~d[N-1]
        res+=d[i]*d[i+j+1]


print(res)
import sys

s = sys.stdin.gets()
t = sys.stdin.gets()

c = 0
for i in range(3):
  if s[i] == t[i]:
    c += 1
    
print(c)

### FIXED CODE ###

import sys

s = sys.stdin.readline()
t = sys.stdin.readline()

c = 0
for i in range(3):
  if s[i] == t[i]:
    c += 1
    
print(c)
n, x, y = map(int, input().split())
x -= 1
y -= 1

k = [0 for _ in range(n)]
for i in range(n):
    for j in range(i + 1, n):
        dist = min(j-i, abs(x-i)+1+abs(j-y))
        if dist < n:
            k[dist] += 1
[for i in range(1, len(k)):
    print(k[i])]


### FIXED CODE ###

n, x, y = map(int, input().split())
x -= 1
y -= 1

k = [0 for _ in range(n)]
for i in range(n):
    for j in range(i + 1, n):
        dist = min(j-i, abs(x-i)+1+abs(j-y))
        if dist < n:
            k[dist] += 1
for i in range(1, len(k)):
    print(k[i])
import sys
input = sys.stdin.readline
from collections import deque
from copy import deepcopy
def main():
    N, M, P = map( int, input().split())
    d = dict()
    E = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map( int, input().split())
        a, b = a-1, b-1
        d[(a,b)] = c-P
        E[b].append(a)
    G = [False]*N
    G[N-1] = True
    q = deque([N-1])
    while q:
        v = q.popleft()
        for w in E[v]:
            if G[w] == False:
                G[w] = True
                q.append(w)
    V = [None]*N
    V[0] = 0
    I = sum([1 for i in range(N) if G[i] == True])
    for _ in range(I-1):
        for (s,t), cost in d.items():
            if V[s] == None or G[t] == False:
                continue
            if V[t] == None:
                V[t] = V[s] + cost
                continue
            if V[s] + cost > V[t]:
                V[t] = V[s] + cost
    W = deepcopy(V) #[ V[i] for i in range(N)]
    for _ in range(I-1):
        for (s,t), cost in d.items(): #d.keys()
            if V[s] == None or G[t] == False:
                continue
            if V[t] == None:
                V[t] = V[s] + cost
                continue
            if V[s] + d[e] > V[t]:
                V[t] = V[s] + cost
    for i in range(N):
        if W[i] == None or G[t] == False:
            continue
        if V[i] > W[i]:
            print(-1)
            return

    print( max(W[-1], 0))
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque
from copy import deepcopy
def main():
    N, M, P = map( int, input().split())
    E = []
    rE = [[] for _ in range(N)]
    
    for _ in range(M):
        a, b, c = map( int, input().split())
        a, b = a-1, b-1
        E.append((a,b,c-P))
        rE[b].append(a)
    # 頂点Nに到達する頂点
    G = [False]*N
    G[N-1] = True
    q = deque([N-1])
    while q:
        v = q.popleft()
        for w in rE[v]:
            if G[w] == False:
                G[w] = True
                q.append(w)
    # Bellman-Ford
    V = [None]*N
    V[0] = 0
    I = sum([1 for i in range(N) if G[i] == True])
    for _ in range(I-1):
        for s, t, cost in E:
            if V[s] == None or G[t] == False:
                continue
            if V[t] == None:
                V[t] = V[s] + cost
                continue
            if V[s] + cost > V[t]:
                V[t] = V[s] + cost
    W = deepcopy(V) #[ V[i] for i in range(N)]
    for _ in range(I-1):
        for s, t, cost in E:
            if V[s] == None or G[t] == False:
                continue
            if V[t] == None:
                V[t] = V[s] + cost
                continue
            if V[s] + cost > V[t]:
                V[t] = V[s] + cost
    for i in range(N):
        if W[i] == None or G[i] == False:
            continue
        if V[i] > W[i]: # 頂点iは、頂点Nに到達するので、負（正？）閉路は伝播する
            print(-1)
            return

    print( max(W[-1], 0))
if __name__ == '__main__':
    main()
while(not((m==-1) and (f==-1) and (r==-1)))
 m,f,r=map(int,input().split())
 if((m==-1) or (f==-1))
   print('F')

 if(m+f>=80)
   print('A')

 if(65<= m+f) and (m+f<80))
   print('B')

 if(50<= m+f) and (m+f<60))
   print('C')

 if(30<= m+f) and (m+f<50))
   if(50<=r)
    print('C')
   else
    print('D')

 if(m+f<30)
   print('F')



 

### FIXED CODE ###

while True:
 m,f,r=map(int,input().split())
 if m==f==r==-1 : break

 if m==-1 or f==-1 :
   print('F')

 elif (m+f)>=80 :
   print('A')

 elif 65<= (m+f) and (m+f)<80 :
   print('B')

 elif 50<= (m+f) and (m+f)<65 :
   print('C')

 elif 30<=(m+f) and (m+f)<50 :
   if 50<=r :
    print('C')
   else:
    print('D')

 elif (m+f)<30 :
   print('F')
N,A,B,C = map(int, input().split())
 
bms = [int(input()) for _ in Range(N)]
 
def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))

### FIXED CODE ###

N,A,B,C = map(int, input().split())

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

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))
# -*- coding: utf-8 -*-

n, k, q =map(int, input().split())
a = []
a = map(int, [input() for i in range(q)])

m = [k]*n

for i in range(a):
  for j in range(n):
    m[j]=m[j]-1
    m[a-1]=m[a-1]+1
  
for i in range(n):
  if m[n]>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k, q =map(int, input().split())
a = [int(input()) for i in range(q)]

p = [0]*(n+1)

for i in range(q):
  p[a[i]] += 1
  

for i in range(1,n+1):
  if p[i]>q-k:
    print("Yes")
  else:
    print("No")
# encoding: utf-8
import math
N, M = map(int, input().split())

def distribute(pos, full, tmp):
    return memo[tmp][pos]

# define search range
p_max = int(M / 2) # M is prime if M has a factor p (> p_max)
ip_up = int(math.log2(p_max))

#### O(MlogM) below (if M has a very large prime factor)
M_tmp = M
ips = []
for p in range(2, p_max + 1):
    if M_tmp % p > 0: continue
    # how many times M_tmp can be divided
    p_tmp = p
    for i_p in range(ip_up + 1):
        if M_tmp % p_tmp > 0: break
        p_tmp = p_tmp * p
    # calculate later
    ips.append(i_p)
    # next
    M_tmp = M_tmp // (p_tmp // p)
    if M_tmp == 1: break
#### O(Mlog M) above

#### O(N) below
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    p_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        p_memo[N - 1 - j] = sum_tmp
#### O(N) above
        
# calculate ans
ans = 1
for i_p in ips: ans = (ans * distribute(0, i_p, i_p)) % (10 ** 9 + 7)

if ip_max = 0: print(N)
else: print(ans)

### FIXED CODE ###

# encoding: utf-8
import math
N, M = map(int, input().split())

ips = []
M_tmp = M
for p in range(2, int(math.sqrt(M)) + 1):
    if M_tmp % p > 0: continue
    for i_p in range(1, 33):
        if M_tmp % (p ** (i_p + 1)) > 0: break
    ips.append(i_p)
    M_tmp = M_tmp // (p ** i_p)
    if M_tmp == 1: break
else:
    ips.append(1)

#### O(NlogM) below ?
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    ptr_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        ptr_memo[N - 1 - j] = sum_tmp
#### O(NlogM) above ?
        
# calculate ans
ans = 1
for i_p in ips:
    ans = (ans * memo[i_p][0]) % (10 ** 9 + 7)

if M == 1: print(1)
elif ip_max < 1: print(N)
else: print(ans)
n = int(input())
F =[list(map(int,input().split())) for i in range(n)]
P =[list(map(int,input().split())) for i in range(n)]

ans = -INF
for i in range(1,1024):
    profit = 0
    for j in range(n):
        cnt = 0
        for x in range(10):
            if (i >> x) %2 == 1 and F[j][x] == 1:
                cnt += 1
        profit += P[j][cnt]
    ans = max(ans,profit)
print(ans) 

### FIXED CODE ###

import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
INF = float("inf")

n = int(input())
F =[list(map(int,input().split())) for i in range(n)]
P =[list(map(int,input().split())) for i in range(n)]

ans = -INF
for i in range(1,1024):
    profit = 0
    for j in range(n):
        cnt = 0
        for x in range(10):
            if (i >> x) %2 == 1 and F[j][x] == 1:
                cnt += 1
        profit += P[j][cnt]
    ans = max(ans,profit)
print(ans)
def abs(k):
  if k >= 0:
    return k
  else:
    return -k
  
def main():
  a, b, c ,n = list(map(int,input().split()))
  i for i in range(n):
    a = b + c
    b = c + a 
    c = a + b
  res = a - b
  if abs(res) > 10 ** 18:
    print('Unfair')
  else:
    print(res)

### FIXED CODE ###

A, B, C, K = map(int, input().split())
print(A - B if K % 2 == 0 else B - A)
2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

### FIXED CODE ###

X,Y,A,B,C =map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

P.sort()
Q.sort()
R.sort()

P_new = P[-X::]
Q_new = Q[-Y::]


agg = P_new + Q_new +R
agg.sort()
print(sum(agg[-X-Y::]))
import sys

a, b = map(int, sys.stdin.readline())

if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(":(")

### FIXED CODE ###

import sys

a, b = map(int, sys.stdin.readline().split())

if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(":(")
a,b,c = map(int,input().split)

if a*b < c:
  print(a:b)
else:
  print(c)

### FIXED CODE ###

a,b,c = map(int,input().split())
if a*b < c:
  print(a*b)
else:
  print(c)
S = input()
N = len(S)
A = int((N - 1) / 2)
B = int((A - 1) / 2)
X = 0

for i in range(A):
  if S[i] != S[-i-1]:
    X += 1

if N == 5:
  if S[0] != S[1]:
    X += 1

if N >= 7:
  for i in range(B):
  	if S[i] != S[A-1]:
    	X += 1
      
if X == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
N = len(S)
A = int((N - 1) / 2)
if A % 2 == 0:
  B = int(A / 2)
else:
  B = int((A - 1) / 2)
X = 0
 
for i in range(A):
  if S[i] != S[-i-1]:
    X += 1
 
if N >= 5:
  for i in range(B):
  	if S[i] != S[A-1-i]:
  	    X += 1
      
if X == 0:
  print("Yes")
else:
  print("No")
import numpy as np

MOD = 10**9+7

n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
    arr[0,i] = 1

for i in np.arange(1,n+1):
    sum_ = 0
    for j in np.arange(3*i,n+1):
        sum_ += arr[i-1,j]
        sum_ %= MOD
        if j+3 >= n + 1:
            break
        arr[i,j+3] = sum_

ans = 0
for i in range(n+1):
    ans += arr[i,n]
    ans %= MOD
print(ans)








### FIXED CODE ###

import numpy as np

MOD = 10**9+7

n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
    arr[0,i] = 1

for i in np.arange(1,n+1):
    sum_ = 0
    for j in np.arange(3*i,n+1):
        sum_ += arr[i-1,j]
        sum_ %= MOD
        if j+3 >= n + 1:
            break
        arr[i,j+3] = sum_

ans = 0
for i in range(n+1):
    ans += arr[i,n]
    ans %= MOD
print(ans)
a,b = input().split()
c = a % b
if b - c <= c :
  print(b - c)
else :
  print(c)

### FIXED CODE ###

n, k = map(int,input().split())
a = n % k
b = k - a
if b <= a:
    print(b)
else:
    print(a)
import fractions
a, b = map(int, input().split())
gc = math.factorial(a, b)

def prime_factorize(n):
    a = []
    if n % 2 == 0:
        a.append(2)
        while n % 2 == 0:
            n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            while n % f == 0:
                n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(prime_factorize(gc) + 1)

### FIXED CODE ###

import fractions
a,b = map(int,input().split())
longer = max(a,b)
lcm = fractions.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    if lcm != 1:
      ans += 1
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
# print(lcm)
print(ans)