Harryxun/stf_run huggingface dataset:
size = int(input())
stones = [int(val) for val in input().split()]

memo = [-1] * size

memo[0] = 0
memo[1] = abs(stones[0] - stones[1])

def ans(n):
	if memo[n] != -1:
		return memo[n]
	else:
		memo[n] = min(
			ans(n - 1) + abs(stones[n] - stones[n - 1]),
			ans(n - 2) + abs(stones[n] - stones[n - 2])
		)
		return memo[n]

print(ans(size - 1))



### FIXED CODE ###


size = int(input())
stones = [int(val) for val in input().split()]
memo = [-1] * (size + 5)

def ans(n):
	if memo[n] != -1:
		return memo[n]
	else:
		memo[n] = min(
			ans(n - 1) + abs(stones[n] - stones[n - 1]),
			ans(n - 2) + abs(stones[n] - stones[n - 2])
		)
		return memo[n]


def ans_iterative(n):
	if memo[n] != -1:
		return memo[n]
	else:
		for idx in range(2, n):
			memo[idx] = min(
				memo[idx - 1] + abs(stones[idx] - stones[idx - 1]),
				memo[idx - 2] + abs(stones[idx] - stones[idx - 2])
			)
		return memo[n - 1]


if size == 1:
	print(0)
else:
	memo[0] = 0
	memo[1] = abs(stones[0] - stones[1])
	print(ans_iterative(size))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    s = input('')
    if s == '':
        break
    cut_ss = [s[i:i+3] for i in range(len(s[:-2]))]

    n_joi = 0
    n_ioi = 0
    for cut_s in cut_ss:
        if cut_s == 'JOI':
            n_joi += 1
        if cut_s == 'IOI':
            n_ioi += 1

    print(n_joi)
    print(n_ioi)

### FIXED CODE ###

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

while True:
    try:
        input_s = input()
    except:
        break

    s_list = [input_s[i:i+3] for i in range(len(input_s[:-2]))]

    n_joi = 0
    n_ioi = 0
    for s in s_list:
        if s == 'JOI':
            n_joi += 1
        if s == 'IOI':
            n_ioi += 1

    print(n_joi)
    print(n_ioi)
N, M = map(int, input().split())

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

X = []

for i in range(0, M):
    B, C = map(int, input().split())
    X.append([C, B])

X.sort(reverse=True)

A.sort()

index = 0
l = 0
a = 0
k = X[a][0]

while A[index] < k and index < N and a < M:
    A[index] = k;
    index += 1;
    l += 1;
    if(l == X[a][1]):
        a += 1
        if a >= M:
            break
        k = X[a][0]
        l = 0

print(sum(A))


### FIXED CODE ###

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

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

X = []

for i in range(0, M):
    B, C = map(int, input().split())
    X.append([C, B])

X.sort(reverse=True)

A.sort()

index = 0
l = 0
a = 0
k = X[a][0]

while index < N and a < M and A[index] < k:
    A[index] = k;
    index += 1;
    l += 1;
    if(l == X[a][1]):
        a += 1
        if a >= M:
            break
        k = X[a][0]
        l = 0

print(sum(A))
def search(i, h, dp):
	if i == 0 or i == 1:
		return dp[i]
	if dp[i] < float('inf'):
		return dp[i]
	a = search(i - 1, h, dp) + abs(h[i] - h[i-1])
	b = search(i - 2, h, dp) + abs(h[i] - h[i-2])
	dp[i] = min(a, b)
	return dp[i]

def resolve():
	N = int(input())
	H = list(map(int, input().split()))
	DP = [float('inf')]*N
	DP[0], DP[1] = 0, abs(H[0] - H[1])
	print(search(N-1, H, DP))
resolve()

### FIXED CODE ###

def resolve():
	N = int(input())
	H = list(map(int, input().split()))
	DP = [-1]*N
	DP[0], DP[1] = 0, abs(H[0] - H[1])
	for i in range(2, N):
		a = DP[i-2] + abs(H[i] - H[i-2])
		b = DP[i-1] + abs(H[i] - H[i - 1])
		DP[i] = min(a, b)
	print(DP[-1])
resolve()
a=int(input())
import math
print(math.factorial(n)%(10**9+7))

### FIXED CODE ###

import math
n=int(input())
print(math.factorial(n)%1000000007)
n = int(input())
a = list(map(int,input().split()))

n = 1

for i in a:
    n *= i
    if n > 10**18:
        print('-1')
        break
else:
    print(n)


### FIXED CODE ###

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

print(a[0]*a[1])
inp = map(int, input().split())
inp = list(inp)
hard = 0
for number in range(0, 3) :
  if inp[number] == inp[number + 1] :
    hard = 1
    
if hard == 0 :
  print ("Good")
else :
  print ("Bad)

### FIXED CODE ###

inp = list(input())
hard = 0
for number in range(0, 3) :
  if inp[number] == inp[number + 1] :
    hard = 1
    
if hard == 0 :
  print("Good")
else :
  print("Bad")
N, K = map(int,input().split())
A = list(map(int,input().split()))
X = [-1 for j in range(N)]
X[0] = 0
Y = [0]
i = 0
Num = 0
MM = 0
for k in range(1,N):
  i = A[i]-1
  if k == K:
    MM = 1
    P = i
  elif X[i] != -1:
    Num = X[i]
    break
  else:
    X[i] = k
    Y.append(i)
Y = Y[Num:]
B = (K-Num)%len(Y)
if MM == 1:
  print(P+1)
else:
  print(Y[B]+1)

### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
X = [-1 for j in range(N)]
X[0] = 0
Y = [0]
i = 0
Num = 0
MM = 0
for k in range(1,N):
  i = A[i]-1
  if k == K:
    MM = 1
    P = i
    break
  elif X[i] != -1:
    Num = X[i]
    break
  else:
    X[i] = k
    Y.append(i)
Y = Y[Num:]
B = (K-Num)%len(Y)
if MM == 1:
  print(P+1)
else:
  print(Y[B]+1)
import math
import itertools

n, m, q = map(int, input().split(" "))
aL = []
_max = 0

for i in range(q):
    aL.append(list(map(int, input().split(" "))))

li = []


def dfs(i, _n, p):
    if i == n:
        li.append(list(map(int, list(str(_n)))))
        return
    for j in range(p, m + 1):
        dfs(i + 1, _n * 10 + j, j)


if m != 1:
    for i in range(1, m + 1):
        dfs(1, i, i)
else:
    li = [[i] for i in range(1, n + 1)]

for t in li:
    if t[0] == 0:
        continue
    _sum = 0
    for a in aL:
        if t[a[1] - 1] - t[a[0] - 1] == a[2]:
            _sum += a[3]
    _max = max(_max, _sum)

print(_max)

### FIXED CODE ###

import math
import itertools

n, m, q = map(int, input().split(" "))
aL = []
_max = 0

for i in range(q):
    aL.append(list(map(int, input().split(" "))))

zLi = itertools.combinations_with_replacement(list(range(m + 1)), n)
for t in zLi:
    if t[0] == 0:
        continue
    _sum = 0
    for a in aL:
        if t[a[1] - 1] - t[a[0] - 1] == a[2]:
            _sum += a[3]
    _max = max(_max, _sum)

print(_max)
mod = 2019
l,r = map(int,input().split())

cnt = 0
tank = []
for i in range(l,r+1):
    tank.append(i%mod)
    cnt += 1
    if cnt >= 2020:
        break

res = 2019

n = len(tank)
for i in range(n):
    for j in range(i+1,n):
        res = min(res,tank[i]*tank[j]%mod)
print(res)

### FIXED CODE ###

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

s = sum(a)
p = 0
for i in range(n):
    if i%2 == 1:
        p += a[i]*2

q = s-p
for i in range(n):
    print(q)
    q = a[i]*2-q
D = input()
if D=="25":
    print("Christmas")
elif D =="24":
    print("Christmas Eve")
elif D =="23":
    print("Christmas Eve Eve")
elif D == "22"
    print("Christmas Eve Eve Eve")

### FIXED CODE ###

D = input()
if D=="25":
    print("Christmas")
elif D =="24":
    print("Christmas Eve")
elif D =="23":
    print("Christmas Eve Eve")
elif D == "22":
    print("Christmas Eve Eve Eve")
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[]
    PAL=[0 for i in range(M)]
    for i in reversed(range(M)):
        if 2*(i+1)>M:
            PAL[i]+=B[i]
            if B[i]==1:
                ANS.append(i+1)
        else:
            if PAL[i]!=B[i]:
                PAL[i]+=1
                ANS.append(i+1)
        for j in fact[i]:
                PAL[j]=(PAL[j]+PAL[i])%2
            
            
    print(len(ANS))
    print(' '.join(map(str,ANS)))

        



### FIXED CODE ###

#ABC134-D
if True:
    N=int(input())
    A=[int(i) for i in input().split()]
    fact=[[1] for i in range(N)]
    for i in range(2,N+1):
        k=2
        while k*i<=N:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    SUM=[0 for i in range(N)]
    ANS=[]
    for i in reversed(range(N)):
        if (i+1)*2>N:
            if A[i]==1:
                ANS.append(i+1)
                SUM[i]=A[i]
            for j in fact[i]:
                SUM[j-1]=(SUM[j-1]+A[i])%2
        else:
            if SUM[i]==1:
                if A[i]==1:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
            else:
                if A[i]==0:
                    continue
                else:
                    ANS.append(i+1)
                    SUM[i]=1
                    for j in fact[i]:
                        SUM[j-1]=(SUM[j-1]+1)%2
    print(len(ANS))
    print(' '.join(map(str,ANS)))
while 1:
        P = map(float,raw_input().split())
        x = (P[2]*P[4]-P[1]*P[5])/(P[0]*P[4]-P[1]*P[3])
        y = (P[2]*P[3]-P[0]*P[5])/(P[1]*P[3]-P[0]*P[4])
        x = x if x else 0
        y = y if y else 0
        print "{:.3f} {:.3f}".format(x,y)

### FIXED CODE ###

while 1:
        try:
                P = map(float,raw_input().split())
        except EOFError:
                break
        x = (P[2]*P[4]-P[5]*P[1])/(P[0]*P[4]-P[3]*P[1])
        y = (P[2]*P[3]-P[5]*P[0])/(P[1]*P[3]-P[4]*P[0])
        x = x if x else 0
        y = y if y else 0
        print "{:.3f} {:.3f}".format(x,y)
MOD=10**9
from decimal import Decimal
import sys
input=sys.stdin.readline
    
def w(i,m):
    cnt=0
    while(i>0 and i%m==0):
        i//=m
        cnt+=1
    return cnt

N=int(input())
A=[int(Decimal(input())*Decimal(MOD)) for i in range(N)]
dic=[{} for i in range(N)]
dp=[[0]*51 for i in range(51)]

for i in range(N):
    dic[i][2],dic[i][5]=w(A[i],2),w(A[i],5)
    dp[dic[i][2]][dic[i][5]]+=1

for i in reversed(range(51)):
    for j in reversed(range(51)):
        if i==50 and j==50:
            continue
        if i==50:
            dp[i][j]+=dp[i][j+1]
        elif j==50:
            dp[i][j]+=dp[i+1][j]
        else:
            dp[i][j]+=dp[i][j+1]+dp[i+1][j]-dp[i+1][j+1]
ans=0

for i in range(N):
    t,f=max(18-dic[i][2],0),max(18-dic[i][5],0)
    res=dp[t][f]
    if t<=a and f<=b:
        res-=1
    ans+=res
print(ans//2)

### FIXED CODE ###

from decimal import Decimal
import sys
input=sys.stdin.readline

    
def w(i,m):
    cnt=0
    while(i>0 and i%m==0):
        i//=m
        cnt+=1
    return cnt

N=int(input())
A=[int(Decimal(input())*Decimal(1000000000)) for i in range(N)]
dic=[None for i in range(N)]
dp=[[0]*51 for i in range(51)]

for i in range(N):
    d={}
    d[2],d[5]=w(A[i],2),w(A[i],5)
    dp[d[2]][d[5]]+=1
    dic[i]=d

for i in reversed(range(51)):
    for j in reversed(range(51)):
        if i==50 and j==50:
            continue
        if i==50:
            dp[i][j]+=dp[i][j+1]
        elif j==50:
            dp[i][j]+=dp[i+1][j]
        else:
            dp[i][j]+=dp[i][j+1]+dp[i+1][j]-dp[i+1][j+1]
ans=0

for i in range(N):
    d=dic[i]
    a,b=d[2],d[5]
    t,f=max(18-a,0),max(18-b,0)
    res=dp[t][f]
    if t<=a and f<=b:
        res-=1
    ans+=res
print(ans//2)
N = int(print())
A = int(print())

if (N%500) > A:
	 print("No")
else:
	print("Yes")


### FIXED CODE ###

N = int(input())
A = int(input())

if (N%500) > A:
	 print("No")
else:
	print("Yes")
import fractions

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

g = fractions.gcd(A, B)

C = []

for j in range(2, i+1):
    while True:
        if i%j == 0:
            i //= j
            C.append(j)
        else:
            break

print(len(set(C))+1)

### FIXED CODE ###

import fractions

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

x = fractions.gcd(A, B)

C = []

def cal(i):
    for j in range(2, int(-(-i**0.5//1))+1):
        while True:
            if i%j == 0:
                i //= j
                C.append(j)
            else:
                break
    if i != 1:
        C.append(i)
        
    return set(C)

print(1+len(cal(x)))
d = int(input())
c = list(map(int,input().split()))
ans = []
pen = [0]*26
sattemp = 0
sat = 0
sl = [list(map(int,input().split())) for i in range(d)]
for k in range(1,20):
    for i in range(d):
        s = sl[i]
        sp = sum(pen)
        temp = -(10**9)
        for j in range(26):
            if s[j]-(sp-pen[j])**k > temp:
                temp = s[j]-(sp-pen[j])**k
                tempans = j+1
        ans += [tempans]
        sattemp += s[tempans-1]-sp+pen[tempans-1]
        for j in range(26):
            pen[j] += c[j]
            pen[tempans-1] = 0
    if sattemp > sat:
        sat = sattemp
        fin = ans
    ans = []
    sattemp = 0
for i in fin:
    print(i)
# print(sat)

### FIXED CODE ###

d = int(input())
c = list(map(int,input().split()))
for i in range(d):
    s = list(map(int,input().split()))
    print(s.index(max(s))+1)
S = list(input())
x, y = map(int, input().split())
c = 0
p = 0
q = 0
now = 0
R = []
L = []
for i in range(len(S)):
    if S[i] == "T":
        if p != 0:
            R.append(p)
            p = 0
        elif q != 0:
            L.append(q)
            q = 0
        c += 1
    elif c == 0:
        now += 1
    elif c % 2 == 0:
        p += 1
    else:
        q += 1
if p != 0:
    R.append(p)
if q != 0:
    L.append(q)

dp_x = [[0]*(8000+sum(R)+now+2) for _ in range(len(R)+2)]
dp_y = [[0]*(8000+sum(L)+2) for _ in range(len(L)+1)]
c = 0
dp_x[0][8000] = 1
dp_y[0][8000] = 1
for i in range(1, len(R)+2):
    for j in range(8000-sum(R)-now, 8000+sum(R)+now+1):
        if i == 1:
            if j - now >= 0:
                if dp_x[i-1][j-now] == 1:
                    dp_x[i][j] = 1
        else:
            if j - R[i-2] >= 0:
                if dp_x[i-1][j-R[i-2]] == 1:
                    dp_x[i][j] = 1
            if j + R[i-2] <= 8000+sum(R)+now+1:
                if dp_x[i-1][j+R[i-2]] == 1:
                    dp_x[i][j] = 1

for i in range(1, len(L)+1):
    for j in range(8000-sum(L), 8000+sum(L)+1):
        if j - L[i-1] >= 0:
            if dp_y[i-1][j-L[i-1]] == 1:
                dp_y[i][j] = 1
        if j + L[i-1] <= 8000+sum(L)+1:
            if dp_y[i-1][j+L[i-1]] == 1:
                dp_y[i][j] = 1

if dp_x[len(R)+1][x+8000] == 1 and dp_y[len(L)][y+8000] == 1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys
S = list(input())
x, y = map(int, input().split())
c = 0
p = 0
q = 0
now = 0
R = []
L = []
for i in range(len(S)):
    if S[i] == "T":
        if p != 0:
            R.append(p)
            p = 0
        elif q != 0:
            L.append(q)
            q = 0
        c += 1
    elif c == 0:
        now += 1
    elif c % 2 == 0:
        p += 1
    else:
        q += 1
if p != 0:
    R.append(p)
if q != 0:
    L.append(q)

A = 2*(sum(R)+now)
B = 2*(sum(L))
dp_x = [[0]*(A+2) for _ in range(len(R)+2)]
dp_y = [[0]*(B+2) for _ in range(len(L)+1)]
c = 0
dp_x[0][sum(R)+now] = 1
dp_y[0][sum(L)] = 1
for i in range(1, len(R)+2):
    for j in range(A+2):
        if i == 1:
            if j - now >= 0:
                if dp_x[i-1][j-now] == 1:
                    dp_x[i][j] = 1
        else:
            if j - R[i-2] >= 0:
                if dp_x[i-1][j-R[i-2]] == 1:
                    dp_x[i][j] = 1
            if j + R[i-2] <= A+1:
                if dp_x[i-1][j+R[i-2]] == 1:
                    dp_x[i][j] = 1

for i in range(1, len(L)+1):
    for j in range(B+2):
        if j - L[i-1] >= 0:
            if dp_y[i-1][j-L[i-1]] == 1:
                dp_y[i][j] = 1
        if j + L[i-1] <= B+1:
            if dp_y[i-1][j+L[i-1]] == 1:
                dp_y[i][j] = 1

if A + 1 < x+sum(R)+now or x+sum(R)+now < 0:
    print("No")
    sys.exit()

if B + 1 < y+sum(L) or y+sum(L) < 0:
    print("No")
    sys.exit()

if dp_x[len(R)+1][x+sum(R)+now] == 1 and dp_y[len(L)][y+sum(L)] == 1:
    print("Yes")
else:
    print("No")
import math
N,K=map(int, input().split()) 
lst=[]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, K+1):
    lst.append((combinations_count(N-K+1, i)) * (combinations_count(K-i+(i-1), i-1)))
        
for i in range(K):
    print(lst[i]%(10**9+7))

### FIXED CODE ###

import math
n,k=map(int,input().split()) 

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod_num = 10 ** 9 + 7
for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(n-k+1, i) * comb(k-i+(i-1), i-1) % mod_num)
A,B=map(int,input().split())
C=list(input().split())
count= 0
for i in range (B):
	count=count+int(C[i])
if count>=A:
	print("Yes")
else: print("No")

### FIXED CODE ###

import math
a, b = map(int, input().split()) 
print(math.ceil(a/b))
x = int(input())

if x <10:
  print(x)
elif x<99:
  print(9)
elif x<999:
  print(9+(x-99))
elif x<9999:
  print(909)
elif x<99999:
  print(909+(x-9999))
elif x==100000:
  print(90909)

### FIXED CODE ###

x = input().split()


d = int(x[2])-(int(x[0])-int(x[1]))

if d>=0:
  print(d)
else:
  print(0)
N,A,B=map(int,input().split())
C=A+B
if (0<C<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue=("a"*A+"b"*B)*(10**100)
    number=queue.count("a",0,N)
    print(number)

### FIXED CODE ###

N,A,B=map(int,input().split())
if (0<A+B<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    if N%(A+B)<=A:
        c=(N//(A+B))*A+N%(A+B)
        print(c)
    else:
        d=(N//(A+B))*A+A
        print(d)
H,W = int(input()),int(input())
h,w = int(input()),int(input())

sum = H*W
ans = sum - h*W - w*H + (h*w)

print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
h,w = map(int,input().split())
ans = (H-h)*(W-w)
print(ans)
n = Input()
ht = false
for char in 'n':
       if char == ‘9’:
               ht = true

if ht :
     print(“Yes”)
else : 
    print(“No”)

### FIXED CODE ###

n = input()
if n.find("9") >= 0:
  print("Yes")
else:
  print("No")
#include <bits/stdc++.h>
using namespace std;

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<long long> vll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    ll n;
    cin >> n;
    ll now[n][2];
    ll a[n][n-1];
    rep(i,n){
        rep(j,n-1){
            cin >> a[i][j];
        }
    }
    ll end=n*(n-1)/2;
    ll nex=0;
    ll day=0;
    ll sumsiai=0;
    ll siaisuu=0;
    ll minusnex=0;
    while(1){
        day++;
        siaisuu=sumsiai;
        rep(i,n){
            if(now[i][0]==n-1 || now[i][1]== day){
                continue;
            }
            nex=a[i][now[i][0]];
            minusnex=nex-1;
            if(i+1==a[nex-1][now[minusnex][0]] && now[minusnex][1] != day){
                siaisuu+=1;
                now[i][0]+=1;
                now[i][1]=day;
                now[minusnex][1]=day;
                now[minusnex][0]+=1;
            }
        }
        if(siaisuu-sumsiai==0){
            cout << -1;
            break;
        }

    if(siaisuu==end){
        cout << day;
        break;
    }
    sumsiai=siaisuu;
    }
}

### FIXED CODE ###

from collections import deque

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

for i in range(n):
    for j in range(n-1):
        a[i][j]-=1
    a[i].reverse()
# print(a)
day=[0]*n
pair=[-1]*n

q=deque(range(n))

while q:
    me=q.popleft()
    if not a[me]:
        continue
    oppo=a[me].pop()
    if pair[oppo]==me:
        now=max(day[me],day[oppo])+1
        day[me]=now
        day[oppo]=now
        q.append(me)
        q.append(oppo)
    else:
        pair[me]=oppo


for i in range(n):
    if a[i]:
        print(-1)
        break
else:
    print(max(day))
N = int(input())
a = list(map(int,(input().split())))
from collections import Counter
c = Counter(a)
L = []
LL = []
for k in c.keys():
    if c[k] >= 2:
        L.append(k)
    if c[k] >= 4:
        LL.append(k)
if LL:
    M = max(LL)**2

if len(L) < 2:
    print(0)
else:
    L.sort(reverse=True)
    print(max(L[0]*L[1],M))

### FIXED CODE ###

N = int(input())
a = list(map(int,(input().split())))
from collections import Counter
c = Counter(a)
L = []
LL = []
for k in c.keys():
    if c[k] >= 2:
        L.append(k)
    if c[k] >= 4:
        LL.append(k)
M = 0 
if LL:
    M = max(LL)**2
if len(L) < 2:
    print(0)
else:
    L.sort(reverse=True)
    print(max(L[0]*L[1],M))
import numpy as np


def main():
    bingo_card = np.array([list(map(int, input().split())) for _ in range(3)])
    counter = int(input())

    for _ in range(counter):
        bingo_card = np.where(bingo_card == int(input()), 0, bingo_card)

    vertical_bingo = min(np.sum(bingo_card, axis=0)) == 0
    horizontal_bingo = min(np.sum(bingo_card, axis=1)) == 0

    diag_normal_bingo = bingo_card[0][0] == 0 and bingo_card[1][1] == 0 and bingo_card[2][2] == 0
    diag_reverse_bingo = bingo_card[0][2] == 0 and bingo_card[1][1] == 0 and bingo_card[2][0] == 0

    if vertical_bingo or horizontal_bingo or diag_normal_bingo or diag_reverse_bingo:
        print('Yes')
        exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

### FIXED CODE ###

table_1 = input().split()
table_2 = input().split()
table_3 = input().split()
bingo_card = table_1 + table_2 + table_3

N = int(input())

for _ in range(N):
    b = str(int(input()))
    if b in bingo_card:
        bingo_card[bingo_card.index(b)] = True
        
if bingo_card[0] == bingo_card[1] == bingo_card[2]:
    print('Yes')
elif bingo_card[3] == bingo_card[4] == bingo_card[5]:
    print('Yes')
elif bingo_card[6] == bingo_card[7] == bingo_card[8]:
    print('Yes')
elif bingo_card[0] == bingo_card[3] == bingo_card[6]:
    print('Yes')
elif bingo_card[1] == bingo_card[4] == bingo_card[7]:
    print('Yes')
elif bingo_card[2] == bingo_card[5] == bingo_card[8]:
    print('Yes')
elif bingo_card[0] == bingo_card[4] == bingo_card[8]:
    print('Yes')
elif bingo_card[2] == bingo_card[4] == bingo_card[6]:
    print('Yes')
else:
    print('No')
import sys
input = sys.stdin.readline

n,q=map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]

graph=[[] for _ in range(n+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value=[0]*(n+1)

for p,x in px:
    value[p]+=x

# print(value)
# print(graph)

def dfs(v,parent,add):
    value[v] += add
    # print(value)
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

ans=' '.join(map(str,value[1:]))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
# 遅延評価で加えてあげるだけ
 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
 
def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])
 
dfs(1,0,0)
 
answer = ' '.join(map(str,value[1:]))
print(answer)
s = input()

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    if s[0] == 'a':
      s = 'er' + s
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

### FIXED CODE ###

s = input()
dp = [0 for i in range(len(s)+1)]
dp[0] = 1
words = ['eraser', 'erase', 'dreamer', 'dream']

for i in range(len(s)):
  i += 1
  for sent in words:
    before = i - len(sent)
    if before < 0:
      continue
    if dp[before] == 1 and s[before:i] == sent:
      dp[i] = 1
print('YES' if dp[-1] else 'NO')