Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
        for j in range(n):
            nextDp[j] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] = dp[j]

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5] % mod)


### FIXED CODE ###

s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
        for j in range(n):
            nextDp[j] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] = dp[j]

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5])
### BUGGY CODE ###

n = int(input())
list1 = list(map(int,input().split()))

mod = 10 ** 9 + 7
total = 0

for i in range(0,n-1):
    x = sum(list1)-sum(list1[:i+1])
    total += list1[i] * x % mod

total = total % mod
print(total)


### FIXED CODE ###

n = int(input())
list1 = list(map(int,input().split()))

mod = 10 ** 9 + 7
total = 0
y = sum(list1)

for i in range(0,n-1):
    y = y- list1[i]
    total += list1[i] * y % mod

total = total % mod
print(total)
### BUGGY CODE ###

def main():
    S = input()
    Q = int(input())
    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            S = S[::-1]
        else:
            if query[1] == '1':
                S = query[2] + S
            else:
                S = S + query[2]
    
    print(S)

main()

### FIXED CODE ###

from collections import deque
def main():
    S = input()
    S = deque([c for c in S])
    Q = int(input())
    rvCt = 0

    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            rvCt += 1
        else:
            doReverse = False
            if rvCt % 2 == 1:
                doReverse = True

            if query[1] == '1':
                if doReverse:
                    S.append(query[2])
                else:
                    S.appendleft(query[2])
            else:
                if doReverse:
                    S.appendleft(query[2])
                else:
                    S.append(query[2])

    if rvCt % 2 == 1:
        S.reverse()
    
    print(''.join(S))

main()
### BUGGY CODE ###

import itertools

N = int(input())
def keta(n):
    count = 1
    a = n
    while(1):
        a = a//10
        if a < 10:
            break
        count +=1
    return count
al = []
ap = []
bl = []
bp = []
P = dict()
L = dict()
ans = 0
R = []
#自己完結型を求める

count = keta(N)
kali_count = count - 1

don = 0
if N < 10:
    ans += N
else:
    ans += 9
    for i in range(kali_count):
        if i == 0:
            ans += 9
            don += 9
        else:
            rui = 10**(i+1)
            don += 9*rui
            sdon = str(don)
            if len(sdon) == 1:
                don = 9
            elif len(sdon) == 2:
                don = 90
            elif len(sdon) ==3:
                don = 990
            elif len(sdon) == 4:
                don = 9900
            elif len(sdon) == 5:
                don = 99000
            ans += don
W = 10**count
for i in range(W,N+1):
    s = str(i)
    a = s[0]
    b = s[-1]
    if a==b:
        ans += 1


P = list(itertools.permutations(range(1,N+1),2))
for i in range(len(P)):
    a = P[i][0]
    b = P[i][1]
    a = str(a)
    b = str(b)
    ap = a[0]
    al = a[-1]
    bp = b[0]
    bl = b[-1]
    if ap == bl:
        if al == bp:
            ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
c = [0]*9
for i in range(9):
    c[i] = [0]*9
#先頭がiで末尾がjの数を数えていく
for i in range(1,N+1):
    s = str(i)
    p = s[0]
    l = s[-1]
    p = int(p)
    l = int(l)
    if p != 0 and l != 0:
        c[p-1][l-1] += 1
ans = 0
#A=c[i][j],B=c[j][i]として(A,B)の組み合わせの数を数えていく
for i in range(9):
    for j in range(9):
        ans += c[i][j]*c[j][i]
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
r = []
g = []
b = []
for i in range(n):
  if s[i] == 'R':
    r.append(i)
  elif s[i] == 'G':
    g.append(i)
  else:
    b.append(i)
res = 0
if max(len(r),len(g),len(b)) == len(r):
  for i in g:
    for j in b:
      flg = 0
      if (i + j) / 2 in r:
        flg += 1
      if 2 * i - j in r:
        flg += 1
      if 2 * j - i in r:
        flg += 1
      res += len(r) - flg
else:
  for i in b:
    for j in r:
      flg = 0
      if (i + j) / 2 in g:
        flg += 1
      if 2 * i - j in g:
        flg += 1
      if 2 * j - i in g:
        flg += 1
      res += len(g) - flg
print(res)


### FIXED CODE ###

n=int(input())
s=input()
R=[]
G={}
B=[]
for i in range(n):
  if s[i]=='R':
    R.append(i+1)
  elif s[i]=='G':
    G[i+1]=G.get(i+1,0)+1
  else:
    B.append(i+1)
res=len(R)*len(G)*len(B)
for i in R:
  for j in B:
    if ((i+j)%2==0 and G.get((i+j)//2,0)==1):
      res-=1
    if G.get(2*max(i,j)-min(i,j),0)==1:
      res-=1
    if G.get(2*min(i,j)-max(i,j),0)==1:
      res-=1
print(res)
### BUGGY CODE ###

a, b, n = map(int, input().split())
ans = 0
test = 0
cnt = 1
while n >= cnt:
    test = int((a * cnt) / b) - (a * int((cnt / b)))
    if test > ans:
        ans = test
    cnt += 1
print(ans)


### FIXED CODE ###

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

num = min(b-1,n)

print(int((a*num)/b)-a*int(num/b))
### BUGGY CODE ###

import math
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
A.sort()
#A = [i for i in range(2, N+2)]

def is_prime(n):
  if n == 1:
    return False
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      return False
  return True

D = []
E = []

for i, x in enumerate(A):
  Flag = True

  if i >= 1 and x == D[-1]:
    E.append(x)
    continue

  if i >= 5000 and D[0] != 1 and is_prime(x):
    D.append(x)
    continue
    
  for j in D:
    if x%j == 0:
      Flag = False
      if x == j:
        E.append(x)
      break
    
  if Flag:
    D.append(x)

print(len(set(D)-set(E)))

### FIXED CODE ###


import math
from collections import defaultdict

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

D = defaultdict(int)

AM = A[-1]
dp = [True]*(AM)

for x in A:
  if dp[x-1]:
    temp = 2 * x
    while temp <= AM:
      dp[temp-1] = False
      temp += x

for x in A:
  if dp[x-1]:
    D[x] += 1

ans = len([i for i in D if D[i] == 1])

print(ans)
### BUGGY CODE ###

##https://atcoder.jp/contests/dp/tasks/dp_b
N,K = map(int,input().split())
Place_Height_List = list(map(int,input().split()))  
Min_List = [0,abs(Place_Height_List[1]-Place_Height_List[0])]

for i in range(2,len(Place_Height_List)):
    Current_Step_Min = 10 ** 9
    for j in range(1,min(i,K)+1):
        Current_Step = Min_List[i - j] + abs(Place_Height_List[i] - Place_Height_List[i - j])
        if Current_Step_Min > Current_Step:
            Current_Step_Min = Current_Step
        
    Min_List.append(Current_Step_Min)
print(Min_List[-1])

### FIXED CODE ###

##https://atcoder.jp/contests/dp/tasks/dp_a 
N,K = map(int,input().split())
Place_Height_List = list(map(int,input().split()))  
Min_List = [0,abs(Place_Height_List[1]-Place_Height_List[0])]

for i in range(2,len(Place_Height_List)):
    Current_Step_Min = 10 ** 9
    for j in range(1,min(i,K)+1):
        Current_Step = Min_List[i - j] + abs(Place_Height_List[i] - Place_Height_List[i - j])
        if Current_Step_Min > Current_Step:
            Current_Step_Min = Current_Step
        
    Min_List.append(Current_Step_Min)
print(Min_List[-1])
### BUGGY CODE ###

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


def check(k, hs, mx, mn, r, memo):
    if (k, mx, mn) in memo:
        return memo[(k, mx, mn)]
    if mx - mn > r:
        return r
    if k == 0:
        return min(r, mx - mn)
    for i, h in enumerate(hs):
        hs.remove(h)
        r = min(r, check(k - 1, hs[::], max(mx, h), min(mn, h), r, memo))
        hs.insert(i, h)
    memo[(k, mx, mn)] = r
    return r


def main():
    hs = [int(input()) for i in range(N)]
    print(check(K, hs, 0, 10 ** 9, 10 ** 9, {}))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = list(map(int, input().split()))
    hs = [int(input()) for i in range(N)]
    hs.sort()
    i = 0
    r = 10 ** 9
    while True:
        if i + K > N:
            break
        r = min(r, hs[i + K - 1] - hs[i])
        i += 1
    print(r)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

cnt_blue = 0
# cnt_red = 0
total = 0

while(True):
    cnt_blue += A
    total += A
    if N <= total:
        cnt_blue = cnt_blue - (total - N)
        break 
#     cnt_red += B
    total += B
    if N <= total:
#         cnt_red = cnt_red - (total - N)
        break
print(cnt_blue)

### FIXED CODE ###

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

cnt_blue = 0
total_tmp = 0

try:
    pre_cnt = N // (A+B)
    total_tmp = pre_cnt * (A+B)
    total_tmp += A
    if N <= total_tmp:
        cnt_blue = N -  (pre_cnt * B)
    else:
        cnt_blue = (pre_cnt * A) + A
    print(cnt_blue)
except Exception as e:
    print(0)
### BUGGY CODE ###

n = int(input())
lst = [0] * n
for i in range(n):
  s = input()
  for j in s:
    lst[i] += (12 ** (ord(j) - ord('a') + 1))
res = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if lst[i] == lst[j]:
      res += 1
print(res)

### FIXED CODE ###

n = int(input())
dic = {}
for i in range(n):
  temp = 0
  s = input()
  for j in s:
    temp += (12 ** (ord(j) - ord('a') + 1))
  dic.setdefault(temp, 0)
  dic[temp] += 1
#print(dic)
res = 0
for i in dic:
  if dic[i] >= 2:
    res += ((dic[i] * (dic[i] - 1)) // 2)
print(res)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

li = [0 for i in range(61)]

for i in range(0, len(A)):
    _a = A[i]
    for j in range(len(li))[::-1]:
        quo = _a // pow(2, j)
        li[j] += quo
        _a -= quo*pow(2, j)


res = 0
for i in range(len(li)):
    res += (pow(2, i) * (li[i]*(N-li[i])))%MOD
    res %= MOD
print(res)


### FIXED CODE ###

import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
MOD = 10**9+7

ans = 0
for i in range(60):
    cnt = np.count_nonzero((A >> i) & 1)
    ans += (2**i * cnt*(N-cnt)) % MOD
    ans %= MOD
print(ans)
### BUGGY CODE ###

import sys
import string
from collections import Counter
mo=10**9+7
sys.setrecursionlimit(10000000)
alp=string.ascii_uppercase

n=int(input())
a=[int(i) for i in input().split()]
#print(len(a),a)
c=Counter(a)
db=c.most_common()[0][0]
#print(db)
fst=a.index(db)
lst=a.index(db,fst+1)
x=n+1-(lst-fst+1)
#print(fst,lst)

cn=[0]*(n+1+1)
cn[0]=1
cx=[0]*(x+1)
cx[0]=1
def com1(k):
    if k>n+1 or k<0:
        return 0
    if cn[k]!=0:
        return cn[k]
    cn[k]=(n+1-k+1)*cn[k-1]//k
    return cn[k]
    
def com2(k):
    if k>x or k<0:
        return 0
    if cx[k]!=0:
        return cx[k]
    cx[k]=(x-k+1)*cx[k-1]//k
    return cx[k]
    
for i in range(1,n+2):
    ans=com1(i)-com2(i-1)
    print(ans%mo)#,com1(i),com2(i-1))

### FIXED CODE ###

import time
st_time=time.time()

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(2,n+1):
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        if self.fac[n]!=0:
            return self.fac[n]
        self.fac[n]=n*self.fact(n-1)%mo
        return self.fac[n]

    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
    
n=int(input())
a=[int(i) for i in input().split()]

cm=Comb(n+1)
c=Counter(a)
db=c.most_common()[0][0]
fst=a.index(db)
lst=a.index(db,fst+1)
x=n+1-(lst-fst+1)

for i in range(1,n+2):
    ans=cm.comb(n+1,i)-cm.comb(x,i-1)
    print(ans%mo)
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))

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

ans = [0]*n
for i in range(n):
  litmp = li[:i] + li[i+1:]
  tmp = litmp[0]
  for j in range(1,n-1):
    tmp = gcd(tmp,litmp[j])
  ans[i] = tmp
print(max(ans))

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))

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

ans = [0]*n
lileft = [0]*(n+1)
liright = [0]*(n+1)
for i in range(n):
  lileft[i+1] = gcd(lileft[i],li[i])
for i in range(n):
  liright[i+1] = gcd(liright[i],li[n-i-1])
for i in range(n):
  ans[i] = gcd(lileft[i],liright[n-i-1])
print(max(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
    
S = list(input())
length=len(S)
dp = [[0 for _ in range(13)] for _ in range(length)]
dp[0][0]=1
for i in range(length-1):
    if S[length-i-2] == "?":
        for k in range(10):
            for j in range(13):
                j_sub = j-k*10**i%13
                if j_sub < 0: j_sub+= 13
                dp[i+1][j]+=dp[i][j_sub]
    else:
        for j in range(13):
            j_sub = j-int(S[length-i-2])*10**i%13
            if j_sub < 0: j_sub+= 13
            dp[i+1][j]+=dp[i][j_sub]
print(dp[length-1][5]%1000000007)

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():  
    S = list(input())
    S.pop()
    length=len(S)
    dp = [0]*13
    dp[0]=1
    mul=1
    mod=1000000007
    for i in range(1,length+1):
        next_dp = [0]*13
        for j in range(13):
            if S[length-i] == "?":
                for k in range(10):
                    j_sub=(j+k*mul)%13
                    next_dp[j_sub]+=dp[j]
                    next_dp[j_sub]%=mod
            else:
                j_sub=(j+int(S[length-i])*mul)%13
                next_dp[j_sub]+=dp[j]
                next_dp[j_sub]%=mod
        dp=next_dp
        mul=mul*10%13
    print(dp[5]%1000000007)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from math import gcd
from functools import reduce

def gcd2(*numbers):
    return reduce(gcd, numbers)

k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd2(a,b,c)
print(ans)

### FIXED CODE ###

from math import gcd

k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(gcd(a,b),c)
print(ans)
### BUGGY CODE ###

def main() :
    n = int(input())
    nums = []
    for i in range(0, n) :
        x = int(input())
        nums.append(x)

    count = 0
    for i in nums :
        judge = 0
        for j in range(2, i) :
            if (i % j) != 0 :
                judge += 0
            else :
                judge += 1

        if judge == 0 :
            count += 1

    print(count)


if __name__ == '__main__' :
    main()

### FIXED CODE ###

import math

def isPrime(x) :
    if x == 2 :
        return True

    if x < 2 or x % 2 == 0 :
        return False

    i = 3
    while i <= math.sqrt(x) :
        if x % i == 0 :
            return False
        i += 2

    return True


def main() :
    n = int(input())
    nums = []
    for i in range(n) :
        x = int(input())
        nums.append(x)

    print(sum(map(isPrime, nums)))


if __name__ == '__main__' :
    main()
### BUGGY CODE ###

n = int(input())
d = []
for i in range(n):
    cmd, string = input().split()
    if cmd == "insert":
        d.append(string)
    else:
        if string in d:
            print("yes")
        else:
            print("no")


### FIXED CODE ###

n = int(input())
d = {}
for i in range(n):
    cmd, string = input().split()
    if cmd == "insert":
        d[string] = True
    else:
        try:
            if d[string]:
                print("yes")
        except:
            print("no")
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = tuple(p)
ans = []
chk = 0
for i in range(n-k+1):
  m = sum(p[i:k+i])
  chk = max(chk,m)
  if chk == m:
    ans = [(j+1)/2 for j in p[i:k+i]]
print(sum(ans))

### FIXED CODE ###

def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  import numpy as np #pypy不可
  n,k = map(int,readline().split())
  p =  np.array(read().split(),np.int32)
  np.cumsum(p,out=p)
  chk = p[k-1]
  for i in range(n-k):
    c = p[i+k]-p[i]
    chk = max(c,chk)
  print((chk+k)/2)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
ans=0
l=[]
for i in range(n):
    l.append(sorted(input()))

ll=sorted(l)

for j in range(n):
    for k in range(j+1,n):
        if ll[j]==ll[k]:
            ans+=1
    
print(ans)


### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
    s = input()
    s = sorted(s)
    l.append(''.join(s))
l.sort()
sa = l[0]
cnt = 0
n = 1
for sb in l[1:]:
  if sb == sa:
    n += 1
  else:
    cnt += (n * (n-1) // 2)
    n = 1
    sa = sb
cnt += (n * (n-1) // 2)
print(cnt)
### BUGGY CODE ###

import math


N = int(input())
X_bin = input()

X_int = int(X_bin, 2)  # bin => int


def calc_bin_cnt(next_int):
    return bin(next_int).count('1')
    if next_int == 0:
        return 0
    '''
    next_bin = bin(next_int)[2:]
    # popcount
    cnt = 0
    for i in next_bin:
        if i == '1':
            cnt += 1
    '''
    cnt = 0
    n = int(math.log2(next_int))
    for i in range(n, -1, -1):
        if next_int >= 2**i:
            next_int -= 2**i
            cnt += 1
    return cnt


def calc_ans(next_int, cnt=None):
    if next_int == 0:
        return 0
    if cnt is None:
        cnt = calc_bin_cnt(next_int)
    next_int = next_int % cnt
    if next_int > 0:
        ans = calc_ans(next_int) + 1
    else:
        ans = 1
    return ans


X_cnt = calc_bin_cnt(X_int)
for i in range(N):
    if X_bin[i] == '1':
        print(calc_ans(X_int - (2**(N-i-1)), X_cnt-1))
    else:
        print(calc_ans(X_int + (2**(N-i-1)), X_cnt+1))


### FIXED CODE ###

N = int(input())
X_bin = input()
#N = 10**5
#X_bin = '1' * N

X_int = int(X_bin, 2)  # bin => int


def calc_bin_cnt(next_int):
    if next_int == 0:
        return 0
    next_bin = bin(next_int)[2:]
    # popcount
    cnt = 0
    for i in next_bin:
        if i == '1':
            cnt += 1
    return cnt


def calc_ans(next_int, cnt=None):
    if next_cnt == 0:
        return 0
    if next_int == 0:
        return 1
    if cnt is None:
        cnt = calc_bin_cnt(next_int)
    next_int = next_int % cnt
    if next_int > 0:
        ans = calc_ans(next_int) + 1
    else:
        ans = 1
    return ans


X_cnt = calc_bin_cnt(X_int)
f_p = X_int % (X_cnt+1)
if X_cnt-1 == 0:
    f_m = 0
else:
    f_m = X_int % (X_cnt-1)
for i in range(N):
    if X_bin[i] == '1':
        next_cnt = X_cnt - 1
        if next_cnt == 0:
            next_int = 0
        else:
            next_int = f_m - pow(2, (N-i-1), next_cnt)  # マイナスでも正しく求まる？
    else:
        next_cnt = X_cnt + 1
        next_int = f_p + pow(2, (N-i-1), next_cnt)
    print(calc_ans(next_int, next_cnt))
    #calc_ans(next_cnt, next_cnt)
### BUGGY CODE ###

N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
for i in range(len(A)):
  if A[i]==sum(A)-N*(N+1)/2:
    se.append(i)

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(se[0]+N-se[1],i-1))%mod)


### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
#重複始点終点調査
se=[]
c=sum(A)-N*(N+1)/2
for i in range(len(A)):
  if A[i]==c:
    se.append(i)
l=se[0]
r=se[1]

mod=10**9+7
 
#階乗計算
factorial=[1]
inverse=[1]
for i in range(1,N+2):
    factorial.append(factorial[-1]*i %mod)
    inverse.append((pow(factorial[i], mod-2, mod)))
#combination計算
def nCr(n,r):
  if n<r or n==0 or r==0:
    return 0
  return factorial[n] * inverse[r] * inverse[n-r] % mod

print(N)
for i in range(2,N+2):
    print(int(nCr(N+1,i)-nCr(l+N-r,i-1))%mod)
### BUGGY CODE ###

K = int(input())
def gcd(a, b):
    while b != 0:
        r = a%b
        a = b
        b = r
    return a
gcds = [gcd(gcd(a,b),c) for a in range(1, K+1) for b in range(1, K+1) for c in range(1, K+1)]
print(sum(gcds))

### FIXED CODE ###

K = int(input())
def gcd(a, b):
    while b != 0:
        r = a%b
        a = b
        b = r
    return a
gcd_ab = [gcd(a,b) for a in range(1, K+1) for b in range(1, K+1)]
gcd_abc = [gcd(a_b,c) for a_b in gcd_ab for c in range(1, K+1)] 
print(sum(gcd_abc))
### BUGGY CODE ###

N=int(input())
S=input()
r=b=g=0
for s in S:
    if s=='R':
        r+=1
    elif s=='B':
        b+=1
    else:
        g+=1
out=0
for i in range(N):
    for j in range(N):
        if 0<=i+j<N and 0<=i-j<N and S[i]!=S[i+j] and S[i]!=S[i-j] and S[i+j]!=S[i-j]:
            out+=1
print(r*b*g-out)

### FIXED CODE ###

N=int(input())
S=input()
r=b=g=0
for s in S:
    if s=='R':
        r+=1
    elif s=='B':
        b+=1
    else:
        g+=1
out=0
for i in range(1,N):
    for j in range(min(i+1,N-i)):
        if S[i]!=S[i+j] and S[i]!=S[i-j] and S[i+j]!=S[i-j]:
            out+=1
print(r*b*g-out)
### BUGGY CODE ###

N, K  = map(int, input().split())
As = sorted(list(map(int, input().split())))
Fs = sorted(list(map(int, input().split())),reverse=True)
Xs = sorted([(a*f,i) for i,(a,f) in enumerate(zip(As,Fs))],reverse=True)

import heapq
q = []
INF = 10**6
heapq.heapify(q)
for i,(a,f) in enumerate(zip(As,Fs)):
    num = -(a*f*INF+i)
    heapq.heappush(q,num)

for k in range(K):
    num = heapq.heappop(q)
    # print(num)
    i = (-num)%INF
    As[i] -= 1
    upd = -(As[i]*Fs[i]*INF+i)
    heapq.heappush(q,upd)
num = heapq.heappop(q)
ans = (-num)//INF
print(ans)




### FIXED CODE ###

N, K  = map(int, input().split())
As = sorted(list(map(int, input().split())))
Fs = sorted(list(map(int, input().split())),reverse=True)
Xs = [a*f for a,f in zip(As,Fs)]
X_M = max(Xs)

def f(x):
    K_tmp = sum([max(0,a-x//f) for a,f in zip(As,Fs)])
    return K_tmp <= K

def  binarySearch(l,r,target):
    while r - l > 1:
        mid = (l+r)//2
        """計算を入れる"""
        # print(mid, guess)
        if f(mid):
            r = mid
        else:
            l = mid
    return r

print(binarySearch(-1,X_M,K))
### BUGGY CODE ###

input_ = input()
a = int(input_.split(' ')[0])
b = int(input_.split(' ')[1])
c = int(input_.split(' ')[2])
k = int(input())
count = 0
ans = "No"
while count < k:
  if a > b:
    b *= 2
    count += 1
  elif b > c:
    c *= 2
    count += 1
  if a < b and b < c:
    ans = "Yes"

print(ans)


### FIXED CODE ###

input_ = input()
a = int(input_.split(' ')[0])
b = int(input_.split(' ')[1])
c = int(input_.split(' ')[2])
k = int(input())
count = 0
ans = "No"
while count < k:
  if a >= b:
    b *= 2
    count += 1
  elif b >= c:
    c *= 2
    count += 1
  if a < b and b < c:
    ans = "Yes"
    break

print(ans)