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

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

ans = []
for i in range(n):
    if i % 2 == 0:
        ans.append(str(a[i]))
    else:
        ans.insert(0, str(a[i]))

if n % 2 == 1:
    ans.reverse()

ans = ' '.join(ans)
print(ans)

### FIXED CODE ###

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

if n % 2 == 0:
    for i in reversed(range(n)):
        if i % 2 == 1:
            print(a[i], end=" ")
    for i in range(n):
        if i % 2 == 0:
            print(a[i], end=" ")
else:
    for i in reversed(range(n)):
        if i % 2 == 0:
            print(a[i], end=" ")
    for i in range(n):
        if i % 2 == 1:
            print(a[i], end=" ")
### BUGGY CODE ###

N = int(input())
for a in range(1, 3501):
    for b in range(1, 3501):
        c1 = a * b * N
        c2 = 4 * a * b - b * N - a * N
        if c2 > 0 and c1/c2 == c1//2:
            print(a,b,c1//c2)
            exit()

### FIXED CODE ###

N = int(input())
for a in range(1, 3501):
    for b in range(a+1, 3501):
        c2 = 4 * a * b - b * N - a * N
        if c2 <= 0:continue
        c1 = a * b * N
        if c1/c2 == c1//c2:
            print(a,b,c1//c2)
            exit()
### BUGGY CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
lst=[1]*n
for i in range(n):
  if i<k-1:
    lst[i]=A[i]
  elif i==k-1:
    temp=1
    for j in range(k):
      temp*=A[j]
    lst[i]=temp
  else:
    temp=lst[i-1]//A[i-k]
    lst[i]=temp*A[i]
    print("Yes" if lst[i]>lst[i-1] else "No")

### FIXED CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(1, n-k+1):
    print("Yes" if A[i+k-1]>A[i-1] else "No")
### BUGGY CODE ###

# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

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

if n == 1:
    print(1)
    exit()

MOD = 10 ** 9 + 7

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

c = p[0]
for x in p[1:]:
    c = c * x // gcd(c, x)

ans = 0
for x in p:
    ans = (ans + c // x) % MOD

print(ans)


### FIXED CODE ###

# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

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

if n == 1:
    print(1)
    exit()

MOD = 10 ** 9 + 7

MAX = max(p) + 1

inv = [0]+[1]
for i in range(2,MAX + 1):
    inv += [inv[MOD % i] * (MOD - MOD // i) % MOD]

prime = [0 for i in range(MAX)]

max_map = dict()


# function to return a^n
def power(a, n):
    if n == 0:
        return 1
    p = power(a, n // 2) % MOD
    p = (p * p) % MOD

    if n & 1:
        p = (p * a) % MOD
    return p


# function to find the smallest prime
# factors of numbers upto MAX
def sieve():
    prime[0], prime[1] = 1, 1
    for i in range(2, MAX):
        if prime[i] == 0:
            for j in range(i * 2, MAX, i):
                if prime[j] == 0:
                    prime[j] = i
            prime[i] = i

        # function to return the LCM MODulo M


def lcmModuloM(arr, n):
    for i in range(n):
        num = arr[i]

        temp = dict()

        # temp stores mapping of prime factors
        # to its power for the current element
        while num > 1:

            # factor is the smallest prime
            # factor of num
            factor = prime[num]

            # Increase count of factor in temp
            if factor in temp.keys():
                temp[factor] += 1
            else:
                temp[factor] = 1

            # Reduce num by its prime factor
            num = num // factor

        for i in temp:
            # store the higest power of every prime
            # found till now in a new map max_map
            if i in max_map.keys():
                max_map[i] = max(max_map[i], temp[i])
            else:
                max_map[i] = temp[i]

    ans = 1

    for i in max_map:
        # LCM is product of primes to their
        # higest powers MODulo M
        ans = (ans * power(i, max_map[i])) % MOD
    return ans

sieve()
c = lcmModuloM(p, n)

ans = 0
for x in p:
    ans = (ans + c * inv[x]) % MOD

print(ans)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=0
MOD=10**9+7
for i in l:
    for j in l:
        ans+=i^j
print(ans//2%MOD)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l=[format(i,"b").zfill(61) for i in l]
ans=0
MOD=10**9+7
la=[0 for i in range(61)]
for i in l:
    for num,j in enumerate(str(i)):
        if j=="1":
            la[60-num]+=1
for num,i in enumerate(la):
    ans+=2**num*i*(n-i)
    ans%=MOD
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**5+10)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
memo = {}
def Fib(n, A, MOD):
    if n in A:
        return 0
    elif n == 0:
        return 1
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, MOD) + Fib(n-2, A, MOD) ) % MOD
        return memo[n]
print(Fib(N, A, MOD))

### FIXED CODE ###

from collections import deque
def C():
    N, M = map(int, input().split())
    A = set([int(input()) for _ in range(M)])
    dp = deque([1, 1 if 1 not in A else 0])
    MOD = 1000000007
    for i in range(2,N+1):
        #print(i, dp)
        if i in A:
            dp.append(0)
        else:
            dp.append((dp[0]+dp[1]) % MOD)
        dp.popleft()
    print(dp[-1])

C()
### BUGGY CODE ###

N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

def num_cut(x):
  if x==0:
    return False
  
  ret=0
  for a in alist:
    ret+=-(-(a-x)//x)
  return ret

#for i in range(1,max(alist)):
#  print(i,num_cut(i))

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  
  if num_cut(mid-1)>K and num_cut(mid)<=K:
    print(mid)
    break
  elif num_cut(mid)<=K:
    r=mid
  else:
    l=mid

### FIXED CODE ###

N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

def num_cut(x):
  if x==0:
    return float("inf")
  
  ret=0
  for a in alist:
    ret+=-(-(a-x)//x)
  return ret

#for i in range(1,max(alist)):
#  print(i,num_cut(i))

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  
  if num_cut(mid-1)>K and num_cut(mid)<=K:
    print(mid)
    break
  elif num_cut(mid)<=K:
    r=mid
  else:
    l=mid
### BUGGY CODE ###

nm = lambda : map(int,input().split())
nl = lambda : list(nm())
import heapq as h

n,m,l = nm()
g = [list() for _ in range(n+1)]
ans = [0]
for _ in range(m):
    a,b,c = nm()
    g[a].append((b,c))
    g[b].append((a,c))
q = int(input())

def move(tup,cost):
    if tup[1] + cost > 0:
        if l < cost:
            return -1
        return (tup[0]+1,cost-l)
    return (tup[0],tup[1]+cost)

for st in range(1,n+1):
    dist = [-1]*(n+1)
    que = [((0,-l),st)]
    while que:
        tup,v = h.heappop(que)
        if dist[v] != -1 and dist[v] < tup:
            continue
        dist[v] = tup
        for x,c in g[v]:
            new = move(tup,c)
            if new != -1 and dist[x] == -1:
                h.heappush(que,(new,x))
    ans.append(dist)

for _ in range(q):
    s,t = nm()
    if ans[s][t] == -1:
        print(-1)
    else:
        print(ans[s][t][0])

### FIXED CODE ###

n,m,l = map(int,input().split())
g = [[1<<30]*n for _ in range(n)]
for _ in range(m):
  a,b,c = map(int,input().split())
  g[a-1][b-1] = c
  g[b-1][a-1] = c
for i in range(n):
  g[i][i] = 0

def bell(g,n):
  for k in range(n):
    for i in range(n-1):
      for j in range(i+1,n):
        if g[i][j] > g[i][k] + g[k][j]:
          g[i][j] = g[i][k] + g[k][j]
          g[j][i] = g[i][j]
  return g

g = bell(g,n)
for i in range(n):
  for j in range(n):
    if i == j:
      g[i][j] = 0
    elif g[i][j] <= l:
      g[i][j] = 1
    else:
      g[i][j] = 1<<30
g = bell(g,n)

q = int(input())
for _ in range(q):
  s,t = map(int,input().split())
  if g[s-1][t-1]>>30:
    print(-1)
  else:
    print(g[s-1][t-1]-1)
### BUGGY CODE ###

#!/usr/bin/env python3

import numpy as np
from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = int(input())
    A = LII()
    A.sort()
    C = Counter(A)
    ans = 0
    while len(A) != 0:
        a = A[0]
        A = list(filter(lambda x: x % a != 0, A))
        if C[a] == 1:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys
import numpy as np
from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))


def main():
    N = int(input())
    A = LII()
    A.sort() 
    
    if N == 1:
        print(1)
        return

    ax = max(A) + 1
    dp = [0] * ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2

    print(sum(filter(lambda x: x == 1, dp)))


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

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

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))
    return diffList.index(min(diffList)) + 1

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )


### FIXED CODE ###

n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
ikeruheya = [[] for i in range(n)]
ans = [0]*(n+1)

ans[0]=-1
ans[1]=1
for i in range(m):
    ikeruheya[a[i][0]-1].append(a[i][1])
    ikeruheya[a[i][1]-1].append(a[i][0])

    
next=[1]
count = 1
while count <= n and len(next)!=0:
    
    imaheya = next.pop(0)
    j = 0
    while j < len(ikeruheya[imaheya-1]) and count <= n:
    
        if ans[ikeruheya[imaheya-1][j]]==0:
            ans[ikeruheya[imaheya-1][j]]= imaheya             
            next.append(ikeruheya[imaheya-1][j])
            count += 1
            j+=1
        else:
            j+=1

print("Yes")
for i in range(2, n+1):
    print(ans[i])



    
    


### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
a=[list(map(int, input().split())) for i in range(m)]
b=[[] for j in range(n)] 

michi=[-1]*(n)
michi[0]=0
heya=[]


for i in range(m):
    b[a[i][0]-1].append(a[i][1])
    b[a[i][1]-1].append(a[i][0])



heya.append(1)


while len(heya):
    now=heya.pop(0)-1
    
    for i in range(len(b[now])):
        if michi[b[now][i]-1] == -1:
            heya.append(b[now][i])
            michi[b[now][i]-1] = now+1
print("Yes")
for i in range(1,n):
    print(michi[i])
### BUGGY CODE ###

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

l = list(map(lambda x: x * (x+1) * 1/2 * 1/x, p))

ans = [0] * (n-k+1)
for i in range(n-k+1):
    ans[i] = sum(l[i:i+k])

print(max(ans))

### FIXED CODE ###

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

p = list(map(lambda x: x * (x+1) /2 /x, p))

for i in range(1, n):
    p[i] = p[i-1] + p[i]

m = p[k-1]
for i in range(k, n):
    a = p[i] - p[i-k]
    if m < a:
        m = a

print(m)
### BUGGY CODE ###

from itertools import chain


def solve(string):
    n, m, k, *abcd = map(int, string.split())
    ab, cd = abcd[:2 * m], abcd[2 * m:]
    fr, br = [[] for _ in range(n + 1)], [[] for _ in range(n + 1)]
    for a, b in zip(*[iter(ab)] * 2):
        fr[a].append(b)
        fr[b].append(a)
    for c, d in zip(*[iter(cd)] * 2):
        br[c].append(d)
        br[d].append(c)

    g = [-1] * (n + 1)
    s = 0
    while s < n:
        s += 1
        if g[s] >= 0:
            continue
        t, tt = set([s]), set(fr[s])
        while tt and t != tt:
            t = t.union(tt)
            tt = tt.union(set(chain.from_iterable(fr[i] for i in tt)))
        for _t in t:
            g[_t] = len(t - set([_t]) - set(fr[_t]) - set(br[_t]))
    return " ".join(map(str, g[1:]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

class UnionFind:

    def __init__(self, n):
        self.t = [-1] * (n + 1)

    def flatten(self):
        for i, _ in enumerate(self.t):
            self.find_root(i)

    def union(self, a, b):
        ra = self.find_root(a)
        rb = self.find_root(b)
        if ra != rb:
            self.t[max(ra, rb)] = min(ra, rb)

    def find_root(self, x):
        t = []
        while self.t[x] > 0:
            t.append(x)
            x = self.t[x]
        for _t in t:
            self.t[_t] = x
        return x


def solve(string):
    n, m, k, *abcd = map(int, string.split())
    ab, cd = abcd[:2 * m], abcd[2 * m:]
    fr, br = [[] for _ in range(n + 1)], [[] for _ in range(n + 1)]
    uf = UnionFind(n)
    for a, b in zip(*[iter(ab)] * 2):
        fr[a].append(b)
        fr[b].append(a)
        uf.union(a, b)
    uf.flatten()
    for i, v in enumerate(uf.t):
        if v < 0:
            uf.t[i] = i
    mp = {k: i for i, k in enumerate(set(uf.t[1:]))}
    g = [[] for _ in enumerate(mp.keys())]
    for i in range(n + 1):
        if uf.t[i] > 0:
            g[mp[uf.t[i]]].append(i)
    for c, d in zip(*[iter(cd)] * 2):
        br[c].append(d)
        br[d].append(c)

    *fr, = map(len, fr)
    *g, = map(set, g)
    *gn, = map(len, g)
    return " ".join([
        str(gn[mp[uf.t[i]]] - 1 - fr[i] - sum(j in g[mp[uf.t[i]]]
                                              for j in br[i]))
        for i in range(1, n + 1)
    ])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
### BUGGY CODE ###

n, a = map(int, input().split())
X = list(map(int, input().split()))
dp = [ [[0]*(n*a+1) for j in range(i+1)] for i in range(n+1) ]
for i in range(n+1):
  dp[i][0][0] = 1
for i in range(n):
  for j in range(i+1):
    for k in range(n*a+1):
      if X[i] > k:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k]
      else:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k] + dp[i][j][k-X[i]]
        else:
          dp[i+1][j+1][k] = dp[i][j][k-X[i]]
ans = 0
for i in range(1, n+1):
  ans += dp[n][i][a*i]
print(ans)

### FIXED CODE ###

n, a = map(int, input().split())
X = list(map(int, input().split()))
dp = [ [[0]*(n*a+1) for j in range(i+1)] for i in range(n+1) ]
for i in range(n+1):
  dp[i][0][0] = 1
for i in range(n):
  for j in range(i+1):
    for k in range(n*a+1):
      if X[i] > k:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k]
      else:
        if i > j:
          dp[i+1][j+1][k] = dp[i][j+1][k] + dp[i][j][k-X[i]]
        else:
          dp[i+1][j+1][k] = dp[i][j][k-X[i]]
ans = 0
for i in range(1, n+1):
  ans += dp[n][i][a*i]
print(ans)
### BUGGY CODE ###

import copy, itertools

N, M, R = map(int, input().split())
r = [x-1 for x in list(map(int, input().split()))]

way_cost = [[float('inf')]*N for _ in range(N)]

for idx in range(N):
    way_cost[idx][idx] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    way_cost[a-1][b-1] = c
    way_cost[b-1][a-1] = c

# ワーシャルフロイド法で全ての街同士の最短距離を求める
shortest_path_cost = copy.deepcopy(way_cost)
for between_point in range(N):
    for start_point in range(N):
        for end_point in range(N):
            shortest_path_cost[start_point][end_point] \
            = min(shortest_path_cost[start_point][end_point], \
            shortest_path_cost[start_point][between_point]+shortest_path_cost[between_point][end_point])

# 巡回ルートを総当りで調べ、最小コストを出力する
route_list = list(itertools.permutations(r))

for route in route_list:
    route_list.remove(route[::-1])

ans = float('inf')
for route in route_list:
    cost = 0
    for idx in range(R-1):
        cost += shortest_path_cost[route[idx]][route[idx+1]]
    ans = min(ans,cost)

print(ans)

### FIXED CODE ###

import copy, itertools
from scipy.sparse.csgraph import floyd_warshall

N, M, R = map(int, input().split())
r = [x-1 for x in list(map(int, input().split()))]

way_cost = [[float('inf')]*N for _ in range(N)]

for idx in range(N):
    way_cost[idx][idx] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    way_cost[a-1][b-1] = c
    way_cost[b-1][a-1] = c

# ワーシャルフロイド法で全ての街同士の最短距離を求める
shortest_path_cost = floyd_warshall(csgraph=way_cost, directed=False)

# 巡回ルートを総当りで調べ、最小コストを出力する
route_list = list(itertools.permutations(r))

ans = float('inf')
for route in route_list:
    cost = 0
    for idx in range(R-1):
        cost += shortest_path_cost[route[idx]][route[idx+1]]
    ans = min(ans,cost)

print(int(ans))
### BUGGY CODE ###

from sys import stdin
from sys import  setrecursionlimit
setrecursionlimit(30000)

[H, N] = [int(x) for x in stdin.readline().rstrip().split()]
As = []
Bs = []

for i in range(N):
    [a, b] = [int(x) for x in stdin.readline().rstrip().split()]
    As.append(a)
    Bs.append(b)


map_list = []
for i in range(10001):
    map_list.append(-1)


def DP(h):
    if h<=0:
        return 0
    if map_list[h]>=0:
        return map_list[h]
    
    temp_array = []
    for i in range(N):
        temp_array.append(DP(h-As[i])+Bs[i])
    map_list[h] = min(temp_array)
    

    return map_list[h]

print(DP(H))    



### FIXED CODE ###

from sys import stdin
from sys import  setrecursionlimit
setrecursionlimit(10000)

[H, N] = [int(x) for x in stdin.readline().rstrip().split()]
As = []
Bs=[]
for i in range(N):
    [A, B] = [int(x) for x in stdin.readline().rstrip().split()]
    As.append(A)
    Bs.append(B)

INF = 10**10
dp_map = [[INF]*(H+1) for _ in range(N+1)]

#dp_map[i][j]: i番目の魔法までを使って、最低でもjのダメージを与える時に必要なMP
dp_map[0][0]  = 0
for i in range(N):
    for j in range(H+1):
        if j<As[i]:
            dp_map[i+1][j] = min(dp_map[i+1][0]+Bs[i],dp_map[i][j])
        else:
            dp_map[i+1][j] = min(dp_map[i+1][j-As[i]]+Bs[i] ,dp_map[i][j])

print(dp_map[N][H])
### BUGGY CODE ###

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

dp = [0]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n):
    cands = [dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)]
    dp[i] = min(cands)

print(dp[n-1])

### FIXED CODE ###

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

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n): 
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)])

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

n = int(input())
a = list(map(int,input().split()))
co = a.copy()
co = sorted(co)
for i in co:
    print(a.index(i)+1,end= " ")

### FIXED CODE ###

n = int(input())
a = []
li = [0] * n
a = list(map(int,input().split()))
for i in range(n):
    li[a[i]-1] = i+1
for i in range(n):
    print(li[i], end = " ")
### BUGGY CODE ###

N,M= list(map(int, input().split()))
li=[list(map(int,input().split())) for _ in range(M)]
lisorted=sorted(li)
div=[0 for _ in range(N)]
memo=0
check=0
for i in range(M):
    if memo!=lisorted[i][0]:
        div[lisorted[i][0]-1]=check
        memo=lisorted[i][0]
        check+=1
    else:
        check+=1
for i in li:
    print("{0:06d}".format(i[0]),end="")
    tmp=lisorted.index(i)-div[i[0]-1]+1
    print("{0:06d}".format(tmp))

### FIXED CODE ###

N,M= list(map(int, input().split()))
li=[list(map(int,input().split())) for _ in range(M)]
lisorted=sorted(li)
dic={}
memo=0
for i in lisorted:
    if memo!=i[0]:
        check=1
        dic[i[1]]="{0:06d}".format(i[0])+"{0:06d}".format(check)
        memo=i[0]
    else:
        check+=1
        dic[i[1]]="{0:06d}".format(i[0])+"{0:06d}".format(check)
for i in li:
    print(dic[i[1]])
### BUGGY CODE ###

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def Prim(N):
    P = []
    M = int(N ** 0.5) + 1
    F = [False, False] + [True] * M
    for n in range(2, M):
        if not F[n]:
            continue
        P.append(n)
        for i in range(n, len(F), n):
            F[i] = False
    
    return P
 

def ps(a, P, K):
    d = {}
    for p in P:
        c = 0
        while a % p == 0:
            c += 1
            a //= p
        d[p] = c

        if a == 1:
            break
    
    if a != 1:
        d[a] = 1
        K.add(a)
    return d


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    P = Prim(max(A))
    K = set()

    DA = [ps(a, P, K) for a in A]
    P.extend(list(K))

    D = {}
    res = 0
    for d in DA:
        b = 1
        for i in P:
            v = d.setdefault(i, 0)
            r = D.setdefault(i, 0)
            if v > r:
                D[i] = v
                res = res * (i ** (v - r)) % mod
            else:
                b = b * (i ** (r - v)) % mod
        
        res = (res + b) % mod

    print(res)


if __name__ == "__main__":
    main()



### FIXED CODE ###

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


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

n,k,q=map(int,input().split())
x=[]
for i in range (q):
    a=int(input())
    x.append(a)

for i in range (1,n+1,1):
    if  k - q + int(x.count(i))>0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

n,k,q=map(int,input().split())
p=k-q
l=[p]*n
for i in range(q):
    a=int(input())
    l[a-1]+=1
for i in range(n):
    print('Yes' if l[i]>0 else 'No')
### BUGGY CODE ###

# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    S = input().rstrip()

    N = len(S)

    M = [0 for i in range(2019)]
    M[0] += 1

    T = 0
    r = 1
    for i in range(N):
        T = int(S[N-i-1]) * r + T
        T = T % 2019
        M[T] += 1
        r *= 10

    res = 0

    for m in M:
        res += m * (m-1) // 2


    print(res)



main()


### FIXED CODE ###

import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
from numba import njit, i8


# @njit(i8[:](i8,i8,i8[:]))
@njit
def loof(a,N):
    M = np.zeros(2019,dtype=np.int16)
    M[0] += 1
    T = 0
    r = 1
    T += a[-1] * r
    T %= 2019
    M[T] += 1
    for i in range(N-2,-1,-1):
        r *= 10
        r %= 2019
        T += a[i] * r
        T %= 2019
        M[T] += 1
    return M


# @njit
# def pow_mod(a,n,mod):
#     memo = np.array([1])
#     if n >= 1:
#         for i in range(n-1):
#             memo = np.append(memo,memo[-1]*a%mod)
#         return memo
#     else:
#         return memo[0]


def main():
    S = input().rstrip()
    S = list(map(int,list(S)))
    a = np.array(S)

    N = len(a)

    # memo = pow_mod(10,N,2019)
    M = loof(a,N)

    res = 0

    for m in M:
        res += m * (m-1) // 2

    print(res)


main()
### BUGGY CODE ###

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

for i in range(n):
    print(a.count(i+1))


### FIXED CODE ###

import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.Counter(a)
for i in range(n):
    print(b[i+1])