Harryxun/stf_run huggingface dataset:
import sys

def trade(n, a, b):
    a0, a1, a2 = a
    b0, b1, b2 = b
    dp = [0] * (n+1)
    for i i range(1, n+1):
        gold, silver, copper = 0, 0, 0
        if i >= a0:
            gold = dp[i-a0] + b0
        if i >= a1:
            silver = dp[i-a1] + b1
        if i >= a2:
            copper = dp[i-a2] + b2
        dp[i] = max(i, gold, silver, copper)

    return dp[n]


def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    # Trade A -> B
    M = trade(N, A, B)
    # Trade B -> A
    return trade(M, B, A)


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    dp = [0] * (N+1)
    for i in range(1, N+1):
        gold, silver, copper = 0, 0, 0
        if i >= A[0]:
            gold = dp[i-A[0]] + B[0]
        if i >= A[1]:
            silver = dp[i-A[1]] + B[1]
        if i >= A[2]:
            copper = dp[i-A[2]] + B[2]
        dp[i] = max(i, gold, silver, copper)

    M = dp[N]
    dp = [0] * (M+1)
    for i in range(1, M+1):
        gold, silver, copper = 0, 0, 0
        if i >= B[0]:
            gold = dp[i-B[0]] + A[0]
        if i >= B[1]:
            silver = dp[i-B[1]] + A[1]
        if i >= B[2]:
            copper = dp[i-B[2]] + A[2]
        dp[i] = max(i, gold, silver, copper)

    return dp[M]


if __name__ == '__main__':
    print(main())
n=int(input())
a=input()
b=[]
for i in range(n):
  b.append(int(a[i*2]))
ave=sum(b)/n
if ave<int(ave)+0.5:
  ave=int(ave)
else:
  ave=int(ave)+1
ans=0
for i in range(n):
  ans+=(b[i]-ave)**2
print(ans)

### FIXED CODE ###

n=int(input())
a=[]
a=list(map(int,input().split()))
ave=sum(a)/n
if ave<int(ave)+0.5:
  ave=int(ave)
else:
  ave=int(ave)+1
ans=0
for i in range(n):
  ans+=(a[i]-ave)**2
print(ans)
n=int(input())
result=''
while True:
    if n==0:
        break
    if n%2==0:
        n=n/(-2)
        result='0'+result
    else:
        n=(n-1)/(-2)
        result='1'+result
print(int(result))

### FIXED CODE ###

n=int(input())
result=''
if n==0:
    result='0'
while True:
    if n==0:
        break
    if n%2==0:
        n=n/(-2)
        result='0'+result
    else:
        n=(n-1)/(-2)
        result='1'+result
print(int(result))
from functools import reduce
from itertools import combinations
from math import gcd

def get_gcd(number_list):
    return reduce(gcd, number_list)

N = int(input())
Numbers = list(map(int, input().split()))

skipped = list(combinations(Numbers, N - 1))

gcd_list = [get_gcd(item) for item in skipped]
    
print(int(max(gcd_list)))

### FIXED CODE ###

from functools import reduce
from itertools import combinations
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))


Left = [0] * (N + 1)
Right = [0] * (N + 1)

for i in range(N):
    Left[i + 1] = gcd(Left[i], A[i])
    Right[N - i - 1] = gcd(Right[N - i], A[N - i - 1])
ans = 0
for i in range(N):
    ans = max(ans, gcd(Left[i], Right[i + 1]))
    
print(ans)
x, n = map(int, input().split())
if n==0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    while i < n and p[i] < x:
        i += 1

    if p[i] != x:
        print(x)
    else:
        j = 1
        up = x+j
        down = x-j
        while True:
            if p[i-j] != x-j:
                print(x-j)
                break
            if p[i+j] != x+j:
                print(x+j)
                break
            j += 1


### FIXED CODE ###

x, n = map(int, input().split())
if n==0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    while i < n and p[i] < x:
        i += 1

    if p[i] != x:
        print(x)
    else:
        j = 1
        up = x+j
        down = x-j
        while True:
            if i-j>=0 and p[i-j] != x-j:
                print(x-j)
                break
            elif i-j < 0:
                print(x-j)
                break
            if i+j<n and p[i+j] != x+j:
                print(x+j)
                break
            elif i+j >= n:
                print(x+j)
                break
            j += 1
a,b = map(int,input().sp;it())
print((a+b)//2)

### FIXED CODE ###

a, b = map(int, input().split())
import math
x = (a + b) /2 
print(math.ceil(x))
# coding: utf-8

import math
import sys

def insertionSort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and A[j] > v:
            a[j+g] = A[j]
            j = j - g
            ct += 1
            a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
cnt = 0
m = 0
h = 0
g = []

while True:
    h = 3*h + 1
    if h > n:
        break
    g.insert(0, h)

for i in g:
    cnt += insertionSort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(cnt)
print(*a, sep="/n")

### FIXED CODE ###

# coding: utf-8

import math
import sys

def insertionSort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            ct += 1
            a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
cnt = 0
m = 0
h = 0
g = []

while True:
    h = 3*h + 1
    if h > n:
        break
    g.insert(0, math.ceil(h))

for i in g:
    cnt += insertionSort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(cnt)
print(*a, sep="\n")
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    res = (solve(i+1, m) or solve(i+1, m-A[i]))
    return res 
 
for m in range M:
    if solve(0, m):
        print "yes"
    else:
        print "no"

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    x = (solve(i+1, m) or solve(i+1, m-A[i]))
    return  x
 
for m in M:
    if solve(0, m):
        print "yes"
    else:
        print "no"
a,b=(int(x) for x in input().split())

#print((a * b) % 2)

if (a * b) % 2 == 1:
    print('Odd')
else:
    print('Even')f

### FIXED CODE ###

a,b=(int(x) for x in input().split())

#print((a * b) % 2)

if (a * b) % 2 == 1:
    print('Odd')
else:
    print('Even')
S, T = input().split()
if len(S) == len(T) - 1:
    Slis = list(S)
    Tlis = list(T)
    removedTlis = Tlis.remove(Tlis[ - 1])
    if Slis  == removedTlis:
        print('Yes')
    else:
        print('No')
else:
    print('No')

### FIXED CODE ###

S = input()
T = input()
 
Slis = list(S)
Tlis = list(T)
Tlis.pop(-1)
if len(S) == 0:
    print('No')
elif Slis  == Tlis:
    print('Yes')
else:
    print('No')
a

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if a+b==c+d:
  print('Balanced')
elif a+b>c+d:
  print('Left')
else:
  print('Right')
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
h,w,m=map(int,input().split())
l={}
u={}
hw=[list(map(int,input().split())) for _ in range(m)]
sl=set()
su=set()

for i in range(m):
    hr,wr=hw[i]
    if hr-1 in u:
        u[hr-1]+=1
    else:
        u[hr-1]=1
    if wr-1 in l:
        l[wr-1]+=1
    else:
        l[wr-1]=1
    sl.add(wr-1)
    su.add(hr-1)
resl=0
resu=0
cl=[]
cu=[]
for i in l:
    if resl<l[i]:
        resl=l[i]
        cl=[i]
    elif resl==l[i]:
        cl.append(i)
for i in u:
    if resu<u[i]:
        resu=u[i]
        cu=[i]
    elif resl==l[i]:
        cu.append(i)
ans=0
if len(cu)*len(cl)>=m:
    ans=resl+resu
else:
    for i in cu:
        for j in cl:
            if i in su and j in sl:
                res=l[j]+u[i]-1
            else:
                res=l[i]+u[j]
            ans=max(res,ans)
print(ans)

### FIXED CODE ###

#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
h,w,m=map(int,input().split())
l={}
u={}
hw=[list(map(int,input().split())) for _ in range(m)]
s=set()

for i in range(m):
    hr,wr=hw[i]
    if hr-1 in u:
        u[hr-1]+=1
    else:
        u[hr-1]=1
    if wr-1 in l:
        l[wr-1]+=1
    else:
        l[wr-1]=1
    s.add((hr-1)*w+wr-1)
resl=0
resu=0
cl=[]
cu=[]
for i in l:
    if resl<l[i]:
        resl=l[i]
        cl=[i]
    elif resl==l[i]:
        cl.append(i)
for i in u:
    if resu<u[i]:
        resu=u[i]
        cu=[i]
    elif resu==u[i]:
        cu.append(i)
ans=0
if resu==m or resl==m :
  print(m)
  exit()
if len(cu)*len(cl)>m:
    ans=resl+resu
else:
    for i in cu:
        for j in cl:
            if i*w+j in s:
                res=resl+resu-1
            else:
                res=resl+resu
            ans=max(res,ans)
print(ans)
for i in range(10000)
  line = int(input())
  if line == 0:
    break
  print('Case {}:{}'.format(i+1, line))

### FIXED CODE ###

for i in range(10000):
  line = int(input())
  if line == 0:
    break
  print('Case {}: {}'.format(i+1, line))
a=int(input())
b=int(input())
x=[1,2,3]
x=x.remove(a)
x=x.remove(b)
print(x)

### FIXED CODE ###

a=int(input())
b=int(input())
x=[1,2,3]
x.remove(a)
x.remove(b)
print(x[0])
if '9'.in input():
  print("Yes")
else:
  print("No")

### FIXED CODE ###

if '9' in input():
  print("Yes")
else:
  print("No")
from sys import stdin
input = stdin.readline

def accumulate(l, X):
    acclist = [0]*(l+1)
    for i in range(1,l+1):
        acclist[i] = acclist[i-1] + X[i]
    return acclist

N,M,K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

X = accumulate(N, A)
Y = accumulate(M, B)

maxbook = 0
j = M
for i in range(N+1):
    x = X[i]
    y = Y[j]
    while x + y > K:
        j -= 1 
        y = Y[j]
        if j <= 0:
            break
    maxbook = max(maxbook, i + j)

print(maxbook)

### FIXED CODE ###

from sys import stdin
input = stdin.readline

def accumulate(l, X):
    acclist = [0]*(l+1)
    for i in range(1,l+1):
        acclist[i] = acclist[i-1] + X[i]
    return acclist

N,M,K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

X = accumulate(N, A)
Y = accumulate(M, B)

maxbook = 0
j = M
for i in range(N+1):
    x = X[i]
    y = Y[j]
    while x + y > K:
        j -= 1 
        if j < 0:
            break
        y = Y[j]
    if j < 0:
        break

    maxbook = max(maxbook, i + j)

print(maxbook)
N = input()
B = False
kaisu = 0
array = map(int,input().split())

def calc(n):
  retuen n/2
  
  
while !B:
	for i in range(N):
  		if array[i]/2 == 1:
    		B = True
  	if !B:
    	array = map(calc, array)
    	kaisu += 1
  	else:
    	break
        
print(kaisu)
    

    

### FIXED CODE ###

N = int(input())
B = False
kaisu = 0
array = list(map(int,input().split()))

def calc(n):
  return int(n) / 2
  
  
while not B:
  for i in range(N):
    if array[i] % 2 == 1:
      B = True
  if not B:
    array = list(map(calc, array))
    kaisu += 1
  else:
    break
        
print(kaisu)
s, w = input()
if s <= w:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

S, W = map(int, input().split())
if S <= W:
    print('unsafe')
else:
    print('safe')
import math
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[0])
by = 0
sq = 0
if b < 10:
	by = a * 10 + b
elif 10 <= b and b < 100:
	by = a * 100 + b
else:
	by = a * 1000 + b
sq = math.sqrt(by)
if type(sqrt) == int:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

import math
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
by = 0
sq = 0
if b < 10:
	by = a * 10 + b
elif 10 <= b and b < 100:
	by = a * 100 + b
else:
	by = a * 1000 + b
sq = math.sqrt(by)
res = str(sq)

if res[-1] == "0":
	print("Yes")
else:
	print("No")
n=int(input())
mod=10**9+7
if n==3:
    print(61)
    exit()
zt=['A','G','C','T']
for i in range(3):
    tmp=[]
    for j in zt:
        for k in list('AGCT'):
            tmp.append(j+k)
    zt=tmp
ng=set([])
for i in list('AGCT'):
    ng.add('AGC'+i)
    ng.add('AG'+i+'C')
    ng.add('A'+i+'GC')
    ng.add(i+'AGC')
    ng.add('ACG'+i)
    ng.add('GAC'+i)
    ng.add(i+'ACG')
    ng.add(i+'GAC')
z=set([])
for j in zt:
    if not j in ng:
        z.add(j)
zn=len(z)
dp=[[0 for j in range(zn)] for i in range(n-3)]
for i in range(zn):
   # if not z[i] in ng:
    dp[0][i]=1
for i in range(n-4):
    for j in range(zn):
        for k in range(zn):
            #if not z[k] in ng:
            if z[j][1:]==z[k][:3]:
                dp[i+1][k]+=dp[i][j]
                dp[i+1][k]%=mod
print(sum(dp[-1])%mod)


### FIXED CODE ###

n=int(input())
mod=10**9+7
if n==3:
    print(61)
    exit()
zt=['A','G','C','T']
for i in range(3):
    tmp=[]
    for j in zt:
        for k in list('AGCT'):
            tmp.append(j+k)
    zt=tmp
ng=set([])
for i in list('AGCT'):
    ng.add('AGC'+i)
    ng.add('AG'+i+'C')
    ng.add('A'+i+'GC')
    ng.add(i+'AGC')
    ng.add('ACG'+i)
    ng.add('GAC'+i)
    ng.add(i+'ACG')
    ng.add(i+'GAC')
z=[]
for j in zt:
    if not j in ng:
        z.append(j)
zn=len(z)
dp=[[0 for j in range(zn)] for i in range(n-3)]
for i in range(zn):
   # if not z[i] in ng:
    dp[0][i]=1
for i in range(n-4):
    for j in range(zn):
        for k in range(zn):
            #if not z[k] in ng:
            if z[j][1:]==z[k][:3]:
                dp[i+1][k]+=dp[i][j]
                dp[i+1][k]%=mod
print(sum(dp[-1])%mod)
ss = ''.join(sorted(input()))
tt = ''.join(sorted(t, reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

ss = ''.join(sorted(input()))
tt = ''.join(sorted(input(), reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")
a,b=map(int, input().split())
if a = 1 or b = 1:
	print(1)
else:
	print(-(-1 * a * b // 2))

### FIXED CODE ###

a,b=map(int, input().split())
if a == 1 or b == 1:
	print(1)
else:
	print(-(-1 * a * b // 2))
M = 1000000007
N = int(input())
A = list(map(int, input().split()))

ans = 1
rgb = [0, 0, 0]
for i in range(N):
    c = rgb.count(A[i])
    p = rgb.index(A[i])
    ans *= c
    rgb[p] += 1

print(ans % M)

### FIXED CODE ###

M = 1000000007
N = int(input())
A = list(map(int, input().split()))

ans = 1
rgb = [0, 0, 0]
for i in range(N):
    c = rgb.count(A[i])
    if c == 0:
        ans = 0
        break
    p = rgb.index(A[i])
    ans *= c
    rgb[p] += 1

print(ans % M)
X = input()

if X>=30:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

X = int(input())

if X>=30:
  print('Yes')
else:
  print('No')
N, M = list(map(int, input().split()))
A=[0] * M
B=[0] * M

import math

for i in range(M):
  A[i], B[i] = list(map(int, input().split()))

  
island_dict = [i for i in range(N+1)] #{i+1:i+1 for i in range(N)} #島が属するグループ
#group_dict = [[i] for i in range(N+1)] #{i+1:[i+1] for i in range(N)} #グループに属する島
group_len_dict= [1 for i in range(N+1)] #{i+1:1 for i in range(N)}

answer = [0] * M
answer[-1] = math.factorial(N) // (math.factorial(N-2)*2)
  
for i in range(M)[:0:-1]:
  if island_dict[A[i]] == island_dict[B[i]]:
    answer[i-1] = answer[i]
  else:
    groupA = island_dict[A[i]]
    groupB = island_dict[B[i]] #グループ合併, groupB消滅
    NA = group_len_dict[groupA]
    NB = group_len_dict[groupB]
    
    if NA>=NB:
      island_dict = [groupA if g==groupB else g for g in island_dict]
      #for j in group_dict[groupB]:
      #  island_dict[j] = groupA
      #group_dict[groupA] = group_dict[groupA] + group_dict[groupB]
      #group_dict[groupB] = []
      group_len_dict[groupA] = group_len_dict[groupA] + group_len_dict[groupB]
      #group_len_dict[groupB] = 0
      
    else:
      island_dict = [groupB if g==groupA else g for g in island_dict]
      #for j in group_dict[groupA]:
      #  island_dict[j] = groupB
      group_dict[groupB] = group_dict[groupA] + group_dict[groupB]
      #group_dict[groupA] = []
      group_len_dict[groupB] = group_len_dict[groupA] + group_len_dict[groupB]
      #group_len_dict[groupA] = 0
      
    answer[i-1] = answer[i] - NA*NB

#print(answer)

for i in range(M):
  print(answer[i])
    
    

### FIXED CODE ###

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

roots = [(i,1) for i in range(N+1)] # root, num_islands_in_group

inconveniences = [0]*(M+1)
inconveniences[-1] = N*(N-1)//2 #すべての橋が崩落するとNC2

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return roots[a]
  else:
    roots[a] = find_root(roots[a][0])
  return roots[a]

def reduce_inconvenience_with_unite(a, b, roots=roots):
  root_a, n_a = find_root(a)
  root_b, n_b = find_root(b)
  if root_a == root_b:
    return 0
  else:
    if n_a > n_b:
      roots[root_a] = (root_a, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_a, n_a + n_b)
    else:
      roots[root_a] = (root_b, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_b, n_a + n_b)
    return n_a * n_b

for i, ab in enumerate(AB[:0:-1]): #実は1個めの橋は全く関係ない
  a, b = ab
  inconveniences[M-1-i] = inconveniences[M-i] - reduce_inconvenience_with_unite(a,b)

for inc in inconveniences[1:]:
  print(inc)
n,m = map(int,input().split())
a = []
mod = 10**9+7
for i in range(m):
    b = int(input())
    a.append(b)
d = [0 for i in range(n+1)]
d[0] = 0
d[1] = 1
d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
ans = 1
if a[0] == 1:
    ans = 1
else:
    ans = ans*d[a[0]-1]%mod
for i in range(m-1):
    ans = ans*d[a[i+1]-a[i]-2]%mod
ans = ans*d[n-a[m-1]-1]%mod
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = []
mod = 10**9+7
d = [0 for i in range(n+1)]
d[0] = 1
d[1] = 1
if n >1 :
    d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
if m != 0:
    d.append(0)
    for i in range(m):
        b = int(input())
        a.append(b)
    ans = 1
    if a[0] == 1:
        ans = 1
    else:
        ans = ans*d[a[0]-1]%mod
    for i in range(m-1):
        ans = ans*d[a[i+1]-a[i]-2]%mod
    ans = ans*d[n-a[m-1]-1]%mod
else:
    ans = d[n]%mod
print(ans)
n,k=map(int,input().split())
s=list(map(int,str(input())))
if s[0]==1:
  a=[0]+[i+1 for i in range(n-1) if s[i]==0 and s[i+1]==1]
else:
  a=[i+1 for i in range(n-1) if s[i]==0 and s[i+1]==1]
if s[n-1]==1:
  b=[i for i in range(n-1) if s[i]==1 and s[i+1]==0]+[n-1]
else:
  b=[i for i in range(n-1) if s[i]==1 and s[i+1]==0]
if s[0]==0:
  c=[0]+[i+1 for i in range(n-1) if s[i]==1 and s[i+1]==0]
else:
  c=[i+1 for i in range(n-1) if s[i]==1 and s[i+1]==0]
if len(c) <= k:
  x=n
else:
    x=max([b[i+k]-a[i]+1 for i in range(len(c)-k+1)])
print(x)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(map(int,str(input())))
if s[0]==1:
  one_st=[0]+[i+1 for i in range(n-1) if s[i]==0 and s[i+1]==1]
  zero_st=[i+1 for i in range(n-1) if s[i]==1 and s[i+1]==0]
else:
  one_st=[i+1 for i in range(n-1) if s[i]==0 and s[i+1]==1]
  zero_st=[0]+[i+1 for i in range(n-1) if s[i]==1 and s[i+1]==0]
if s[n-1]==1:
  one_en=[i for i in range(n-1) if s[i]==1 and s[i+1]==0]+[n-1]
  zero_en=[i for i in range(n-1) if s[i]==0 and s[i+1]==1]
else:
  one_en=[i for i in range(n-1) if s[i]==1 and s[i+1]==0]
  zero_en=[i for i in range(n-1) if s[i]==0 and s[i+1]==1]+[n-1]
if len(zero_st) <= k:
  x=n
else:
  y=[one_en[i+k]-one_st[i]+1 for i in range(len(zero_st)-k+1) if i+k+1<=len(one_en)]
  y=y+[one_en[k-1]+1,n-one_st[len(one_st)-k]]
  x=max(y)
print(x)
mod=1e9+7
n,k=map(int,input().split())

l=list(map(int,input().split()))
ans=0
for i in range(len(l)):
    for j in range(i):
        if l[j]>l[i]:
            ans+=1
ans*=k

l.sort()

a=0
f=0
for i in range(n-1):
    if l[i]==l[i+1]:
        a+=f
    else:
        f+=1
a+=f
print(ans+a*k(k-1)//2)

### FIXED CODE ###

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

l=list(map(int,input().split()))
mod=10**9+7

ain=0
aout=0

for i in range(n):
    for j in range(n):
        if l[i]>l[j]:
            aout+=1
            if i<j:
                ain+=1
ain*=k
aout*=k*(k-1)//2

print((ain+aout)%mod)
x=[]
total=[]
for i in range(5):
  t=list(input())
  if t[-1]=='0':
    total.append(t)
  else:
    x.append(t)
x=sorted(x, key=lambda x: x[-1])
for i in range(1,len(x)):
  total.append(x[i])
last=int(''.join(x[0]))
for i in range(4):
  total[i]=int(''.join(total[i]))
  total[i]=-(-total[i]//10)*10

print(sum(total)+last)

### FIXED CODE ###

x=[]
total=[]
for i in range(5):
  t=list(input())
  if t[-1]=='0':
    total.append(t)
  else:
    x.append(t)
x=sorted(x, key=lambda x: x[-1])
for i in range(1,len(x)):
  total.append(x[i])
if len(x)!=0:
  last=int(''.join(x[0]))

for i in range(4):
  total[i]=int(''.join(total[i]))
  total[i]=-(-total[i]//10)*10
if len(x)==0:
  total[-1]=int(''.join(total[-1]))
  print(sum(total))
else:
  print(sum(total)+last)
from collections import deque

K = int(input()) 
a = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K-1):
    j = a.popleft()
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))
    
a.popleft()

### FIXED CODE ###

i = list(map(int, input().split())) 
X = i[0]
Y = i[1]
Z = i[2]

print(Z, X, Y)
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=[]
for i in [0,1,2,3,4,5.6,7,8,9]:
  if i not in a:
    m.append(i)
k=0
for a in m:
  for b in m:
    for c in m:
      for d in m:
        if k:
          break
        num=a*1000+b*100+c*10+d
        if num>=n:
          ans=num
          k=1
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
m=list(map(int,input().split()))
for i in range(n,100000):
  k=1
  for a in str(i):
    if int(a) in m:
      k=0
  if k:
    print(i)
    break
x = int(input())
import math
flag = False
for i in range(x):
    ans = x - i
    for j in range(2,x):
        b = math.pow(ans, 1/j)
        if b % 1 == 0:
            flag = True
            break
        elif b < 1:
            break
    if flag:
        break
print(ans)

### FIXED CODE ###

a, b, c, d = map(int,input().split(" "))
ans = "No"
if abs(c-a) <= d:
    ans = "Yes"
elif abs(b-a) <= d and abs(c-b) <= d:
    ans = "Yes"
print(ans)
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 = p[::-1]
p = [:x]
q = [::-1]
q = [:y]
ans = p + q + r
ans.sort()
print(sum(ans[:x+y]))

### 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 = p[::-1]
q = q[::-1]
r = r[::-1]

ir = 0
ig = 0

red = 0
for i in range(x):
    red += p[i]
    ir = i
green = 0
for i in range(y):
    green += q[i]
    ig = i

ino = 0
while (0 <= ir or 0 <= ig) and ino < c:
    iir = ir
    iig = ig
    iino = ino

    if ig < 0:
        if p[ir] < r[ino]:
            red -= p[ir]
            red += r[ino]
            ino += 1
            ir -= 1
    elif ir < 0:
        if q[ig] < r[ino]:
            green -= q[ig]
            green += r[ino]
            ino += 1
            ig -= 1
    elif p[ir] < q[ig]:
        if p[ir] < r[ino]:
            red -= p[ir]
            red += r[ino]
            ino += 1
            ir -= 1
    else:
        if q[ig] < r[ino]:
            green -= q[ig]
            green += r[ino]
            ino += 1
            ig -= 1

    if iir == ir and iig == ig and iino == ino:
        break

print(green + red)
N = int(input())
a = list(map(int, input().split()))
i_list = []
for x in range(max(a)):
    cnt = 0
    for i in range(N):
        if abs(x - a[i]) == 1 or x == a[i]:
            cnt += 1
    i_list.append(cnt)
print(max(i_list))

### FIXED CODE ###

from collections import Counter
N = int(input())
a = list(map(int, input().split()))
i_list = []
for i in a:
    i_list.append(i-1)
    i_list.append(i)
    i_list.append(i+1)
print(Counter(i_list).most_common()[0][1])
x = list(map(int,input().split()))
print(x[0]*x[1] x[0]*2+x[1]*2)

### FIXED CODE ###

a,b = map(int, input().split())
print(a*b, a*2+b*2)