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

S = list(input())

dp = [[0 for _ in range(13)] for _ in range(len(S))]
# 上からj桁目までの数を13で割ったあまりがiであるものの個数

for i, sk in enumerate(S):
    if i == 0:
        if sk == '?':
            for j in range(10):
                dp[0][j] = 1
        else:
            s = int(sk)
            dp[0][s] = 1
        continue
    if sk == '?':
        for j in range(13):
            for l in range(10): # 上からi桁目に入れる数字
                k = (10*j+l)%13
                dp[i][k] += dp[i-1][j]
    else:
        s = int(sk)
        for j in range(13):
            for l in range(10):
                k = (10*j+l)%13
                if l % 10 == s:
                    dp[i][k] += dp[i-1][j]
    for j in range(13):
        dp[i][j] = dp[i][j] % 1000000007

print(dp[-1][5])


### FIXED CODE ###


def main():
    S = list(input())

    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    # 上からj桁目までの数を13で割ったあまりがiであるものの個数

    for i, sk in enumerate(S):
        if i == 0:
            if sk == '?':
                for j in range(10):
                    dp[0][j] = 1
            else:
                s = int(sk)
                dp[0][s] = 1
            continue
        if sk == '?':
            for j in range(13):
                for l in range(10): # 上からi桁目に入れる数字
                    k = (10*j+l)%13
                    dp[i][k] += dp[i-1][j]
        else:
            s = int(sk)
            for j in range(13):
                k = (10*j+s)%13
                dp[i][k] += dp[i-1][j]
        for j in range(13):
            dp[i][j] = dp[i][j] % 1000000007

    print(dp[-1][5])

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

import numpy as np
import bisect 

h, w = list(map(int, input().split()))
d = {".":0, "#":1}
ss = np.array([list(input()) for _ in range(h)])
ss = np.array([[d[x] for x in s] for s in ss])

ans = 0
ws = np.zeros((h, w))
hs = np.zeros((h, w))

i = 0
while i < h:
	j = 0
	while j < w:
		if ss[i, j] == 0:
			end = w
			for k in range(j + 1, w):
				if ss[i, k] == 1:
					end = k
					break
			ws[i, j:end] = end - j
			j = end + 1
		else:
			j += 1
	i += 1

j = 0
while j < w:
	i = 0
	while i < h:
		if ss[i, j] == 0:
			end = h
			for k in range(i + 1, h):
				if ss[k, j] == 1:
					end = k
					break
			hs[i:end, j] = end - i
			i = end + 1
		else:
			i += 1
	j += 1

# print(ss)
# print(ws)
# print(hs)
print(max(int(np.amax(ws + hs) - 1), 0))


### FIXED CODE ###

import numpy as np

h, w = list(map(int, input().split()))
d = {".":1, "#":0}
ss = np.array([list(input()) for _ in range(h)]) == "."
ss_t = ss.transpose()

ls, rs, us, ds = [np.zeros((h, w), dtype=int) for _ in range(4)]

ls, rs = ls.transpose(), rs.transpose()

ls[0] = ss_t[0]
rs[w-1] = ss_t[w-1]
us[0] = ss[0]
ds[h-1] = ss[h-1]

for i in range(1, w):
	ls[i] = ss_t[i] * (ls[i - 1] + 1)

for i in reversed(range(w - 1)):
	rs[i] = ss_t[i] * (rs[i + 1] + 1)

for i in range(1, h):
	us[i] = ss[i] * (us[i - 1] + 1)

for i in reversed(range(h - 1)):
	ds[i] = ss[i] * (ds[i + 1] + 1)

# print(ss)
# print(ls)
# print(rs)
# print(us)
# print(ds)
print(max(np.amax((ls.transpose() + rs.transpose() + us + ds) - 3), 0))
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [input() for i in range(h)]
q = []
dist = [[True] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            q.append((i, j))
            dist[i][j] = False
cnt = -1
while q:
    cnt += 1
    qq = []
    for y, x in q:
        if x + 1 < w and dist[y][x + 1]:
            dist[y][x + 1] = False
            qq.append((y, x + 1))
        if x - 1 >= 0 and dist[y][x - 1]:
            dist[y][x - 1] = False
            qq.append((y, x - 1))
        if y + 1 < h and dist[y + 1][x]:
            dist[y + 1][x] = False
            qq.append((y + 1, x))
        if y - 1 >= 0 and dist[y - 1][x]:
            dist[y - 1][x] = False
            qq.append((y - 1, x))
    q = qq
print(cnt)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [input() for i in range(h)]
q = []
dist = [[False] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            q.append((i, j))
            dist[i][j] = True
test = [(0, 1), (0, -1), (1, 0), (-1, 0)]
cnt = -1
while q:
    cnt += 1
    qq = []
    for y, x in q:
        for dy, dx in test:
            yy, xx = y + dy, x + dx
            if xx < 0 or yy < 0 or xx > w - 1 or yy > h - 1 or dist[yy][xx]:
                continue
            else:
                dist[yy][xx] = True
                qq.append((yy, xx))
    q = qq
print(cnt)
### BUGGY CODE ###

n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
p=[]
remain = set(range(1, n+1))
for i in range(m):
    p.append(list(map(int, input().split())))
#p.sort()
temp = []
for a,b in p:
    temp.append([b,a])
p = p + temp
p.sort()
for a,b in p:
    if not (a in remain):
        continue
    if h[a-1]<=h[b-1]:
        remain = remain - set([a])
print(len(remain))

### FIXED CODE ###

n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
p=[]
remain = set(range(1, n+1))
for i in range(m):
    p.append(list(map(int, input().split())))
temp = []
for a,b in p:
    temp.append([b,a])
p = p + temp
delset = set()
for a,b in p:
    if h[a-1]<=h[b-1]:
        #remain = remain - set([a])
        delset.add(a)
remain = remain - delset
print(len(remain))
### BUGGY CODE ###

n = int(input())
A = sorted(list(map(int, input().split())))
amax =max(A)
amin =min(A)
cntm = A.count(amin - 1)
cntz = A.count(amin)
cntp = A.count(amin + 1)
ans = cntm + cntz + cntp
for i in range(amin + 1 , amax):
    cntm = cntz
    cntz = cntp
    cntp = A.count(i + 1)
    ans = max(ans,cntm + cntz + cntp)
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
lst =[0] * (10 ** 5 +10)
for i in A:
    if i > 0:
        lst[i - 1] += 1
    lst[i] += 1
    lst[i + 1] += 1
print(max(lst))
### BUGGY CODE ###

import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

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

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    random.seed(20)
    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


### FIXED CODE ###

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

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

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])):
                max = s[i][j] + c[j] * (i-last_d[j])
                idx = j
        last_d[idx] = i
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

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

B,W=map(int,input().split())
mod=10**9+7
kaijo=[1]
Xdiv=[1]
two=pow(2,mod-2,mod)
for i in range(1,1+B+W):
    kaijo.append((kaijo[-1])*i%mod)
    Xdiv.append((Xdiv[-1]*two)%mod)
from collections import deque
gyaku=deque()
gyaku.append(pow(kaijo[B+W],mod-2,mod))
for i in range(B+W,0,-1):
    gyaku.appendleft((gyaku[0]*i)%mod)
def conb(a,b):
    if a<b:return 0
    return (kaijo[a]*gyaku[a-b]*gyaku[b])%mod
Blost,Wlost=[0],[0]
for k in range(1,B+W):
    Blost.append((Blost[-1]+conb(k-1,B-1)*Xdiv[k])%mod)
    Wlost.append((Wlost[-1]+conb(k-1,W-1)*Xdiv[k])%mod)
    print(((1+Wlost[k-1]-Blost[k-1])*two)%mod)
print(((1+Wlost[B+W-1]-Blost[B+W-1])*two)%mod)

### FIXED CODE ###

B,W=map(int,input().split())
mod=10**9+7
kaijo={0:1}
Xdiv={0:1}
two=pow(2,mod-2,mod)
for i in range(1,1+B+W):
    kaijo[i]=(kaijo[i-1]*i)%mod
    Xdiv[i]=(Xdiv[i-1]*two)%mod
gyaku={B+W:pow(kaijo[B+W],mod-2,mod)}
for i in range(B+W,0,-1):
    gyaku[i-1]=(gyaku[i]*i)%mod
def conb(a,b):
    if a<b:return 0
    return (kaijo[a]*gyaku[a-b]*gyaku[b])%mod
Blost,Wlost=0,0
for k in range(1,B+W):
    print(((1+Wlost-Blost)*two)%mod)
    Blost=(Blost+conb(k-1,B-1)*Xdiv[k])%mod
    Wlost=(Wlost+conb(k-1,W-1)*Xdiv[k])%mod
print(((1+Wlost-Blost)*two)%mod)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if A[i] == min(A[:i+1]):
    cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
m = N + 1
cnt = 0
for i in range(N):
  if m > A[i]:
    m = A[i]
    cnt += 1
print(cnt)
### BUGGY CODE ###

import numpy as np

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

points = np.asarray([k for i in range(n)])

for i in A:
		points = points -1
		points[i-1] += 1


for i in  points:
		if i <= 0:
				print("No")
		else: 
				print("Yes")


### FIXED CODE ###


n, k, q = map(int, input().split())
A = []

for i in range(q):
		A.append(int(input()))

points = [k-q for i in range(n)]

for i in A:
		points[i-1] += 1


for i in  points:
		if i <= 0:
				print("No")
		else: 
				print("Yes")
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
for i in range(k):
    b *= a[i]
for i in range(k,n):
    c = b
    b = b // a[i-k]
    b *= a[i]
    if b > c:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

from collections import deque

N=int(input())
deg=[0 for v in range(N+1)];deg[0]=None
out=[set() for v in range(N+1)];deg[0]=None
for e in range(1,N):
    a,b=map(int,input().split())
    out[a].add((b,e));out[b].add((a,e))
for v in range(N+1):
    deg[v]=len(out[v])
# print(out) #DB
# print(deg) #DB

K=max(deg[1:])
# print(K) #DB

vcol=[set() for v in range(N+1)];vcol[0]=None # 頂点vから出る辺に含まれる色
ecol=[0 for e in range(N)];ecol[0]=None # 辺eの色
#r=[False for v in range(N+1)];r[0]=None # その頂点にたどり着いたか→vcolで代用

q=deque()
q.append(1)
while q:
    u=q.popleft() # 今いる頂点
    for vs in out[u]: # 今いる頂点の隣にある頂点と，その頂点に行くための辺の番号
        if not vcol[vs[0]]: # その頂点にまだ辿り着いていなければ（書き換え後）
        #if not r[vs[0]]: # その頂点にまだ辿り着いていなければ
            for col in range(1,K+1): # 各色を順に選び
                if col not in vcol[u]: # その色が，今いる頂点から生える辺にまだ使われていなければ
                    ecol[vs[1]]=col # その辺をその色で塗り
                    vcol[u].add(col) # 今いる頂点から生える辺の色の集合に加え
                    vcol[vs[0]].add(col) # 進んだ先の頂点から生える辺の色の集合に加える。
                    break
            # r[vs[0]]=True # その頂点にたどり着いたこととし（削る）
            q.append(vs[0]) # その頂点をキューに加える。

# print(vcol) #DB
# print(ecol) #DB

print(K)
for ecoli in ecol[1:]:
    print(ecoli)

### FIXED CODE ###

# アイデア：（これまでどおり）BFS。
# まず頂点に色を塗り，次に，その頂点から出る辺に色を塗ってゆく。
# 頂点に塗られた色及び「その頂点から出る何本目の辺か」によって，その辺に塗る色を決定する。
# 頂点に入ってくるときには，その際に取った辺の色を頂点に塗る。

from collections import deque

N=int(input())
d={} # 辺の両端の頂点→辺の番号を辿れるようにしておく
out=[set() for v in range(N+1)];out[0]=None # 隣接リスト，頂点の番号も問題文どおり1-initial,1~N
for i in range(1,N): # 問題文どおり辺の番号は1-initial,1~N-1
    u,v=map(int,input().split())
    out[u].add(v);out[v].add(u)
    u,v=min(u,v),max(u,v);d[(u,v)]=i
K=max([len(out[v]) for v in range(1,N+1)])
    
vcol=[0 for v in range(N+1)];vcol[0]=None
ecol=[0 for e in range(N)];ecol[0]=None

vr=[False for v in range(N+1)];vr[0]=None

q=deque()
q.append(1);vr[1]=True
vcol[1]=1 # 頂点1を色1で塗る
while q:
    u=q.popleft() # 今いる頂点    
    i=1 # その頂点から塗り始める何本目の辺か(1-initial),1<=i<=K
    for v in out[u]:
        if not vr[v]:
            col=(vcol[u]+i-1)%K+1
            vcol[v]=ecol[d[(min(u,v),max(u,v))]]=col
            vr[v]=True
            q.append(v)
            i+=1

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

N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

for i in range(N):
    print(max(A[:i]+A[i+1:]))


### FIXED CODE ###

import heapq
N = int(input())
A = [None]*N
for i in range(N):
    A[i] = {
        "index": i,
        "value": int(input())
    }

B = heapq.nlargest(2, A, key=lambda e:e["value"])
for i in range(N):
    if i == B[0]["index"]:
        print(B[1]["value"])
    else:
        print(B[0]["value"])
### BUGGY CODE ###

from collections import defaultdict
from fractions import Fraction
import sys
input = sys.stdin.readline
N=int(input())
mod=10**9+7
dic=defaultdict(lambda: [0,0])
c=0
d=0
e=0
for i in [0]*N:
 A,B = map(int,input().split())
 if A==0 and B==0:
  e+=1
 elif A==0:
  c+=1
 elif B==0:
  d+=1
 else:
  dic[Fraction(A,B)][0]+=1
  dic[Fraction(-B,A)][1]+=1
ans=1
for k in dic:
 if k>0:
  ans*=(pow(2,dic[k][0],mod)+pow(2,dic[k][1],mod) -1)
  ans%=mod
ans*=(pow(2,c,mod)+pow(2,d,mod)-1)
print((ans-1+e)%mod)


### FIXED CODE ###

from collections import defaultdict
from math import gcd
import sys
input = sys.stdin.readline
N=int(input())
mod=10**9+7
dic=defaultdict(lambda: [0,0])
c=0
d=0
e=0
for i in [0]*N:
 A,B = map(int,input().split())
 if A==0 and B==0:
  e+=1
 elif A==0:
  c+=1
 elif B==0:
  d+=1
 else:
  g=gcd(A,B)
  A//=g
  B//=g
  if A*B>0:
   dic[(abs(A),abs(B))][0]+=1
  else:
   dic[(abs(B),abs(A))][1]+=1
ans=1
for k in dic:
 ans=ans*(pow(2,dic[k][0],mod)+pow(2,dic[k][1],mod) -1)
ans=ans*(pow(2,c,mod)+pow(2,d,mod)-1)
print((ans-1+e)%mod)
### BUGGY CODE ###

import sys

n,m = map(int,input().split())
a_arr = []
b_arr = []
c_arr = []

dic_arr = [{i:sys.maxsize for i in range(2 ** n)}]
dic_arr[0][0] = 0

for i in range(m):
  a,b = map(int,input().split())
  a_arr.append(a)
  b_arr.append(b)
  tmp_arr = list(map(int, input().split()))
  
  arr = []
  for i in range(1, n+1):
    if i in tmp_arr:
      arr.append('1')
    else:
      arr.append('0')
  
  c_arr.append(int(''.join(arr),2))

for i in range(m):
  a = a_arr[i]
  b = b_arr[i]
  c = c_arr[i]
  
  dic_arr.append(dic_arr[i].copy())
  
  for k,v in dic_arr[i].items():
    dic_arr[i+1][k|c] = min(dic_arr[i+1][k|c],a+v)

if dic_arr[m][(2**n)-1] != sys.maxsize:
  print(dic_arr[m][(2**n) -1])
else:
  print(-1)

### FIXED CODE ###

n,m = map(int,input().split())
 
dic = {0:0}
 
for i in range(m):
  a,b = map(int,input().split())
  tmp_arr = list(map(int, input().split()))
  
  arr = []
  for j in range(1, n+1):
    if j in tmp_arr:
      arr.append('1')
    else:
      arr.append('0')
  
  c = int(''.join(arr),2)
  
  dic2 = dic.copy()
  
  for k,v in dic.items():
    if (k|c) in dic2.keys():
      dic2[k|c] = min(dic2[k|c],a+v)
    else:
      dic2[k|c] = a+v
 
  dic = dic2
 
if ((2**n)-1) in dic.keys():
  print(dic[(2**n) -1])
else:
  print(-1)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(n-2,-1,-1):
    for j in range(i+1,n):
        dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1])
print(dp[0][n-1])


### FIXED CODE ###

def kukan(n, a):
    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = a[i]
    for i in range(n - 2, -1, -1):
        for j in range(i + 1, n):
            L = a[i] - dp[i + 1][j]
            R = a[j] - dp[i][j - 1]
            dp[i][j] = L if L > R else R
    return dp[0][n - 1]


n = int(input())
a = list(map(int, input().split()))
print(kukan(n, a))
### BUGGY CODE ###

N,Q = input().split(" ")
sentence = input()

for i in range(int(Q)):
	count = 0
	l,r = input().split(" ")
	for j in range(int(r)-int(l)):
		if sentence[int(l)-1+j] == "A":
			if sentence[int(l)+j] == "C":
				count += 1
	print(count)

### FIXED CODE ###

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

"""
###文章そのままの実装ー＞N,Q によりオーダーが大きくなりすぎる
for i in range(int(Q)):
	count = 0
	l,r = map(int, input().split(" "))
	for j in range(r-l):
		if sentence[l-1+j:l+j+1] == "AC":
			count += 1
	print(count)

"""

###累積和を用いて高速に計算
#予め累積和を計算　クエリで高速回答
#ACACTGC
#0112222
AC_list = [0]*(N)
count = 0
for i in range(N-1):
	if sentence[i : i+2] == "AC":
		count += 1
	AC_list[i+1] = count

for i in range(Q):
	l,r = map(int, input().split())
	print(AC_list[r-1]-AC_list[l-1])
### BUGGY CODE ###

X = input()
for _ in range(len(X)//2):
  X = X.replace('ST','')

print(len(X))

### FIXED CODE ###

X = input()

s_stack=0
t_stack=0

for x in X:
  if x=='S':
    s_stack +=1
  if x=='T':
    if s_stack:
      s_stack -=1
    else:
      t_stack +=1

answer = s_stack + t_stack
print(answer)
### BUGGY CODE ###

def solve():
  h,w = (int(i) for i in input().split())
  maze = [input() for _ in range(h)]
  visit = [[False]*w for i in range(h)]
  count = h*w
  ans = 0
  
  white = []
  for i in range(h):
    for j in range(w):
      if maze[i][j] == "#":
        white.append((i,j))
        count -= 1
        visit[i][j] = True
        
  d = [(1,0),(0,1),(-1,0),(0,-1)]
  while count > 0:
   ans += 1
   newwhite = []
   while white:
      x,y = white.pop(0)
      for dx,dy in d:
        nx,ny = x+dx,y+dy
        if nx < 0 or nx >= h or ny < 0 or ny >=w :
         continue 
        elif visit[nx][ny]:continue
          
        if maze[nx][ny] == ".":
          count -= 1
          str_list = list(maze[nx])
          str_list[ny] = "#"
          maze[nx] = "".join(str_list)          
          newwhite.append((nx,ny))
          visit[nx][ny] =True
   white = newwhite
    
  print(ans)
solve()


### FIXED CODE ###


from collections import deque
def solve():
  h,w = (int(i) for i in input().split())
  maze = ["0"*(w+2)]
  for i in range(h):
    maze.append("0"+input()+"0")
  maze.append("0"*(w+2))
  black = deque([])
  count = 0
  visit = [[False]*(w+2) for _ in range(h+2)]
  
  for i in range(h+2):
    for j in range(w+2):
      if maze[i][j] == "#":
        black.append((0,i,j)) #move,h,w

  d = [(0,1),(1,0),(-1,0),(0,-1)]
  ans = 0
  
  while count != h*w:
    move,y,x = black.popleft()
    #print(move,y,x)
    if visit[y][x]:
      continue
    else:
      visit[y][x] = True
      count += 1
      for dy,dx in d:
        ny,nx = y+dy,x+dx
        if visit[ny][nx]:
          continue
        elif maze[ny][nx] ==".":
          black.append((move+1,ny,nx))
  print(move)
          

    
solve()
### BUGGY CODE ###

import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nms = lambda: map(str, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()
h = nl()
INF = 10 ** 9
dp = [INF for i in range(n)]
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    for j in h:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])

### FIXED CODE ###

import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nms = lambda: map(str, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()
h = nl()
INF = 10 ** 9
dp = [INF for i in range(n)]
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[-1])
### BUGGY CODE ###

n = int(input())
a = []
ans = 0
for i in range(n):
    b = input()
    if b not in a:
        a += [b]
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = []
ans = 0
for i in range(n):
    b = input()
    a+=[b]
c = sorted(a)
b = 0
for i in range(n-1):
    if c[i] == c[i+1]:
        b += 1

print(n-b)
### BUGGY CODE ###

n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
mi = 10000000000000
res = []
res.append(dat[0])
import bisect
for i in range(1, n):
    a = bisect.bisect_left(res, dat[i])
    if a == 0:
        a = bisect.insort_left(res, dat[i])
    else:
        res[a-1] = dat[i]
print(len(res))


### FIXED CODE ###

def bisect_right(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x > a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo

import collections
n = int(input())
dat = []
for i in range(n):
    dat.append(int(input()))
res = collections.deque([])

res.append(dat[0])
import bisect

for i in range(1, n):
    a = bisect_right(res, dat[i])
    #print("2 : {0}".format(a))

    if a == len(res):
        res.append(dat[i])
    else:
        res[a] = dat[i]
print(len(res))
#print(res)
### BUGGY CODE ###

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

x = 0
for i in range(N):
    if min(Ps[:i+1]) == Ps[i]:
        x += 1
print(x)

### FIXED CODE ###

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

x = 0
min_now = max(Ps)

for i in range(N):
    if min_now >= Ps[i]:
        x += 1
        min_now = Ps[i]
print(x)
### BUGGY CODE ###

n = int(input())
c = 0
s = []
for i in range(n):
  ss = input()
  if not ss in s:
    c+=1
    s.append(ss)
print(c)    

### FIXED CODE ###

n = int(input())
c = 1
s = []
for i in range(n):
  ss = input()
  s.append(ss)
s.sort()  
for j in range(1,n):
  #print(s[i],s[i-1])
  if s[j] !=s[j-1]:
    c+=1 
print(c)