Harryxun/stf_run huggingface dataset:
def calc_cost(now, next):
  global h_list
  global N
  if next > N - 1: return
  if dp[next] > dp[now] + abs(h_list[next] - h_list[now]):
    dp[next] = dp[now] + abs(h_list[next] - h_list[now])

  calc_cost(next, next + 1)
  calc_cost(next, next + 2)

N = int(input())
h_list = list(map(int, input().split()))
dp = [float('INF') for i in range(N)]
dp[0] = 0

calc_cost(0, 0)

print(dp[N - 1])

### FIXED CODE ###

N = int(input())
h_list = list(map(int, input().split()))
dp = [float('INF') for i in range(N)]
dp[0] = 0

def calc_cost(now, next):
  global h_list
  global dp
  global N
  if next > N - 1: return
  if dp[next] > dp[now] + abs(h_list[next] - h_list[now]):
    dp[next] = dp[now] + abs(h_list[next] - h_list[now])

for i in range(N):
  calc_cost(i, i + 1)
  calc_cost(i, i + 2)

print(dp[N - 1])
a=int(input())
n=list(range(1,a+1))
m=n
o=n
for i in n:
  for j in m:
    for q in o:
      u=list(i,j,k,sep='')
print(len(u))

### FIXED CODE ###

a=int(input())
n=list(range(1,a+1))
m=n
o=n
count=0
for i in n:
  for j in m:
    for q in o:
        u=i,j,q
        count+=1
print(count)
G = [set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2])]
def check(x, y):
  for g in G:
    if x in g and y in g:
      return True
  return False
print("Yes" if check(x, y) else "No")

### FIXED CODE ###

G = [set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2])]
def check(x, y):
  for g in G:
    if x in g and y in g:
      return True
  return False
x, y = map(int, input().split())
print("Yes" if check(x, y) else "No")
from collections import defaultdict
input()
a = [*map(int, input().split())]
s = sum(a)
b = [[*map(int,input().split())] for _ in range(int(input()))]
c = defaultdict(int)
for i in a:
    c[i]+=1
for i,j in b:
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)


### FIXED CODE ###

def base(n, b):
    d="abcdefghijklmnopqrstuvwxyz"
    s = []
    while True:
        s.append(d[n % b])
        n = n//b -1
        if n < 0:
          break
    return ''.join(reversed(s))
print(base(int(input())-1,26))
n=int(input())
red=[[] for i in range(n)]
blue=[[] for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    red[i].append(a)
    red[i].append(b)
for i in range(n):
    a,b=map(int,input().split())
    blue[i].append(a)
    blue[i].append(b)
red=sorted(red)
blue=sorted(blue)
ans=0
for i in range(n):
    x=blue[i][0]
    y=blue[i][1]
    maxy=-1
    for j in range(n):
        if x>red[j][0] and y>red[j][1]:
            maxy=max(maxy,red[j][1])
    for j in range(n):
        if x>red[j][0] and maxy==red[j][1]:
            ans+=1
            red[j][0]=1000
            break
print(ans)


### FIXED CODE ###

a,b,c=map(int,input().split())
print("Yes" if a+b>=c else "No")
a, b = map(int, __import('sys')__.stdin.readline().split())
print(a * b)

### FIXED CODE ###

x, y = map(int, input().split())
print(x * y)
A = []
n = input()

for i in range(n):
    command = raw_input().split()

    if command[0] == 'insert':
        A.insert(0, command[1])
    elif command[0] == 'delete':
        A.remove(command[1])
    elif command[0] == 'deleteFirst':
        A.pop(0)
    elif command[0] == 'deleteLast':
        A.pop()

for i in range(len(A)):
    print A[i],

### FIXED CODE ###

A=[]
fp =0
bp =0
n=int(raw_input())
while n: 
    cmd = raw_input()
    if cmd[0] == 'i':
        A.append(int(cmd[7:]))
        fp += 1
    elif cmd[6] == ' ':
        try:
            i = A[::-1].index(int(cmd[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif cmd[6] == 'F':
        A.pop()
        fp -=1
    elif cmd[6] == 'L':
        bp +=1
    n -=1
 
for k in A[bp:fp+1][::-1]:
    print int(k),
import collections
import sys

N = int(input())
S = [input() for _ in range(N)]
# print(S)

c = collections.Counter(S)
# print(c.most_common())

outputs = []
for i, (key, value) in enumerate(c.most_common()):
    outputs.append(key)
    if not (i == len(c.most_common())-1 and c.most_common()[i+1][1] == value):
        break
for x in reversed(outputs):
    print(x)
    

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
S.sort()

ans = []
counter = 1
memo = 0

for i in range(1, N):
    if S[i] == S[i-1]:
        counter += 1
    else:
        if counter == memo:
            ans.append(S[i-1])
        elif counter > memo:
            ans.clear()
            ans.append(S[i-1])
            memo = counter
        counter = 1
if counter == memo:
    ans.append(S[N-1])
elif counter > memo:
    ans.clear()
    ans.append(S[N-1])
    memo = counter
for a in ans:
    print(a)
N, K = map(int, input().split())
mod = 10**9 + 7
nums = []
p_cnt = 0
m_cnt = 0
for i in list(map(int, input().split())):
    if i >= 0:
        nums.append((i, True))
        p_cnt += 1
    else:
        nums.append((-i, False))
nums.sort()
if p_cnt == 0 and K%2!=0:
    ans = 1
    for k in range(K):
        ans *= -nums[k][0]
        ans %= mod
    print(ans)
    import sys
    sys.exit()
pl = []
ml = []
for k in range(K):
    x, b = nums.pop()
    if x == 0:
        print(0)
        import sys
        sys.exit()
    if b:
        pl.append(x)
    else:
        ml.append(x)
if len(ml) % 2 != 0:
    while nums:
        x, b = nums.pop()
        p = -1
        px = -1
        m = -1
        mx = -1
        if b:
            if ml and p == -1:
                p = x/ml[-1]
                px = x
                continue
        else:
            if pl and m == -1:
                m = x/pl[-1]
                mx = x
                continue
        if ml != -1 and pl != -1:
            if p > m:
                ml.pop()
                pl.append(px)
            else:
                pl.pop()
                ml.append(mx)
            break
    else:
        if p != -1:
            ml.pop()
            pl.append(px)
        elif m != -1:
            pl.pop()
            ml.append(mx)
ans = 1
for x in pl:
    ans *= x
    ans %= mod
for x in ml:
    ans *= -x
    ans %= mod
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
mod = 10**9 + 7
nums = []
p_cnt = 0
for i in list(map(int, input().split())):
    if i >= 0:
        nums.append((i, True))
        p_cnt += 1
    else:
        nums.append((-i, False))
nums.sort()
if p_cnt == 0 and K%2!=0:
    ans = 1
    for k in range(K):
        ans *= -nums[k][0]
        ans %= mod
    print(ans)
    import sys
    sys.exit()
pl = []
ml = []
for k in range(K):
    x, b = nums.pop()
    if x == 0:
        print(0)
        import sys
        sys.exit()
    if b:
        pl.append(x)
    else:
        ml.append(x)
if len(ml) % 2 != 0:
    p = float("inf")
    px = float("inf")
    m = float("inf")
    mx = float("inf")
    while nums:
        x, b = nums.pop()
        if b:
            if ml and p == float("inf"):
                p = ml[-1]
                px = x
        else:
            if pl and m == float("inf"):
                m = pl[-1]
                mx = x
        if m != float("inf") and p != float("inf"):
            if px * m > mx * p:
                ml.pop()
                pl.append(px)
            else:
                pl.pop()
                ml.append(mx)
            break
    else:
        if p != float("inf"):
            ml.pop()
            pl.append(px)
        elif m != float("inf"):
            pl.pop()
            ml.append(mx)
ans = 1
for x in pl:
    ans *= x
    ans %= mod
for x in ml:
    ans *= -x
    ans %= mod
print(ans)
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
while M > 0:
    A.sort()
    while A[-1] >= A[-2]:
        A[-1] //= 2
        M -= 1
print(sum(A))

### FIXED CODE ###

from heapq import heapify, heappush, heappop
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapify(A)
while M > 0:
    heappush(A, heappop(A) / 2)
    M -= 1
print(-sum(int(i) for i in A))
import numpy as np


def main():
	n = int(input())
    nums = np.array([int(input()) for i in range(n)])
    n_total = nums.prod()
    n_denominator = sum([n_total/num for num in nums])
    ans = n_total / n_denominator
    print(ans)
  
  
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    nums = list(map(int, input().split()))
    print('{:.16g}'.format(1 / sum(1 / x for x in nums)))


if __name__ == '__main__':
    main()
import pandas as pd
date = pd.to_datetime(input().rstrip())
if date > pd.to_datetime("2019/4/30"):
  print("TBD)
else:
  print("Heisei")

### FIXED CODE ###

y,m,d = [int(s) for s in input().rstrip().split("/")]

if y == 2019:
  if m >= 5:
    print("TBD")
    exit()
elif y > 2019:
  print("TBD")
  exit()

print("Heisei")
a=int(input())
t=100
sum=0
while(t<a):
	t=floor(t*101/100)
    sum=sum+1
print(sum)


### FIXED CODE ###

import math
a=int(input())
t=100
sum=0
while(t<a):
	t=math.floor(t*101/100)
	sum=sum+1
print(sum)
dishes = [input() for _ in range(5)]

sum_dishes = []
last_dish = 0
last_tmp = 0
for idx, dish in enumerate(dishes):
    tmp = 10 - int(dish[-1])
    dish = int(dish)
    if tmp == 10:
        sum_dishes.append(dish)
    elif tmp > last_tmp:
        sum_dishes.append(last_dish + last_tmp)
        last_dish = dish
        last_tmp = tmp
        last_idx = idx
    else:
        sum_dishes.append(dish + tmp)

print(sum(sum_dishes) + int(dishes[last_idx]))

### FIXED CODE ###

dishes = [input() for _ in range(5)]


def tanuki(dishes):
    if all([i[-1] == '0' for i in dishes]):
        return sum([int(i) for i in dishes])

    sum_dishes = 0
    last_dish = 0
    last_tmp = 0
    for idx, dish in enumerate(dishes):
        tmp = 10 - int(dish[-1])
        dish = int(dish)
        if tmp == 10:
            sum_dishes += dish
        elif tmp > last_tmp:
            sum_dishes += last_dish + last_tmp
            last_dish = dish
            last_tmp = tmp
            last_idx = idx
        else:
            sum_dishes += dish + tmp
    return sum_dishes + int(dishes[last_idx])


print(tanuki(dishes))
N, M = map(int, input().split())
a_n = [int(input()) for i in range(M)]

def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)
      
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break    
    answer *= Fib( a - 1 - now + 2 )
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)

print(answer % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
a_n = [int(input()) for i in range(M)]
def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break

    answer *= Fib( a - 1 - now + 2 )
    answer %= 1000000007
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)
    answer %= 1000000007

print(answer)
import math
n = int(input())
print(math.factorial(n) % (1e9+7))

### FIXED CODE ###

import math
n = int(input())
ans = math.factorial(n) % (10**9+7)
print(int(ans))
x,y=map(int,input()..split())
if x%y==0:
  print(-1)
else:
  print(x)

### FIXED CODE ###

x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  print(x)
fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    n=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*n)%998244353
        n=(n**2)%998244353
    inv_fact_list[n]=s
    return s

def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    return (((fact_list[n]*inv(n-r))%998244353)*inv(r))%998244353

for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353

s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)


### FIXED CODE ###

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
"""
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s
 
def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""
def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    if inv_fact_list[n-r]!=None:
        invnr=inv_fact_list[n-r]
    else:
        m=fact_list[n-r]
        invnr=1
        for i in range(30):
            if i!=23 and i!=26:
                invnr=(invnr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[n-r]=invnr
    if inv_fact_list[r]!=None:
        invr=inv_fact_list[r]
    else:
        m=fact_list[r]
        invr=1
        for i in range(30):
            if i!=23 and i!=26:
                invr=(invr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[r]=invr
    return (((fact_list[n]*invnr)%998244353)*invr)%998244353
 
for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353
 
s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)
A,B,C = map(int,input().split())
K = int(input())
count = 0
while B <= A:
    B *= 2
    count += 1
while C <= B :
    C *= 2
    count += 1
if count > K :
    print("No")
else:
    pirnt("Yes")


### FIXED CODE ###

A,B,C = map(int,input().split())
K = int(input())
count = 0
while B <= A:
    B *= 2
    count += 1
while C <= B :
    C *= 2
    count += 1
if count > K :
    print("No")
else:
    print("Yes")
c_11, c_12, c_13 = input()
c_21, c_22, c_23 = input()
if c_11 == c_23 and c_12 == c_22 and c_13 == c_21:
  print(YES)
else:
  print(NO)

### FIXED CODE ###

c_11, c_12, c_13 = input()
c_21, c_22, c_23 = input()
if c_11 == c_23 and c_12 == c_22 and c_13 == c_21:
  print('YES')
else:
  print('NO')
import sys
i=1
for s in sys.stdin:
 if s=='0\n':break
 print(f'Case {i}: {a}')
 i+=1

### FIXED CODE ###

import sys
i=1
for e in sys.stdin:
 if'0\n'==e:break
 print(f'Case {i}: {e[:-1]}');i+=1
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = [0]*n
judge_s = 0
judge_c = 0
sc = sorted(sc)
for i in range(m):
    if judge_s == sc[i][0] and judge_c != sc[i][1]:
        ans = -1
        break
    judge_s = sc[i][0]
    judge_c = sc[i][1]
    ans[sc[i][0]-1] = sc[i][1]


if ans != -1:
    if ans[0] == 0:
        ans = -1
    else:
        ans = ans[0]*100+ans[1]*10+ans[2]
    
print(ans)

### FIXED CODE ###

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

ans = [0]*n
judge_s = 0
judge_c = 0
sc = sorted(sc)

if m == 0:
    if n == 1:
        ans = 0
    else:
        ans = 10**(n-1)
else:
    for i in range(m):
        if judge_s == sc[i][0] and judge_c != sc[i][1]:
            ans = -1
            break
        if n != 1 and sc[i] == [1,0]:
            ans = -1
            break
        judge_s = sc[i][0]
        judge_c = sc[i][1]
        ans[sc[i][0]-1] = sc[i][1]


    if ans != -1:
        ans_ = ans.copy()
        ans = 0
        for i in range(n):
            ans += ans_[i]*10**(n-i-1)
        
        if ans_[0] == 0 and n != 1:
            ans += 10**(n-1)
            
    
print(ans)
n = int(input())
print(sum(list(range(n))))

### FIXED CODE ###

n = int(input())
print((n-1) * n // 2 )
def make_Graph(N, edges):#頂点の名前はi - 1で受け付ける
    graph = [ [] for i in range(N)]
    for edge in edges:
        a, b, c = edge
        graph[a].append((b,c))
        graph[b].append((a,c))
    return graph

def BFS(N, graph, start):
    Q = []
    V = []
    d = [float("inf")] * N
    Q.append(start)
    d[start] = 0
    while len(V) < N:
        a = Q.pop(0)
        V.append(a)
        for b, c in graph[a]:
            if not b in V:
                Q.append(b)
                d[b] = d[a] + c
    return d

N = int(input())
graph = [ [] for i in range(N)]
for i in range(N-1):
    a, b, c = (int(j) for j in input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))

Q, K =(int(i) for i in input().split())

d = BFS(N, graph, K-1)
for i in range(Q):
    x, y = (int(a) for a in input().split())
    print(d[x-1] + d[y-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

def make_Graph(N, edges):#頂点の名前はi - 1で受け付ける
    graph = [ [] for i in range(N)]
    for edge in edges:
        a, b, c = edge
        graph[a].append((b,c))
        graph[b].append((a,c))
    return graph

def BFS(N, graph, start):
    Q = []
    V = []
    prev = [None] * N
    dd = [float("inf")] * N
    Q.append(start)
    dd[start] = 0
    while len(V) < N:
        a = Q.pop(0)
        V.append(a)
        for b, c in graph[a]:
            if b != prev[a]:
                Q.append(b)
                prev[b] = a
                dd[b] = dd[a] + c
    return dd

def DFS(N, graph, a, p, d):
    dd[a] = d
    for b, c in graph[a]:
        if b == p or dd[b] != 0:
            continue
        else:
            DFS(N, graph, b, a, d + c)

N = int(input())
graph = [ [] for i in range(N)]
for i in range(N-1):
    a, b, c = (int(j) for j in input().split())
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))

Q, K =(int(i) for i in input().split())
dd = [0] * N

try:
    DFS(N, graph, K-1, -1, 0)
except:
    dd = BFS(N, graph, K-1)

for i in range(Q):
    x, y = (int(a) for a in input().split())
    print(dd[x-1] + dd[y-1])
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

#define MAX_N 200001
#define MAX_M 200001

int N, M;
int K = 0;
int res = 0;

int A[MAX_N];
int B[MAX_M];


int main(int argc, const char * argv[]) {

    cin >> N >> M >> K;
    
    rep(i, N){
        int a;
        cin >> a;
        if(i==0) A[i] = a;
        else A[i] = A[i-1] + a;
    }
    
    rep(i, M){
        int b;
        cin >> b;
        if(i==0) B[i] = b;
        else B[i] = B[i-1] + b;
    }
    
    int a=0;
    for(int i=0; i<N; i++){
        if(A[i]>K) continue;
        
        a=i+1;
    }
    int b=M;
    for(int j=M-1; j>=0; j--){
        if(B[j] <= K-A[a]){
            res = max(res, a+b);
            break;
        }
        b--;
    }
    
    cout << res << endl;
    
    return 0;
}


### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
# Aの累積和
a_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
# Bの累積和
b_sum = [0]
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
b_sum.append(10**20)
ans = 0
# Aを固定する
for i in range(n+1):
    t = a_sum[i]
    l = 0
    r = len(b_sum)
    # Bのうち何冊目まで読めるか二分探索する
    while l+1<r:
        # c:探索範囲の中央
        c = (l + r) // 2
        # 中央がK以下の場合は、求めたい位置が右にあるので
        # 探索範囲の左端を中央にする
        if t+b_sum[c]<=k:
            l = c
        # 中央がKよりも大きい場合は、求めたい位置が左にあるので
        # 探索範囲の右端を中央にする
        else:
            r = c
    # 合計がKを超えないか確認する
    if a_sum[i]+b_sum[l]<=k:
        ans = max(ans,i+l)
print(ans)
123456789012 123456789012

### FIXED CODE ###

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

# 2進数のn桁目の0からxまでの和が偶数か奇数かを返す
def even_odd(x, n):
    if n == 1:
        if x % 4 == 1 or x % 4 == 2:
            return 1
        else:
            return 0

    num = (x % (2 ** n)) - 2 ** (n - 1)
    if num < 0:
        return 0
    elif num % 2 == 0:
        return 1
    else:
        return 0

# 10 ** 12 => 2 ** 40
s = 0
for i in range(1, 41):
    if (even_odd(B, i) + even_odd(A-1, i)) % 2 == 1:
        s += 2 ** (i - 1)
print(s)
from fractions import gcd
n = int(input())

al = list(map(int,input().split()))

front_gcd = []

a_init = al[0]
for a in al:
    a_init = gcd(a, a_init)
    front_gcd.append(a_init)
    
back_gcd = []

b_init = al[-1]
for b in al[::-1]:
    b_init = gcd(b, b_init)
    back_gcd.append(b_init)
    
back_gcd = back_gcd[::-1]

ans = 1
for i in range(n):
    if i == 0:
        gcd = back_gcd[1]
    elif i == n-1:
        gcd = front_gcd[-2]
    else:
        gcd = gcd(front_gcd[i-1], back_gcd[i+1])
    if gcd > ans:
        ans = gcd

print(ans)



### FIXED CODE ###

import fractions
n = int(input())

al = list(map(int,input().split()))

front_gcd = []

a_init = al[0]
for a in al:
    a_init = fractions.gcd(a, a_init)
    front_gcd.append(a_init)
    
back_gcd = []

b_init = al[-1]
for b in al[::-1]:
    b_init = fractions.gcd(b, b_init)
    back_gcd.append(b_init)
    
back_gcd = back_gcd[::-1]

ans = 1
for i in range(n):
    if i == 0:
        x = back_gcd[1]
    elif i == n-1:
        x = front_gcd[-2]
    else:
        x = fractions.gcd(front_gcd[i-1], back_gcd[i+1])
    if x > ans:
        ans = x

print(ans)
%%time
from copy import deepcopy
rotate = lambda x,y:x[y:] + x[:y]
S = input()
mod = 13
amari = 5

dp_tmp = [0]*13
dp_tmp[0] = 1
for i,s in enumerate(S[::-1]):
    dp = [0]*13
    if s == "?":
        for n in range(10):
            dp_tmp_roll = rotate(dp_tmp,n*(10**i)%mod)
            for i in range(13):
                dp[i] += dp_tmp_roll[i]
    else:
        dp_tmp_roll = rotate(dp_tmp,int(s)*(10**i)%mod)
        for i in range(13):
            dp[i] += dp_tmp_roll[i]
    for n in range(13):
        dp[n] = dp[n]%(10**9+7)
    dp_tmp = deepcopy(dp)
print(dp[amari])

### FIXED CODE ###

rotate = lambda x,y: x[-y:] + x[:-y]
S = input()
mod = 13
amari = 5
dp_tmp = [0]*13
dp_tmp[0] = 1
mul = 1
for s in S[::-1]:
    dp = [0]*13
    if s == "?":
        for n in range(10):
            dp_tmp_roll = rotate(dp_tmp,n*mul%mod)
            for k in range(13):
                dp[k] += dp_tmp_roll[k]
    else:
        dp_tmp_roll = rotate(dp_tmp,int(s)*mul%mod)
        for k in range(13):
            dp[k] += dp_tmp_roll[k]
    for n in range(13):
        dp[n] = dp[n]%(10**9+7)
    dp_tmp = dp
    mul = mul*10%13
print(dp[amari])
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

prin(ans)


### FIXED CODE ###

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

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

print(ans)