Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
W = set()
for a in range(0, F+1, 100*A):
    for b in range(0, F+1, 100*B):
        W.add(a+b)
S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1, D):
        S.add(c+d)

rate = -1
for w in W:
    for s in S:
        if 0 < w + s <= F and s * 100 <= E * w:
            if s / (s + w) > rate:
                rate = s / (s + w)
                ans = w + s, s
print(ans[0], ans[1])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

mx = -s
ans = 0, 0
for a in range(0, F+1, A*100):
    for b in range(0, F-a+1, B*100):
        if a + b == 0:
            continue

        for c in range(0, F-a-b+1, C):
            for d in range(0, F-a-b-c+1, D):
                x = 100 * (c + d) / (a + b)
                if x <= E and mx < x:
                    mx = x
                    ans = (a + b + c + d), int(x)
print(*ans)

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())


ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F-a+1, B*100):
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F-c+1, D):
        ss.add(c + d)

mx = 0
ans = None
for w in ws:
    if w == 0:
        continue
    for s in ss:
        x = s * 100 / w
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = [s + w, s]

print(' '.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())


ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F-a+1, B*100):
        if a + b == 0:
            continue
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F-c+1, D):
        ss.add(c + d)

mx = 0
ans = None
for w in ws:
    for s in ss:
        x = s * 100 / w
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = [s + w, s]

print(*ans)

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

mx = 0
ans = None
for a in range(0, F+1, A*100):
    for b in range(0, F-a+1, B*100):
        if a + b == 0:
            continue

        for c in range(0, F-a-b+1, C):
            for d in range(0, F-a-b-c+1, D):
                if c + d == 0:
                    continue
                x = 100 * (c + d) / (a + b)
                if x <= E and mx < x:
                    mx = x
                    ans = ((a + b + c + d), int(x))
print(*ans)
Problem p02823 (python)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	if (b-1) < (n-a):
		ans = min(n-a, b-1, a+(b-a-1)//2)
	else:
		ans = min(n-a, b-1, n-b+1+(b-a-1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	ans = min(n-a, b-1, (b-a-1)//2
print(ans)
Problem p03282 (python)

Fixed submission:
S=list(input())
K=int(input())
a=b=0

for s in S:
	if s=='1':
		a+=1
	else:
		b=s
		break
if a>=K:
	print(1)
else:
	print(b)

Buggy submission (verdict: Runtime Error):
S=list(input())
K=int(input())
a=b=0

for s in S:
	if s=='1':
		a+=1
	else:
		b=s
		break
if a>=K:
	print(i)
else:
	print(b)
Problem p03293 (python)

Fixed submission:
s=input()
t=input()
a=0
f=False

for i in range(len(s)):
	a=s[-1]
	s=s[:-1]
	s=a+s
	
	if s==t:
		f=True
		break
		
if f:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a=0
f=False

for i in range(len(s)):
	a=s[-1]
	s=s[:-1]
	s=a+s
	
	if s==t:
		f=True
		break
		
if f:
	print('Yes')
else:
	print('No')
Problem p03695 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(n):
  if a[i]<400:
    b[0]+=1
  elif a[i]<800:
    b[1]+=1
  elif a[i]<1200:
    b[2]+=1
  elif a[i]<1600:
    b[3]+=1
  elif a[i]<2000:
    b[4]+=1
  elif a[i]<2400:
    b[5]+=1
  elif a[i]<2800:
    b[6]+=1
  elif a[i]<3200:
    b[7]+=1
  else:
    b[8]+=1
    
min=8-b[:8].count(0)
max=min+b[8]

if min==0:
  min=1
print(min,max)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in range(n):
  if a[i]<400:
    b[0]+=1
  elif a[i]<800:
    b[1]+=1
  elif a[i]<1200:
    b[2]+=1
  elif a[i]<1600:
    b[3]+=1
  elif a[i]<2000:
    b[4]+=1
  elif a[i]<2400:
    b[5]+=1
  elif a[i]<2800:
    b[6]+=1
  elif a[i]<3200:
    b[7]+=1
  else:
    b[8]+=1
    
min=8-b[:8].count(0)
max=min+b[8]

if min=0:
  min=1
print(min,max)
Problem p02608 (python)

Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())

anss = [0 for i in range(N + 1)]
for x in range(1, int(math.sqrt(N))):
    for y in range(1, int(math.sqrt(N))):
        for z in range(1, int(math.sqrt(N))):
            tmp = x ** 2 + y ** 2 + z ** 2 + x*y + x*z + y*z
            if tmp <= N:
                anss[tmp] += 1 

for i in range(1, N + 1):
    print(anss[i])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N = int(input())

anss = [0 for i in range(1001)]
for x in range(1, int(math.sqrt(N))):
    for y in range(1, int(math.sqrt(N))):
        for z in range(1, int(math.sqrt(N))):
            tmp = x ** 2 + y ** 2 + z ** 2 + x*y + x*z + y*z
            if tmp <= 1000:
                anss[tmp] += 1 

for i in range(1, N + 1):
    print(anss[i])
Problem p02615 (python)

Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A.sort(reverse=1)
ans = 0
ans += A[0]

tmp = 1
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

ans = 0
ans += A[0]
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)
Problem p02642 (python)

Fixed submission:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 

"""
3
1 1 2
のパターンが例外だった
"""

N = int(input())
A = LI()
A.sort()

table = [0 for i in range(10 ** 6 + 1)]
cnt = 0

cc = collections.Counter(A)
duplicate = []
for key in cc.keys():
    if cc[key] > 1:
        duplicate.append(key)

for a in A:
    if table[a] != 0:
        pass
    else:
        if a not in duplicate:
            cnt += 1
        for i in range(1, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            table[a * i] = 1

print(cnt)

Buggy submission (verdict: Runtime Error):
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 

"""
3
1 1 2
のパターンが例外だった
"""

N = int(input())
A = LI()
A.sort()

table = [0 for i in range(2 * 10 ** 5 + 1)]
cnt = 0
for a in A:
    if table[a] != 0:
        pass
    else:
        cnt += 1
        for i in range(2 * 10 ** 5):
            if a * i > 2 * 10 ** 5:
                break
            table[a * i] = 1

A_dic = collections.Counter(A)
for key in A_dic.keys():
    if A_dic[key] > 1:
        cnt -= 1
    
print(cnt)
Problem p02677 (python)

Fixed submission:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, H, M = LI()

pi = math.pi
h_p = [A * math.cos(2 * pi * (H * 60 + M) / 720), A * math.sin(2 * pi * (H * 60 + M) / 720)]
m_p = [B * math.cos(2 * pi * M / 60), B * math.sin(2 * pi * M / 60)]

# print(h_p, m_p)
length = ((h_p[0] - m_p[0])**2 + (h_p[1] - m_p[1])**2)**0.5
print(length)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる
import sympy
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, H, M = LI()
sympy.pi.evalf(30)
pi = sympy.pi

h_p = [A * math.cos(2 * pi * (H * 60 + M) / 720), A * math.sin(2 * pi * (H * 60 + M) / 720)]
m_p = [B * math.cos(2 * pi * M / 60), B * math.sin(2 * pi * M / 60)]

# print(h_p, m_p)
length = ((h_p[0] - m_p[0])**2 + (h_p[1] - m_p[1])**2)**0.5
print(length)
Problem p02696 (python)

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

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
if N < B:
    ans = math.floor(A * N / B)
elif N >= B:
    ans = math.floor(A * (B - 1) / B)
print(ans)

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

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
ans = math.floor(A * N / B)
if N > B:
    ans = max(ans, math.floot(A * (B - 1) / B))
print(ans)
Problem p02715 (python)

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

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()

# 逆に考える
"""
X = gcd(A_1, A_2,...A_K)
となるようなXを考えると溶ける
X = 3の時その個数は
[K/3]**N
"""

x_cnt = [0] * (K + 1)
for x in range(K, 0, -1):
    # print(x)
    tmp = pow(K // x, N, mod)
    for j in range(x + x, K+1, x):
        tmp -= x_cnt[j]
    x_cnt[x] = tmp

ans = 0
for i in range(1,K+1):
    ans += i * x_cnt[i]
    ans %= mod
print(ans)

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

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()

# 逆に考える
"""
X = gcd(A_1, A_2,...A_K)
となるようなXを考えると溶ける
X = 3の時その個数は
[K/3]**N
"""

x_cnt = [0 for i in range(K + 1)]
for x in range(N, 0, -1):
    # print(x)
    tmp = pow(K // x, N, mod)
    for x_n in range(x + x, N+1, x):
        tmp -= x_cnt[x_n]
    x_cnt[x] = tmp % mod

ans = 0
for i in range(1,K+1):
    ans += i * x_cnt[i]
    ans %= mod
print(ans)
Problem p02719 (python)

Fixed submission:
# encoding:utf-8
N, K = [int(i) for i in input().split()]
print(min(abs(N % K), abs(N % K - K), N))

Buggy submission (verdict: Runtime Error):
# encoding:utf-8
N, K = LI()


ans = min(abs(N % K), abs(N % K - K), N)
print(ans)
Problem p02748 (python)

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

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, M = LI()
a = LI()
b = LI()
xyc = [[] for i in range(M)]
for i in range(M):
    x, y, c = LI()
    x -= 1
    y -= 1
    xyc[i] = [x, y, c]

ans = mod
for i in range(M):
    x, y, c = xyc[i]
    ans = min(ans, a[x] + b[y] - c)

ans = min(ans, min(a) + min(b))
print(ans)

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

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, M = LI()
a = LI()
b = LI()
xyc = [[] for i in range(M)]
for i in range(M):
    x, y, c = LI()
    x -= 1
    y -= 1
    xyc[i] = [x, y, c]

ans = mod
for i in range(M):
    x, y, c = xyc[i]
    ans = min(ans, a[x] + a[y] - c)

ans = min(ans, min(a) + min(b))
print(ans)
Problem p02838 (python)

Fixed submission:
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()))

N = int(input())
A = LI()

count_list = [0 for i in range(61)]
def counts(count_list, a):
    for i in range(61):
        if a <= 0:
            break
        count_list[i] += a % 2
        a = a // 2
    return count_list

A.reverse()
ans = 0
ans_list = [0 for i in range(61)]
for i in range(N-1):
    count_list = counts(count_list, A[i])
    hikaku = counts([0 for i in range(61)], A[i + 1])
    for j in range(61):
        if hikaku[j] == 1:
            ans_list[j] += i+1 - count_list[j]
        else:
            ans_list[j] += count_list[j]

for i in range(61):
    ans += ans_list[i] * (2 ** i % mod)
    ans = ans % mod
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import numpy as np

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

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

N = int(input())
A = LI()

count_list = [0 for i in range(61)]
def counts(count_list, a):
    for i in range(61):
        if a <= 0:
            break
        count_list[i] += a % 2
        a = a // 2
    return count_list

A.reverse()
ans = 0
ans_list = [0 for i in range(61)]
for i in range(N-1):
    count_list = counts(count_list, A[i])
    hikaku = counts([0 for i in range(61)], A[i + 1])
    for j in range(61):
        if hikaku[j] == 1:
            ans_list[j] += i+1 - count_list[j]
        else:
            ans_list[j] += count_list[j]

for i in range(61):
    ans += ans_list[i] * (2 ** i % mod)
    ans = ans % mod
print(ans)
Problem p02843 (python)

Fixed submission:
# 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()))
X = int(input())
prices = [100,101,102,103,104,105]


dp = [0 for i in range(2002)]
for price in prices:
    dp[price] = 1
for i in range(len(dp)):
    for price in prices:
        if i > price and dp[i-price] == 1:
            dp[i] = 1

if X > 2000:
    print("1")
else:
    print(dp[X])

Buggy submission (verdict: Runtime Error):
# 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()))
X = int(input())
prices = [100,101,102,103,104,105]

#
# dp = [0 for i in range(2002)]
# for price in prices:
#     dp[price] = 1
# for i in range(len(dp)):
#     for price in prices:
#         if i > price and dp[i-price] == 1:
#             dp[i] = 1
#
# if X > 2000:
#     print("1")
# else:
#     print(dp[X])



dp = [0 for i in range(X + 1)]
for price in prices:
    dp[price] = 1
for i in range(len(dp)):
    for price in prices:
        if i > price and dp[i - price] == 1:
            dp[i] = 1

print(dp[X])
Problem p02900 (python)

Fixed submission:
# 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()))


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


A,B = LI()

gcd = fractions.gcd(A,B)
ans = 1
for facter in factorization(gcd):
    if facter[0] == 1:
        pass
    else:
        ans += 1
print(ans)


'''
12 18
1 2 3 6
1 2 3

6 9
1 3
1 2 3

420 660
210 330
105 165
35 55
7 11

2**2*3
1 2 3 5
'''

Buggy submission (verdict: Runtime Error):
# 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()))


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


A,B = LI()

gcd = math.gcd(A,B)
ans = 1
for facter in factorization(gcd):
    if facter[0] == 1:
        pass
    else:
        ans += 1
print(ans)


'''
12 18
1 2 3 6
1 2 3

6 9
1 3
1 2 3

420 660
210 330
105 165
35 55
7 11

2**2*3
1 2 3 5
'''
Problem p02909 (python)

Fixed submission:
# 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 = str(input())
weather = ["Sunny","Cloudy","Rainy"]
print(weather[(weather.index(S)+1) % len(weather)])

Buggy submission (verdict: Runtime Error):
# 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()))

N,K,Q = LI()
A = [0 for i in range(Q)]
for i in range(Q):
    A[i] = int(input()) - 1

cnt = {}

for i in range(N):
    cnt[i] = 0

for a in A:
    cnt[a] += 1

for i in range(N):
    if K - Q + cnt[i] > 0:
        print("Yes")
    else:
        print("No")
Problem p02960 (python)

Fixed submission:
# 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 submission (verdict: Runtime Error):
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import numpy as np

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

each_extras = np.array(each_extras)
# print(extra)
dp = np.array([[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(each)
        dp[i+1] += np.roll(dp[i],each) % mod

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