Harryxun/stf_run huggingface dataset:
import numpy as np
MOD = 1000000007
s = (list(input()))
s = s[::-1]
dp = np.full((len(s), 13), 0)

if s[0] == "?":
    dp[0][0:10] = 1
else:
    dp[0][int(s[0])] = 1

for index in range(1, len(s)):
    if not s[index] == "?":
        value = int(s[index])
        for old_amari in range(13):
            new_amari = (value * pow(10, index) + old_amari) % 13
            dp[index][new_amari] += dp[index-1][old_amari]
    else:
        for value in range(10):
            for old_amari in range(13):
                new_amari = (value * pow(10, index) + old_amari) % 13
                dp[index][new_amari] += dp[index - 1][old_amari]
    dp = dp % MOD

print(dp[len(s)-1][5])import numpy as np
MOD = 1000000007
s = (list(input()))
s = s[::-1]
dp = np.full((len(s), 13), 0)

if s[0] == "?":
    dp[0][0:10] = 1
else:
    dp[0][int(s[0])] = 1

for index in range(1, len(s)):
    if not s[index] == "?":
        value = int(s[index])
        for old_amari in range(13):
            new_amari = (value * pow(10, index) + old_amari) % 13
            dp[index][new_amari] += dp[index-1][old_amari]
    else:
        for value in range(10):
            for old_amari in range(13):
                new_amari = (value * pow(10, index) + old_amari) % 13
                dp[index][new_amari] += dp[index - 1][old_amari]
    dp = dp % MOD

print(dp[len(s)-1][5])

### FIXED CODE ###

MOD = 1000000007
s = [int(x) if x!="?" else -1 for x in input()]
dp = [[0] *  13 for _ in range(len(s))] 

if s[0] == -1:
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
 
table = [ s % 13 for s in range(130)]
for index in range(1, len(s)):
    if not s[index] == -1:
        value = int(s[index])
 
        for old_amari in range(13):
            new_amari = (table[old_amari * 10] + value) % 13
            dp[index][new_amari] += dp[index-1][old_amari]
    else:
        for value in range(10):
            for old_amari in range(13):
                new_amari = (table[old_amari * 10] + value) % 13
                dp[index][new_amari] += dp[index - 1][old_amari]
 
    for i in range(len(dp[index])):
        dp[index][i] %= MOD

print(dp[len(s)-1][5])
d,n = map(int,input().split())

if n != 100:
        print(100**d*n)
else:
        print(100**d8(n+1))

### FIXED CODE ###

d,n = map(int,input().split())

if n != 100:
        print(100**d*n)
else:
        print(100**d*(n+1))
N, K = [int(item) for item in input().split()]
S = [item for item in input()]

def compress(arr):
    """圧縮して消えた人はhappy"""
    cnt_h = 0
    new_arr = []
    comp_arr = ['L']

    #最初は先頭をLにする　この回転はノーカン
    if arr[0] == 'R':
        for item in arr:
            if item == 'L':
                new_arr.append('R')
            else:
                new_arr.append('L')

            prev_item = item
    else:
        new_arr = arr
    # 圧縮操作と圧縮されたかずを数える

    for i in range(1, N):
        if new_arr[i - 1] == new_arr[i]:
            cnt_h += 1
        else:
            comp_arr.append(new_arr[i])

    return [comp_arr, cnt_h] 


def execute(arr, cnt_h, K):
    # 境界を全て反転するために必要な操作回数
    max_rotation = len(arr)//2
    # 全てLになるか反転回数がKに到達するかで終了
    if max_rotation <= K:
        cnt += len(arr) - 1
    else:
            cnt_h += 2*K

    return cnt_h

arr, cnt_h = compress(S)
print(execute(arr, cnt_h, K))

### FIXED CODE ###

N, K = [int(item) for item in input().split()]
S = [item for item in input()]

def compress(arr):
    """圧縮して消えた人はhappy"""
    cnt_h = 0
    new_arr = []
    comp_arr = ['L']

    #最初は先頭をLにする　この回転はノーカン
    if arr[0] == 'R':
        for item in arr:
            if item == 'L':
                new_arr.append('R')
            else:
                new_arr.append('L')

            prev_item = item
    else:
        new_arr = arr
    # 圧縮操作と圧縮されたかずを数える

    for i in range(1, N):
        if new_arr[i - 1] == new_arr[i]:
            cnt_h += 1
        else:
            comp_arr.append(new_arr[i])

    return [comp_arr, cnt_h] 


def execute(arr, cnt_h, K):
    # 境界を全て反転するために必要な操作回数
    max_rotation = len(arr)//2
    # 全てLになるか反転回数がKに到達するかで終了
    if max_rotation <= K:
        if arr[-1] == 'R':
            cnt_h += max_rotation*2 -1
        elif arr[-1] == 'L':
            cnt_h += max_rotation*2
    else:
        if arr[2*K] == 'R':
            cnt_h += 2*K - 1
        elif arr[2*K] == 'L':
            cnt_h += 2*K

    return cnt_h

arr, cnt_h = compress(S)
print(execute(arr, cnt_h, K))
K,S= map(int, input().split())

number_lis = []
ans = 0

for i in range(0,K+1):
    number_lis.append(i)

for j in number_lis:
    for k in number_lis:
        for l in number_lis:
            if 0<= (S　-j -k) <=K:
                ans = ans + 1
                
print(ans)

### FIXED CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(min(K,S)+1):
	for y in range(min(K,S)+1):
		if 0 <= S - x - y <= K:
			ans += 1
print(ans)
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
    

for i in range(N):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    print(a)


### FIXED CODE ###

N = int(input())
a = input().split()
b = [int(n) for n in a]


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))
n, k = map(int, input().split())
P = list(map(int, input().split()))
P = P.sort()
ans = 0
for i in range(k):
    ans += P[i]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
P = list(map(int, input().split()))
P = sorted(P)
ans = 0
for i in range(k):
    ans += P[i]
print(ans)
N,Q = map(int, input().split())
L = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
cnt = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p-1] += x


flag = [-1]*N
q = [0]
cnt[0] = qlist[0]
while q:
    temp = q.pop(0)
    for i in L[temp]:
        if flag[i] < 0:
            q.append(i)
            cnt[i] += cnt[temp]
            flag[i] = 1
            
for i in range(N):
    print(cnt[i])

### FIXED CODE ###

N,Q = map(int, input().split())
L = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
cnt = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p-1] += x

flag = [1]*N
q = [0]
while q:
    temp = q.pop()
    flag[temp] = 0
    for i in L[temp]:
        if flag[i]:
            q.append(i)
            cnt[i] += cnt[temp]
            
print(*cnt)
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

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

phase = 0
now = [0,0,0]
ans=1

for i in range(n):
    if(a[i]==0):
        now[phase]=1
        ans*=3-phase
        ans%=1000000007
        phase+=1
    else:
        corr = []
        for j in range(3):
            if(now[j]==a[i]):
                corr.append(j)
        ans*=len(corr)
        ans%=1000000007
        now[corr[0]]+=1
print(ans) 


### FIXED CODE ###

import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

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

phase = 0
now = [0,0,0]
ans=1

for i in range(n):
    if(a[i]==-1):
        now[phase]=1
        ans*=3-phase
        ans%=1000000007
        phase+=1
    else:
        corr = []
        for j in range(3):
            if(now[j]==a[i]):
                corr.append(j)
        ans*=len(corr)
        ans%=1000000007
        if(len(corr)!=0):
            now[corr[0]]+=1
print(ans)
def segfunc(x,y):return max(x,y)
ide_ele=0
class segtree():
  def __init__(self,init_val,segfunc=segfunc,ide_ele=ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num+1
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res
def isok(mid,key):
  return st.query(x-1,mid-1)>=key
def b_search(x,key):
  ng=x-1
  ok=n+1
  while abs(ng-ok)>1:
    mid=(ng+ok)//2
    if isok(mid,key):ok=mid
    else:ng=mid
  return ok
n,q=map(int,input().split())
a=list(map(int,input().split()))
st=segtree(a)
ans=[]
for _ in range(q):
  c,x,y=map(int,input().split())
  if c==1:st.update(x-1,y)
  elif c==2:ans+=[st.query(x-1,y)]
  else:ans+=[b_search(x,y)]
print(*ans,sep='\n')


### FIXED CODE ###

def segfunc(x,y):return max(x,y)
ide_ele=0
class segtree():
  def __init__(self,init_val,segfunc=segfunc,ide_ele=ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num+1
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res
def isok(mid,key):
  return st.query(x-1,mid-1)>=key
def b_search(x,key):
  ng=x-1
  ok=n+1
  while abs(ng-ok)>1:
    mid=(ng+ok)//2
    if isok(mid,key):ok=mid
    else:ng=mid
  return ok
n,q=map(int,input().split())
a=list(map(int,input().split()))
st=segtree(a)
ans=[]
for _ in range(q):
  c,x,y=map(int,input().split())
  if c==1:st.update(x-1,y)
  elif c==2:ans+=[st.query(x-1,y-1)]
  else:ans+=[b_search(x,y)]
print(*ans,sep='\n')
def readinput():
    n=int(input())
    x=input()
    return n,x

def popcount(x):
    return bin(x).count('1')

def f(x):
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        return ans    

def main(n,x):
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    xmodm1=xint%(m-1)
    xmodp1=xint%(m+1)
    ans=[]
    b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                ans.append(0)
            else:
                xx=( xmodm1 + (m-1) -b%(m-1) )%(m-1)
                ans.append(f(xx)+1)
        else:
            xx=( xmodp1 + b%(m+1) )%(m+1)
            ans.append(f(xx)+1)
        b=b//2
    return ans

if __name__=='__main__':
    n,x=readinput()
    ans=main(n,x)
    for a in ans:
        print(a)



### FIXED CODE ###

def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    if poptbl[x]!=0:
        return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    if ftbl[x]!=0:
        return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    pow2mod1=[0]*n
    pow2mod2=[0]*n
    pow2mod1[0]=1
    pow2mod2[0]=1
    for i in range(1,n):
        if m!=1:
            pow2mod1[i]=pow2mod1[i-1]*2 % (m-1)
        pow2mod2[i]=pow2mod2[i-1]*2 % (m+1)

    ans=[]
    #b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                a=0
                ans.append(a)
            else:
                xx=( xmodm1 + (m-1) -pow2mod1[n-i-1] )%(m-1)
                #ans.append(f(xx)+1)
                a=f(xx)+1
                ans.append(a)
        else:
            xx=( xmodp1 + pow2mod2[n-i-1] )%(m+1)
            #ans.append(f(xx)+1)
            a=f(xx)+1
            ans.append(a)
        #b=b//2
        print(a)
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    #for a in ans:
    #    print(a)
while True:
    data = input()
    if data[0] == '0':
        break

    print(sum([int(i) for i in data]))

for str in iter(input, "0"):
  print(sum(int(c) for c in str))

### FIXED CODE ###

for str in iter(input, "0"):
  print(sum(int(c) for c in str))
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

### FIXED CODE ###

N = int(input())
ans = float('inf')
for i in range(1,N):
	num = i
	j = N - num
	d = 0
	while num != 0:
		d += (num % 10)
		num //= 10
	while j != 0:
		d += (j % 10)
		j //= 10

	ans = min(d,ans)

print(ans)
A, B, K = map(int, input().split())
print(max(0, A - K), max(0, min(A + B -K, B)))

### FIXED CODE ###

S, T = input().split()
print(T+S)
a=int(input())
while x<10:
if a%x=0 and a//x<10:
	print('Yes')
    x += 1
else:
  print('No')

### FIXED CODE ###

a=int(input())
for i in range(1,10):
  if a//i<10:
    if a%i==0:
      print('Yes')
      break
else:
  print('No')
A = int(input())
B = int(input())
K = int(input())


for i in range(1, K+1) :
    if A >0:
        A -= 1
    elif B > 0 :
        B -= 1
        
print(A, B)
    

### FIXED CODE ###

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

a = max(A-K, 0)
K -= A - a
b = max(B-K, 0)

print(a, b)
def gcd(a,b):
            return b


def lcm(a,b):
    c=gcd(a,b);
    return a/c*b

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

### FIXED CODE ###

N = input()
n=int(N)
n2=(n%10)*100
n2+=(n%100)-n%10
n2+=(n-n%100)/100
if n==n2 :
	print('Yes\n')
else:
	print('No\n')
quit()
import math
from collections import defaultdict

mod = pow(10, 9) + 7

n, k = map(int, input().split())

graph = {}

for _ in range(n-1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	graph[a] = graph.get(a, []) + [b]
	graph[b] = graph.get(b, []) + [a]

def dfs(v):
	ans = k	# k choices of color for root
	stack = [v]
	vis_set = {v, }

	while stack:
		v = stack.pop()
		if v==0: avail_count = k-1
		else: avail_count = k-2
		for nxt in graph[v]:
			if nxt not in vis_set:
				if avail_count <= 0:
					return 0
				ans = (ans*avail_count)%mod
				avail_count -= 1
				stack.append(nxt)
				vis_set.add(nxt)
	return ans

ans = dfs(0)
print(ans)

### FIXED CODE ###

from collections import defaultdict

mod = pow(10, 9) + 7

n, k = map(int, input().split())

graph = defaultdict(list)

for _ in range(n-1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	graph[a].append(b)
	graph[b].append(a)

def dfs(v):
	global graph, k
	ans = k	# k choices of color for root
	stack = [v]
	vis_set = {v, }

	while stack:
		v = stack.pop()
		if v==0: 
			avail_count = k-1
		else: 
			avail_count = k-2
		for nxt in graph[v]:
			if nxt not in vis_set:
				if avail_count <= 0:
					return 0
				ans = (ans*avail_count)%mod
				avail_count -= 1
				stack.append(nxt)
				vis_set.add(nxt)
	return ans

ans = dfs(0)
print(ans)
import numpy as np
N = int(input())
w = np.zeros(shape = (N,N))
flag = N-1
while flag:
    l = input().split()
    i = int(l[0])-1
    j = int(l[1])-1
    w[i][j] = int(l[2])
    flag -= 1
color = np.ones(shape = (N,))
for i in range(N//2 + 1):
    for j in range(i+1,N):
        weight = w[i][j]
        if weight!=0 and weight % 2 == 0:
            color[j] = color[i]       
        else:
            color[j] = -color[i]
for i in color:
    if i == -1:
        print(0)
    else:
        print(1)

### FIXED CODE ###

read = input
n = int(read())
v = [[] for i in range(n+1)] # 邻接
used = [0 for i in range(n+1)] # 节点 1~n
def add(f,t,w):
    v[f].append((t, w))
for i in range(n-1):
    f,t,w = map(int, read().split())
    add(f,t,w)
    add(t,f,w)
# 从1出发，贪心即可，1画1，理论不会有回环，总是能画成二分图
from queue import Queue
q = Queue() # 队列
#def dfs(f, s, fa=-1):
#    if s % 2 == 0: 
#        used[f] = 1
#    for t, w in v[f]:
##         print('%d->%d->%d'%(fa, f, t,), s, w)
#        if t == fa:continue
#        dfs(t, w + s, f)
#
#
#dfs(1,0)
q.put_nowait((1, 0, -1)) #(目标节点号，根节点到目标节点的距离，与目标节点相连的上一个节点号)
while not q.empty():
    f, s, fa = q.get_nowait()
    if s % 2 == 0: 
        used[f] = 1 #used数组从1开始填充颜色
    for t, w in v[f]:
#         print('%d->%d->%d'%(fa, f, t,), s, w)
        if t == fa:continue  #fa为与目标节点相连的上一个节点号，防止成环。2->3则，3->2不能再遍历一遍
        q.put_nowait(
            (t, w + s, f)
        )
    
for i in used[1:]: #球号从1开始，故used[0]无意义
    print(used[i])
N = int(input())
r = range(N)
#print(r)
l = list(r)
#print(l)

if N == 1:
  print(1)
else:
  print(sum(l))

### FIXED CODE ###

N = int(input())
result = int(N*(N-1)//2)

print(result)
n,m = map(int,input().split())
s = []
c = []
ans = [1]
for i in range(n-1):
    ans.append("0")

for i in range(m):
    S,C = map(int,input().split())
    s.append(S)
    c.append(C)
    
for i in range(m):
    ans[s[i]-1] = c[i]
    
    if i == m-1:
        ANS = ""
        for j in range(n):
            ANS += str(ans[j])
            
for i in range(m):
    if s[i] == 1 and c[i]==0:
        ANS = -1
    
    for j in range(m):
        if s[i] == s[j] and c[i] != c[j]:
            ANS = -1
            
print(ANS)

### FIXED CODE ###

n,m = map(int,input().split())
s = []
c = []
ans = [1]
for i in range(n-1):
    ans.append("0")
ANS = ""

for i in range(m):
    S,C = map(int,input().split())
    s.append(S)
    c.append(C)
    
for i in range(m):
    ans[s[i]-1] = c[i]
    
    if i == m-1:
        for j in range(n):
            ANS += str(ans[j])
            
for i in range(m):
    if s[i] == 1 and c[i]==0 and n!=1:
        ANS = -1
    
    for j in range(m):
        if s[i] == s[j] and c[i] != c[j]:
            ANS = -1
            
if m == 0:
    if n == 1:
        ANS = 0
    else:
        ANS = "1"+"0"*(n-1)
            
print(ANS)
# C - Snack
import math
A,B = map(int, input().split())
ans = (A * B) // math.gcd(A, B)
print(ans)

### FIXED CODE ###

# C - Snack
import fractions
A,B = map(int, input().split())
ans = (A * B) // fractions.gcd(A, B)
print(ans)
# coding: utf-8
# Your code here!
H,W=map(int,input().split())
S=[]
        
for _ in range(H):
    S.append(list(input()))

def bfs(h,w,num):
    if h==H-1 and w==W-1:
        print(num)
        exit()
    if h!=0:
        if S[h-1][w]!="#":
            temp.append([h-1,w])
    if w!=0:
        if S[h][w-1]!="#":
            temp.append([h,w-1])
    if h!=H:
        if S[h+1][w]!="#":
            temp.append([h+1,w])
    if w!=W:
        if S[h][w+1]!="#":
            temp.append([h,w+1])
    
q=[[0,0]]
temp=[]

while True:
    while q:
        bfs(q.pop(0))
    q=temp[:]




### FIXED CODE ###

# coding: utf-8 
# Your code here! 
H,W=map(int,input().split()) 
S=[] 

ku=0
for _ in range(H): 
    S.append(list(input()))
    ku+=S[-1].count(".")


def bfs(h,w,num):
    if h==H-1 and w==W-1:
        print(ku-num-1)
        exit() 
    else:
        pass

    if h!=0: 
        if S[h-1][w]!="#": 
            temp.append([h-1,w])
            S[h-1][w]="#"

    if w!=0: 
        if S[h][w-1]!="#": 
            temp.append([h,w-1]) 
            S[h][w-1]="#"

    if h!=H-1: 
        if S[h+1][w]!="#": 
            temp.append([h+1,w]) 
            S[h+1][w]="#"

    if w!=W-1: 
        if S[h][w+1]!="#": 
            temp.append([h,w+1]) 
            S[h][w+1]="#"
        
q=[[0,0]] 
count=-1
while True: 
    count+=1
    #print(q)
    temp=[]
    while q:
        l=q.pop(0)
        bfs(l[0],l[1],count)
        
    q=temp[:]
    if len(q)==0:
        print(-1)
        exit()
S=input()
n=len(S)
def T(i):
    if i == 0:
        return 0
    else:
        i-=1
        return T(i)+(10**i)*int(S[n-1-i])
s=[0]*2019
s[0]=1
for j in range(1,n+1):
    m=T(j)%2019
    s[m]+=1

c=0

for m in s:
    c += m*(m-1)/2

print(int(c))

### FIXED CODE ###

s = input()
p = 2019
n = 0
ans = 0
mods = [0]*p
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n += int(j)*pow(10, i, p)
  n %= p
  mods[n] += 1
for i in mods:
  ans += i*(i-1)//2
print(ans)
A,P = map(int,input.split())

N = A*3+P
M = int(N/2)

print(M)

### FIXED CODE ###

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

num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  for f in sympy.divisors(i)[:-1]:
    if f in a:
      b += 1
      break
print(num - b)      

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0] * a[-1]
c = Counter(a)
for i in a:
    for j in range(i, a[-1]+1, i):
        dp[j-1] += 1
ans = 0
for i in a:
    if dp[i-1] == 1 and c[i]:
        ans += 1
print(ans)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8

import math
import re
import sys
 
args = sys.argv

if __name__ == "__main__":
	X = args[1]
	Y = args[2]
	Z = args[3]
	# 人数
	a = (X-Z)/(Y+Z)

	int(a)

	

### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
 
import math
import re
import sys
 
args = input().split()

X = args[0]
Y = args[1]
Z = args[2]
 
# 人数
a = (int(X)-int(Z))/(int(Y)+int(Z))
 
print(int(a))
import collections

N = int(input())
A = list(map(int, input().split()))
A_ = [0]
count = 0

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)

for a in A:
    A_.append(a+A_[-1])

for v in collections.Counter(A_).values():
    if v-1 != 0:
        count += factorial(v-1)

print(count)

### FIXED CODE ###

import collections

N = int(input())
A = list(map(int, input().split()))
A_ = [0]
count = 0

for a in A:
    A_.append(a+A_[-1])

for v in collections.Counter(A_).values():
        count += sum([i for i in range(1, v)])

print(count)
S, T = [int(c)-1 for c in input().split()]

reach = [[-1 for _ in range(N)] for _ in range(3)]
reach[0][S] = 0

queue={S}

time = 1
for _ in range(4*N):
    queue_new = set()
    for q in queue:
        for v in path[q]:
            if reach[time%3][v]==-1:
                reach[time%3][v]=time
        queue_new.add(v)
		
    queue = queue_new
    time += 1

if reach[0][T]==-1:
    print(-1)
else:
    print(reach[0][T]//3)

### FIXED CODE ###

N, M = [int(c) for c in input().split()]
path = [[] for _ in range(N)]
for i in range(M):
    u, v = [int(c) for c in input().split()]
    path[u-1].append(v-1)

S, T = [int(c)-1 for c in input().split()]

reach = [[-1 for _ in range(N)] for _ in range(3)]
reach[0][S] = 0

queue={S}

time = 1
for _ in range(4*N):
    queue_new = set()
    for q in queue:
        for v in path[q]:
            if reach[time%3][v]==-1:
                reach[time%3][v]=time
                queue_new.add(v)
		
    queue = queue_new
    time += 1

if reach[0][T]==-1:
    print(-1)
else:
    print(reach[0][T]//3)
A,B=map(int,input().split())

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))

### FIXED CODE ###

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

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A,B))
N = int(input())
print(n**3)


### FIXED CODE ###

N = int(input())
print(N**3)