Harryxun/stf_run huggingface dataset:
n,k,q=map(int,input().split())
ans=[-q]*n
for i in range(q):
  a=int(input())
  ans[a]+=1
print(sum(x > -k for x in ans))
  
print('Yes' if x > -k for x in ans else 'No')

### FIXED CODE ###

n=input()
if n=='Sunny':
  print('Cloudy')
elif n=='Cloudy':
  print('Rainy')
else:
  print('Sunny')
import numpy
A, B = map(int, input().split())

C = print(A+B)
D = print(A-B)
E = print(A*B)

if C > D and C > E:
    print(C) 
elif D > C and D > E:
    print(D)
elif E > C and E > D:
    print(E)

### FIXED CODE ###

A, B = map(int, input().split())
 
C = A+B
D = A-B
E = A*B
 
LIST = [C,D,E]
 
print(max(LIST))
while True:
    a=input()
    if a==0: break
    sum([int(i) for i in a])

### FIXED CODE ###

while True:
    a=str(raw_input())
    if a=="0": break
    print(sum([int(i) for i in a]))
H, N = int(input())
PP = list(map(int, input().split()))
print("Yes" if sum(PP)>=H else(No))

### FIXED CODE ###

H, N = map(int, input().split())
PP = list(map(int, input().split()))
print("Yes" if sum(PP) >= H else "No")
N = int(input())

tree = {}
for i in range(1,N):
    u, v, w = map(int, input().split())
    w = w%2
    if u in tree:
        tree[u].append([v,w])
    else:
        tree[u] = [[v,w]]

    if v in tree:
        tree[v].append([u,w])
    else:
        tree[v] = [[u,w]]

iro = [-1]*(N)
def seachTree(current, parent):
    if len(tree[current]) == 0:
        return

    for elms in tree[current]:
        if elms[0] == parent:
            continue
        if elms[1] == 0:
            iro[elms[0]-1] = iro[current-1]
        else:
            iro[elms[0]-1] = not iro[current-1]

        seachTree(elms[0], current)

iro[0] = False
seachTree(1, 0)
for val in iro:
    print(int(val))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N = int(input())

tree = {}
for i in range(1,N):
    u, v, w = map(int, input().split())
    w = w%2
    if u in tree:
        tree[u].append([v,w])
    else:
        tree[u] = [[v,w]]

    if v in tree:
        tree[v].append([u,w])
    else:
        tree[v] = [[u,w]]

iro = [-1]*(N)
def seachTree(current, parent):
    if len(tree[current]) == 0:
        return

    for elms in tree[current]:
        if elms[0] == parent:
            continue
        if elms[1] == 0:
            iro[elms[0]-1] = iro[current-1]
        else:
            iro[elms[0]-1] = not iro[current-1]

        seachTree(elms[0], current)

iro[0] = False
seachTree(1, 0)
for val in iro:
    print(int(val))
def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
from collections import OrderedDict
def solve(N,X,M):
    A=X
    ans=A
    seen=set()
    order_seen=[]
    for i in range(2,N+1):
        A=f(A,M)
        if i!=2:
            if A not in seen:
                seen.add(A)
                order_seen.append(A)
            else:  # If A has already been seen we are just going to repeat so break out of the loop.
                break
        if A==0:   # If A=0 it will repeat forever.
            return ans
        ans+=A
    n=len(order_seen)
    i-=1 # Correcting factor for fact that when we break out of the loop we go one above with i
    N-=i
    mult_factor=N//n
    total_sum_seen=sum(order_seen)
    ans+=(total_sum_seen*mult_factor)
    number_remaining=N%n
    for i in range(number_remaining):
        ans+=order_seen[i]
    return ans

# The function for the recurrence relation.  A_n+1=A_n^2%M
def f(A,M):
    return A**2%M

N,X,M=readMap()
print(solve(N,X,M))

### FIXED CODE ###

def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
def solve(N,X,M):
    seen=set()
    order_seen=[]
    while X not in seen:
        seen.add(X)
        order_seen.append(X)
        X=f(X,M)
    pos=order_seen.index(X)  # Find position of when the cycle begins
    if pos>N:  # If position is greater than N, then we know we are not going to include any values from the cycle.
        return sum(order_seen[:N])
    terms_before_cycle=order_seen[:pos]
    sum_terms_before_cycle=sum(terms_before_cycle)
    ans=sum_terms_before_cycle
    terms_in_cycle=order_seen[pos:]
    sum_cycle=sum(terms_in_cycle)
    length_cycle=len(terms_in_cycle)
    number_remaining_terms=N-pos
    mult_factor=(number_remaining_terms)//length_cycle
    ans+=(sum_cycle*mult_factor)
    numb_remain=(number_remaining_terms)%length_cycle
    ans+=sum(terms_in_cycle[:numb_remain])
    return ans

# The function for the recurrence relation.  A_n+1=A_n^2%M
def f(A,M):
    return pow(A,2,M)

N,X,M=readMap()
print(solve(N,X,M))
def C158():
    A, B = [int(_) for _ in input().split()]
    X1 = int(A / 0.08)
    # パターンを探す
    X = []
    for i in range(X1, 10000):
        if int(i * 0.08) == A:
            X.append(i)
        else:
            break

    for i in X:
        if int(i * 0.1) == B:
            print(i)
            exit(1)
    else:
        print("-1")

if __name__ == "__main__":
    C158()

### FIXED CODE ###

def C158():
    A, B = [int(_) for _ in input().split()]
    N = 1
    while N <= 10000:
        if int(N * 8/100) == A and int(N * 10/100) == B:
            break
        N += 1
    if N <= 10000:
        print(N)
    else:
        print(-1)
        
if __name__ == "__main__":
    C158()
a,b,c=map(int,input().split())
print(['Impossible','Possible'][a%3==0 or b%3==0 or (a+b)%3==0])

### FIXED CODE ###

a,b=map(int,input().split())
print(['Impossible','Possible'][a%3==0 or b%3==0 or (a+b)%3==0])
N, X, Y = map(int, input().split())

mind = [[N] * N for i in range(N)]
    
for i in range(N):
    for j in range(i+1, N):
        mind[i][j] = min(abs(j-i), abs((X-1)-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

mindcnt = [0] * N
for i in range(N):
    for j in range(i+1, N):
        mind = mind[i][j]
        mindcnt[mind] += 1

for k in range(1, N):
    print(mindcnt[k])


### FIXED CODE ###

N, X, Y = map(int, input().split())

mind = [[N] * N for i in range(N)]
    
for i in range(N):
    for j in range(i+1, N):
        mind[i][j] = min(abs(j-i), abs((X-1)-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

mindcnt = [0] * N
for i in range(N):
    for j in range(i+1, N):
        d = mind[i][j]
        mindcnt[d] += 1

for k in range(1, N):
    print(mindcnt[k])
def fib(n):
	if n<0:
		return 0
	if n in [0, 1]:
		return 1
	return fib(n-1) + fib(n-2)

N, M = map(int, input().split())
if M==0:
	ans = fib(N)
else:
	A = [int(input()) for _ in range(M)]
	A.append(N+1)
	ans = fib(A[0]-1)
	for i in range(M):
		ans = ans * fib(A[i+1]-A[i]-2)

print(ans%1000000007)

### FIXED CODE ###

def solve():
	N, M = map(int, input().split())

	dp = [0]*(N+1)
	for _ in range(M):
		a = int(input())
		dp[a] = -1

	dp[0] = 1
	if dp[1]==-1:
		dp[1] = 0
	else:
		dp[1] = 1

	for i in range(2, N+1):
		if dp[i]==-1:
			dp[i] = 0
		else:
			dp[i] = dp[i-1] + dp[i-2]

	print(dp[N]%1000000007)

solve()
s = input()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n,m = map(int,input().split())
if n <= 1:
  n = 0
else:
  n = n * (n-1) / 2
if m <= 1:
  m = 0
else:
  m = m * (m-1) / 2
print(int(n+m))
s = input()
S = []
xid = [0] * (10 ** 5)
xcnt = 0
for c in s:
    if c != "x":
        S.append(c)
        xcnt += 1
    else:
        xid[xcnt] += 1
xid = xid[:xcnt + 1]
ans = 0
if S[0:xcnt // 2] == S[-1:-(xcnt // 2) - 1:-1]:
    for i in range(-(-xcnt // 2)):
        ad = xid[i] - xid[xcnt - i]
        if ad < 0:
            ad = -ad
        ans += ad
    print(ans)
else:
    print(-1)

### FIXED CODE ###

s = input()
S = []
xid = [0] * (10 ** 5 + 1)
xcnt = 0
for c in s:
    if c != "x":
        S.append(c)
        xcnt += 1
    else:
        xid[xcnt] += 1
xid = xid[:xcnt + 1]
ans = 0
if S[0:xcnt // 2] == S[-1:-(xcnt // 2) - 1:-1]:
    for i in range(-(-xcnt // 2)):
        ad = xid[i] - xid[xcnt - i]
        if ad < 0:
            ad = -ad
        ans += ad
    print(ans)
else:
    print(-1)
import math

N,X = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
d = [abs(X-i) for i in x if abs(X-i)!=0]

gcd = d[0]
for i in range(N-1):
    gcd = math.gcd(gcd,d[i+1])

print(gcd)

### FIXED CODE ###

import fractions

N,X = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
#d = [abs(X-i) for i in x if abs(X-i)!=0]
d = [abs(X-i) for i in x]

gcd = d[0]
i=1
while True:
    if i>=N:
        break
    gcd = fractions.gcd(gcd,d[i])
    i=i+1 

print(gcd)
import math
A,B=map(int,input().split())
c=A*B/math.gcd(A,B)
print(int(c))

### FIXED CODE ###

import fractions
A,B=map(int,input().split())
c=A*B/fractions.gcd(A,B)
print(int(c))
import sys
C=range(1000)
m=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":m+=1
    else:
        a,b=map(int,s.split(','))
        d[m][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a!=0 and b!=0:print i,a+b

### FIXED CODE ###

import sys
C=range(1001)
m=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":m+=1
    else:
        a,b=map(int,s.split(','))
        d[m][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a and b:print i,a+b
import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))
if all((a // reduce(gcd, A)) % 2 for a in A):
    print(round((m+1) / reduce(lambda x, y: x*y // gcd(x, y), A))
else:
    print(0)

### FIXED CODE ###

import sys
from fractions import gcd
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))

a = A[0]
for i in range(1, len(A)):
    z = gcd(a, A[i])
    x, y = a // z, A[i] // z
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(round(((m+1)/a)))
# n,m = map(int,input().split())
n = int(input())
# n = input()
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
left = 0
for i in range(n):
    a1,b1 = a[i],b[i]
    if a1 <= b1 + left:
        cnt += a1
        left = min(b1 - a1 + left,b1)
    else:
        cnt += b1 + left
        left = 0
if a[n] <= left:
    cnt += a[n]
else:
    cnt += left
print(cnt)


### FIXED CODE ###

n,m = map(int,input().split())
# n = int(input())
# n = input()
if (n + m) % 2 == 0:
    print((n + m) // 2)
else:
    print('IMPOSSIBLE')
N=int(input())
M=int(input())
N=N-M
if N>0:
   print(N)
else:
   print(-1)

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=0
for i in A:
    B=B+i       
N=N-B
if 0<=N:
    print(N)
else:
    print(-1)
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import gcd, ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N,M,C = LMIIS()
    B = LMIIS()
    A = [LMIIS() for _ in range(N)]

    ans = 0
    for i in range(N):
        dot = C
        for a,b in zip(A[i],B):
            dot += a*b
        if dot > 0:
            ans += 1
    print(ans)

    

if __name__ == '__main__':
    main()

### FIXED CODE ###

#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7
    
    N,M,C = LMIIS()
    B = LMIIS()
    A = [LMIIS() for _ in range(N)]

    ans = 0
    for i in range(N):
        dot = C
        for a,b in zip(A[i],B):
            dot += a*b
        if dot > 0:
            ans += 1
    print(ans)

    

if __name__ == '__main__':
    main()
N,K = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
for i in range(K):
  H[i] = 0
print(sum(H))

### FIXED CODE ###

N,K = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
print(sum(H[K:]))
a,b,c =map(int, input().split())

if(a==b and a!=c) or (a==c and a!=b) or (c==b and a!=c)
    print("yes")
else:
    print("no")

### FIXED CODE ###

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

if a==b and a!=c:
    print("Yes")
elif a==c and a!=b:
    print("Yes")
elif b==c and b!=a:
    print("Yes")
else:
    print("No")
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))

n = inN()
a = inL()

kab = 0
mon = 1000
f = []
i=0
state = 0
while(i < n-1):
    if i == 0:
        if a[i+1] > a[i]:
            f.append(1)
            state = 1
        else:
            f.append(0)
    elif state == 1:
        while(i<n-1 and a[i+1]>=a[i]):
            f.append(0)
            i+=1
        f.append(2)
        state = 0
    elif state == 0:
        while(i<n-1):
            if a[i+1]<=a[i]:
                f.append(0)
                i +=1
            else:
                f.append(1)
                i += 1
                state = 1
                break
    else:
        f.append(0)
    i += 1
f.append(2)
    
print(f)   
for i in range(n):

    if f[i] == 1 :
        kab += mon//a[i]
        mon = mon % a[i]
    elif f[i] == 2:
        mon += a[i]*kab
        kab = 0
    
print(mon)



### FIXED CODE ###

def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))

n = inN()
a = inL()

kab = 0
mon = 1000
f = []
i=0
state = 0
while(i < n-1):
    if state == 1:
        while(i<n-1):
            #print(a[i],a[i+1])
            if a[i+1]>=a[i]:
                f.append(0)
                i+=1
            else:
                f.append(2)
                #i+=1
                break
        state = 0
    elif state == 0:
        while(i<n-1):
            if a[i+1]<=a[i]:
                f.append(0)
                i +=1
            else:
                f.append(1)
                #i += 1
                state = 1
                break
    else:
        f.append(0)
    i += 1
f.append(2)
    
#print(f)   
for i in range(n):

    if f[i] == 1 :
        kab += mon//a[i]
        mon = mon % a[i]
    elif f[i] == 2:
        mon += a[i]*kab
        kab = 0
    
print(mon)
a=[]
b=[]
for _ in range(5):
    a.append(int(input()))
for i in  a:
    if i%10!=0:
        b.append(10-i%10)
b.remove(max(b))
c=sum(b)
print(sum(a)+c)
    

### FIXED CODE ###

a=[]
b=[]
for _ in range(5):
    a.append(int(input()))
for i in  a:
    if i%10!=0:
        b.append(10-i%10)
if b:
             
    b.remove(max(b))
c=sum(b)
print(sum(a)+c)
N = int(input())
str = "Christmas"
 
if N != 25:
	while N >= 22:
		str += " Eve"
        N -= 1
        
print(str)

### FIXED CODE ###

N = int(input())
str = "Christmas"
 
if N != 25:
	while N < 25:
		str += " Eve"
		N += 1
        
print(str)
s=input()
if(s[0]==s[1] & s[2]==s[3]):
  print("Yes")
elif(s[0]==s[2] & s[1]==s[3]):
  print("Yes")
elif(s[0]==s[3] & s[1]==s[2]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
if(s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]):
  print("Yes")
elif(s[0]==s[2] and s[1]==s[3] and s[0]!=s[3]):
  print("Yes")
elif(s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]):
  print("Yes")
else:
  print("No")
from math import gcd
n = int(input())
nums = list(map(int, input().split()))

prefix_gcd = []

prefix_gcd.append(nums[0])

for i in nums[1:]:
    prefix_gcd.append(gcd(i,prefix_gcd[-1]))

postfix_gcd = []
postfix_gcd.append(nums[-1])

for j in range(n-2,-1,-1):
    postfix_gcd.append(gcd(nums[j],postfix_gcd[-1]))

postfix_gcd = postfix_gcd[::-1]

ans = 1

for i in range(n):
    # del i
    if i == 0:
        ans = max(ans,postfix_gcd[i+1])
    elif i == n-1:
        ans = max(ans,prefix_gcd[i-1])
    else:
        ans = max(ans, gcd(prefix_gcd[i-1], postfix_gcd[i+1]))
print(ans)


### FIXED CODE ###

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


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

prefix_gcd = []

prefix_gcd.append(nums[0])

for i in nums[1:]:
    prefix_gcd.append(gcd(i,prefix_gcd[-1]))

postfix_gcd = []
postfix_gcd.append(nums[-1])

for j in range(n-2,-1,-1):
    postfix_gcd.append(gcd(nums[j],postfix_gcd[-1]))

postfix_gcd = postfix_gcd[::-1]

ans = 1

for i in range(n):
    # del i
    if i == 0:
        ans = max(ans,postfix_gcd[i+1])
    elif i == n-1:
        ans = max(ans,prefix_gcd[i-1])
    else:
        ans = max(ans, gcd(prefix_gcd[i-1], postfix_gcd[i+1]))
print(ans)
n = int(input())
num = map (str(n))

if num[print(len(n))] == [2, 4, 5, 7, 9]:
	print("hon")
elif num[print(len(n))] == [0, 1, 6, 8]:
	print("pon")
else:
	print("bon")

### FIXED CODE ###

n = str(input())
num = int(n[-1])

if num in [2, 4, 5, 7, 9]:
    print("hon")
elif num in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
m,a,r,c,h = 0
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h	

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = input()
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(N):
	S = raw_input()
	if S[:1] == "M":
		m += 1
	elif S[:1] == "A":
		a += 1
	elif S[:1] == "R":
		r += 1
	elif S[:1] == "C":
		c += 1
	elif S[:1] == "H":
		h += 1
print m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h
import sympy as sp
import heapq as hq
N = int(input())
A = sp.factorint(N)
B = []
hq.heapify(B)
for i,j in A.items():
    while j != 0:
        hq.heappush(B,i)
        j -= 1
leng = len(B)
if leng == 1:
    print(B[0]-1)
    exit()

while leng > 2:
    a = hq.heappop(B)
    b = hq.heappop(B)
    hq.heappush(B,a*b)
    leng -= 1
print(sum(B)-2)

### FIXED CODE ###

N = int(input())
ans = []
for i in range(1,int(pow(N,0.5))+1):
    j = N//i
    if i*j == N:
        ans.append(i+j)

print(min(ans)-2)
N = int(input())

A = [int(input()) for _ in range(N)]
Ans = 0

for i in range(N):
    v += 1 / a[i]
print(1 / Ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
 
ans = 0
 
for i in range(N):
    ans = ans + 1 / A[i]
 
ans = 1 / ans 
 
print(ans)
s = [int(input()) for i in range(3)]
if s[0] == 1:
    print('Hello World')
if s[0] == 2:
    print(int(s[1] + s[2]))

### FIXED CODE ###

age = int(input())
if age == 1:
    print('Hello World')
    
if age == 2:
    s = [int(input()) for i in range(2)]
    print(int(s[0] + s[1]))
import math
N,K = map(int,input().split())
if N > 3000:
  raise IndexError
cnt = 0
for n in range(1,N+1):
    if K/n <= 1:
        x = 0
    elif math.log(K/n)%math.log(2)<=0.00001:
        x = (math.log(K)-math.log(n))//math.log(2)
    else:
        x = (math.log(K)-math.log(n))//math.log(2)+1
    cnt += (0.5)**x
 
print(cnt/N)

### FIXED CODE ###

import math
N,K = map(int,input().split())
cnt = 0
for n in range(1,N+1):
    x = 0
    while n*(2**x) < K:
        x += 1
    cnt += (0.5)**x

print(cnt/N)
def son():
    h,w=map(int,input().split())
    c=[]
    for i in range(10):
        l=[int(i) for i in input().split()]
        c.append(l)
    a=[]
    for i in range(h):
        l=[int(i) for i in input().split()]
        a.append(l)
    p=[0]*10
    for i in range(10):
        if i==1: continue
        d=[1003]*10
        d[i]=0
        q=set([i])
        while 1:
            if len(q)==0: break
            x=q.pop()
            for j in range(10):
                if i==j: continue
                if (d[j]>d[x]+c[x][j]):
                    d[j]=d[x]+c[x][j]
                    q.add(j)
        p[i]=d[1]
    ans=0
    for i in range(h):
        for j in range(w):
            if a[i][j]==-1: pass
            else: ans+=p[a[i][j]]
    print(ans)

if __name__=="__main__":
    sol()


### FIXED CODE ###

h,w=map(int,input().split())
c=[]
for i in range(10):
    l=[int(i) for i in input().split()]
    c.append(l)
a=[]
for i in range(h):
    l=[int(i) for i in input().split()]
    a.append(l)
p=[0]*10
for i in range(10):
    if i==1: continue
    d=[1003]*10
    d[i]=0
    q=set([i])
    while 1:
        if len(q)==0: break
        x=q.pop()
        for j in range(10):
            if i==j: continue
            if (d[j]>d[x]+c[x][j]):
                d[j]=d[x]+c[x][j]
                q.add(j)
    p[i]=d[1]
ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]==-1: pass
        else: ans+=p[a[i][j]]
print(ans)
a = int(input())
b = int(input())

if (1 <= a <= 9) and (1<= b <= 9):
  print("{}".format(a*b))
else:
  print("{}".format(-1))


### FIXED CODE ###

x = input().split()

a = int(x[0])
b = int(x[1])

if (1 <= a <= 9) and (1<= b <= 9):
  print("{}".format(a*b))
else:
  print("{}".format(-1))
n, m = map(int, input().split())

scores = [[0, False] for _ in range(n)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)


### FIXED CODE ###

n, m = map(int, input().split())

scores = [[0, False] for _ in range(n+1)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

a,b=input.split()
b.remove(".")
ans=int(a)*int(b)
print(ans//100)


### FIXED CODE ###

from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

a,b=input().split()
b=b.replace(".","")
ans=int(a)*int(b)
print(ans//100)
import sys
A, B, C = map(int,input())
for i in range(B):
    if A * i % B == C:
        print('YES')
        sys.exit()
print('NO')

### FIXED CODE ###

import sys
A, B, C = map(int,input().split())
for i in range(B):
    if A * i % B == C:
        print('YES')
        sys.exit()
print('NO')
A, B = map(int, input().split())
a, b = input().split("-")
if len(a)==A and len(b)==B:
    print("Yes")
    exit()
print("No")


### FIXED CODE ###

A, B = map(int, input().split())
s = input()
for i in range(len(s)):
    if i<A and s[i]=='-':
        print("No")
        exit()
    elif i==A and s[i]!='-':
        print("No")
        exit()
    elif A<i<=A+B and s[i]=='-':
        print("No")
        exit()
print("Yes")
from functools import lru_cache
import sys
sys.setrecursionlimit(5000)
INF = float('inf')

N = int(input())
h = list(map(int, input().split()))
n = len(h)-1

@lru_cache(maxsize=None)
def rec(i):
    if i==0:
        return 0
    res = INF
    res = min(res, rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        res = min(res, rec(i-2)+abs(h[i]-h[i-2]))
    return res
print(rec(n))

### FIXED CODE ###

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])