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

import numpy as np

MOD = 1000000007;

dp=np.zeros(13*2,dtype='int64')

s = [int(x) if x!="?" else -1 for x in input()]

n=len(s)

r=np.zeros(13,dtype='int64')
c=s[0]

if (c!=-1):
	r[c]=1
else:
	for i in range(10):r[i]=1

for i in range(1,n):
	dp.fill(0)
	for j in range(13):dp[j*10%13]+=(r[j]%MOD)
	dp[13:26]=dp[0:13]
	c=s[i]
	r.fill(0)
	if (c==-1):
		for j in range(10):r+=dp[13-j:26-j]
	else:
		r+=dp[13-c:26-c]
print (r[5]%MOD)


### FIXED CODE ###

MOD = 1000000007;

s = [int(x) if x!="?" else -1 for x in input()]

n=len(s)

r=[0]*13

c=s[0]
if (c!=-1):
	r[c]=1
else:
	for i in range(10):r[i]=1

for i in range(1,n):
	dp=[0]*26
	for j in range(13):dp[j*10%13]+=(r[j]%MOD)
	dp[13:26]=dp[0:13]
	c=s[i]
	r=[0]*13
	if (c==-1):
		w=sum(dp[4:14])
		for j in range(13):
				r[j]+=w
				w=w+dp[j+1]-dp[4+j]
	else:
		for j in range(13):
			r[j]+=dp[13-c+j]
print (r[5]%MOD)
### BUGGY CODE ###

#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *A = map(int, read().split())

for _ in range(K):
    acc = [0] * (N + 1)
    for i, a in enumerate(A):
        l = max(0, i - a)
        r = min(N, i + a + 1)
        acc[l] += 1
        acc[r] -= 1
    acc[0] = min(N, acc[0])
    for i in range(N):
        acc[i + 1] = min(N, acc[i] + acc[i + 1])
    A = acc[:-1]

print(*A)


### FIXED CODE ###

#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *A = map(int, read().split())

for _ in range(min(K, 42)):
    acc = [0] * (N + 1)
    for i, a in enumerate(A):
        l = max(0, i - a)
        r = min(N, i + a + 1)
        acc[l] += 1
        acc[r] -= 1
    acc[0] = min(N, acc[0])
    for i in range(N):
        acc[i + 1] = min(N, acc[i] + acc[i + 1])
    A = acc[:-1]
    if all(a == N for a in A):
        break
print(*A)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]

ans = 0
flag = True

while flag:
    for i in A:
        if i % 2 == 0:
            i %= 2
        else:
            flag = False
    if flag == True:
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
while 1 not in [a%2 for a in A]:
    A = [a//2 for a in A]
    ans += 1
print(ans)
### BUGGY CODE ###

s = list(str(input()))
b = {}
b[0] = 1
c_ = 0
s.reverse()
for num,i in enumerate(s):
  c = (c_+int(i)*10**num)%2019
  if c in b:
    b[c] += 1
  else:
    b[c] = 1
  c_ = c
ans = 0
for i in b.values():
  ans += i*(i-1)//2
print(ans)

### FIXED CODE ###

s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

S = input()
Q = int(input())

querys = []
op1_cnt = 0
op2_cnt = 0
op2_C = {"1": [], "2": []}
for i in range(Q):
    query = input()
    if len(query) == 1:
        op1_cnt += 1

        if op2_cnt != 0:
            args = op2_C["1"][::-1]
            args.extend(S)
            args.extend(op2_C["2"])
            S = ''.join(args)
            op2_C = {"1": [], "2": []}
            op2_cnt = 0

    else:
        op2_cnt += 1

        if op1_cnt % 2 != 0:
            S = S[::-1]

        op1_cnt = 0

        t, F, C = query.split()
        op2_C[F].append(C)

if op1_cnt % 2 != 0:
    S = S[::-1]

if op2_cnt != 0:
    args = op2_C["1"][::-1]
    args.extend(S)
    args.extend(op2_C["2"])
    S = ''.join(args)


print(S)


### FIXED CODE ###

# -*- coding: utf-8 -*-
S = input()
Q = int(input())

reverse = 0
head = []
tail = []
for i in range(Q):
    query = input()
    if len(query) == 1:
        reverse = (reverse + 1) % 2

    else:
        t, F, C = query.split()
        if reverse == 0:
            if F == "1":
                head.append(C)
            else:
                tail.append(C)
        else:
            if F == "1":
                tail.append(C)
            else:
                head.append(C)

if reverse == 0:
    S = ''.join(head[::-1] + list(S) + tail)
else:
    S = ''.join(tail[::-1] + list(S[::-1]) + head)


print(S)
### BUGGY CODE ###

import numpy as np
n = list(map(int, input().split()))
h = list(map(int, input().split()))
h = sorted(h, reverse = True)
i = 0
for i in range(n[1]):
    h[0] = h[0]/2
    h = sorted(h, reverse  = True)
    i = i + 1
h = np.floor(h)
print(int(sum(h)))

### FIXED CODE ###

import numpy as np
import heapq
n = list(map(int, input().split()))
h = list(map(lambda x: int(x)*-1, input().split()))
heapq.heapify(h)
for i in range(n[1]):
    small = heapq.heappop(h)
    heapq.heappush(h, -1*(-small//2))
print(-sum(h))
### BUGGY CODE ###

import math

K = int(input())

ans = 0

for a in range(1, K+1):
	for b in range(1, K+1):
		for c in range(1, K+1):
			ans += math.gcd(math.gcd(a,b), c)

print(ans)

### FIXED CODE ###

import math
 
K = int(input())
 
ans = 0
 
for a in range(1, K+1):
	for b in range(1, K+1):
		tmp = math.gcd(a,b)
		for c in range(1, K+1):
			ans += math.gcd(tmp,c)
 
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC141 E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
S = input()
ans = 0
for k in range(1,n):
    s,t = S[:k],S[k:]
    dp = [[0 for _ in range(n-k+1)] for _ in range(k+1)]
    for i in range(k):
        for j in range(n-k):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j+1],dp[i+1][j])
    ans = max(ans,dp[-1][-1])
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC141 E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
dp = [[0]*(n+1) for _ in range(n+1)]
dp[-1][-1] = 1
for i in range(n)[::-1]:
    for j in range(n)[::-1]:
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans,min(i-j,dp[i][j]))
print(ans)
### BUGGY CODE ###

import bisect
a,b,q=map(int,input().split())
S=[];T=[]
for _ in range(a):
    s=int(input())
    S.append(s)
for _ in range(b):
    t=int(input())
    T.append(t)
S.append(10**12)
T.append(10**12)

for _ in range(q):
    x=int(input())
    idx_s=bisect.bisect_left(S,x)
    idx_t=bisect.bisect_left(T,x)
    se=S[idx_s]
    sw=S[idx_s-1]
    te=T[idx_t]
    tw=T[idx_t-1]

    m1=abs(x-se)+abs(se-te)
    m2=abs(x-se)+abs(se-tw)
    m3=abs(x-sw)+abs(sw-te)
    m4=abs(x-sw)+abs(sw-tw)
    m5=abs(x-te)+abs(te-se)
    m6=abs(x-te)+abs(te-sw)
    m7=abs(x-tw)+abs(tw-se)
    m8=abs(x-tw)+abs(tw-sw)
    print(min(m1,m2,m3,m4,m5,m6,m7,m8)) 
    




### FIXED CODE ###

import bisect
a,b,q=map(int,input().split())
S=[];T=[]
for _ in range(a):
    s=int(input())
    S.append(s)
for _ in range(b):
    t=int(input())
    T.append(t)
S.append(10**12)
T.append(10**12)

for _ in range(q):
    x=int(input())
    idx_s=bisect.bisect_left(S,x)
    idx_t=bisect.bisect_left(T,x)
    se=S[idx_s]
    sw=S[idx_s-1]
    te=T[idx_t]
    tw=T[idx_t-1]

    ans=float("inf")
    for ss in [se,sw]:
        for tt in [te,tw]:
            ans=min(ans,abs(ss-x)+abs(tt-ss),abs(tt-x)+abs(tt-ss))
    print(ans)
### BUGGY CODE ###

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

curr_a, curr_b = 0, 0

for v1, v2 in votes:
    a, b = v1, v2
    i = 2

    while a < curr_a or b < curr_b:
        a = v1 * i
        b = v2 * i
        i += 1

    curr_a, curr_b = a, b

print(curr_a + curr_b)


### FIXED CODE ###

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

curr_a, curr_b = 0, 0

for v1, v2 in votes:
    a, b = v1, v2
    i = max(curr_a // v1, curr_b // v2)

    while a < curr_a or b < curr_b:
        a = v1 * i
        b = v2 * i
        i += 1

    curr_a, curr_b = a, b

print(curr_a + curr_b)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[[0]*len(a) for i in range(len(a))]
c=[]
all=0
for i in range(len(a)):
  c.append(0)
for i in range(len(a)):
  for j in range(len(a)):
    if a[i]==a[j] and i!=j:
      b[i][j]=1
      c[i]+=1/2
      c[j]+=1/2
      all+=0.5
for i in range(len(a)):
  print(int(all-c[i]))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
c=[0]*n
#a[i]は1以上n以下で、cの要素番号は0~n-1(acは1ずれている。)
all=0
for i in range(n):
  c[a[i]-1]+=1
for i in range(n):
  if c[i]>=2:
    d=c[i]*(c[i]-1)/2
    all+=d
for i in range(n):
  print(int(all-(c[a[i]-1]-1)))
### BUGGY CODE ###

# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

### FIXED CODE ###

# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
    order %=mod
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 21:49:24 2020

@author: NEC-PCuser
"""

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

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

A.sort()

minus_list = []
plus_list = []
for i in range(len(A)):
    if (A[i] <= 0):
        minus_list.append(A[i])
    else:
        plus_list.append(A[i])

ans = 1
mod = 10 ** 9 + 7   
if N == K:
    for i in A:
        ans = (ans * i) % mod
elif 0 == len(plus_list) and  K % 2 == 1:
    minus_list.sort(reverse=True)
    for i in range(K):
        ans = (ans * minus_list[i]) % mod
else:
    minus_list.sort()
    plus_list.sort(reverse=True)
    if K % 2 == 1:
        ans = plus_list.pop(0)
    for i in range(K // 2):
        if (len(plus_list) < 2):
            ans = (minus_list.pop(0) * ans) % mod
            ans = (minus_list.pop(0) * ans) % mod
        elif (len(minus_list) < 2):
            ans = (plus_list.pop(0) * ans) % mod
            ans = (plus_list.pop(0) * ans) % mod
        elif (plus_list[0] * plus_list[1] > minus_list[0] * minus_list[1]):
            ans = (plus_list.pop(0) * ans) % mod
            ans = (plus_list.pop(0) * ans) % mod
        else:
            ans = (minus_list.pop(0) * ans) % mod
            ans = (minus_list.pop(0) * ans) % mod
print(ans)
        

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 21:49:24 2020

@author: NEC-PCuser
"""

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

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

A.sort()

minus_list = []
plus_list = []
for i in range(len(A)):
    if (A[i] <= 0):
        minus_list.append(A[i])
    else:
        plus_list.append(A[i])

ans = 1
mod = 10 ** 9 + 7   
if N == K:
    for i in A:
        ans = (ans * i) % mod
elif 0 == len(plus_list) and  K % 2 == 1:
    minus_list.sort(reverse=True)
    for i in range(K):
        ans = (ans * minus_list[i]) % mod
else:
    minus_list.sort(reverse=True)
    plus_list.sort()
    if K % 2 == 1:
        ans = plus_list.pop()
    for i in range(K // 2):
        if (len(plus_list) < 2):
            ans = (minus_list.pop() * ans) % mod
            ans = (minus_list.pop() * ans) % mod
        elif (len(minus_list) < 2):
            ans = (plus_list.pop() * ans) % mod
            ans = (plus_list.pop() * ans) % mod
        elif (plus_list[len(plus_list) - 1] * plus_list[len(plus_list) - 2] > minus_list[len(minus_list) - 1] * minus_list[len(minus_list) - 2]):
            ans = (plus_list.pop()* ans) % mod
            ans = (plus_list.pop() * ans) % mod
        else:
            ans = (minus_list.pop() * ans) % mod
            ans = (minus_list.pop()* ans) % mod
print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [int(n) for n in input().split()]

    M = 10 ** 9 + 7

    ans = 0
    for i in range(N-1):
        ans += sum([A[i] * A[j] % M for j in range(i+1, N)])
    print((ans + M) % M)


main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(n) for n in input().split()]

    M = 10 ** 9 + 7

    ans = 0
    cache = sum(A) % M
    for i in range(N-1):
        cache -= A[i]
        ans += A[i] * cache % M
    print(ans % M)


main()
### BUGGY CODE ###

N, M, S = map(int, input().split(" "))
adj = [ [] for _ in range(N) ] 
convert = []
cost_max = 0
for _ in range(M) :
    u, v, a, b = map(int, input().split(" "))
    adj[u-1].append( (v-1,a,b) )
    adj[v-1].append( (u-1,a,b) )
    cost_max = max(cost_max, a)

for _ in range(N) :
    c, d = map(int, input().split(" "))
    convert.append( (c, d) )  

import heapq 

limit = cost_max*N
S = min(S, limit)
h = [ (0, 0, S) ] 
ans = [  [float('inf')]*(limit+1) for _ in range(N) ]

while h != [] :
    time_consumed, city, coin = heapq.heappop(h)
    if ans[city][coin] < time_consumed:
        continue
    ans[city][coin] = time_consumed
    
    if coin + convert[city][0] < limit and ans[city][coin + convert[city][0]] > time_consumed + convert[city][1] :
        ans[city][coin + convert[city][0]] = time_consumed + convert[city][1]
        heapq.heappush(h, (time_consumed + convert[city][1], city, coin+convert[city][0] ) )

    for v, a, b in adj[city] :
        if coin - a < 0 or ans[v][coin-a] <= time_consumed+b :
            continue
        heapq.heappush( h, (time_consumed+b, v, coin-a) )
    
for i in range(1, N) :
    print(min(ans[i]))


### FIXED CODE ###

N, M, S = map(int, input().split(" "))
adj = [ [] for _ in range(N) ] 
convert = []
for _ in range(M) :
    u, v, a, b = map(int, input().split(" "))
    adj[u-1].append( (v-1,a,b) )
    adj[v-1].append( (u-1,a,b) )

for _ in range(N) :
    c, d = map(int, input().split(" "))
    convert.append( (c, d) )  

import heapq 

limit = 2500
S = min(S, limit)
h = [ (0, 0, S) ] 
ans = [  [float('inf')]*(limit+1) for _ in range(N) ]

while h != [] :
    time_consumed, city, coin = heapq.heappop(h)
    if ans[city][coin] < time_consumed:
        continue
    ans[city][coin] = time_consumed
    
    if coin + convert[city][0] < limit and ans[city][coin + convert[city][0]] > time_consumed + convert[city][1] :
        ans[city][coin + convert[city][0]] = time_consumed + convert[city][1]
        heapq.heappush(h, (time_consumed + convert[city][1], city, coin+convert[city][0] ) )

    for v, a, b in adj[city] :
        if coin - a < 0 or ans[v][coin-a] <= time_consumed+b :
            continue
        ans[v][coin-a] = time_consumed+b
        heapq.heappush( h, (time_consumed+b, v, coin-a) )
    
for i in range(1, N) :
    print(min(ans[i]))
### BUGGY CODE ###

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

ans = 0

for i in range(1000):
    t = str(i)
    t = t.zfill(3)
    now = t[0]
    count = 0
    for j in S:
        if count == 0 and now == j:
            now = t[1]
            count += 1
            continue
        if count == 1 and now == j:
            now = t[2]
            count += 1
            continue
        if count == 2 and now == j:
            ans += 1
            break

print(ans)

### FIXED CODE ###

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

ans = 0

for i in range(1000):
    t = str(i)
    t = t.zfill(3)
    now = t[0]
    count = 0
    for j in S:
        if count == 0 and now == j:
            now = t[1]
            count += 1
            continue
        if count == 1 and now == j:
            now = t[2]
            count += 1
            continue
        if count == 2 and now == j:
            ans += 1
            break

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

import sys

a,aa = map(int,input().split())

b = [sys.maxsize for i in range(a)]

c = list(map(int,input().split()))
b[0] = 0
for i in range(1,a):
	k = min(i,aa)
	for j in range(1,k+1):
		ma = min(b[i],b[i-j] + abs(c[i]-c[i-j]))
		b[i] = ma
print(b[-1])

### FIXED CODE ###

import sys

a,aa = map(int,input().split())

b = [sys.maxsize for i in range(a)]

c = list(map(int,input().split()))
b[0] = 0
for i in range(1,a):
	k = min(i,aa)
	for j in range(1,k+1):
		ma = min(b[i],b[i-j] + abs(c[i]-c[i-j]))
		b[i] = ma
print(b[-1])
### BUGGY CODE ###


import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

h,w=input_list()
a=[[s for s in  input()] for _ in range(h)]

l=[[0 for _ in range(w)] for _ in range(h)]
r=[[0 for _ in range(w)] for _ in range(h)]
u=[[0 for _ in range(w)] for _ in range(h)]
d=[[0 for _ in range(w)] for _ in range(h)]
#left
for w_i in range(1,w):
    for h_i in range(h):

        if a[h_i][w_i]=="#" or a[h_i][w_i-1]=="#":
            continue
        l[h_i][w_i]=l[h_i][w_i-1]+1
    
#right
for w_i in range(w-2,-1,-1):
    for h_i in range(h):

        if a[h_i][w_i]=="#" or a[h_i][w_i+1]=="#":
            continue
        r[h_i][w_i]=r[h_i][w_i+1]+1


#up
for w_i in range(w):
    for h_i in range(1,h):

        if a[h_i][w_i]=="#" or a[h_i-1][w_i]=="#":
            continue
        u[h_i][w_i]=u[h_i-1][w_i]+1


#down
for w_i in range(w):
    for h_i in range(h-2,-1,-1):

        if a[h_i][w_i]=="#" or a[h_i+1][w_i]=="#":
            continue
        d[h_i][w_i]=d[h_i+1][w_i]+1
ans=0
for w_i in range(w):
    for h_i in range(h):
        if a[h_i][w_i]=="#":
            continue
        cal=l[h_i][w_i]+r[h_i][w_i]+u[h_i][w_i]+d[h_i][w_i]+1
        ans=max(ans,cal)

print(ans)



### FIXED CODE ###

#import numpy as np
h,w=list(map(int,input().split()))
s=[[i for i in input() ] for _ in range(h)]

l=[[1 if s[h_i][w_i]=="." else 0 for w_i in range(w)] for h_i in range(h)]
r=[[1 if s[h_i][w_i]=="." else 0 for w_i in range(w)] for h_i in range(h)]
u=[[1 if s[h_i][w_i]=="." else 0 for w_i in range(w)] for h_i in range(h)]
d=[[1 if s[h_i][w_i]=="." else 0 for w_i in range(w)] for h_i in range(h)]
for h_i in range(h):
    for w_i in range(w):
        rev_w=w-w_i-1
        rev_h=h-h_i-1
        if s[h_i][w_i]!="#" and w_i!=0:
            l[h_i][w_i]+=l[h_i][w_i-1]
        if s[h_i][rev_w]!="#" and w_i!=0:
            r[h_i][rev_w]+=r[h_i][rev_w+1]
        if s[h_i][w_i]!="#" and h_i!=0:
            u[h_i][w_i]+=u[h_i-1][w_i]
        if s[rev_h][w_i]!="#" and h_i!=0:
            d[rev_h][w_i]+=d[rev_h+1][w_i]
ans=0
for h_i in range(h):
    for w_i in range(w):
        tmp=l[h_i][w_i]+r[h_i][w_i]+u[h_i][w_i]+d[h_i][w_i]-3
        ans=max(ans,tmp)

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

from decimal import *
A,B = map(str,input().split())
A = int(A)
B = float(B)
ans = 0

for i in range(1,A+1):
    ans += B

print(int(ans))

### FIXED CODE ###

A,B = map(str,input().split())
A = int(A)
B = int(float(B)*1000)
ans = A*B

print(int(A*B)//1000)
### BUGGY CODE ###

n,m=map(int,input().split())
edges=[[] for i in range(1+n)]
for i in range(m):
    """#weighted->erase_,__,___=map(int,input().split())
    edges[_].append((__,___))
    #undirected->erase#edges[__].append((_,___))
    """
    _,__=map(int,input().split())
    edges[_].append(__)
    #undirected->erase#edges[__].append(_)
    """
"""#weighted->erase

s,T=map(int,input().split())
from collections import deque
dq=deque([])
dq.append((s,0,0))
seen=[set()for i in [0,0,0]]
while dq:
    now,o,c=dq.popleft()
    seen[o].add(now)
    nex=(o+1)%3
    for t in edges[now]:
        if t==T and nex==0:print((c+1)//3);exit()
        if not(t in seen[nex]):
            dq.append((t,nex,c+1))
print("-1")

### FIXED CODE ###

import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
edges=[[] for i in range(3+3*n)]
o=inputs()
s,T=map(int,o.pop().split())
for i in o:
    _,__=map(int,i.split())
    _*=3;__*=3
    edges[_].append(__+1)
    edges[_+1].append(__+2)
    edges[_+2].append(__)

from collections import deque
dq=deque([])
dq.append((3*s,0))
T*=3
seen=[0]*(3*n+3)
seen[3*s]=1
while dq:
    now,c=dq.popleft()
    if now==T :print(c//3);exit()
    for t in edges[now]:
        if seen[t]==0:
            dq.append((t,c+1))
            seen[t]=1
print("-1")
### BUGGY CODE ###

N=int(input())
a1=input().split()
a2=[int(i) for i in a1]
prod=1
for i in a2:
    prod=prod*i
if prod<=1e18:
    print(prod)
else:
    print('-1')

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
if A[0]==0:
    print('0')
    A.remove(0)
    exit()
prod=1
for i in A:
    prod=prod*i
    if prod>1e18:
        print('-1')
        exit()
else:
    print(prod)
### BUGGY CODE ###

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

def gcd(num):
    k = []
    for i in range(1, num+1):
      if i > 2 and i%2 ==0:
        continue
      else:
        if num%i == 0:
            k.append(i) 
    return k

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = []
for i in ka:
  if b%i == 0:
    if is_prime(i):
        kb.append(i)

print(len(kb))

### FIXED CODE ###

def f(n):
    res = set()
    for i in range(2, int(n ** 0.5)):
        if n % i: continue
        while not n % i: n //= i
        res.add(i)
    return res | {n}
 
a, b = map(int,input().split())
print(len(f(a) & f(b) | {1}))
### BUGGY CODE ###

k = int(input())
ans = 0
import math
from functools import reduce
import itertools

def gcd(num):
    return reduce(math.gcd, num)
numlist = list(range(1, k+1))
l = list(itertools.product(numlist, repeat=3))
l2 = map(gcd, l)

ans = sum(l2)

print(ans)

### FIXED CODE ###

k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)
### BUGGY CODE ###

s = list(input())
i = 0

for i in range(len(s)-1):
    if s[i] == 'B' and s[i+1] == 'C':
        s[i] = 'D'
        s.pop(i+1)
    if i >= len(s) - 2:
        break

a = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'D':
        ans += a
    else:
        a = 0
print(ans)

### FIXED CODE ###

#%%
s = list(input())
i = 0
ss = ''

while True:
    if i <= len(s) - 2:
        if s[i] == 'B' and s[i+1] == 'C':
            ss += 'D'
            i += 2
        else:
            ss += s[i]
            i += 1          
    else:
        ss += s[i]
        i += 1
    if i >= len(s):
        break
#print(ss)

a = 0
ans = 0
for i in range(len(ss)):
    if ss[i] == 'A':
        a += 1
    elif ss[i] == 'D':
        ans += a
    else:
        a = 0
print(ans)

#%%