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

N = int(input())
list_S = [input() for i in range(N)]
list_S.sort()
list_a = []
a = 0
for i in range(N-1):
    if list_S[i] == list_S[i+1]:
        a += 1
    else:
        list_a.append(a+1)
        a = 0
list_a.append(a+1)
newlist_a = sorted(list_a,reverse=True)
n = newlist_a.count(newlist_a[0])
ans = ""
if n == 1:
    t = 0
    for i in range(list_a.index(newlist_a[0])):
        t += list_a[i]
    if N == 1:
        ans = list_S[t]
    else:
        ans = list_S[t+1]
else:
    if newlist_a[0]==1:
        for i in range(len(list_S)):
            ans += list_S[i]
            ans += "\n"
    else:            
        list_t = []
        b = 0
        for i,x in enumerate(list_a):
            if x == newlist_a[0]:
                list_t.append(sum(list_a[0:i]))
                ans += list_S[list_t[b]]
                ans += "\n"
                b += 1
print(ans)

### FIXED CODE ###

import collections

N = int(input())
S = [input() for i in range(N)]
c =collections.Counter(S)
C = c.most_common()
list_C = []
for i in range(len(c)):
    list_C.append(C[i][1])
m = 1
for i in range(len(list_C)-1):
    if list_C[i]==list_C[i+1]:
        m += 1
    else:
        break
ans= []
for i in range(m):
    ans.append(C[i][0])
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
    
edges = ABC[:]

def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)] for i in range(N+1)] 
for x,y,z in edges:
    graph[x][y] = z
    graph[y][x] = z
for i in range(N+1):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N+1)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import queue

rest = set(R_LIST[:])

import copy  
def dfs(cost,pre,rest):
    if len(rest) == 0:
        return cost
    
    ret = INT_MAX
    for r in rest:
        if pre == None:
            next_cost = 0
        else:
            next_cost = cost + shortest[pre][r]
        
        if next_cost >= ret:
            continue
            
        next_rest = copy.copy(rest)
        next_rest.remove(r)
        
        tmp_ret = dfs(next_cost, r, next_rest)
        ret = min(ret, tmp_ret)
        
    return ret
        
    

print(dfs(0, None, rest))
            
      
        
        



### FIXED CODE ###

N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
    
    
edges = ABC[:]


def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)] for i in range(N+1)] 
for x,y,z in edges:
    graph[x][y] = z
    graph[y][x] = z
for i in range(N+1):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N+1)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import queue

rest = set(R_LIST[:])

import copy  
def dfs(cost,pre,rest):
    if len(rest) == 0:
        return cost
    
    ret = INT_MAX
    for r in rest:
        if pre == None:
            next_cost = 0
        else:
            next_cost = cost + shortest[pre][r]
        next_rest = copy.copy(rest)
        next_rest.remove(r)
        
        tmp_ret = dfs(next_cost, r, next_rest)
        ret = min(ret, tmp_ret)
        
    return ret
        
    

print(dfs(0, None, rest))
### BUGGY CODE ###

import sys
import copy

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

def main():
    N,K = LI()[:]
    A = LI()
    #print(N,K)
    #print(A)

    for _ in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            #print(i, a)
            if a == 0:
                B[i] += 1
            else:
                # i-(a+0.5) ~ i+(a+0.5)
                # i: 整数、a: ＋整数　なので +0.5 は切り捨てられる。
                #　影響範囲は、 i-a ~ i+a
                for p in range(i-a,i+a+1):
                    #print("p:",p)
                    if p >=0 and p < N:
                        B[p] += 1
                #print(B)
        A = B

    print(" ".join(map(str,A)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import numpy as np
from numba import njit
 
readline = sys.stdin.readline
 
@njit('i8,i8,i8[::1]',cache=True)
def loop(n,k,a):
    for j in range(k):
        b = np.zeros(n+1, dtype=np.int64)
        for i in range(n):
            b[max(i-a[i], 0)] += 1
            b[min(i+a[i]+1, n)] -= 1
        a = np.cumsum(b)[:-1]
        if np.all(a==n):
            return(a)
            break
    else:
        return(a)
 
 
n, k = map(int, readline().split())
a = np.array(readline().split(), dtype=np.int64)
 
ans = loop(n,k,a)
print(*ans)
### BUGGY CODE ###

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            for z in range(k+1):
                if x+y+z == s:
                    ans += 1
    print(ans)


if __name__=="__main__":
    main()


### FIXED CODE ###

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k,s = i_map()
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s-x-y
            if 0<=z <=k:
                ans += 1
    print(ans)

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

import itertools
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
for i in range(n-1):
  ans = (ans+(a[i]*sum(a[i+1:])%MOD))%MOD
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
t = sum(a)
MOD = 10**9+7
ans = 0
for i in range(n-1):
  t -= a[i]
  ans = (ans+(a[i]*t%MOD))%MOD
print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

f = [1 if s[i:i+2] == "AC" else 0 for i in range(n-1)]

for l, r in lr:
    print(sum(f[l-1:r-1]))

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

f = [0]*(n)
x = 0
for i in range(n):
    f[i] = x
    if s[i:i+2] == "AC":
        x += 1
        
for l, r in lr:
    print(f[r-1] - f[l-1])
### BUGGY CODE ###

S=str(input())
n=len(S)
mod=2019
ans=0
box=[0 for i in range(n)]
T=[0 for i in range(n)]
T[-1]=int(S[-1])
box[-1]=1
for i in range(n-2,-1,-1):
    box[i]=box[i+1]*10%mod
    a=int(S[i])*box[i]+T[i+1]
    k=a%mod
    T[i]=k
T.append(0)
for i in range(mod):
    if i in T:
        m=T.count(i)
        ans+=m*(m-1)//2
print(ans)


### FIXED CODE ###

S=str(input())
n=len(S)
mod=2019
ans=0
mod_set=[0]*mod
mod_set[0]+=1
ten=1
k=0
for i in range(n-1,-1,-1):
    k=(k+ten*int(S[i]))%mod
    mod_set[k]+=1
    ten=(ten*10)%mod

for i in mod_set:
    ans+=i*(i-1)//2
print(ans)
### BUGGY CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

### FIXED CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
dic=collections.Counter(a)
for i in range(1,n+1):
    if i in dic.keys():
        print(dic[i])
    else:
        print(0)
### BUGGY CODE ###

N=int(input())
P=list(map(float,input().split()))

NOW=[1]

for i in range(N):
    NEXT=[0]*(i+2)

    for j in range(i+1):
        NEXT[j]+=NOW[j]*(1-P[i])
        NEXT[j+1]+=NOW[j]*P[i]

    NOW=NEXT
    #print(NOW)

print(sum(NOW[1+N//2:]))

### FIXED CODE ###

N=int(input())
P=list(map(float,input().split()))

NOW=[1]

for i in range(N):
    NEXT=[0]*(i+2)

    for j in range(i+1):
        NEXT[j]+=NOW[j]*(1-P[i])
        NEXT[j+1]+=NOW[j]*P[i]

    NOW=NEXT
    #print(NOW)

print(sum(NOW[1+N//2:]))
### BUGGY CODE ###

import numpy as np
n, k, q = map(int, input().split())
point = np.array([k for _ in range(n)])
for _ in range(q):
    a = int(input())
    point -= 1
    point[a-1] += 1
for i in range(n):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

n, k, q = map(int, input().split())
def judge():
    val = {}
    for _ in range(q):
        a = int(input())
        val[a-1] = val.get(a-1,0) + 1
    #print(val)
    for i in range(n):
        if val.get(i,k-q) + (k - q) > 0:
            print('Yes')
        else:
            print('No')
if k > q:
    print(*['Yes' for _ in range(n)])
else:
    ans = judge()
### BUGGY CODE ###

MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
X = [0]*60
sumA = 0
for i in A:
    for j in range(60):
        if i >> j & 1 == 1:
            X[j] += 1
    sumA += i
ans = 0
for i in range(N):
    sumA -= A[i]
    ans += sumA
    for j in range(60):
        if A[i] >> j & 1 == 1:
            X[j] -= 1
            ans += ((2**j) * (N-i-1-X[j]*2))%MOD
    ans %= MOD

print(ans)

### FIXED CODE ###

MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
X = [0]*60
sumA = 0
for i in A:
    for j in range(60):
        if i >> j & 1 == 1:
            X[j] += 1
    sumA += i
ans = 0
for i in range(N):
    sumA -= A[i]
    ans += sumA
    for j in range(60):
        if A[i] >> j & 1 == 1:
            X[j] -= 1
            ans += ((2**j) * (N-i-1-X[j]*2))%MOD
    ans %= MOD

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

import numpy as np

a,b,q=map(int,input().split())

ST=[]
for i in range(a):
    k=int(input())
    ST.append([k,0,0])
for i in range(b):
    k=int(input())
    ST.append([k,1,0])

ST.sort()
for i in range(a+b):
    ty=ST[i][1]
    le=i-1
    ri=i+1
    moyori=np.inf
    while le>=0 and ST[le][1]==ty :
        le-=1
    if le>=0:
        moyori=min(moyori,abs(ST[i][0]-ST[le][0]))
    while ri<=a+b-1 and ST[ri][1]==ty :
        ri+=1
    if ri<=a+b-1:
        moyori=min(moyori,abs(ST[i][0]-ST[ri][0]))
    ST[i][2]=moyori

for i in range(q):
    k=int(input())
    ST.append([k,2,0,i])

ST.sort()

ANS=[]
for i in range(a+b+q):
    if ST[i][1]==2 :
        moyori=np.inf
        for typ in range(2):
            le=i-1
            ri=i+1
            
            while le>=0 and (ST[le][1]==typ or ST[le][1]==2) :
                le-=1
            if le>=0:
                moyori=min(moyori,abs(ST[i][0]-ST[le][0])+ST[le][2])
                #print("L")
                #print(moyori)
            while ri<=a+b+q-1 and (ST[ri][1]==typ or ST[ri][1]==2):
                ri+=1
            if ri<=a+b+q-1 :
                moyori=min(moyori,abs(ST[i][0]-ST[ri][0])+ST[ri][2])
                #print("R")
                #print(moyori)
        ST[i][2]=moyori
        ANS.append([ST[i][3],moyori])

ANS.sort()

#print(ST)

for i in range(q):
    print(ANS[i][1])


### FIXED CODE ###

import bisect as bi

a,b,q=map(int,input().split())

INF=10**15

S=[-INF]+[int(input()) for i in range(a)]+[INF]
T=[-INF]+[int(input()) for i in range(b)]+[INF]
X=[int(input()) for i in range(q)]

for i in range(q):
    d=bi.bisect_right(S,X[i])
    e=bi.bisect_right(T,X[i])
    as0=abs(X[i]-S[d-1])
    as1=abs(X[i]-S[d])
    at0=abs(X[i]-T[e-1])
    at1=abs(X[i]-T[e])
    ans=min(max(as0,at0),max(as1,at1),2*as0+at1,as0+2*at1,2*at0+as1,at0+as1*2)
    print(ans)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
ans = 0
def find(x, arr):
  a = len(arr)//2
  cur = a
  while True:
    a //= 2
    if arr[cur] < x:
      if cur == len(arr)-1:
        return cur+1
      elif arr[cur+1] >=x:
        return cur+1
      else:
        cur += max(1, a)
    else:
      if cur == 0:
        return 0
      else:
        cur -= max(1, a)
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += find(L[i] + L[j], L[j+1:])
print(ans)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
ans = 0
def find(x, arr):
  a = len(arr)//2
  cur = a
  while True:
    a //= 2
    if arr[cur] < x:
      if cur == len(arr)-1:
        return cur+1
      elif arr[cur+1] >=x:
        return cur+1
      else:
        cur += max(1,a)
    else:
      if cur == 0:
        return 0
      else:
        cur -= max(1, a)
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += find(L[i] + L[j], L)-j-1
print(ans)
### BUGGY CODE ###

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
from collections import deque
def main():
    s = input()
    n = len(s)

    amari = [0] * n
    ketaamari = 1
    for i1 in range(n):
        t = (ketaamari * int(s[-i1 -1])) % 2019
        amari[-i1-1] = t
        ketaamari = (ketaamari * 10) % 2019
    amaria = tuple(accumulate(amari))
    r = 0
    minus = 0
    for j1 in range(n):
        r += sum([(ae - minus) % 2019 == 0 for ae in amaria[j1:]])
        minus = amaria[j1]
    print(r)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
    s = input()
    n = len(s)

    amari = [0] * n
    ketaamari = 1
    t = 0
    for i1 in range(n):
        t = (t + ketaamari * int(s[-i1 -1])) % 2019
        amari[-i1-1] = t
        ketaamari = (ketaamari * 10) % 2019
    amari.append(0)
    ac = Counter(amari)
    r = 0
    for v in ac.values():
        r += v * (v - 1) // 2
    print(r)

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

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

def cf(x1,x2):
  cf=[]
  for i in range(1,min(x1,x2)+1):
    if x1 % i == 0 and x2 % i == 0:
      cf.append(i)
  return cf

def using_sqrt(limit):
    n = 0
    for k in range(2, limit+1):
        factor = 0
        
        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue
        
        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
                
        if factor == 0:
            n += 1
            
    return n

l = cf(A, B)

cnt = 0
for i in range(len(l)):
  if using_sqrt(l[i]) <= 2:
    cnt += 1
  else:
    break

print(cnt)

### FIXED CODE ###

from fractions import gcd

def prime_factorize(n):
  factor = []
  for i in range(2, int(n**0.5)+1):
    while n % i == 0:
      n //= i
      factor.append(i)
  if n != 1:
    factor.append(n)
  return factor

A, B = map(int, input().split())
N = gcd(A, B)
l = set(prime_factorize(N))
print(len(l)+1)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
d = dict()
for i in range(n):
  d[a[i]] = i
b = [0]*n
tot = 0
for i in range(n,0,-1):
  b[d[i]] = n
  l,r = d[i],d[i]+1
  lb = 1
  rb = 1
  while l>0 and b[l-1] > i:
    l -= 1
    lb += 1
  while r<n and b[r] > i:
    r += 1
    rb += 1
  tot += lb*rb*i
print(tot)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
p = [0]*(n+1)
ans = 0
for i in range(n):
  p[a[i]] = i+1
l = [i-1 for i in range(n+2)]
l[0] = 0
r = [i+1 for i in range(n+2)]
r[-1] = n+1
for i in range(n,0,-1):
  ans += (p[i]-l[p[i]])*(r[p[i]]-p[i])*i
  l[r[p[i]]] = l[p[i]]
  r[l[p[i]]] = r[p[i]]
print(ans)
### BUGGY CODE ###

import bisect
n = int(input())
a = list(map(int, input().split())); a.sort()
b = list(map(int, input().split())); b.sort()
c = list(map(int, input().split())); c.sort()
ab = [0 for i in range(n)]
bc = [0 for i in range(n)]

for i in range(n):
  ab[i] = bisect.bisect_left(a, b[i])
for i in range(n):
  bc[i] = sum(ab[:bisect.bisect_left(b, c[i])])
  
print(sum(bc))



### FIXED CODE ###

import bisect
n = int(input())
a = list(map(int, input().split())); a.sort()
b = list(map(int, input().split())); b.sort()
c = list(map(int, input().split())); c.sort()
ab = [0 for i in range(n)]
ans = 0

for i in range(n):
  ab[i] = ab[i-1] + bisect.bisect_left(a, b[i])
for i in range(n):
  tmp = bisect.bisect_left(b, c[i])
  if tmp != 0:
  	ans += ab[tmp-1] 

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

# -*- coding: utf-8 -*-
import sys

def main():
	N, K = map(int, input().split(" "))
	H = input().split(" ")
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i, val in enumerate(H):
		if i == 0:
			continue
		ans = -1
		for j in range(1, K+1):
			if i - j >= 0:
				tmp = abs(val - H[i-j]) + DP[i-j]
				if ans == -1 or ans > tmp:
					ans = tmp
		DP[i] = ans
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
	

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	N, K = map(int, input().split(" "))
	H = input().split(" ")
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i in range(1, len(H)):
		paths = [DP[j] + abs(H[j] - H[i]) for j in range(max(0, i-K), i)]
		DP[i] = min(paths)
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
### BUGGY CODE ###

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

result = 0
for b in range(60):
  bs = sum((e >> b) & 1 for e in A)
  result = (result + bs * (N - bs) * (1 << b)) % 1000000007
print(result)


### FIXED CODE ###

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

    r = list(range(N - 2, -1, -1))
    result = 0
    for b in range(60):
        t = 0
        bs = (A[N - 1] >> b) & 1
        for i in r:
            if (A[i] >> b) & 1 == 0:
                t += bs
            else:
                t += (N - (i + 1)) - bs
                bs += 1
        result = (result + t * (1 << b)) % 1000000007
    print(result)
main()
### BUGGY CODE ###

N = int(input())
A_n = list(map(int, input().split(' ')))
total = 1
boolean = True
for i in A_n:
    total *= i

if total <= 10 ** 18:
    print(total)
else:
    print('-1')


### FIXED CODE ###

N = int(input())
A_n = list(map(int, input().split(' ')))
zero = 0 in A_n
if zero:
    total = 0
else:
    total = 1
    for i in A_n:
        total *= i
        if total > 10 ** 18:
            total = -1
            break
print(total)
### BUGGY CODE ###

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

from collections import Counter
from functools import lru_cache

ans = [0]*(N+1)

@lru_cache(maxsize=1000)
def main(i):
    ans[i] = A.count(i)
    print(ans[i])

for i in range(1,N+1):
    main(i)


### FIXED CODE ###

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

import collections
c = collections.Counter(A)

for i in range(1,N+1):
    print(c[i])
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
for i in range(m):
    a += bc[i][0] * [bc[i][1]]
sorted_a = sorted(a, reverse=True)
print(sum(sorted_a[0:n]))

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = [list(map(int, input().split())) for _ in range(m)]
bc = sorted(bc, key=lambda x: -x[1])
for b, c in bc:
    for _ in range(b):
        x = heapq.heappop(a)
        if c > x:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, x)
            break
print(sum(a))
### BUGGY CODE ###

def main():
    n = int(input())
    b = []
    for a in map(int, input().split()):
        b.append(str(a))
        b.reverse()

    print(" ".join(b))

main()

### FIXED CODE ###

from collections import deque

def main():
    input()
    A = list(enumerate(input().split()))
    size = len(A)
    b = deque()
    for i, a in A:
        if i % 2 == 0:
            if size % 2 == 0:
                b.append(a)
            else:
                b.appendleft(a)    
        else:
            if size % 2 == 0:
                b.appendleft(a)
            else:
                b.append(a)

    print(" ".join(list(b)))

main()
### BUGGY CODE ###

'''Author- Akshit Monga'''
n=int(input())
x=input()
for i in range(n):
    if x[i]=='1':
        temp='0'
    else:
        temp='1'
    var=x[0:i]+temp+x[i+1:]
    pivot=int(var,2)
    a=0
    while pivot:
        a+=1
        c=bin(pivot).count('1')
        pivot=pivot%c
    print(a)

### FIXED CODE ###

'''Author- Akshit Monga'''
n=int(input())
x=input()
x=x[::-1]
ans1=0
ans2=0
c=x.count('1')
for i in range(0,n):
    if x[i]=='1':
        ans1=(ans1+pow(2,i,c+1))%(c+1)
        if c!=1:
            ans2=(ans2+pow(2,i,c-1))%(c-1)
to_print=[]
for i in range(0,n):
    if x[i]=='1':
        if c==1:
            to_print.append(0)
            continue
        var=(ans2%(c-1)-pow(2,i,c-1))%(c-1)
        a = 1
        while var:
            var = var % bin(var).count('1')
            a += 1
        to_print.append(a)
    else:
        # print(ans1)
        var = (ans1%(c+1) + pow(2, i, c +1))%(c+1)
        # print(c+1)
        # print(var)
        a = 1
        while var:
            var = var % bin(var).count('1')
            a += 1
        to_print.append(a)
for i in to_print[::-1]:
    print(i)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)
    

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 1
count = 0
if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans > 10**18:
            count = 1
            print(-1)
            break
    if count == 0:
        print(ans)
### BUGGY CODE ###

MOD = 10 ** 9 + 7
S = input()
N = len(S)
mod13 = [0] * 13
mod13[0] = 1
exponent = 1
for i in range(1, N + 1):
    mod13_new = [0] * 13
    c = S[-i]
    if c == "?":
        for n in range(10):
            m = n * exponent % 13
            for r in range(13):
                mod13_new[(r + m) % 13] += mod13[r]
    else:
        for r in range(13):
            mod13_new[(r + int(c) * exponent) % 13] = mod13[r]
    exponent = exponent * 10 % 13
    for r in range(13):
        mod13_new[r] %= MOD
    mod13 = mod13_new
print(mod13[5])

### FIXED CODE ###

def main():
    MOD = 10 ** 9 + 7
    S = input()
    N = len(S)
    mod13 = [[0] * 13 for _ in range(N + 1)]
    mod13[0][0] = 1
    exponent = 1
    for i in range(1, N + 1):
        c = S[-i]
        if c == "?":
            for n in range(10):
                m = n * exponent % 13
                for r in range(13):
                    mod13[i][(r + m) % 13] += mod13[i - 1][r]
        else:
            m = int(c) * exponent % 13
            for r in range(13):
                mod13[i][(r + m) % 13] = mod13[i - 1][r]
        exponent = exponent * 10 % 13
        for r in range(13):
            mod13[i][r] %= MOD
    print(mod13[N][5])

if __name__ == "__main__":
    main()