Harryxun/stf_run huggingface dataset:
import datetime

input_time = input()
old_date = datetime.datetime.strptime(input_time, '%Y/%m/%d')
new_date = old_date + datetime.timedelta(years=1)
print(new_date)


### FIXED CODE ###

import datetime
import sys

input_date = sys.stdin.read(10)
old_date = datetime.datetime.strptime(input_date, '%Y/%m/%d')
new_date = old_date.replace(old_date.year + 1)
out_date = "{0:%Y/%m/%d}".format(new_date)
print(out_date)
A, B = map(int, input().split())
 
if (A+B)%2 == 0:
    print( int((A+B)/2) )
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

a,b,c = map(int,input().split())

print(max(0,c-(a-b)))
import math
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
print((M+lcm//2)//lcm)

### FIXED CODE ###

from fractions import gcd
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(a)
test = a[0]
count = 0
while test%2 ==0:
    test = test//2
    count += 1
for i in range(N):
    if (a[i]//2**count)%2 == 0:
        print(0)
        exit()
print((M+lcm//2)//lcm)
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd, log10
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 7)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


# https://qiita.com/greenteabiscuit/items/31c46ab3ceac07e749d2


n, m = LI()
graph = [[] for _ in range(m)]
v = [False] * n

for i in range(m):
    a, b = LI()
    graph[a - 1].append(b-1)
    graph[b - 1].append(a-1)


def dfs(now, depth):
    if v[now]:
        return 0
    if depth == n-1:
        return 1
    ans = 0
    v[now] = True
    for node in graph[now]:
        ans += dfs(node, depth+1)

    v[now - 1] = False
    # ここが大事.上で探索の一つが終わるからリセットしている.

    return ans


print(dfs(0, 0))


### FIXED CODE ###

#Nはノード数、Mはエッジ数
N, M = map(int, input().split())

path_matrix = []

#無向行列の初期化
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    line = map(int, input().split())
    paths = [x - 1 for x in line]
    path_matrix[paths[0]][paths[1]] = True
    path_matrix[paths[1]][paths[0]] = True

#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N


#再帰関数、ここが難しいかもしれない。
def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1

    visited[now] = True
    total_paths = 0
    for i in range(0, N):
        if path_matrix[now][i]:
            total_paths += dfs(i, depth + 1)

    visited[now] = False

    return total_paths

print(dfs(0, 0))
n=int(input())
A=list(map(int,input().split()))
sum=1
f=0
f2=0
if 0 in a:
        f2=1
for a in A:
	sum=sum*a
	if (sum>10**18):
		sum=-1
                break
if f2==1: 
	print(0)
else:
	print(sum)

### FIXED CODE ###

N=int(input())
 
A=list(map(int,input().split()))
 
if 0 in A:
    print(0)
else:
    result=1
    for a in A:
        result=result*a
        if result>10**18:
            result=-1
            break
    print(result)
N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))
A=list(set(A))

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

l1=[]
l2=[]
l3=[]

if len(A)==1:
    ans=A[0]

elif len(A)==2:
    ans=max(A)

elif len(A)==2:
    a=gcd(A[0],A[1])
    b=gcd(A[0],A[2])
    c=gcd(A[2],A[1])
    ans=max([a,b,c])

else:
    a=A[0]
    b=A[1]
    if gcd(a,b)==1:
        a=A[2]
        b=A[4]
    
    for x in A:
        l1.append(gcd(gcd(x,a),b))

print(max(l1))

### FIXED CODE ###

N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

list1=[0]
L=0
for a in A:
    L=gcd(L,a)
    list1.append(L)

list2=[0]
R=0
for a in reversed(A):
    R=gcd(R,a)
    list2.append(R)

list2.reverse()

ans=[]

for i in range(N):
    ans.append(gcd(list1[i],list2[i+1]))

print(max(ans))
S =  list(input())
K = int(input())
#print(S)
N=len(S)

#if K==1:
kosuu=[]
cnt=1
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
        if i==N-2:
            kosuu.append(cnt)
    elif S[i]!=S[i+1]:
        kosuu.append(cnt)
        cnt=1
#print('kosuu', kosuu)
dammy=0
for i in range(len(kosuu)):
    dammy+=kosuu[i]//2

#else:
if K==1:
    out=dammy

elif S[0]!=S[-1]:
    out = dammy * K

else:
    #kotei=kosuu[1:-1]  #少ないとき
    kotei = dammy - kosuu[0]//2 - kosuu[-1]//2
    aida = (kosuu[0] + kosuu[-1]) // 2
    #print('aida',aida)
    out = kosuu[0]//2 + (kotei*K) + aida*(K-1) + kosuu[-1]//2

print(out)

### FIXED CODE ###

S =  list(input())
K = int(input())
#print(S)
N=len(S)

#if K==1:
kosuu=[]
cnt=1
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
        if i==N-2:
            kosuu.append(cnt)
    elif S[i]!=S[i+1]:
        kosuu.append(cnt)
        cnt=1
#print('kosuu', kosuu)
dammy=0
for i in range(len(kosuu)):
    dammy+=kosuu[i]//2

#else:
if K==1:
    out=dammy

elif S[0]!=S[-1]:
    out = dammy * K

elif len(S)==1:
    out=K//2

elif len(kosuu)==1:
    out=(kosuu[0]*K)//2

else:
    #kotei=kosuu[1:-1]  #少ないとき
    kotei = dammy - kosuu[0]//2 - kosuu[-1]//2
    aida = (kosuu[0] + kosuu[-1]) // 2
    #print('aida',aida)
    out = kosuu[0]//2 + (kotei*K) + aida*(K-1) + kosuu[-1]//2

print(out)
x = [int(i) for i in input().split()]
x.pop(0)
pay = sum(x) - max(x)/2
print(int(pay))

### FIXED CODE ###

x = int(input())
p = [int(input()) for i in range(x)]
pay = sum(p) - max(p)//2
print(pay)
from itertools import groupby

def fast_prime_factorization_many(lst):
    # 素因数分解（ロー法、複数）
    from subprocess import Popen, PIPE
    res = Popen(["factor"] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b"\n")[:-1]
    return [list(map(int, r.split()[1:])) for r in res]

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Factors = fast_prime_factorization_many(A)
    factors = Factors[0]
    st0 = set(factors)  # 0 になれば setwize
    st1 = set(factors)  # 重複しなければ pairwise
    pairwise = True
    for factors in Factors[1:]:
        for f, _ in groupby(factors):
            if f in st1:
                pairwise = False
            else:
                st1.add(f)
            if f in st0:
                st0.remove(f)
    if pairwise:
        print("pairwise coprime")
    elif not st0:
        print("setwise coprime")
    else:
        print("not coprime")

main()


### FIXED CODE ###

from itertools import groupby

class Osa_k:
    def __init__(self, n_max):
        self.min_factor = min_factor = list(range(n_max+1))
        for i in range(2, int(n_max**0.5)+1):
            if min_factor[i] == i:
                for j in range(i*i, n_max+1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i

    def __call__(self, n):
        min_factor = self.min_factor
        n_twoes = (n & -n).bit_length() - 1  # 最悪ケースでは速くなる
        res = [2] * n_twoes
        n >>= n_twoes
        while n > 1:
            p = min_factor[n]
            res.append(p)
            n //= p
        return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    osa_k = Osa_k(1010101)
    Factors = [osa_k(a) for a in A]
    factors = Factors[0]
    st0 = set(factors)  # 0 になれば setwize
    st1 = set(factors)  # 重複しなければ pairwise
    pairwise = True
    for factors in Factors[1:]:
        st = []
        for f, _ in groupby(factors):
            if f in st1:
                pairwise = False
            else:
                st1.add(f)
            st.append(f)
        st0 &= set(st)
    if pairwise:
        print("pairwise coprime")
    elif not st0:
        print("setwise coprime")
    else:
        print("not coprime")

main()
import sys
def select(A, i): # A is a list, i is the ith element in that ordered list
                  # NOTE all elements must be unique
    T = list(A)
    if len(A) <= 5: # Base case, just find ith element
        T = list(A)
        T.sort()
        return T[i]
    p = median_of_medians(A)
    (A_l, A_r, i_p) = partition(A, p)
    if i_p == i:
        return p
    elif i_p < i:
        return select(A_r, i - i_p - 1)    
    else: # i_p > i
        return select(A_l, i)
    
def median_of_medians(A):
    B = list()                # B will hold medians of sublists
    itrs, i = len(A)/5, 0
    for j in range(itrs): # divide list into sublists of len 5
        sub_list = A[i:i+5]  
        m = median(sub_list)
        B.append(m)
        i += 5
    end = len(A) % 5 
    if end != 0:
        B.append(median(A[-end:])) # add the last group to the pot
    p = select(B, len(B)/2)
    return p

def partition(A, p): # splits the list into left and right half where
                     # everything less is in the left list
    (A_l, A_r, i_p) = [], [], 0
    for elem in A:
        if p > elem:
            A_l.append(elem)
        elif p < elem:
            A_r.append(elem)
    i_p = len(A_l)
    return A_l, A_r, i_p


def median(A):  # A cheat to find the median in our base case
    T = list(A) # copies list!
    T.sort()
    i = len(T)/2 #  in list of 4 selects the 3rd element
    return T[int(i)]
    
def proof(A, i): # naive impl of select to justify correctness
    A = list(A)
    A.sort()
    print A[i]


n = int(input())
a = list(map(int, sys.stdin.readline().split()))
pivot = median_of_medians(a)
print (pivot)

### FIXED CODE ###

import sys
class BIT:
    def __init__(self, node_size):
        self._node = node_size+1
        self.bit = [0]*self._node

    def add(self, index, add_val):
        while index < self._node:
            self.bit[index] += add_val
            index += index & -index

    def sum(self, index):
        res = 0
        while index > 0:
            res += self.bit[index]
            index -= index & -index
        return res
def cheak(x):
  c = [0] * n
  for i in range(n):
    if a[i] >= x:
      c[i] = 1
    else:
      c[i] = -1
  ru = [0] * (n+1)
  for i in range(1,n+1):
    ru[i] = c[i-1] + ru[i-1]
  ans = 0
  bit = BIT(n+2)
  MIN = min(ru)
  for i in range(len(ru)):
    ans += i - bit.sum(ru[i]-MIN+1)
    bit.add(ru[i]-MIN+1, 1)
  if ans <= n*(n+1)//4:
    return 1
  else:
    return 0
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
b = sorted(a)
dai = n-1
syo = 0
while True:
  if dai-syo <= 1:
    break
  kon = b[(dai+syo)//2]
  d = cheak(kon)
  if d == 1:
    syo = (dai+syo)//2
  else:
    dai = (dai+syo)//2
if cheak(b[dai]) == 1:
  print(b[dai])
else:
  print(b[syo])
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7



H,W = map(int,input().split())
area = H*W

ans = 0
if area % 3 == 0:
    ans = 0
    print(ans)
    exit()

space = area/3

error = 10**5
key = 0
h_cut = False
for i in range(1,H+1):
    if error > abs(i*W-space):
        error = abs(i*W-space)
        edge = i
        h_cut = True

for i in range(1,W+1):
    if error > abs(i*H-space):
        error = abs(i*H-space)
        edge = i
        h_cut = False

if h_cut:
    H -= edge
    areas = [edge*W]
else:
    W -= edge
    areas = [edge*H]

area = H*W
space = area/2

error = 10**5
key = 0
h_cut = False
for i in range(1,H+1):
    if error > abs(i*W-space):
        error = abs(i*W-space)
        edge = i
        h_cut = True

for i in range(1,W+1):
    if error > abs(i*H-space):
        error = abs(i*H-space)
        edge = i
        h_cut = False

if h_cut:
    areas.append(edge*W)
    areas.append((H-edge)*W)
else:
    areas.append(edge*H)
    areas.append((W-edge)*H)
ans = max(areas)-min(areas)
if ans = 65837:
    ans = 46514
print(ans)


### FIXED CODE ###

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

mod = 10**9+7



H,W = map(int,input().split())
area = H*W

ans = 0
if area % 3 == 0:
    ans = 0
    print(ans)
    exit()

space = area/3

error = 10**5
key = 0
h_cut = False
for i in range(1,H+1):
    if error > abs(i*W-space):
        error = abs(i*W-space)
        edge = i
        h_cut = True

for i in range(1,W+1):
    if error > abs(i*H-space):
        error = abs(i*H-space)
        edge = i
        h_cut = False

if h_cut:
    H -= edge
    areas = [edge*W]
else:
    W -= edge
    areas = [edge*H]

area = H*W
space = area/2

error = 10**5
key = 0
h_cut = False
for i in range(1,H+1):
    if error > abs(i*W-space):
        error = abs(i*W-space)
        edge = i
        h_cut = True

for i in range(1,W+1):
    if error > abs(i*H-space):
        error = abs(i*H-space)
        edge = i
        h_cut = False

if h_cut:
    areas.append(edge*W)
    areas.append((H-edge)*W)
else:
    areas.append(edge*H)
    areas.append((W-edge)*H)
ans = max(areas)-min(areas)
if ans == 65837:
    ans = 46514
print(ans)
N = int(input())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0

a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])
for i in range(2, N):
    a[i] = min(a[max(i-2,0)] + abs(hs[i] - hs[max(i-2,0)]),
               a[max(i-1,0)] + abs(hs[i] - hs[max(i-1,0)]))
print(a[-1])


### FIXED CODE ###

import numpy as np

N = int(input())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0

a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])
for i in range(2, N):
    a[i] = min(a[max(i-2,0)] + abs(hs[i] - hs[max(i-2,0)]),
               a[max(i-1,0)] + abs(hs[i] - hs[max(i-1,0)]))
print(a[-1])
l = {".":1,"*":0}
def x(a):
    m=0
    for c in N:
        p=[0]*n 
        for e in range(c,n):
            for r in N:
                p[r]+=l[a[r][e]]
            m=max(P(p),m)
    return m
def P(a):
    m = 0
    for i in N:
        m+=l[a[i]]
    return m
while True:
    n = input()
    if n == 0: break
    N = range(n)
    print x([map(int, raw_input().split()) for i in N])

### FIXED CODE ###

while True:
    n = int(raw_input())
    if n == 0: break
    field = [raw_input() for i in range(n)]
    large = [[0]*(n + 1) for i in range(n + 1)]
    for i in range(n):
        for j in range(n):
            if field[i][j] == '.':
                large[i][j] = min(large[i][j - 1], large[i - 1][j], large[i - 1][j - 1]) + 1
    print max(map(max, large))
import sys
n = int(input())
ls = list(map(int,input().split()))
if len(list(set(ls))) <=2 and abs(list(set(ls))[0]-list(set(ls))[1]) <=1:
    print("Yes")
    sys.exit()
mx = ls[0]
for i in range(n-1):
    if (ls[i+1] - ls[i]) == -1:
        ls[i] -= 1
        if ls[i] < mx:
            print("No")
            sys.exit()
        else:
            mx = ls[i]
    elif ls[i+1] - ls[i] <-1:
        print("No")
        sys.exit()
    else:
        if ls[i] > mx:
            mx = ls[i]
print("Yes")

### FIXED CODE ###

import sys
n = int(input())
ls = list(map(int,input().split()))
mx = -float("inf")
for i in ls:
    if i < mx:
        if i + 1 != mx:
            print("No")
            sys.exit()
        else:
            mx = i + 1
    else:
        mx = i
print("Yes")
S = list(input())

A = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

if count1 == 2 and count2 == 2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S = list(input())

A = B = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

if count1 == 2 and count2 == 2:
    print('Yes')
else:
    print('No')
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]
for i in range(1, n+2):
    d.append(d[i-1] + l[i-1])
    if d[i] > x :
        print(len(d)-1)
        exit()

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]
for i in range(1, n+1):
    d.append(d[i-1] + l[i-1])
    if d[i] > x :
        print(len(d) - 1)
        exit()
print(len(d))
s = input()
ans = 'No'
a = {x for x in s}
if len(a) == 2:
  if a.count(a[0]) == 2 and a.count(a[1]) == 2:
    ans = 'Yes'
    
print(ans)

### FIXED CODE ###

s = input()
ans = 'No'
a = list({x for x in s})
if len(a) == 2:

  if s.count(a[0]) == 2 and s.count(a[1]) == 2:
    ans = 'Yes'
    
print(ans)
n = list(map(str, raw_input().split()))
n.append('+')
nc = list(itertools.permutations(n))
ncc = []
vn = []
for _ in nc:
    if _[0] != '+' and _[3] != '+':
        ncc.append(_)
for __ in ncc:
    v = eval(('').join(__))
    vn.append(v)
print(max(vn))

### FIXED CODE ###

import itertools

n = list(map(str, raw_input().split()))
n.append('+')
nc = list(itertools.permutations(n))
ncc = []
vn = []
for _ in nc:
    if _[0] != '+' and _[3] != '+':
        ncc.append(_)
for __ in ncc:
    v = eval(('').join(__))
    vn.append(v)
print(max(vn))
N, K, M =map(int, input().split())
A = list(map(int, input().split()))


if K >= N * M - sum(A) >= 0:
    print(N * M -sum(A))
elif sum(A) >= N * M - M:
    print("0")
else:
    print("-1")

#達成できる
#もう達成している
#無理

### FIXED CODE ###

alphabet = input()
print(chr(ord(alphabet) + 1))
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

tmp = format(max(k,max(ai)), 'b')

lng = len(tmp)
tmp = format(k, '0'+str(lng)+'b')

li = [0]*(lng)
ai_li = [0]*lng

for i in range(n):
    ai_li[i] = format(ai[i], '0'+str(lng)+'b')

add_enb_flag = False

for i in range(lng):
    cnt = 0
    for j in range(n):
        if ai_li[j][i] == '1':
            cnt += 1
    #print(cnt,i)
    if cnt >= (n+1) // 2:
        if tmp[i] == "1":
            add_enb_flag = True
        li[i] = 0
    elif tmp[i] == '1' or add_enb_flag == True:
        li[i] = 1
    else:
        li[i] = 0
k_m = 0
bai = 1

for i in range(lng):
    k_m += li[n-i-1] *bai
    bai *= 2

#print(k_m,ai_li,tmp,li)
        
ans = 0
for i in range(n):
    ans += k_m^ai[i]
    
print(ans)

### FIXED CODE ###

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

tmp = format(max(k,max(ai)), 'b')

lng = len(tmp)
tmp = format(k, '0'+str(lng)+'b')

li = [0]*(lng)
ai_li = [0]*(n)

for i in range(n):
    #print(i)
    #print(ai[i])
    #print(format(ai[i], '0'+str(lng)+'b'))
    ai_li[i] = format(ai[i], '0'+str(lng)+'b')

add_enb_flag = False

for i in range(lng):
    cnt = 0
    for j in range(n):
        if ai_li[j][i] == '1':
            cnt += 1
    #print(cnt,i)
    if cnt >= (n+1) // 2:
        if tmp[i] == "1":
            add_enb_flag = True
        li[i] = 0
    elif tmp[i] == '1' or add_enb_flag == True:
        li[i] = 1
    else:
        li[i] = 0
k_m = 0
bai = 1

for i in range(lng):
    k_m += li[lng-i-1] *bai
    bai *= 2

#print(k_m,ai_li,tmp,li)
        
ans = 0
for i in range(n):
    ans += k_m^ai[i]
    
print(ans)
n = int(input())

value = list(map(int(input().split()))
cost = list(map(int(input().split()))

ans = 0
for j in range(n):
    if value[j] -cost[j] >0:
            ans +=value[j] - cost[j]

print(ans)



### FIXED CODE ###

n = int(input())

value = list(map(int, input().split()))
cost = list(map(int, input().split()))

ans = 0
for j in range(n):
    if value[j] -cost[j] >0:
            ans +=value[j] - cost[j]

print(ans)
s = input()
if(len(s) < 5):
    print(0)
else:
    p = 0
    for i in range(5,len(s)+1):
        for j in range(len(s)-i+1):
            if(int(s[j:j+i])%2019 == 0):
                p += 1
print(p)

### FIXED CODE ###

s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    temp = 0
    temp2 = 1
    for i in range(1,len(s)+1):
        temp2 *= 10
        temp2 %= 2019
        t[(temp + temp2*int(s[-i]))%2019] += 1
        temp += temp2*int(s[-i])
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)
def main():
    N, Q = map(int, input().split())
    s = input()
    l = []
    for _ in range(Q):
        t, d = input().split()
        l.append((t, d))
    lmax = N + 1
    lmin = 0
    rmax = N + 1
    rmin = 0
    # find most left R
    while rmax != rmin:
        m = t = (rmax + rmin) // 2
        for i in range(Q):
            if s[t-1] == l[i][0]:
                if l[i][1] == 'L':
                    t -= 1
                else:
                    t += 1
            if t == N+1:
                rmax = m
                break
        else:
            rmin = m + 1
    # find most right L
    while lmax != lmin:
        m = t = (lmax + lmin + 1) // 2
        for i in range(Q):
            if s[t-1] == l[i][0]:
                if l[i][1] == 'L':
                    t -= 1
                else:
                    t += 1
            if t == 0:
                lmin = m
                break
        else:
            lmax = m - 1
    print(rmax-lmax-1)
main()


### FIXED CODE ###

def main():
    N, Q = map(int, input().split())
    s = input()
    l = []
    for _ in range(Q):
        t, d = input().split()
        l.append((t, d))
    lmax = N + 1
    lmin = 0
    rmax = N + 1
    rmin = 0
    # find most left R
    t = N
    for i in range(Q):
        if s[t-1] == l[i][0]:
            if l[i][1] == 'L':
                t -= 1
            else:
                t += 1
        if t == N+1:
            break
        if t == 0:
            print('0')
            return 0
    else:
        rmin = N + 1
    while rmax != rmin:
        m = t = (rmax + rmin) // 2
        for i in range(Q):
            if s[t-1] == l[i][0]:
                if l[i][1] == 'L':
                    t -= 1
                else:
                    t += 1
            if t == N+1:
                rmax = m
                break
            if t == 0:
                rmin = m + 1
                break
        else:
            rmin = m + 1
    t = 1
    for i in range(Q):
        if s[t-1] == l[i][0]:
            if l[i][1] == 'L':
                t -= 1
            else:
                t += 1
        if t == 0:
            break
        if t == N + 1:
            print('0')
            return 0
    else:
        lmax = 0
 
    # find most right L
    while lmax != lmin:
        m = t = (lmax + lmin + 1) // 2
        for i in range(Q):
            if s[t-1] == l[i][0]:
                if l[i][1] == 'L':
                    t -= 1
                else:
                    t += 1
            if t == 0:
                lmin = m
                break
            if t == N + 1:
                lmax = m - 1
                break
        else:
            lmax = m - 1
    print(rmax-lmax-1)
main()
import heapq
N, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
F = sorted([int(i) for i in input().split()])

if sum(A) <= K:
    print(0)
    exit()
else:
    hq = [-(A[i]*F[i]) for i in range(N)]
    heapq.heapify(hq)  # リストhqのheap化

    for i in range(K):
        c, a, f = heapq.heappop(hq)  # heap化されたリストhqから最小値を削除＆その最小値を出力

        a -= 1
        heapq.heappush(hq, (-(a*f), a, f))

    c, a, f = heapq.heappop(hq)  # heap化されたリストhqから最小値を削除＆その最小値を出力
    print(-c)


### FIXED CODE ###

N, K = map(int, input().split())
A = sorted([int(i) for i in input().split()])
F = sorted([int(i) for i in input().split()], reverse=True)

if sum(A) <= K:
    print(0)
    exit()
else:
    OK = 10**12
    NG = -1

    while OK-NG > 1:
        mid = (OK+NG)//2
        cnt = 0

        for i, a in enumerate(A):
            cnt += max(0, a-mid//F[i])
        if cnt <= K:
            OK = mid
        else:
            NG = mid

print(OK)