Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()


# 最初(N//2)**2にしていた、それぞれの場合の数ではなくなってしまう
print((2**(N // 2))%(10**9+7))

### FIXED CODE ###

N = int(input())
if N == 1:
    print(1)
    exit()
A = list(map(int, input().split()))
A = sorted(A)[::-1]
memo = [0 for i in range(N)]
memo[0] = N-1
memo[1] = N-1
if N % 2 == 0:
    for i in range(2, N):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()
else:
    for i in range(2, N-1):
        memo[i] = memo[i-2]-2
        if memo[i] != A[i]:
            print(0)
            exit()


# 最初(N//2)**2にしていた、それぞれの場合の数ではなくなってしまう
print((2**(N // 2))%(10**9+7))
S=input()
T=input()

lt=len(T)
ls=len(S)
S+='%'*lt

for i in range(ls-lt+1):
    # print('***',S[i:i+lt])
    flg=1
    for j in range(i,i+lt):
        s=S[j]
        # print(s,T[j-i])
        if s=='?': continue
        if s=='%' or s!=T[j-i]:
            flg=0
            break
    if flg==1:
        break
if flg:
    print((S[0:i]+T+S[i+lt:ls]).replace('?','a'))
else:
    print('UNRESTORABLE')

### FIXED CODE ###

S=input()
T=input()

lt=len(T)
ls=len(S)
S+='%'*lt

if ls<lt:
    flg=0
else:
    for i in range(ls-lt+1,-1,-1):
        # print('***',S[i:i+lt])
        flg=1
        for j in range(i,i+lt):
            s=S[j]
            # print(s,T[j-i])
            if s=='?': continue
            if s=='%' or s!=T[j-i]:
                flg=0
                break
        if flg==1:
            break
if flg:
    print((S[0:i]+T+S[i+lt:ls]).replace('?','a'))
else:
    print('UNRESTORABLE')
N = int(input())
S = int(input())


def f(b, n):
    s = 0
    while n > 0:
        s += n % b
        n //= b
    return s


num = -1
for i in range(2, int(N ** 0.5) + 1):
    if f(i, N) == S:
        num = i
        break


if num == -1:
    for i in range(1, int(N ** 0.5) + 1):
        if (N - S) % i == 0:
            b = (N - S) // i + 1
            if f(b, N) == S:
                num = b
                break

print(num)

### FIXED CODE ###

N = int(input())
S = int(input())


def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n // b) + n % b


if N == S:
    print(N + 1)
    exit()
elif N < S:
    print(-1)
    exit()

num = -1
for i in range(2, int(N ** 0.5) + 1):
    if f(i, N) == S:
        num = i
        break


if num == -1:
    for i in range(int(N ** 0.5) + 1, 0, -1):
        if (N - S) % i == 0:
            b = (N - S) // i + 1
            if f(b, N) == S:
                num = b
                break

print(num)
n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h)
for i in range(k):
 H[n-k+1]=0
print(sum(H))

### FIXED CODE ###

n,k=map(int, input().split())
h=list(map(int,input().split()))
H=sorted(h,reverse=True)
if n>=k:
	for i in range(k):
		H[i]=0
	print(sum(H))
else: 
	print(0)
from sys import stdin
def main():
    A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))

    wc = A.count(1)
    indices = [i for i, x in enumerate(A) if x == 1]
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()


### FIXED CODE ###

from sys import stdin

def main():
    A=stdin.readline().replace('B', '0').replace('W', '1')
    #A=list(map(int,bw))
    #A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))

    wc = A.count('1')
    indices = [i for i, x in enumerate(A) if x == '1']
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()
import sys

tree={}
np = -1

home=0
tree[home]=[None, None, None]

def search(p, x):
    while p != None:
        tmp = tree[p]
        if tmp[0] == x: return True
        if x < tmp[0]:
            p = tmp[1]
        else:
            p = tmp[2]
    return False

def node(x):
    global np
    np += 1
    tree[np] = [x, None, None]
    return np

def insert(p, x):
    if p == None or np == -1: return node(x)
    tmp = tree[p]
    if x== tmp[0]: return p
    elif x<tmp[0]:
        tree[p][1]=insert(tmp[1],x)
    else:
        tree[p][2]=insert(tmp[2],x)
    return p

def preorder(p):
    if p == None: return []
    p1, p2 = tree[p][1:3]
    return [tree[p][0]] + preorder(p1) + preorder(p2)

def inorder(p):
    if p == None: return []
    p1, p2 = tree[p][1:3]
    return inorder(p1) + [tree[p][0]] +inorder(p2)

n = int(input())
i = 0
while i<n:
    s = raw_input()
    if s[0]=='i':
        insert(0,int(s[7:]))
    elif s[0]=='f':
        if search(0,int(s[5:])): print 'yes'
        else print 'no'
    elif s[0]=='p':
        print ' ' + ' '.join(map(str, inorder(home)))
        print ' ' + ' '.join(map(str, preorder(home)))
    i += 1

### FIXED CODE ###

import sys

tree={}
np = -1

home=0
tree[home]=[None, None, None]

def search(p, x):
    while p != None:
        tmp = tree[p]
        if tmp[0] == x: return True
        if x < tmp[0]:
            p = tmp[1]
        else:
            p = tmp[2]
    return False

def node(x):
    global np
    np += 1
    tree[np] = [x, None, None]
    return np

def insert(p, x):
    if p == None or np == -1: return node(x)
    tmp = tree[p]
    if x== tmp[0]: return p
    elif x<tmp[0]:
        tree[p][1]=insert(tmp[1],x)
    else:
        tree[p][2]=insert(tmp[2],x)
    return p

def preorder(p):
    if p == None: return []
    p1, p2 = tree[p][1:3]
    return [tree[p][0]] + preorder(p1) + preorder(p2)

def inorder(p):
    if p == None: return []
    p1, p2 = tree[p][1:3]
    return inorder(p1) + [tree[p][0]] +inorder(p2)

n = int(input())
i = 0
while i<n:
    s = raw_input()
    if s[0]=='i':
        insert(0,int(s[7:]))
    elif s[0]=='f':
        if search(0,int(s[5:])): print 'yes'
        else: print 'no'
    elif s[0]=='p':
        print ' ' + ' '.join(map(str, inorder(home)))
        print ' ' + ' '.join(map(str, preorder(home)))
    i += 1
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if A in "0":
        print("0")
    else:
        for i in A:
            ans *= i
            if ans > 10**18:
                print("-1")
                exit()
        print(ans)
resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if 0 in A:
        print(0)
        exit()
    for i in A:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
resolve()
n, m, x = [int(e) for e in input().split()]

import numpy as np

all = np.zeros(n*(m+1)).reshape(n,m+1)

for i in range(n):
    all[i] += [int(e) for e in input().split()]

bool_list = np.array([])
a = []
b = []
def make(n):
    if len(a) == n:
        b.append([0 for _ in range(n)])
        for i,v in enumerate(a) :
            if v == True:
                b[-1][i] = True
            else:
                b[-1][i] = False
    else:
        for i in [True,False]:
            a.append(i)
            make(n)
            a.pop()

make(n)
c=np.array(b)

dp=[10**10]

for i in c:
    if all[i][:,1].sum(axis = 0) >=x :
        dp = min(dp,all[i][:,0].sum(axis = 0))


print(int(dp))

### FIXED CODE ###

n, m, x = [int(e) for e in input().split()]

import numpy as np

all = np.zeros(n*(m+1)).reshape(n,m+1)

for i in range(n):
    all[i] += [int(e) for e in input().split()]

bool_list = np.array([])
a = []
b = []
def make(n):
    if len(a) == n:
        b.append([0 for _ in range(n)])
        for i,v in enumerate(a) :
            if v == True:
                b[-1][i] = True
            else:
                b[-1][i] = False
    else:
        for i in [True,False]:
            a.append(i)
            make(n)
            a.pop()

make(n)
c=np.array(b)

dp=10**10

for i in c:
    if (all[i][:,1:].sum(axis = 0) >=x).all() :
        dp = min(dp,all[i][:,0].sum(axis = 0))

if dp ==10**10:
    dp = -1
print(int(dp))
N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
E=[0]*N
for i in range (N):
	E[i]=(P[i]+1)/2
for i in range(A):
	cnt=max(cnt,E[i:i+K])
print(cnt)

### FIXED CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
E=[0]*N

for i in range (N):
	E[i]=((P[i]+1)/2)

L=[0]*(N+1)
L[0]=0

for i in range (N):
	L[i+1]=L[i]+E[i]

ans=0

for i in range (K,N+1):
	ans=max(ans,L[i]-L[i-K])

print(ans)
c11,c12,c13=map(str,input().split())
c21,c22,c23=map(str,input().split())
if c11==c23 and c12==c22 and c13==c21:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a=input()
b=input()
if a==b[::-1]:
    print("YES")
else:
    print("NO")
r = int(input())
print(3 * a**2)

### FIXED CODE ###

r = int(input())
print(3*r**2)
import sys
from collections import defaultdict
from itertools import product, permutations, combinations
from time import time

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

q = list(range(N))
c = defaultdict(int)
t = [0]*N
r = 0
a = time()

while q:
    b = time()
    if b - a > 0.9:
        print(N*(N-1)//2)
        exit()
    r += 1
    nq = []
    for i in q:
        j = A[i][t[i]] - 1
        k = i
        if k < j:
            j, k = k, j
        c[(j, k)] += 1
        if c[(j, k)] == 2:
            t[j] += 1
            t[k] += 1
            if t[j] < N-1:
                nq.append(j)
            if t[k] < N-1:
                nq.append(k) 
    q = nq

for tt in t:
    if tt != N-1:
        print(-1)
        exit()

print(r)

### FIXED CODE ###

import sys
input = sys.stdin.readline
MAX = 1000000

N, M = map(int, input().split())
ab = [0]*M
C = [0]*M
for i in range(M):
    ab[i] = list(map(int, input().split()))
    c = list(map(int, input().split()))
    for cc in c:
        C[i] += (1<<(cc-1)) # bit

dp = [[MAX]*(2**N) for _ in range(M)]
dp[0][0] = 0

for i in range(M-1):
#    for p in range(M):
#        print(dp[p])
    for j in range(1<<N):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][j|C[i]] = min(dp[i+1][j|C[i]], dp[i][j]+ab[i][0])

res = dp[-1][-1]
if res == MAX:
    print(-1)
else:
    print(res)
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
X = [0 for _ in range(N)]
P = [0 for _ in range(N)]

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

for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    X[p] += x


def dfs(p, x, parent):

    P[p] += x + X[p]
    for node in G[p]:
        if node == parent:
            continue
        dfs(node, x + X[p], p)


dfs(0, 0, -1)

print(' '.join([str(p) for p in P]))


### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion

N, Q = map(int, input().split())

v = [[] for i in range(N)]
score = [0]*N

def dfs(cur,par):
  for chi in v[cur]:
    if chi == par:
      continue
    score[chi] += score[cur]
    dfs(chi, cur)
      
for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  v[a].append(b)
  v[b].append(a)

for j in range(Q):
  p, x = map(int, input().split())
  score[p-1] += x

dfs(0,-1)
score_int=[str(a) for a in score]
output= ' '.join(score_int)
print(output)
import sys
sys.setrecursionlimit(100001)

# 一人消してgcd
n = int(input())
l = sorted(list(map(int, input().split(' '))))
def gcd(b, s):
  return s if b % s == 0 else gcd(s, b % s)

memo = {}
mmm = 0
def ggcd(l, i, skip, current):
  global mmm
  if i == len(l) or current == 1 or current <= mmm:
    if mmm < current:
      mmm = current
    return current
  key = (i, skip, current)
  if key not in memo:
    if i == skip:
      memo[key] = ggcd(l, i+1, skip, current)
    else:
      memo[key] = ggcd(l, i+1, skip, gcd(l[i], current))
  return memo[key]
[ggcd(l, 0, skip, l[1] if skip == 0 else l[0]) for skip in range(len(l))]
print(mmm)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100001)

def gcd(b, s):
    return s if b % s == 0 else gcd(s, b % s)

# 一人消してgcd
n = int(input())
nl = sorted(list(map(int, input().split(' '))))
rl = nl[::-1]
sumnl = [nl[0]]
sumrl = [rl[0]]
for i in range(1, len(nl)):
    sumnl.append(gcd(sumnl[-1], nl[i]))
    sumrl.append(gcd(sumrl[-1], rl[i]))
sumrl = sumrl[::-1]
if len(sumnl) == 1:
    print(sumnl[0])
else:
    print(max([sumnl[-2]] + [gcd(sumnl[i],sumrl[i+2]) for i in range(len(sumrl) - 2)] + [sumrl[1]]))
a,b,h=map(int, input().split());print((a+b)*h/2)

### FIXED CODE ###

a,b,h=[int(input()) for i in range(3)];print((a+b)*h//2)
N, X=map(int, input().split())
A=[int(input()) for _ in range(N)]
rest=X-sum(A)
print(rest//min(A)+N)

### FIXED CODE ###

print(input().count("o")*100+700)
a,b = map(int, input())
if a*b%2==0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = map(int, input().split())
c = a*b
if c%2 == 0:
    print("Even")
else:
    print("Odd")
import sys
sys.setrecursionlimit(10**5+10)
N=int(input())
a=[-1]+[int(input())-1 for i in range(1,N)]
DP=[-1 for i in range(N)]
G=[[] for i in range(N)]
for i in range(1,N):
    G[a[i]].append(i)
def dp(i):
    if DP[i]!=-1:
        return DP[i]
    if len(G[i])==0:
        DP[i]=0
        return 0
    X=sorted([(dp(j),j) for j in G[i]],reverse=True)
    K=len(X)
    Y=[X[i][0]+i+1 for i in range(K)]
    return max(Y)
print(dp(0))

### FIXED CODE ###

import sys
import heapq
sys.setrecursionlimit(2*10**5)
N=int(input())
a=[-1]+[int(input())-1 for i in range(1,N)]
G=[[] for i in range(N)]
for i in range(1,N):
    G[a[i]].append(i)
def dp(i):
    if len(G[i])==0:
        return 0
    q=[]
    for j in G[i]:
        heapq.heappush(q,-dp(j))
    k=1
    res=0
    while(q):
        x=-heapq.heappop(q)
        res=max(res,x+k)
        k+=1
    return res
print(dp(0))
import sys
e = sys.stdin.readlines():
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)


### FIXED CODE ###

import sys
e = [int(i) for i in sys.stdin.readlines()]
for i in range(3):
    m = max(e)
    e.remove(m)
    print (m)
import copy
h,w = map(int,input().split())

s = [['#' for _ in range(w+2)]]
for i in range(h):
    si = ['#']
    sij = list(input())
    si.extend(sij)
    si.append('#')
    s.append(si)
s.append(['#' for _ in range(w+2)])

def bfs(i,j):
    root = copy.deepcopy(s)
    q = []
    q.append([i,j])
    root[i][j] = 0
    while q:
        ij = q.pop(0)
        i = ij[0]
        j = ij[1]
        
        if root[i-1][j] == '.': #左
            q.append([i-1,j])
            root[i-1][j] = root[i][j] + 1
        if root[i+1][j] == '.': #右
            q.append([i+1,j])
            root[i+1][j] = root[i][j] + 1
        if root[i][j+1] == '.': #上
            q.append([i,j+1])
            root[i][j+1] = root[i][j] + 1
        if root[i][j-1] == '.': #下
            q.append([i,j-1])
            root[i][j-1] = root[i][j] + 1
    max = 0
    for i in range(1,h+1):
        for j in range(1,w+1):
            if root[i][j] != '#' and root[i][j] > max:
                max = root[i][j]
    return max

ans = -1
for i in range(1,h+1):
    for j in range(1,w+1):
        k = bfs(i,j)
        if ans < k:
            ans = k
print(ans)

### FIXED CODE ###

import copy
h,w = map(int,input().split())

s = [['#' for _ in range(w+2)]]
for i in range(h):
    si = ['#']
    sij = list(input())
    si.extend(sij)
    si.append('#')
    s.append(si)
s.append(['#' for _ in range(w+2)])

def bfs(i,j):
    root = copy.deepcopy(s)
    q = []
    q.append([i,j])
    root[i][j] = 0
    while q:
        ij = q.pop(0)
        i = ij[0]
        j = ij[1]
        
        if root[i-1][j] == '.': #左
            q.append([i-1,j])
            root[i-1][j] = root[i][j] + 1
        if root[i+1][j] == '.': #右
            q.append([i+1,j])
            root[i+1][j] = root[i][j] + 1
        if root[i][j+1] == '.': #上
            q.append([i,j+1])
            root[i][j+1] = root[i][j] + 1
        if root[i][j-1] == '.': #下
            q.append([i,j-1])
            root[i][j-1] = root[i][j] + 1
    max = 0
    for i in range(1,h+1):
        for j in range(1,w+1):
            if root[i][j] != '#' and root[i][j] > max:
                max = root[i][j]
    return max

ans = -1
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == '.':
            k = bfs(i,j)
            if ans < k:
                ans = k
print(ans)
n, m = input()
A, b = []
c = 0
  
for i in range(n):
   A += [map(int, raw_input().split())]

for j in range(m):
   b += [input()]
  
for i in range(n):
   for j in range(m):
      c += A[i][j] * b[j]
   print c

### FIXED CODE ###

n, m = map(int, raw_input().split())
A = []
b = []
    
for i in range(0, n):
   A += [map(int, raw_input().split())]
  
for j in range(0, m):
   b += [input()]
     
for i in range(0, n):
   c = 0
   for j in range(0, m):
      c += A[i][j] * b[j]
   print c
hen = map(int(input()))

print(hen[0]*hen[2] " " hen[0]*2+hen[2])

### FIXED CODE ###

a,b=map(int, input().split())
print(a*b,2*a+2*b)
import sys
sys.setrecursionlimit(10 ** 6)

N, M = map(int, input().split())

graph = [[] for i in range(M)]
for i in range(M):
    v, e = map(int, input().split())
    graph[v - 1].append(e - 1)
    graph[e - 1].append(v - 1)

def dfs(v, seen, res):
    end = True
    for i in range(len(seen)):
        if seen[i] == False and i != v:
            end = False
    if end:
        res[0] += 1
        return
    seen[v] = True
    for i in graph[v]:
        if seen[i]:
            continue
        dfs(i, seen, res)
    seen[v] = False

res = [0]
seen = [False] * N
dfs(0, seen, res)
print(res[0])

### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for _ in range(N)]
seen = [False] * N
for i in range(M):
    a, b = map(lambda x: int(x) - 1 ,input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(x, G, seen):
    seen[x] = True
    flag = True
    for i in seen:
        if i == False:
            flag = False
    if flag:
        return 1
    res = 0
    for i in G[x]:
        if seen[i]:
            continue
        res += dfs(i, G, seen)
        seen[i] = False
    return res

print(dfs(0, G, seen))
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

if p[-1] == n:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
    
print(ans)
def main():
    import math
    n,k=map(int,input().split(" "))
    a=list(map(int,input().split(" ")))
    g=a[0]
    m=max(a)
    for i in range(n):
        g=math.gcd(g,a[i])
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

### FIXED CODE ###

def gcd(a,b):
    if a==0: return b
    else: return gcd(b%a,a)

def main():
    n,k=map(int,input().split(" "))
    a=list(map(int,input().split(" ")))
    g=a[0]
    m=a[0]
    for e in a:
        g=gcd(g,e)
        if m<e: m=e
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()
from collections import Counter
n=int(input())
alist=list(map(int,input().split()))
a1=[]
a2=[]
for i,a in enumerate(alist):
  a2.append(i-a)
  a1.append(i+a)
aa=Counter(a2)
count=0
for k in a1:
  count+=aa.get(k,0)
print(count)

### FIXED CODE ###

import numpy as np
n,m=map(int,input().split())
hlist = list(map(int,input().split()))
ablist = []
for i in range(m):
    ablist.append(input().split())
x=np.zeros(n,int)
for ab in ablist:
  a=int(ab[0])
  b=int(ab[1])
  if hlist[a-1]<hlist[b-1]:
    x[a-1]=1#ダメ
  elif hlist[a-1]>hlist[b-1]:
    x[b-1]=1#ダメ
  elif hlist[a-1]==hlist[b-1]:
    x[a-1]=1
    x[b-1]=1
count=0
for l in range(n):
  if x[l]==0:
    count+=1
print(count)
import numpy as np
n = int(input())

l = np.empty(n)
l[:] = np.nan
k = 0
for i in range(1,n):
  if n % i == 0:
    l[k] = i + (n / i)
    k += 1
print(int(np.nanmin(l)))

### FIXED CODE ###

n = int(input())

for i in range(int(n ** 0.5)):
  if n % (int(n ** 0.5) - i) == 0:
    j = n // (int(n ** 0.5) - i)
    break
    
print(int(n ** 0.5) - i + j - 2)
C = [list(map(int,input().split())) for i in range(2)]
if C[0][0] == C[1][2] and C[1][0] == C[0][2] and C[0][1] == C[1][1]:
    print('YES')
else:
    print('NO')



### FIXED CODE ###

C = [list(input()) for i in range(2)]
if C[0][0] == C[1][2] and C[1][0] == C[0][2] and C[0][1] == C[1][1]:
    print('YES')
else:
    print('NO')
s = input()
a = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        a.append(s[i:j])

l = []
x = 2019
while x<=200000:
    l.append(x)
    x += 2019
ans = 0

for x in l:
    ans += a.count(str(x))
print(ans)

### FIXED CODE ###

s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)
a,b = map(int,input().split())
c =

if b<=1:
	print("0")
else:
	while 1+(a-1)*c<b:
		c=c+1


print(c)

### FIXED CODE ###

a,b = map(int,input().split())
c =1

if b==1:
	c =0
else:
	while 1+(a-1)*c<b:
		c=c+1


print(c)
import collections

N,K = map(int, input().split())
arr = list(map(int, input().split()))
c = collections.Counter(arr)

counts = list(c.values())[::-1]

if len(counts)==1:
  print(0)
else:
  value = 0
  for num in enumerate(arr):
    value += len([1 for x in arr if x<num])
  out_arr = value*K*(K-1)//2
  
  in_arr = 0
  for j,num in enumerate(arr):
    in_arr += len([1 for x in arr[j+1:] if x<num])
  in_arr = in_arr*K
  print((out_arr+in_arr)%1000000007)
  
  

### FIXED CODE ###

import collections

N,K = map(int, input().split())
arr = list(map(int, input().split()))
c = collections.Counter(arr)

counts = list(c.values())[::-1]

if len(counts)==1:
  print(0)
else:
  value = 0
  for num in arr:
    value += len([1 for x in arr if x<num])
  out_arr = value*K*(K-1)//2
  
  in_arr = 0
  for j,num in enumerate(arr):
    in_arr += len([1 for x in arr[j+1:] if x<num])
  in_arr = in_arr*K
  print((out_arr+in_arr)%1000000007)
8
27 23 76 2 3 5 62 52

### FIXED CODE ###

N = int(input())
W = [int(s) for s in input().split()]
ans = float("inf")
for i in range(1, N):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)
from math import factorial

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


x_dist=[x[i+1]-x[i] for i in range(N-1)]

def Cn(n,Cn_1):
    return n*Cn_1+1

ans=0
Cn_list=[1]

for n in range(2,N):
    temp=Cn(n,Cn_list[n-2])
    Cn_list.append(temp)

for i in range(N-1):
    ans+=Cn_list[i]*x_dist[i]*factorial(N-1)/(i+1)

print((ans)%MOD)

### FIXED CODE ###

MOD = 10 ** 9 + 7
N = int(input())
x = list(map(int, input().split()))
x.sort()
 
kaijo = [1]
for i in range(1, N):
    kaijo.append(kaijo[-1] * i % MOD)
 
ans = 0
for i in range(N - 1):
    ans = (ans * (i + 1) + (x[-1] - x[i]) * kaijo[i]) % MOD
 
print(ans)
a, b = map(str, raw_input().split())

print a*b, (a+b)*2

### FIXED CODE ###

a, b = [int(x) for x in raw_input().split()]
 
print a*b,(a+b)*2
a,b=map(int, input().split( ))
if a<=5:
  print 0
elif a<12:
  print b/2
else:
  print b


### FIXED CODE ###

a,b=(int(i) for i in input().split())
if a<=5:
  print(0)
elif 5<a<=12:
  print(b//2)
else:
  print(b)
N,C=map(int,input().split())
Time=[[0]*(10**5+1) for c in range(C)]
for i in range(N):
  s,t,c=map(int,input().split())  
  Time[c-1][s-1:t] = [1]*(t-s+1)
Times=max(map(sum,zip(*Time)))
print(Times)

### FIXED CODE ###

N,A,B=map(int,input().split())
print(min(A*N,B))
n,w=map(int,input().split())
goods=[list(map(int,input().split())) for _ in range(n)]
DP=[[0]*(w+1) for _ in range(n+1)]
for i in list(range(n))[::-1]:
  wi,vi=goods[i][0],goods[i][1]
  for j in range(w+1):
    if j<wi:
      DP[i][j]=DP[i+1][j]
    else:
      DP[i][j]=max(DP[i+1][j],DP[i+1][j-wi]+vi)
print(DP[0][w])

### FIXED CODE ###

n=int(input())
h=[10**6]+list(map(int,input().split()))
c=[0]*(n+1)
for i in range(2,n+1):
  a=c[i-1]+abs(h[i]-h[i-1])
  b=c[i-2]+abs(h[i]-h[i-2])
  c[i]=min(a,b)
print(c[n])