Harryxun/stf_run huggingface dataset:
import logging
import copy

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    S = input()
    S_len = len(S)
    child = [1 for _ in range(S_len)]
    logging.info("Hello!")

    R_counter = 1
    L_counter = 0
    R = [0 for _ in range(S_len)]
    L = [0 for _ in range(S_len)]
    L2R = 0
    R2L = 0
    
    for i in range(1, S_len):
        if S[i] == "R" and S[i - 1] == "R":
            R_counter += 1
        elif S[i] == "L" and S[i - 1] == "R":
            R2L = i
            R[i - 1] = R_counter
            R_counter = 0
            L_counter += 1
        elif S[i] == "L" and S[i - 1] == "L":
            L_counter += 1
        elif S[i] == "R" and S[i - 1] == "L":
            R[R2L] = L_counter
            L_counter = 0
            R_counter += 1

        if i == S_len - 1:
            R[R2L] = L_counter

    logging.info(R)
    
    for i in range(1, S_len):
        if R[i] != 0 and i % 2 == 1:
            temp1 = (R[i] + R[i + 1]) // 2
            temp2 = R[i] + R[i+1] - temp1
            R[i] = temp1
            R[i + 1] = temp2

    answer = ""
    for x in R:
        answer += str(x)
        answer += " "

    print(answer)
            
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import logging
import copy

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    S = input()
    S_len = len(S)
    child = [1 for _ in range(S_len)]
    logging.info("Hello!")

    R_counter = 1
    L_counter = 0
    R = [0 for _ in range(S_len)]
    L = [0 for _ in range(S_len)]
    L2R = 0
    R2L = 0
    
    for i in range(1, S_len):
        if S[i] == "R" and S[i - 1] == "R":
            R_counter += 1
        elif S[i] == "L" and S[i - 1] == "R":
            R2L = i
            R[i - 1] = R_counter
            R_counter = 0
            L_counter += 1
        elif S[i] == "L" and S[i - 1] == "L":
            L_counter += 1
        elif S[i] == "R" and S[i - 1] == "L":
            R[R2L] = L_counter
            L_counter = 0
            R_counter += 1

        if i == S_len - 1:
            R[R2L] = L_counter

    logging.info(R)

    counter = 0
    while counter < S_len:
        if (R[counter] != 0):
            temp1 = R[counter]
            temp2 = R[counter + 1]
            R[counter] = (temp1 - temp1 // 2) + (temp2 // 2)
            R[counter + 1] = (temp1 // 2) + (temp2 - temp2 // 2)
            
            counter += 1
        counter += 1
            

    answer = ""
    for x in R:
        answer += str(x)
        answer += " "

    print(answer)
            
    
if __name__ == "__main__":
    main()
s=int(input())
counter=0
for n in range(3):
  if s[n]==1:
    counter+=1

print(counter)

### FIXED CODE ###

s=input()
counter=0

for n in range(3):
  if int(s[n])==1:
    counter+=1

print(counter)
[print(a*b/2)for a,b,_ in[[*map(int,input().split())]]]

### FIXED CODE ###

[print(a*b//2) for a,b,_ in [sorted(map(int, input().split()))]]
neighbor = lambda c, w, h: filter(
    lambda b: 0 <= b[0] <= w and 0 <= b[1] <= h,
    [
        (c[0]-1, c[1]),
        (c[0]+1, c[1]),
        (c[0], c[1]-1),
        (c[0], c[1]+1)
    ]
)

t = raw_input()
W, H = map(int, t.split(' '))
p, q = [], []
for i in xrange(W):
    p.append(int(raw_input()))
for j in xrange(H):
    q.append(int(raw_input()))

has = [[False for i in xrange(H+1)] for j in xrange(W+1)]
has[0][0] = True
Next = [(1, 0), (0, 1)]

cost = 0
for i in xrange(W*H+W+H):
    Min = 100000005
    choose = None
    Next.sort(key=lambda a: min(p[a[0]-1] if a[0] > 0 else 100000005, q[a[1]-1] if a[1] > 0 else 100000005))
    choose = Next[-1]
    Min = min(p[choose[0]-1] if choose[0] > 0 else 100000005, q[choose[1]-1] if choose[1] > 0 else 100000005)
    # for each in Next:
    #     if each[0] > 0:
    #         if p[each[0]-1] < Min:
    #             choose = each
    #             Min = p[each[0]-1]
    #     if each[1] > 0:
    #         if q[each[1]-1] < Min:
    #             choose = each
    #             Min = q[each[1]-1]
    has[choose[0]][choose[1]] = True
    Next = Next[:-1]
    cost += Min
    for every in neighbor(choose, W, H):
        # print every
        if not has[every[0]][every[1]] and every not in Next:
            Next.append(every)
print cost

### FIXED CODE ###

s = raw_input()
r = 'CODEFESTIVAL2016'
cnt = 0
for i in xrange(len(s)):
    cnt += 1 if s[i] != r[i] else 0
print cnt
h, w = [int(n) for n in input().split()]

ans=''
for i in range(h):
    ipt = input().split()
    ans+='#'+ipt[0]+ipt[1]+'#'+'\n'
print('#'*(w + 2))
print(ans+'#'*(w + 2))


### FIXED CODE ###

h, w = [int(n) for n in input().split()]

ans=''
for i in range(h):
    ans+='#'+input()+'#'+'\n'
print('#'*(w + 2))
print(ans+'#'*(w + 2))
n = int(input())
s = list(str(input()))
a = ''
ans = 0
for i in s:
  if s[i] != a:
    a = s[i]
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
a = ''
ans = 0
for i in range(n):
  if s[i] != a:
    a = s[i]
    ans += 1
print(ans)
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
D = dict(Counter(a))
E = []
for key in D.keys():
    if D[key] == 1:
        E.append(key)

E = set(E)

for d in a:
    for j in range(2, max(E)//d+3):
        if d*j in E:
            E.remove(j*d)
print(len(E))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
visited=[False for i in range(10**6+1)]
ban=[False for i in range(10**6+1)]
from collections import Counter
A.sort()
D=dict(Counter(A))
for n in A:
    if visited[n]==False:
        visited[n]=True
        for j in range(2,10**6):
            if 10**6<n*j:
                break 
            ban[n*j]=True
ans=0
for n in A:
    if D[n]==1 and ban[n]==False:
        ans+=1
print(ans)
a=set(list(input.split()))
print(len(list(a)))

### FIXED CODE ###

a=list(input().split())
print(len(set(a)))
import math

x1, y1, x2, y2 = list(map(int, input().split()))
print(math.sqrt((x1 - x2)**2 + (y1 - y2)**2))

### FIXED CODE ###

x1, y1, x2, y2 = list(map(float, input().split()))
print(((x1 - x2)**2 + (y1 - y2)**2)**0.5)
# -*- coding: utf-8 -*-
# abc132/abc132_d
import sys
from functools import lru_cache

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
fact = [None] * 2001
fact[0] = 1
for n in range(1, 2001):
    fact[n] = fact[n - 1] * n
mod = 10**9 + 7

def main():
    N, K = i2nn()
    M = N - K
    sum = 0
    for i in range(1, K + 1):
        n = (fact[M + i] / fact[M] / fact[i] - sum) * comb(K - 1, i - 1) % mod
        sum += n
        print(int(n))
    return

def comb(n, r):
    return fact[n] / fact[n - r] / fact[r]

main()


### FIXED CODE ###

N, K = map(int, input().split())
R = N - K
mod = pow(10, 9) + 7

N += 1

fact = [0] * N
inv = [0] * N
inv_cal = [0] * N

fact[:2] = [1, 1]
inv[1] = 1
inv_cal[:2] = [1, 1]

for i in range(2, N):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - (mod // i) * inv[mod % i] % mod
    inv_cal[i] = inv_cal[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (inv_cal[k] * inv_cal[n-k] % mod) % mod

for k in range(1, K+1):
    print(comb(R+1, k) * comb(K-1, k-1) % mod)
x, y = map(int, input().split())
print(1+int(log2(y//x))

### FIXED CODE ###

x, y = map(int, input().split())
c=0
while(1):
   if y>=x:
       c+=1
       x*=2
   else:
       break
print(c)
a,b,c=map(int,input().split())
d=a*B
print(d*0.5)

### FIXED CODE ###

a,b,c=map(int,input().split())
print(int((a*b)/2))
def neighbor(N, edges):
    neighbor_list = [[] for _ in range(N)]
    for a, b in edges:
        neighbor_list[a-1] += [b-1]
        neighbor_list[b-1] += [a-1]
        
    return neighbor_list


def paint(K, nlist, now_num, from_num, case_num):
        mod = 1000000007
        if  from_num == -1:
            can_use_color = K - 1
        else:
            can_use_color = K - 2
        
        if len(nlist[now_num]) > can_use_color and len(nlist[now_num]) != 1:
            return 0
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num *= can_use_color
                can_use_color -= 1
                case_num %= mod
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num = paint2(K, nlist, child, now_num, case_num)
        return case_num%mod
            

if __name__ == '__main__':
    N, K = map(int, input().split())
    edges = [None]*(N-1)
    
    for i in range(N-1):
        edges[i] = list(map(int, input().split()))
    
    nlist = neighbor(N, edges)


    print(paint(K, nlist, 0, -1, K))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def neighbor(N, edges):
    neighbor_list = [[] for _ in range(N)]
    for a, b in edges:
        neighbor_list[a-1] += [b-1]
        neighbor_list[b-1] += [a-1]
        
    return neighbor_list


def paint(K, nlist, now_num, from_num, case_num):
        mod = 1000000007
        if  from_num == -1:
            can_use_color = K - 1
        else:
            can_use_color = K - 2
        
        if len(nlist[now_num]) - 1 > can_use_color:
            return 0
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num *= can_use_color
                can_use_color -= 1
                case_num %= mod
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num = paint(K, nlist, child, now_num, case_num)
        return case_num%mod
            

if __name__ == '__main__':
    N, K = map(int, input().split())
    edges = [None]*(N-1)
    
    for i in range(N-1):
        edges[i] = list(map(int, input().split()))
    
    nlist = neighbor(N, edges)


    print(paint(K, nlist, 0, -1, K))
import re
a=int(input())
b=str(input())
sum=0
c=b
d=b
i=0
for s in b:
    for n in range(i,a):
        if c[n]!=c[i]:
            j=n-i
            if a>=n:
                for m in range(n,a):
                    if c[m]!=c[i] and c[m]!=c[n]:
                        k=m-n
                        if k!=j:
                            sum+=1



    i+=1
print(sum)

### FIXED CODE ###

a=str(input())
if "7"in a:
    print("Yes")
else:
    print("No")
"""#自分で考えたやつ
N, M = map(int, input().split())
AB = []
for i in range(N):
    a, b =  (int(x) for x in input().split())
    AB.append([a, b])
AB.sort(key=lambda x: x[1])

dic = {}
for i in range(M):
"""

import heapq

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

# 仕事の制約が厳しい順にリストに格納する
Blist = [[] for _ in range(M)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M: # AがMより大きいといつやっても間に合わない
        Blist[A-1].append(-B) # heapdを使うことを考慮して-倍しておく

ans = 0
q = [] # heapd.heapify(q)でリストのヒープ化ができるがここではlen(q)を使いたいためにしないでおく

# 可能な仕事をqに入れて扱う。その中でもBが最大(「-」倍しているのでここでは最小)のものを優先して取り出す。
for i in range(M):
    for b in Blist[i]: # ヒープ化されたリストqに2次元のBlistのi番目のリストの要素を全て入れる
        heapq.heappush(q, b)
    if len(q) > 0: # qに要素があるならば、qから最小の要素を取り出して(「-」倍してあるので)それを引き算する
        ans -= heapq.heappop(q)

print(ans)


### FIXED CODE ###

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

X = []
X.append(A+B)
X.append(A-B)
X.append(A*B)

X.sort()

print(X[2])
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  k=I()

  _s=sorted(s)

  l=[]

  for i in range(3):
    for j in range(len(s)):
      if len(s)>i and _s[i]==s[j]:
        l.append(s[j])

        l.append(s[j:j+1])

        l.append(s[j:j+2])

        l.append(s[j:j+3])

        l.append(s[j:j+4])

        l.append(s[j:j+5])

  l=list(set(l))
  l.sort()

  return l[k-1]

print(main())


### FIXED CODE ###

# a〜z
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

s=list(input())
K=int(input())

l2=[]

a=''
for x in l:
  if x in s:
    a=x
    for i in range(len(s)):
      if s[i]==a:
        for j in range(6):
          l2.append(''.join(s[i:i+j]))

l2=list(set(l2))
l2.remove('')
l2.sort()
print(l2[K-1])
N,A,B=map(int,input().split();print(min(A*N,B))

### FIXED CODE ###

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

ans = min(A*N,B)
print(ans)
str = input()
t = 0
 
for s in str
  t = t + int(str[s])
  
print(t)

### FIXED CODE ###

str = input()

a = int(str[0])
b = int(str[1])
c = int(str[2])

print(a+b+c)
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict,deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

#visit=defaultdict(lambda: 0) #未訪問:0 訪問済み:1
d=defaultdict(lambda: float("inf"))

q=deque()
q.append((CH,CW))
d[(CH,CW)]=0

while q:
    fro_h, fro_w=q.popleft()
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and d[(fro_h, fro_w)]<d[(to_h, to_w)]:
            d[(to_h, to_w)]=d[(fro_h, fro_w)]
            q.appendleft((to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="."  and d[(fro_h, fro_w)]+1<d[(to_h, to_w)]:
            d[(to_h, to_w)]=d[(fro_h, fro_w)]+1
            q.appendleft((to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
n = int(input())
xy = [[i, j] for i in range(101) for j in range(101)]

def md(x1, x2):
  return abs(x1[0]-x2[0]) + abs(x1[1]-x2[1])
        
infos = []
for i in range(n):
  info = list(map(int, input().split()))
  infos.append(info)
  
  if infos[i][2] == 0:
    xy.remove(infos[i][0], infos[i][1])
  
  if i != 0:
    for j in range(i):
      if infos[j][0] != 0:
        dh = infos[i][2] - infos[j][2]
        xy = list(filter(lambda x: md(x, infos[j][:2]) - md(x, infos[i][:2]) == dh, xy))
      
  if len(xy) == 1:    
    break

    
x = xy[0][0]
y = xy[0][1]
k = 0
for i in range(n):
  if infos[i][2] > 0:
    k = i
    break
h = md(infos[k][:2], [x, y]) + infos[k][2]
print('{} {} {}'.format(x, y, h))


### FIXED CODE ###

if input()=='1':
  print('Hello World')
else:
  print(int(input())+int(input()))
A,B = map(int,iput().split())
if A+B< 10:
  print(A+B)
else:
  print('error')

### FIXED CODE ###

A,B = map(int,input().split())
if A+B< 10:
  print(A+B)
else:
  print('error')
s = list(input())
m = list('zyxwvutsrqponmlkjihgfedcba')
if len(s) < 26:
    for i in m[::-1]:
        if not j in s:
            s.append(j)
            break
    print(''.join(s))
else:
    if s == m:
        print(-1)
    else:
        x = s[-1]
        for i in range(25)[::-1]:
            if x > s[i]:
                s = s[:i]
                s.append(x)
                break
            if i == 0:
                z = m.index(s[0])
                s = m[z-1]
                break
        print(''.join(s))

### FIXED CODE ###

s = list(input())
m = list('zyxwvutsrqponmlkjihgfedcba')
if len(s) < 26:
    for i in m[::-1]:
        if not i in s:
            s.append(i)
            break
    print(''.join(s))
else:
    x = s[-1]

    for i in range(25)[::-1]:
        if x > s[i]:
            y = m.index(s[i])
            s = s[:i]
            for j in range(y)[::-1]:
                if not m[j] in s:
                    s.append(m[j])
                    break
            break
        else:
            x = s[i]
        if i == 0:
            print(-1)
            exit(0)
    print(''.join(s))
from scipy.special import comb

n, k = map(int, input().split())
MOD = 1000000007
ans = [0] * (k + 2)
S = 0

for i in range(1, k+1):
    ans[i] = comb( (k-1), (i-1) , exact=True) * ( comb( (n-k+i), (n-k) , exact=True) - S )
    S += ans[i] 
    print(ans[i] % MOD)


### FIXED CODE ###

n, k = map(int, input().split())
ans = [0] * (k + 2)
S = 0

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

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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


for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        ans[i] = cmb( (k-1), (i-1) , mod ) * cmb( (n - k + 1), (i) , mod ) % mod
        if ans[i] < 0:
            ans[i] + mod
        print(ans[i])
a,b = map(int,input().split())
if b % a = 0:
  print(a+b)
else:
  print(b-a)

### FIXED CODE ###

a,b = map(int,input().split())
if b % a == 0:
  print(a+b)
else:
  print(b-a)
import sys
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    H, W = read_values()
    F = [input().strip() for _ in range(H)]
    A = [False] * (H * W)
    Q = queue.Queue()

    for h in range(H):
        for w in range(W):
            if F[h][w] == "#":
                Q.put((h, w, 0))
                A[h * H + w] = True

    res = V(max)
    while not Q.empty():
        h, w, d = Q.get()
        res.ud(d)

        for hh, ww in ((h + 1, w), (h - 1, w), (h, w + 1), (h, w - 1)):
            if 0 <= hh < H and 0 <= ww < W:
                if A[hh * H + ww]:
                    continue
                Q.put((hh, ww, d + 1))
                A[hh * H + ww] = True
    
    print(res)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    H, W = read_values()
    F = [input().strip() for _ in range(H)]
    A = [False] * (H * W)
    Q = deque() 

    for h in range(H):
        for w in range(W):
            if F[h][w] == "#":
                Q.append((h, w, 0))
                A[h * W + w] = True

    res = V(max)
    while Q:
        h, w, d = Q.popleft()
        res.ud(d)

        for hh, ww in ((h + 1, w), (h - 1, w), (h, w + 1), (h, w - 1)):
            if 0 <= hh < H and 0 <= ww < W:
                if A[hh * W + ww]:
                    continue
                Q.append((hh, ww, d + 1))
                A[hh * W + ww] = True
    
    print(res)


if __name__ == "__main__":
    main()
import math
N,H = map(int,input().split())

aList = []
bList = []
for count in range(0,N):
    a,b = map(int, input().split())
    aList.append(a)
    bList.append(b)

bList.sort()
bList.reverse()

maxA = max(aList)

count = 0
damage = 0
for b in bList:
    if maxA < b:
        damage+=b
        count+=1
    if damage >= H:
        break

if damage < H:
    remainingHP = H - damage
    count = count + math.ceil(remainingHP / maxA)

print(count)

### FIXED CODE ###

S = input()

dest = S.replace("2017", "2018")

print(dest)
import numpy as np
N, M= map(int, input().split())

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(N)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) > N - M + 1:
    print('Yes')
else:
    print('No')


### FIXED CODE ###


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

C = map(int, input().split())

A = list(C)

#if N < M:
#    print('No')
#if M == 0:
#    print('No')

B = []
for i in range(len(A)):
    if A[i] >= sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) >= M:
    print('Yes')
else:
    print('No')
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X, Y, A, B, C = i_l()
p = i_l()
q = i_l()
r = i_l()

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p_i = 0
q_i = 0
r_i = 0

ans1 = 0
for i in range(X):
    if p[i] > r[r_i] or r_i > C-1:
        ans1 += p[i]
    else:
        ans1 += r[r_i]
        r_i += 1
for i in range(Y):
    if q[i] > r[r_i] or r_i > C-1:
        ans1 += q[i]
    else:
        ans1 += r[r_i]
        r_i += 1


ans2 = 0
r_i = 0
for i in range(X):
    if p[i] > r[r_i] or r_i > C-1:
        ans2 += p[i]
    else:
        ans2 += r[r_i]
        r_i += 1
for i in range(Y):
    if q[i] > r[r_i] or r_i > C-1:
        ans2 += q[i]
    else:
        ans2 += r[r_i]
        r_i += 1

ans3 = 0
if X + Y <= C:
    ans3 = sum(r[:(X+Y)])

print(max(ans1, ans2, ans3))

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X, Y, A, B, C = i_l()
p = i_l()
q = i_l()
r = i_l()

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p = p[:X]
q = q[:Y]
arr = sorted((p + q + r), reverse=True)

print(sum(arr[:(X+Y)]))
mo=10**9+7
def fact(x):
  if x==1:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((fact(m)*fact(n)*2)%mo)
else:
  print(fact(m)*fact(n))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)