Harryxun/stf_run huggingface dataset:
A,B = map(int,input().split())
N = 100

def printAns(ans):
	h = len(ans)
	w = len(ans[0])
	print(h, w)
	for l in ans:
		print(''.join(l))

if A <= B:
	minority = '.'
	majority = '#'
else:
	A,B = B,A
	minority = '#'
	majority = '.'

diff = abs(A-B)
if B <= N:
	ans = [[majority if (i+j) % 2 == 0 else minority for i in range(B)] for j in range(2)]
	a,b = B,B
	endsWithMajor = B % 2 == 0
	cnt = 1
	while a > A:
		if endsWithMajor:
			ans[1][-(2*cnt - 1)] = minority
			if cnt == 1:
				a -= 1
				b -= 1
			else:
				a -= 2
				b -= 1
		else:
			ans[1][-(2*cnt)] = minority
			a -= 2
			b -= 1
		cnt += 1
	while a < A:
		ans.append([majority] * B)
		ans.append([minority] * B)
		a += 1
		b += 1
	index = len(ans) - 1
	for i in range(diff // ((B+1) // 2) + 1):
		app = [minority for i in range(B)]
		for j in range((B+1) // 2):
			if b < B:
				app[2*j] = majority
				b += 1
		ans.append(app)
		ans.append([minority] * B)
		if b == B:
			break

else:
	ans = []
	a,b =0, 0
	for i in range(A // N + 1):
		ans.append([majority if (j + 0) % 2 == 0 else minority for j in range(N)])
		ans.append([majority if (j + 1) % 2 == 0 else minority for j in range(N)])
		a += N
		b += N

	endsWithMajor = N % 2 == 0
	cnt = 1
	index = len(ans) - 1
	while a > A:
		if endsWithMajor:
			ans[index][-(2*cnt - 1)] = minority
			if cnt == 1:
				a -= 1
				b -= 1
			else:
				a -= 2
				b -= 1
		else:
			ans[index][-(2*cnt)] = minority
			a -= 2
			b -= 1
		cnt += 1
	while a < A:
		ans.append([majority] * N)
		ans.append([minority] * N)
		a += 1
		b += 1
	index = len(ans) - 1
	for i in range(diff // (N // 2) + 1):
		app = [minority for i in range(N)]
		for j in range((N+1) // 2):
			if b < B:
				app[2*j] = majority
				b += 1
		ans.append(app)
		ans.append([minority] * N)
		if b == B:
			break
printAns(ans)




### FIXED CODE ###

# coding: utf-8
# Your code here!
A,B = map(int,input().split())
h,w = 100, 100
grid = [['.' if j < 50 else '#' for i in range(w)] for j in range(h)]
A -= 1
B -= 1
reg = ['.' if i % 2 == 0 else '#' for i in range(w)]
for i in range(25):
    if B >= 50:
        grid[i*2] = reg
        B -= 50
    else:
        for j in range(B):
            grid[i*2][j*2] = '#'
        break
for i in range(25):
    if A >= 50:
        grid[99 - i*2] = reg
        A -= 50
    else:
        for j in range(A):
            grid[99 - i*2][j*2] = '.'
        break
print(h,w)
for row in grid:
    print(''.join(row))
import numpy as np
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if M != 0:
  A = []
  ACnum = []
  ACkazu = []
  for i in range(M):
    hoge = input().split()
    if hoge[1] == "AC" and hoge[0] not in ACkazu:
      ACnum.append(i)
      ACkazu.append(hoge[0])
      A.append(hoge)
    elif hoge[0] not in ACkazu:
      A.append(hoge)
  pena = 0
  _remove = []
  for i in ACnum:
    i = int(i)
    AC_num = A[i][0]
    for j in range(0,i):
      if A[j][0] == A[i][0]:
        pena += 1
        _remove.append(j)
    _remove.append(i)
  # popでケツから消していく
  for i in reversed(_remove):
    A.pop(i)
  pena += len(A)
  print(len(ACnum), end="")
  print(" ", end="")
  print(pena, end="")
else:
  print(0, end="")
  print(" ", end="")
  print(0, end="")

### FIXED CODE ###

hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

WA = [0] * 105000
AC = [False] * 105000

WAnum = 0
ACnum = 0

for i in range(M):
    hoge = input().split()
    if AC[int(hoge[0])]:
      continue
    if hoge[1] == "AC":
      AC[int(hoge[0])] = True;
      ACnum += 1
      WAnum += WA[int(hoge[0])]
    elif hoge[1] == "WA":
      WA[int(hoge[0])] += 1
      
print(ACnum, WAnum)
def main():
    import sys
    from collections import deque
    from operator import itemgetter
    b=sys.stdin.buffer
    n,d,a=map(int,b.readline().split())
    m=map(int,b.read().split())
    p,q=deque(),deque()
    pl,ql=p.popleft,q.popleft
    pa,qa=p.append,q.append
    s=b=0
    for x,h in sorted(zip(m,m),key=itemgetter(0)):
        while p and p[0]<x:
            f()
            b-=g()
        h-=b
        t=0--h//a
        if t>0:
            s+=t
            b+=t*a
            pa(x+d+d)
            qa(t*a)
    print(s)
main()

### FIXED CODE ###

from bisect import*
def _add(data, k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def add(l, r, x):
    _add(data0, l, -x*(l-1))
    _add(data0, r, x*(r-1))
    _add(data1, l, x)
    _add(data1, r, -x)

def _get(data, k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def query(l, r):
    return _get(data1, r-1) * (r-1) + _get(data0, r-1) - _get(data1, l-1) * (l-1) - _get(data0, l-1)
N,d,a,*t=map(int,open(0).read().split())
N+=1
z=sorted(zip(*[iter(t)]*2))
data0=[0]*(N+1)
data1=[0]*(N+1)
y=[x for x,_ in z]
c=0
for i,(x,h)in enumerate(z,1):
    h-=query(i,i+1)
    t=0--max(0,h)//a
    j=bisect(y,x+d+d)
    add(1,j+1,t*a)
    c+=t
print(c)
import math

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

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if i <= (N / 2) - 1
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

### FIXED CODE ###

n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)
import copy
import math
# N=int(input())
# a = list(map(int,input().split()))

# N=3
# a = [7,6,8]

# N = 40
# a = np.array([4,8,6,12]*(N//4), dtype=np.int)

N=10
a = [56,58,82,46,67,36,98,68,24,46]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# 一番近い大きい側の2の累乗の数が，segtreeの葉の数になる．
N_ADJUST = 2**int(math.ceil(math.log2(N)))
# segtreeのサイズはN_ADJUSTを葉とする木のノード数．
ST_SIZE = N_ADJUST*2-1
# binopに合わせて単位元として決める．maxならINT_MAX(問題文の制限)
INT_IDENTITY = 0
li = [INT_IDENTITY]*ST_SIZE
# li_initは，葉の配列．
# 節点kが [l,r) にbinopという演算で結びついている．
def init_segtree(li, k, l, r, binop, li_init):
    if r-l==1:
        li[k] = INT_IDENTITY if l >= len(li_init) else li_init[l]
    elif r-l>1:
        k_l, k_r = k*2+1, k*2+2
        init_segtree(li, k_l, l, (l+r)//2, binop, li_init)
        init_segtree(li, k_r, (l+r)//2, r, binop, li_init)
        li[k] = binop(li[k_l],li[k_r])

init_segtree(li,0,0,N_ADJUST,gcd,a)

# print(li)

# 下からupdateする．
def update_segtree(li,k,binop):
    if k > 0:
        k_l, k_r = ((k-1)//2)*2+1, ((k-1)//2)*2+2
        li[(k-1)//2] = binop(li[k_l],li[k_r])
        update_segtree(li,k//2,binop)

val = []
l2 = copy.deepcopy(li)
for i in range(N_ADJUST-1,N_ADJUST+N-1):
    l2[i] = 0
    update_segtree(l2,i,gcd)
    # print(i, l2)
    val.append(l2[0])
    l2[i] = li[i]
    update_segtree(l2,i,gcd)

print(max(val))

### FIXED CODE ###

# @profile
def main():
    import math

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

    # N=5
    # a = [12,15,18,36,42]

    # N = 10**5
    # a = [1]*N

    # N=11
    # a = [56,58,82,46,67,36,98,68,24,46,52]

    #a,bの最大公約数
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a

    # 一番近い大きい側の2の累乗の数が，segtreeの葉の数になる．
    N_ADJUST = 2**int(math.ceil(math.log(N)/math.log(2)))
    # segtreeのサイズはN_ADJUSTを葉とする木のノード数．
    ST_SIZE = N_ADJUST*2-1
    # binopに合わせて単位元として決める．maxならINT_MAX(問題文の制限)
    INT_IDENTITY = 0
    li = [INT_IDENTITY]*ST_SIZE
    # li_initは，葉の配列．
    # 節点kが [l,r) にbinopという演算で結びついている．
    def init_segtree(li, k, l, r, binop, li_init):
        if r-l==1:
            li[k] = INT_IDENTITY if l >= len(li_init) else li_init[l]
        elif r-l>1:
            k_l, k_r = k*2+1, k*2+2
            init_segtree(li, k_l, l, (l+r)//2, binop, li_init)
            init_segtree(li, k_r, (l+r)//2, r, binop, li_init)
            li[k] = binop(li[k_l],li[k_r])

    init_segtree(li,0,0,N_ADJUST,gcd,a)

    # print(li)
    # 下からupdateする．
    def update_segtree(li,k,binop):
        if k > 0:
            k_2 = (k-1)//2
            k_l = k_2*2+1
            k_r = k_l+1
            li[k_2] = binop(li[k_l],li[k_r])
            update_segtree(li,k_2,binop)

    val = []
    for i in range(N_ADJUST-1,N_ADJUST+N-1):
        tmp = li[i]
        li[i] = 0
        update_segtree(li,i,gcd)
        # print(i, li)
        val.append(li[0])
        li[i] = tmp
        update_segtree(li,i,gcd)

    print(max(val))

main()
N, A, B = map(int, input().split())
if A*N>=B:
  print(b)
else:
  print(A*N)

### FIXED CODE ###

N, A, B = map(int, input().split())
if A*N>=B:
  print(B)
else:
  print(A*N)
r=range
def a(i,j,k,l=0):print("+<"[l],i,j,k)
p(6484)
a(0,1,3)
a(2,3,3,1)
for x in 0,1:
	a(x,3,x)
	for t in r(30):a(v:=x+4,v,v);a(v,3,6),exec('a(6,6,6);'*(29-t));a(6,x,T:=x*60+35+t,1);a(v,T,v)
for t in r(60):a(2,2,2);[(a(34+t-s,95+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

### FIXED CODE ###

n=97
r=range
L='<'
P='+'
l=[3933,P,0,1,n,L,2,n,n,P,0,n,3,P,1,n,4]
a=lambda i,j:[P,i,j,i]
b=lambda i:[P,i,i,i+1]
def d(x,i,j):
	return sum([sum([b(j+t-1),a(j+t,n),*(b(s)for s in r(j+t,j+29)),[L,j+29,x,i+t],b(j+t-1),a(j+t,i+t)],[])for t in r(30)],[])
l+=d(3,5,36)
l+=d(4,36,67)
for t in r(59):
	l+=a(2,2)
	for s in r(t+1):
		if t-30<s<30:l+=[P,5+t-s,36+s,98];l+=[L,n,98,99];l+=a(2,99)
print(*l)
N = int(input())
A = [int(_) for _ in input().split()]
dp = []
ans = 1
for a in A:
    N = len(dp)
    if N < a:
        dp += [1] * (a - N)
    else:
        flag = True
        for i in range(a, -1, -1):
            if dp[i] < ans:
                dp = dp[:i] + [dp[i] + 1] + [1] * (a - i - 1)
                flag = False
                break
        if flag:
            ans += 1
            dp = dp[:a - 1] + [ans]
print(ans)


### FIXED CODE ###

import random
input()
A = [int(_) for _ in input().split()]
A = [A[0]] + [j for i, j in zip(A, A[1:]) if i >= j]
N = len(A)


def cut(array, index):
    if index < 1:
        return []
    if index <= array[0][0]:
        return [(index, array[0][1])]
    for _ in range(len(array)-1, 0, -1):
        if array[_ - 1][0] < index:
            return array[:_] + [(index, array[_][1])]


def is_possible(K):
    dp = [(A[0], 0)]
    for a in A[1:]:
        if a <= dp[-1][0]:
            dp = cut(dp, a)
        else:
            dp += [(a, 0)]
        is_added = False
        for j in range(len(dp) - 1, -1, -1):
            if dp[j][1] < K - 1:
                dp = cut(dp, dp[j][0] - 1) + [(dp[j][0], dp[j][1] + 1)]
                if dp[-1][0] < a:
                    dp += [(a, 0)]
                is_added = True
                break
        if not is_added:
            return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))
n=int(input())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-i>1:
    print('No')
    return 0
print('Yes')


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-i>1:
    print('No')
    exit()
print('Yes')
n, k = list(map(int, input().split()))
s = input()

data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)

current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data), 2):
    if (start + 2*k-1) < len(data): 
        diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
        current_sum += diff

        if current_sum > ret:
            ret = current_sum
    else:
        break
print(ret)

### FIXED CODE ###

n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)
x = map(int,input().split())
print(" ".join(x.sort()))

### FIXED CODE ###

x = list(map(int,input().split()))
x = sorted(x)
print("{0} {1} {2}".format(x[0],x[1],x[2]))
X, Y, A, B, C = map(int, input().split())
p = sorted([int(i) for i in input().split()], reverse=True)
q = sorted([int(i) for i in input().split()], reverse=True)
r = sorted([int(i) for i in input().split()])

p = p[:X]
q = q[:Y]
plus_r = []

while r != [] and (p != [] and r[-1] > p[-1]) or (q != [] and r[-1] > q[-1]):
    if p[-1] < q[-1]:
        p.pop()
    else:
        q.pop()
    plus_r.append(r.pop())

print(sum(p) + sum(q) + sum(plus_r))


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = sorted([int(i) for i in input().split()], reverse=True)
q = sorted([int(i) for i in input().split()], reverse=True)
r = sorted([int(i) for i in input().split()])

p = p[:X]
q = q[:Y]
plus_r = []

while r != [] and ((p != [] and r[-1] > p[-1]) or (q != [] and r[-1] > q[-1])):
    if p == []:
        q.pop()
        plus_r.append(r.pop())
        continue
    elif q == []:
        p.pop()
        plus_r.append(r.pop())
        continue

    if p[-1] < q[-1]:
        p.pop()
    else:
        q.pop()
    plus_r.append(r.pop())

print(sum(p) + sum(q) + sum(plus_r))
def gcd(a, b):
    md = a % b
    if md == 0:
        return b
    return gcd(b, md)

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

def lcm_mlt(a, num_list):
    if len(num_list) == 0:
        return a
    n = num_list.pop()
    a = max(a, n)
    b = min(a, n)
    return lcm_mlt(lcm(a, b), num_list)

n = int(input())
nl = [int(input()) for _ in range(n)]

print(lcm_mlt(1, nl))

### FIXED CODE ###

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

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)
n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())))
ope = [list(map(int, input().split())) for i in range(m)]
ope.sort(key=lambda x: x[1], reverse=True)
i, j, k = 0, 0, 0
while  j < m and cards[i] < ope[j][1]:
    cards[i] = ope[j][1]
    i += 1
    k += 1
    if k >= ope[j][0]:
        j += 1
        k = 0
print(sum(cards))

### FIXED CODE ###

n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())))
ope = [list(map(int, input().split())) for i in range(m)]
ope.sort(key=lambda x: x[1], reverse=True)
i, j, k = 0, 0, 0
while i < n and j < m and cards[i] < ope[j][1]:
    cards[i] = ope[j][1]
    i += 1
    k += 1
    if k >= ope[j][0]:
        j += 1
        k = 0
print(sum(cards))
N = int(input())
A = [int(x) for x in input().split()]
count = 0
for i in N-1:
  if i == 

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n):
    print(ans[i])
i=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
A=i[0]
B=i[1]
M=i[2]
x = []
y = []
c = []
for j in range(M):
    x1,y1,c1=[int(j) for j in input().split()]
    x.append(x1)
    y.append(y1)
    c.append(c1)
d=200001
e=100001
f=100001
for k in range (A):
    if a[k]<e:
        e=a[k]

for l in range (B):
    if b[k]<f:
        f=b[k]
d=e+f

for p in range (M):
    if a[x[p]-1]+b[y[p]-1]-c[p]<d:
        d= a[x[p]-1]+b[y[p]-1]-c[p]

print(d)

### FIXED CODE ###

i=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
A=i[0]
B=i[1]
M=i[2]
x = []
y = []
c = []
for j in range(M):
    x1,y1,c1=[int(j) for j in input().split()]
    x.append(x1)
    y.append(y1)
    c.append(c1)
d=200001
e=100001
f=100001
for k in range (A):
    if a[k]<e:
        e=a[k]

for l in range (B):
    if b[l]<f:
        f=b[l]
d=e+f

for p in range (M):
    if a[x[p]-1]+b[y[p]-1]-c[p]<d:
        d= a[x[p]-1]+b[y[p]-1]-c[p]

print(d)
import sys
import numpy as np

# N 時計の数
n = int(input())

# Ti 各時計が1周する秒数
t = []
for i in range(n):
    t.append(int(input()))
    
# 最大公約数を求める
def gcb(a, b):
    if b == 0:
        return a
    return int(gcb(b, a % b))

def lcm(a, b):
    g = gcb(a, b)
    return int(a / g * b)

ans = 1

for num in t:
    ans = lcm(ans, num)

print(int(ans))


### FIXED CODE ###

import sys
import numpy as np

# N 時計の数
n = int(input())

# Ti 各時計が1周する秒数
t = []
for i in range(n):
    t.append(int(input()))
    
# 最大公約数を求める
def gcb(a, b):
    if b == 0:
        return a
    return int(gcb(b, a % b))

def lcm(a, b):
    g = gcb(a, b)
    return a * b // g

if (n == 1):
    print(t[0])
else:
    ans = 1
    for num in t:
        ans = lcm(ans, num)
    print(int(ans))
class atcorder:
    
    S=list(input())
    inv=list(reversed(S))
    i=0
    j=0
    if len(S)%2==0:
        pass
    else:
        if S==inv:
            i+=1
            N=int((len(S)-1)/2)
        for x in range(N-1):
            if S[x]==S[N-1-x] and inv[x]==inv[N-1-x]:
                pass
            else:
                j+=1
                
    if j==0 and i==1:
        print('yes')
    else:
        print('no')

### FIXED CODE ###

class atcorder:
    
    S=list(input())
    inv=list(reversed(S))
    i=0
    j=0
    if S==inv:
        i+=1
        
    N=int((len(S)-1)/2)
    for x in range(N-1):
        if S[x]==S[N-1-x] and inv[x]==inv[N-1-x]:
            pass
        else:
            j+=1
                
    if j==0 and i==1:
        print('Yes')
    else:
        print('No')
a,b=(int(i) for i in input().split())
c = b-a

for s in range(c):
    sum += s+1

print(sum-b)

### FIXED CODE ###

a,b=(int(i) for i in input().split())
c = b - a
zako = 0
for d in range(c):
    zako += d + 1
print(zako-b)
N=int(input())
X=input()
XX=0
for i in range(N):
    XX+=int(X[N-i-1])*2**i
#print(XX)

POPCOUNT_TABLE16 = [0] * 2**16
for index in range(len(POPCOUNT_TABLE16)):
    POPCOUNT_TABLE16[index] = (index & 1) + POPCOUNT_TABLE16[index >> 1]

def popcnt5(v):
    return (POPCOUNT_TABLE16[ v        & 0xffff] +
            POPCOUNT_TABLE16[(v >> 16) & 0xffff] +
            POPCOUNT_TABLE16[(v >> 32) & 0xffff] +
            POPCOUNT_TABLE16[(v >> 48)         ])

table=[0,1]+[-1 for i in range(219998)]
for i in range(2,220000):
    table[i]=table[i%popcnt5(i)]+1

table2=[0 for i in range(N)]
moto=0
for i in range(N):
    if X[i]=='1':
        moto+=1
mod=0

#print(table[:21])

plus=0  #もとの数字に1のときのmodをしたやつ
minus=0

for i in range(N):
    plus+=int(X[i])*pow(2,N-1-i,moto-1)
    minus+=int(X[i])*pow(2,N-1-i,moto+1)
    plus%=(moto-1)
    minus%=(moto+1)

#print(moto,plus,minus)

for i in range(N):
    ans=0
    if X[i]=='1':
        ans=plus
        ans-=pow(2,N-1-i,moto-1)
        ans%=(moto-1)
    else:
        ans=minus
        ans+=pow(2,N-1-i,moto+1)
        ans%=(moto+1)
    print(table[ans]+1)

### FIXED CODE ###

N=int(input())
X=input()

def popcnt(x):
    n=x
    res=0
    while n>0:
        res+=n%2
        n//=2
    return res

table=[0,1]+[-1 for i in range(219998)]
for i in range(2,220000):
    table[i]=table[i%popcnt(i)]+1

moto=0
for i in range(N):
    if X[i]=='1':
        moto+=1

plus=0  #もとの数字に1のときのmodをしたやつ
minus=0

for i in range(N):
    plus+=int(X[i])*pow(2,N-1-i,max(1,moto-1))
    minus+=int(X[i])*pow(2,N-1-i,moto+1)
    plus%=(max(1,moto-1))
    minus%=(moto+1)

for i in range(N):
    ans=0
    if X[i]=='1':
        ans=plus
        ans-=pow(2,N-1-i,max(1,moto-1))
        ans%=(max(1,moto-1))
        if moto==1:
            ans=-1
    else:
        ans=minus
        ans+=pow(2,N-1-i,moto+1)
        ans%=(moto+1)
    if ans==-1:
        print(0)
    else:
        print(table[ans]+1)
import numpy as np
S = input().strip()

MOD = 10**9 + 7
dp = np.zeros((100005, 13))
N = len(S)

dp[0][0] = 1
for i in range(N):
    c = -1
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])

    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]

    for j in range(13):
        dp[i+1][j] %= MOD

res = int(dp[N][5])

print(res)


### FIXED CODE ###

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

if A == 0 or B == 0:
    print("IMPOSSIBLE")
else:
    if (A + B) % 2 == 0:
        print(int((A+B)/2))
    else:
        print("IMPOSSIBLE")
N = int(input())
A = list(map(int,input().split()))

if len(set(a)) == N:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

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

A.sort()
ans = "YES"
for i in range(N-1):
    if A[i] == A[i+1]:
        ans = "NO"
        break

print(ans)
import math
from decimal import *

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = 1
total_A = 1

for t,a in _input:
    #n = max(math.ceil(total_T/t),math.ceil(total_A/a))
    n = max(-(-t//Ti), -(-a//Ai))
    total_T = int(t*n)
    total_A = int(a*n)

print(total_A+total_T)


### FIXED CODE ###

import math
from decimal import *

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = 1
total_A = 1

for t,a in _input:
    #n = max(math.ceil(total_T/t),math.ceil(total_A/a))
    n = max(-(-total_T//t), -(-total_A//a))
    total_T = int(t*n)
    total_A = int(a*n)

print(total_A+total_T)
n=int(input())
arr=list(map(int,input().split()))
vis={}
vis[0] = 0
vis[1] = 0
if n > 1:
  vis[2] = abs(arr[0]-arr[1])

for i in range(3, n+1):
    step_1 = abs(arr[i-1]-arr[i-2]) + vis[i-1]
    step_2 = abs(arr[i-1]-arr[i-3]) + vis[i-2]
    vis[i] = min(step_1, step_2)
   
print(vis[i])

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
import sys
write=sys.stdout.write
while True:
	h,w=map(int,raw_input().split())
	if h==w==0: break
	for i in xrange(h):
		l=[('#' if i%2==j%2==0 else ('.' if (i%2==1 and j%2==0) or (i%2==0 and j%2==1) else '#') for j in xrange(w)]
		for i in l:
			write(i)
		print ""
	print ""

### FIXED CODE ###

import sys
write=sys.stdout.write
while True:
	h,w=map(int,raw_input().split())
	if h==w==0: break
	for i in xrange(h):
		l=[('#' if i%2==j%2==0 else ('.' if (i%2==1 and j%2==0) or (i%2==0 and j%2==1) else '#')) for j in xrange(w)]
		for i in l:
			write(i)
		print ""
	print ""
A ,P = int(input()).split()

P = P + 3 * A
k = P//2
print(k)


### FIXED CODE ###

A, P =map(int, input().split())
pie = (A * 3 + P)//2
print(pie)
n = int(input())
numList  = [input() for i in range(n)]
maxVal = max(numList)
workList = numList[:]
secondVal = max(workList.remove(maxVal))
for num in numList:
  if num != maxVal:
    print(maxVal)
  else
    print(secondVal)

### FIXED CODE ###

n = int(input())
numList  = [int(input()) for i in range(n)]
maxVal = max(numList)
workList = numList[:]
workList.remove(maxVal)
secondVal = max(workList)
for num in numList:
  if num != maxVal:
    print(maxVal)
  else:
    print(secondVal)
a=int(input())
*b,=map(open(0))
s=set(b)
print(min(a,len(s)))

### FIXED CODE ###

a,*b=map(str, open(0).read().split())
s=set(b)
print(min(int(a),len(s)))
print(a)

### FIXED CODE ###

A, P = map(int, input().split())
print((P+A*3)//2)
import itertools

n,m,q = map(int,input().split())

total = 0

memo = []
number = []
for i in range(m):
    number.append(i+1)
len = len(number)

for j in range((len+3-1)*(len+2-1)*(len)//6):
    memo.append(0)


for i in range(q):
    num = list(map(int,input().split()))
    for j in range((len+3-1)*(len+2-1)*(len)//6):
        a = list(itertools.combinations_with_replacement(number,n))
        if int(a[j][num[1]-1])-int(a[j][num[0]-1]) == num[2]:
            memo[j] += num[3]


print(max(memo))



### FIXED CODE ###

import itertools

n,m,q = map(int,input().split())
num = [list(map(int,input().split())) for i in range(q)]

number = []
for i in range(m):
    number.append(i+1)
a = list(itertools.combinations_with_replacement(number,n))
length = len(a)
memo = [0] * length
ans = 0

for i in range(length):#組み合わせの数回す
    sum = 0
    for j in range(q):
       if a[i][num[j][1]-1] - a[i][num[j][0]-1]  == num[j][2]:
            sum += num[j][3]
    ans = max(sum,ans)
print(ans)