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

n,m=map(int,input().split())
A=list(map(int,input().split()))
while m>0:
    max=0
    num=0
    for i in range(n):
        if A[i]>max:
            max=A[i]
            num=i
    A[num]=A[num]/2
   # print(num+1)
    m+=-1
sum=0
for a in A:
    #print(a)
    sum+=(a//1)
print(int(sum))
    


### FIXED CODE ###

import heapq
n,m=map(int,input().split())
def func(x):
    return -1*int(x)
A=list(map(func,input().split()))
#print(A)
heapq.heapify(A)
while m>0:
    x=heapq.heappop(A)
    x/=2
    heapq.heappush(A,x)
    m+=-1
sum=0
for a in A:
    #print((-1*a)//1)
    sum+=((-1*a)//1)
print(int(sum))
### BUGGY CODE ###

import sys

input = sys.stdin.readline

def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H+1)
    ws = [0]*(W+1)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append([h, w])
        hs[h] += 1
        ws[w] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    isfound = False

    for i in range(H):
        if isfound == True:
            break
        if hs[i+1] == maxh:
            for j in range(W):
                if ws[j+1] == maxw:
                    if [i+1, j+1] not in bombs:
                        isfound = True
                        break
    if isfound == False:
        ans -= 1

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    ans = 0
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0]*(H)
    ws = [0]*(W)
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    isfound = False

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()

    print(ans-1)

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

N, K = map(int, input().split())
*A, = map(int, input().split())
for _ in range(K):
    B = [0] * N
    for i, a in enumerate(A):
        l = max(0, i - a)
        r = min(N - 1, i + a)
        B[l] += 1
        if r + 1 < N: B[r + 1] -= 1
    end = True
    for i in range(1, N):
        B[i] += B[i-1]
        if B[i] != N: end = False
    A = B
    if end: break
print(*A)

### FIXED CODE ###

N, K = map(int, input().split())
*A, = map(int, input().split())
for k in range(41):
    B = [0] * N
    for i, a in enumerate(A):
        l = max(0, i - a)
        r = min(N - 1, i + a)
        B[l] += 1
        if r + 1 < N: B[r + 1] -= 1
    for i in range(1, N): B[i] += B[i-1]
    A = B
    if k == K - 1: break
print(*A)
### BUGGY CODE ###

def main():
    N = int(input())
    S = input()
    # N = 39
    # S = 'RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB'
    
    # ######### Index
    # R, G, B = [], [], []
    # for i, s in enumerate(S):
    #     if s == 'R':
    #         R.append(i)
    #     elif s == 'G':
    #         G.append(i)
    #     elif s == 'B':
    #         B.append(i)
    
    C = 0
    out = 0
    # for i in R:
    # for i in B:
    for i in range(len(S)):
        
        
        # for j in G:
        # for j in B:
        for j in range(i+1, len(S)):
            

            # for k in B:
            # for k in G:
            # for k in R:
            for k in range(j+1, len(S)):
                
                # print(i, j, k)
                
                if not (j - i) == (k - j):
                    if (S[i] != S[j]) and (S[i] != S[k]) and (S[k] != S[j]):
                    
                        
                        out += 1


    print(out)

    
main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(300000)
from collections import defaultdict
 
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
 
 
N = I()
S = input()

# N = 39
# S = 'RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB'
 
d = defaultdict(int)
for c in S:
    d[c] += 1
plus = d['R'] * d['G'] * d['B']

# print(plus)
 
minus = 0
for j in range(1, N - 1):
    for l in range(1, N):
        i, k = j - l, j + l
        if i < 0 or k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            minus += 1
 
print(plus - minus)
### BUGGY CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)
nums = set()
A.sort()
sA = list(set(A))
cnt = 0 
ans = defaultdict(int)
for a in sA:
    new = False
    if not(a in nums):
        cnt += 1
        ans[a] += 1
        new = True
    nums.add(a)
    # while new and a + mlt < maxA+2:
    if new:
        for val in range(a+a, maxA+2, a):
            nums.add(val)

for an in ans.keys():
    if A.count(an)>1:
        cnt -= 1
print(cnt)

### FIXED CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))
### BUGGY CODE ###

import sys
#from collections import deque as dq
input = sys.stdin.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
	#N,A,B = map(int, input().split())
	S = input().rstrip()
	Q = int(input())
	#vA = list(map(int, input().split()))
	#vX = [input().rstrip() for _ in [0,]*N]
	
	rev = 0		# reverse
	
	DF = "" #dq([]) # reversed Head!!
	DR = "" #dq([])
	for q in range(Q):
		tq = input().split()
		if tq[0]=="1":
			rev ^= 1
		else:
			T,F,C = tq
			if F=="1":
				# C to top
				if rev == 0:
					DF += C #DF.appendleft(C) 
				else:
					DR += C #DR.append(C)
			else:
				# C to bottom
				if rev == 0:
					DR += C #DR.append(C)
				else:
					DF += C #DF.appendleft(C)	
	
	
	if rev == False:
		res = DF[::-1] + S + DR
	else:
		res = DR[::-1] + S[::-1] + DF

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


### FIXED CODE ###

import sys
#from collections import deque as dq
input = sys.stdin.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
	#N,A,B = map(int, input().split())
	S = input().rstrip()
	Q = int(input())
	#vA = list(map(int, input().split()))
	#vX = [input().rstrip() for _ in [0,]*N]
	
	rev = 0		# reverse
	
	DF = "" #dq([]) # reversed Head!!
	DR = "" #dq([])
	for q in range(Q):
		tq = input().split()
		if tq[0]=="1":
			rev ^= 1
		else:
			T,F,C = tq
			if F=="1":
				# C to top
				if rev == 0:
					DF += C #DF.appendleft(C) 
				else:
					DR += C #DR.append(C)
			else:
				# C to bottom
				if rev == 0:
					DR += C #DR.append(C)
				else:
					DF += C #DF.appendleft(C)	
	
	
	if rev == False:
		res = DF[::-1] + S + DR
	else:
		res = DR[::-1] + S[::-1] + DF

	print(res)
	
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n,x=int(input()),input()
o=x.count("1")
l={}
a=int(x,2)
l[0]=0
for i in range(1,o+1):
    t=i
    t%=bin(t).count("1")
    l[i]=l[t]+1

c=pow(2,n-1)
for b in x:
    if b=="1":
        k=a-c
        gg=o-1
    else:
        k=a+c
        gg=o+1
    if k:
        k%=gg
        print(1+l[k])
    else:print(0)
    c//=2

### FIXED CODE ###

n,x=int(input()),input()
o=x.count("1")
if o==1:
    for i,v in enumerate(x):
        if v=="1":print(0)
        else:
            if i!=n-1:
                if x[-1]=="0":print(1)
                else:print(2)
            else:print(2)

else:
    m=o-1
    M=o+1
    mp,mm={0:1},{0:1}
    for i in range(1,n):
        mp[i]=mp[i-1]*2%M
        mm[i]=mm[i-1]*2%m
    A=int(x,2)
    a=A%m
    b=A%M
    rest={0:0}
    for i in range(1,o+1):
        rest[i]=1+rest[i%bin(i).count("1")]
    for i,v in enumerate(x):
        if v=="1":
            print(1+rest[(a-mm[n-i-1])%m])
        else:
            print(1+rest[(b+mp[n-i-1])%M])
### BUGGY CODE ###

from queue import Queue

#入力
H, W = map(int, input().split())

lst = [['a']*W for _ in range(H)]
count = 0 #白色のマスの総数
for i in range(H):
    row = input()
    for j in range(W):
        lst[i][j] = row[j]
        if row[j] == '.':
            count += 1

 
#for i in range(H):
#    for j in range(W):
#        if lst[i][j] == '.':
#            count += 1

sx, sy = 1, 1 #スタート位置
gx, gy = H, W #ゴール位置

move = [[-1, 0], [1,0], [0, -1], [0, 1]]

def bfs(x, y):
    q = Queue()
    INF = 10 ** 9
    d = [[INF]* W for _ in range(H)]
    q.put(x)
    q.put(y)
    d[x][y] = 0

    while True:
        px = q.get()
        py = q.get()
        if px == gx-1 and py == gy-1:
            break
        else:
            for dx, dy in move:
                nx = px + dx
                ny = py + dy

                if 0 <= nx and nx < H and 0 <= ny and ny < W and lst[nx][ny] == '.' and d[nx][ny] == INF:
                    q.put(nx)
                    q.put(ny)
                    d[nx][ny] = d[px][py] + 1
    return d[gx-1][gy-1]

a = bfs(sx-1, sy-1)

if a == 10 **9:
    print (-1)
else:
    print (count - a - 1)

### FIXED CODE ###

from queue import Queue

#入力
H, W = map(int, input().split())

#lst = [['a']*W for _ in range(H)]
count = 0 #白色のマスの総数
lst = []
row = []
for i in range(H):
    row = list(input())
    count += row.count('.')
    lst += [row]
 
#for i in range(H):
#    for j in range(W):
#        if lst[i][j] == '.':
#            count += 1

#sx, sy = 1, 1 #スタート位置
#gx, gy = H, W #ゴール位置

move = [[-1, 0], [1,0], [0, -1], [0, 1]]

def bfs():
    q = Queue()
    INF = 10 ** 9
    d = [[INF]* W for _ in range(H)]
    q.put(0)
    q.put(0)
    d[0][0] = 0

    while True:
        if q.empty():
            break
        else:
            px = q.get()
            py = q.get()
            if px == H-1 and py == W-1:
                break
            else:
                for dx, dy in move:
                    nx = px + dx
                    ny = py + dy

                    if 0 <= nx and nx < H and 0 <= ny and ny < W and lst[nx][ny] == '.' and d[nx][ny] == INF:
                        q.put(nx)
                        q.put(ny)
                        d[nx][ny] = d[px][py] + 1
    return d[H-1][W-1]

a = bfs()

if a == 10 **9:
    print (-1)
else:
    print (count - a - 1)
### BUGGY CODE ###

n,K = map(int,input().split())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    for k in range(K):
        if i+1-k>=0:
            dp[i+2] = min(dp[i+2],dp[i+1-k]+abs(v[i+2]-v[i+1-k]))


print(dp[n-1])

### FIXED CODE ###

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N, K= MI()
S = [0]+LI()
S += [0]
dp = [INF]*(N+5)
dp[1] = 0
for i in range(N):
    for j in range(1,K+1):
        if i+j <= N:
            dp[i+j] = min(dp[i+j],dp[i] + abs(S[i+j]-S[i]))
print(dp[N])
### BUGGY CODE ###

n,m=map(int,input().split())
lr=[list(map(int,input().split())) for i in range(m)]
a=set(range(lr[0][0],lr[0][1]+1))
for j in range(1,m):
  a=a&set(range(lr[j][0],lr[j][1]+1))
print(len(a))

### FIXED CODE ###

n,m=map(int,input().split())
l,r=map(int,input().split())
for i in range(m-1):
  x,y=map(int,input().split())
  l=max(l,x)
  r=min(r,y)
print(r-l+1 if l<=r else(0))
### BUGGY CODE ###

S = list(input())
T = list(input())

ans = True 

while S != []:
    lis = []
    lit = []
    x = S[0]
    y = T[0]
    for i in range(len(S)):
        if x == S[i]:
            lis.append(i)
        if y == T[i]:
            lit.append(i)
    if lis == lit:
        S = [S[i] for i in range(len(S)) if i not in lis]
        T = [T[i] for i in range(len(T)) if i not in lis]
        continue
    else:
        ans = False
        break
if ans:
    print('Yes')
if not ans:
    print('No')

### FIXED CODE ###

Sp = list(input())
Tp = list(input())
S = [ord(Sp[i])-ord('a') for i in range(len(Sp))]
T = [ord(Tp[i])-ord('a') for i in range(len(Tp))]
lis = [-1]*26
lit = [-1]*26
ans = True
for i in range(len(S)):
    if lis[S[i]] == -1:
        lis[S[i]] = T[i]
    else:
        if lis[S[i]] != T[i]:
            ans = False
            break
for i in range(len(T)):    
    if lit[T[i]] == -1:
        lit[T[i]] = S[i]
    else:
        if lit[T[i]] != S[i]:
            ans = False
            break
if ans:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import sys
readline = sys.stdin.buffer.readline

n = int(readline())
a = list(map(int, readline().split()))
q = int(readline())
L = []
for i in range(q):
  L.append(list(map(int, readline().split())))

s = sum(a)
for b, c in L:
  for i, v in enumerate(tuple(a)):
    if v == b:
      s -= (c - a[i])
      a[i] = c
  print(sum(a))


### FIXED CODE ###

import sys
from collections import Counter
readline = sys.stdin.buffer.readline
 
n = int(readline())
a = Counter(map(int, readline().split()))
q = int(readline())
L = []
for i in range(q):
  L.append(list(map(int, readline().split())))
 
s = sum(x * y for x, y in a.items())
for b, c in L:
  # print(a)
  if b in a:
    s += (c - b) * a[b]
    a[c] += a[b]
    del a[b]
  print(s)
### BUGGY CODE ###

from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    @lru_cache()
    def f(i, j):
        if i < 0 or j < 0:
            return -INF
        if i == 0:
            return -INF
        if j == 0:
            return 0
        if j == 1:
            return max(A[:i])
        return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))

    print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    @lru_cache(None)
    def f(i, j):
        if i < 0 or j < 0:
            return -INF
        if i == 0:
            return -INF
        if abs(j - i // 2 - 1) >= 2:
            return -INF
        if j == 0:
            return 0
        if j == 1:
            return max(A[:i])
        return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))

    print(f(N, math.floor(N / 2)))


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

import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10*5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
a = LIST()

a1 = a[:2*n]
a2 = a[n:]
a2.reverse()
for i in range(2*n):
    a2[i] = a2[i]*-1

def searchmax(a):
    maxl = [0]*(n+1)
    left = a[:n]
    center = a[n:]
    heapq.heapify(left)
    maxl[0] = sum(left)
    for i in range(1,n+1):
        heapq.heappushpop(left, center[i-1])
        maxl[i] = sum(left)
    return maxl

maxll = searchmax(a1)
minrr = searchmax(a2)
minrr.reverse()

res = [INF *-1]*(n+1)
for i in range(n+1):
    res[i] = maxll[i] + minrr[i]

print(max(res)) 




### FIXED CODE ###

import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10*5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

def main():
    n = INT()
    a = LIST()

    a1 = a[:2*n]
    a2 = a[n:]
    a2.reverse()
    for i in range(2*n):
        a2[i] = a2[i]*-1

    def searchmax(a):
        maxl = [0]*(n+1)
        left = a[:n]
        center = a[n:]
        heapq.heapify(left)
        maxl[0] = sum(left)
        for i in range(1,n+1):
            poped = heapq.heappushpop(left, center[i-1])
            maxl[i] = max(maxl[i-1], maxl[i-1]-poped+center[i-1])
        return maxl

    maxll = searchmax(a1)
    minrr = searchmax(a2)
    minrr.reverse()

    res = [INF *-1]*(n+1)
    for i in range(n+1):
        res[i] = maxll[i] + minrr[i]

    print(max(res)) 

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

n = int(input())
sn = []
set_sn = []
dic_sn = []
cnt = 0
for i in range(n):
    sn.append(input())
    set_sn = set(sn[i])
    dic_sn.append({})
    for si in set_sn:
        dic_sn[i][si] = sn[i].count(si)

for i in range(n):
    for j in range(i + 1, n):
        if dic_sn[i] == dic_sn[j]:
            cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
dic_sorted_s = {}
count = 0
for i in range(n):
    s = input()
    str_sorted_s = ''.join(sorted(s))
    try:
        count += dic_sorted_s[str_sorted_s]
        dic_sorted_s[str_sorted_s] += 1
    except KeyError:
        dic_sorted_s[str_sorted_s] = 1
print(count)
### BUGGY CODE ###

while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	x,y = xy[0]
	xy = sorted(xy, key = lambda XY:(XY[0]-x)**2 + (XY[1]-y)**2)
	ans = 0
	for i in range(n):
		x1,y1 = xy[i]
		for j in range(n-3,i,-1):
			x2,y2 = xy[j]
			dx,dy = x2-x1,y2-y1
			if [x1-dy,y1-dx] in xy[j+1:] and [x2+dy,y2-dx] in xy[j+1:]:
				ans = dx**2+dy**2
			if [x1-dy,y1+dx] in xy[j+1:] and [x2-dy,y2+dx] in xy[j+1:]:
				ans = dx**2+dy**2
			if ans: break
		if ans: break
	print ans

### FIXED CODE ###

while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans
### BUGGY CODE ###

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

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
S = list(str(input()))

S.reverse()

extra = 0
each_extras = [[0 for i in range(10)] for i in range(S.count("?"))]
cnt = 0
for i in range(len(S)):
    if S[i] != "?":
        extra += int(S[i]) * 10 ** i
    else:
        for x in range(10):
            each_extras[cnt][x] = x * 10 ** i % 13
        cnt += 1

# print(extra)
dp = [[0 for i in range(13)] for j in range(cnt+1)]
dp[0][extra % 13] = 1
for i in range(cnt):
    for each in each_extras[i]:
        for j in range(13):
            dp[i+1][(j + each) % 13] += dp[i][j] % mod

print(dp[-1][5] % mod)


### FIXED CODE ###

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

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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


"""
S.reverse()
extra = 0
each_extras = [[0 for i in range(10)] for i in range(S.count("?"))]
cnt = 0
for i in range(len(S)):
    if S[i] != "?":
        extra += int(S[i]) * 10 ** i
    else:
        each_extras[cnt] = []
        for x in range(10):
            each_extras[cnt].append(x * 10 ** i % 13)
            # each_extras[cnt][x * 10 ** i % 13] = 1
        cnt += 1

# print(each_extras)

# print(extra)
dp = [[0 for i in range(13)] for j in range(cnt+1)]
dp[0][extra % 13] = 1
for i in range(cnt):
    for extras in each_extras[i]:
        for j in range(13):
            dp[i+1][(extras + j)%13] += dp[i][j]
            dp[i+1][(extras + j)%13] %= mod
    for j in range(13):
        dp[i+1][j] = dp[i+1][j] % mod


# print(dp)
print(dp[-1][5] % mod)
"""


S = list(str(input()))

dp = [[0 for i in range(13)]for j in range(len(S)+1)]
dp[0][0] = 1
S.reverse()
mul = 1
for i in range(len(S)):
    if S[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(mul*j+k)%13] += dp[i][k]
                dp[i+1][(mul*j+k)%13] %= mod
    else:
        for k in range(13):
            dp[i+1][(int(S[i])*mul+k)%13] += dp[i][k]
            dp[i+1][(int(S[i])*mul+k)%13] %= mod
    mul *= 10
    mul %= 13

# print(dp)
print(dp[-1][5])
### BUGGY CODE ###

# ABC 155 C
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)
 
uni = np.unique(S) # return_counts is not available in numpy 1.8.2
count = np.zeros(len(uni))
for i,element in enumerate(uni):
    count[i] = (S==element).sum()
    
max_list = np.argwhere(count==np.max(count))
for index in max_list:
    print(str(uni[index][0]))

### FIXED CODE ###

# ABC 155 C
from collections import Counter
import numpy as np
N = int(input())
S = [str(input()) for i in range(N)]
S = np.array(S)

count = Counter(S)
max_num = max(count.values())
max_list = [i for i,j in count.items() if j==max_num]

max_list.sort()
print('\n'.join(max_list))
### BUGGY CODE ###

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

L = []
b = 0
cnt = 0
for i,a in enumerate(A):
    cnt += 1
    while i < N-1:
        i += 1
        if a & A[i]==0:
            cnt += 1
            a ^= A[i]
        else:
            break

print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
cnt = 0
t = 0
r = 0
for l in range(N):
    while r < N and (t & A[r]) == 0:
        t += A[r]
        r += 1
    t -= A[l]
    cnt += (r-l)

print(cnt)