Harryxun/stf_run huggingface dataset:
def resolve():

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

    AA=Counter(A).most_common()

    ls=[]
    for i in range(len(AA)):
        if AA[i][1]>=2:
            ls.append(AA[i][0])

    ls.sort()
    try:
        print(ls[-1]*ls[-2])
    except:
        print(0)



resolve()

### FIXED CODE ###

# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys

sys.setrecursionlimit(10 ** 5 + 10)


# input = sys.stdin.readline

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    AA = Counter(A).most_common()

    ls = []
    for i in range(len(AA)):
        if AA[i][1] >= 2:
            ls.append(AA[i])
        else:
            break

    ls=sorted(ls, key=lambda x: x[0])

    try:
        ans = ls[-1][0] * ls[-2][0]
        for i in reversed(range(len(ls))):
            if ls[i][1] >= 4:
                ans = max(ans, ls[i][0] ** 2)
        print(ans)
    except:
        print(0)


resolve()
from collections import defaultdict
n, m = map(int, input().split())
nums = [int(i) for i in input().split()]

num_freq = defaultdict(int)

for _ in range(m):
    b, c = map(int, input().split())
    num_freq[c] += b


new_list = []
for num, freq in sorted(num_freq.items(), key=lambda x: -x[0]):
    new_list += [num] * freq
    if len(new_list) >= n:
        break
tmp = sorted(nums + new_list)[::-1]
print(sum(tmp[:n]))


### FIXED CODE ###

# from collections import defaultdict
# n, m = map(int, input().split())
# nums = [int(i) for i in input().split()]
#
# num_freq = defaultdict(int)
#
# for _ in range(m):
#     b, c = map(int, input().split())
#     num_freq[c] += b
#
#
# new_list = []
# for num, freq in sorted(num_freq.items(), key=lambda x: -x[0]):
#     new_list += [num] * freq
#     if len(new_list) >= n:
#         break
# tmp = sorted(nums + new_list)[::-1]
# print(sum(tmp[:n]))

# ↑と同じ処理なのに↑のはREになる
n, m = map(int, input().split())
nums = list(map(int, input().split()))
exc = []

for i in range(m):
    exc.append(list(map(int, input().split())))
exc.sort(key=lambda x: x[1], reverse=True)
e = []
count = 0
for i in range(m):
    freq = exc[i][0]
    e += [exc[i][1]] * freq
    count += freq
    if count >= n:
        break
cards = sorted(nums + e, reverse=True)
print(sum(cards[:n]))
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    return 

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        return 

print(Π)

### FIXED CODE ###

import sys

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

if 0 in A:
    print(0)
    sys.exit(0) 

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        sys.exit(0)

print(Π)
kazu,sozai =  map(int,input().split())

for i in kazu:

    titi = max(int(sozai))
    haha = min(int(sozai))

    int(sozai).remove(titi)
    int(sozai).remove(haha)

    son = (titi + haha)/2 

    sozai.add(str(son))

print(str(sozai))



### FIXED CODE ###

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

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

print(son)
n,k=map(int,input())
s=list(input())
s[k-1]=s[k-1].lower()
print(''.join(s))

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print(''.join(s))
l = [int(i) for i in input().split(" ")]
print((l[0]-1)*(l[1]-1))
l = [int(i) for i in input().split(" ")]
print((l[0]-1)*(l[1]-1))


### FIXED CODE ###

l = [int(i) for i in input().split(" ")]
print((l[0]-1)*(l[1]-1))
a,b,c=input().split()
count=0
for i in range(a,b+1) :
    if c%i == 0:
        count += 1
print(count)

### FIXED CODE ###

a,b,c=map(int,input().split())
d=[i for i in range(a,b+1)]
count=0
for i in d:
    if c%i==0:
        count+=1
print(count)
N = int(input())
H = list(map(int, input().split()))

result = []

for i in range(N-1):
    ans = 0
    for j in range(N-i-1):
        if H[i + j] >= H[i + j + 1]: 
            ans += 1
        else:
            break
    if ans >= (N-i-2):
        print(ans)
        exit()
    else:
        result.append(ans)

print(max(result))


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 0
result = 0

for i in range(N-1):
    if H[i] >= H[i+1] and i == N-2:
        ans += 1
        if result < ans:
            result = ans
    elif H[i] >= H[i+1]:
        ans +=1
    else:
        if result < ans:
            result = ans
        ans = 0

print(result)
N, M = map(int, input().split())
edge = [[] for _ in range(M)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

def dp(v,dpv,e):
    if dpv[v] != -1:
        return dpv[v]
    if len(e[v])==0:
        dpv[v]=0
        return 0
    res = 0
    for w in e[v]:
        res = max(dp(w,dpv,e),res)
    res += 1
    dpv[v] = res
    return res

def solve(edge):
    dpv = [-1]*N
    for i in range(N):
        dp(i,dpv,edge)
    ans = max(dpv)
    return ans
print(solve(edge))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

def dp(v,dpv,e):
    if dpv[v] != -1:
        return dpv[v]
    if len(e[v])==0:
        dpv[v]=0
        return 0
    res = 0
    for w in e[v]:
        res = max(dp(w,dpv,e),res)
    res += 1
    dpv[v] = res
    return res

def solve(edge):
    dpv = [-1]*N
    for i in range(N):
        dp(i,dpv,edge)
    ans = max(dpv)
    # print(dpv)
    return ans
print(solve(edge))
from collections import Counter

n=int(input())
s=list(input(i).split() for i in range(n))

counter = Counter(s)
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

print(*names, sep='\n')

### FIXED CODE ###

from collections import Counter

stdin = open(0)
N = int(stdin.readline())
S = stdin.read().split()

counter = Counter(S)
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

print(*names, sep='\n')
import heapq


def solve(N, ABs):
    # print(N, ",", ABs)
    taken = {i: False for i in range(N)}
    As = [(ab[0], i) for i, ab in enumerate(ABs)]
    Bs = [(ab[1], i) for i, ab in enumerate(ABs)]
    heapq.heapify(As)
    heapq.heapify(Bs)
    ans = 0
    taken_count = 0
    for _ in range(N // 2 + 1):
        if taken_count >= N:
            break
        if not len(As):
            break
        am = As.pop(len(As) - 1)
        while taken[am[1]]:
            am = As.pop(len(As) - 1)

        if not len(Bs):
            ans += am[1]
            break

        bm = Bs.pop(len(Bs) - 1)
        while taken[bm[1]]:
            bm = Bs.pop(len(Bs) - 1)
        if am[1] == bm[1]:
            ans += am[0]
            taken[am[1]] = True
            taken_count += 1
            if len(Bs):
                bm = Bs.pop(len(Bs) - 1)
                while taken[bm[1]]:
                    bm = Bs.pop(len(Bs) - 1)
                ans -= bm[0]
                taken[bm[1]] = True
                taken_count += 1
        elif am[0] > bm[0]:
            ans += am[0]
            ans -= bm[0]
            taken[am[1]] = True
            taken[bm[1]] = True
            taken_count += 2
        elif am[0] < bm[0]:
            ans += bm[0]
            ans -= am[0]
            taken[am[1]] = True
            taken[bm[1]] = True
            taken_count += 2

    return ans


if __name__ == "__main__":
    N = int(input())
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(solve(N, ABs))


### FIXED CODE ###

def cheat_solve(N, ABs):
    Ds = sorted([ab[0] + ab[1] for ab in ABs], reverse=True)
    bsum = sum([ab[1] for ab in ABs])
    dsum = sum(Ds[::2])
    return dsum - bsum

if __name__ == "__main__":
    N = int(input())
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(cheat_solve(N, ABs))
def makeFibonacci(n):
    F = [None]*n
    F[0] = 1
    F[1] = 1
    for i in range(2, n):
        F[i] = F[i-1] + F[i - 2]
    return str(F[n-1])

n = int(input())
print(makeFibonacci(n))

### FIXED CODE ###

def makeFibonacci(n):
    if n <= 1:
        return str(1)
    F = [None]*(n+1)
    F[0] = 1
    F[1] = 1
    for i in range(2, n+1):
        F[i] = F[i-1] + F[i - 2]
    return str(F[n])

n = int(input())
print(makeFibonacci(n))
a,b=raw_input().split(" ")
if a<b: print("a < b")
elif a>b: print("a > b")
else print("a == b")

### FIXED CODE ###

a,b = input().split(" ")
a=int(a)
b=int(b)
if a<b :
	print("a < b")
elif a>b :
	print("a > b")
else :
	print("a == b")
n,m=map(int,input().split())
broken=[int(input()) for i in range(m)]
mod=10**9+7

dp=[0]*(n+1)
if 1 not in broken:
  dp[1],dp[2]=1,2
else:
  if 2 not in broken:
    dp[2]=1

for i in range(3,n+1):
  if i in broken:
    dp[i]=0
    
  elif  i-1 not in broken and i-2 not in broken:
    dp[i]=dp[i-1]+dp[i-2]
    dp[i]%=mod
    
  elif i-1 not in broken:
    dp[i]=dp[i-1]
    dp[i]%=mod
    
  elif i-2 not in broken:
    dp[i]=dp[i-2]
    dp[i]%=mod
    
  else:
    dp[i]=0
print(dp[n])

### FIXED CODE ###

n,m=map(int,input().split())
broken=[int(input()) for i in range(m)]
mod=10**9+7

is_broken=[True]*(n+1)
for i in range(m):
  is_broken[broken[i]]=False
   
dp=[0]*(n+1)
dp[0]=1
if is_broken[1]:
  dp[1]=dp[0]
  
for i in range(2,n+1):
    if is_broken[i]:
       dp[i]=dp[i-1]+dp[i-2]
       dp[i]%=mod
    else:
      dp[i]=0
      
print(dp[n])
def main(a, b, c, x):

    def gen(coin, n_of_coins, x_parts):
        for x_part in x_parts:
            for i in range(n_of_coins + 1):
                new_x_part = x_part + coin * i
                yield new_x_part

    x_maybe_iter = gen(50, c, gen(100, b, gen(500, a, [0])))
    patterns = sum(x_maybe == x for x_maybe in x_maybe_iter)
    return patterns


if __name__ == '__main__':
    a, b, c, x = [int(input()) for _ in range(4)]
    print(main(a, b, c, x))


### FIXED CODE ###

def main():
    x, a, b = [int(input()) for i in range(3)]
    ans = (x - a) % b
    print(ans)


if __name__ == "__main__":
    main()
from math import floor
import sys
sys.setrecursionlimit(500000)
T = int(input())
for i in range(T):
    if B > D:
        print("No")
    else:
        memo = {}
        def buy(A):
            if A < B:
                return False
            else:
                if A % B > C:
                    return False
                else:
                    A = floor((C-A%B)/B)*B+A%B+D%B
                    if A not in memo:
                        memo[A] = 0
                        return buy(A)
                    else:
                        return(True)
        A,B,C,D = map(int,input().split())
        if buy(A):
            print("Yes")
        else:
            print("No")




### FIXED CODE ###

from math import floor
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D or B > A:
        print("No")
    else:
        if A%B>C:
            print("No")
        else:
            d = gcd(B,D%B)
            r = (A%B)%d
            if B - d + r > C:
                print("No")
            else:
                print("Yes")
N, K = map(int, input().split())
S = input()
M = [[0], [0]]
start = int(S[0])
M[start].append(1)
prev = start
for s in S[1:]:
    if int(s) == prev:
        M[prev][-1] += 1
    else:
        prev = (prev + 1) % 2
        M[prev].append(M[prev][-1] + 1)
if len(M[0]) - 1 <= K:
    print(N)
else:
    ans = 0
    if start == 0:
        for i in range(len(M[1]) - K):
            ns = M[0][i + K] - M[0][i]
            hs = M[1][i + K] - M[1][i]
            ans = max(ans, ns + hs)
    else:
        for i in range(len(M[0]) - K):
            ns = M[0][i + K] - M[0][i]
            hs = M[1][i + K + 1] - M[1][i]
            ans = max(ans, ns + hs)
    print(ans)

### FIXED CODE ###

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

left = 0
right = 0
op = 0
prev = '1'
ans = 0
while right < N:
    while right < N:
        if prev == '1' and S[right] == '0':
            op += 1
            if op > K:
                break
        prev = S[right]
        right += 1
    ans = max(ans, right - left)
    prev = S[left]
    while left < right:
        if prev == '0' and S[left] == '1':
            break
        prev = S[left]
        left += 1
    op -= 1
print(ans)
n = map(int, input().split())
a = 0
while n > 0:
    a += n
    n -= 1
print(a)


### FIXED CODE ###

n = int(input())
a = 0
while n > 0:
    a += n
    n -= 1
print(a)
a=raw_input()
print(48-int(a))

### FIXED CODE ###

a=input()
print(48-int(a))
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
d={}
for a in A:
    if a in d:
        d[a]+=1
    else:
        d[a]=1

ans=0
for i in range(N):
    a=A[i]
    p=1
    if d[a]>1:
        continue
    for j in range(2,int(a**0.5)+1):
        if a%j==0:
            if j in d or a//j in d:
                p=0
                break
    ans+=p

if A[-1]==1:
    if A[-2]>1:
        ans=1
    else:
        ans=0
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
M=max(A)+1
table=[0 for _ in range(M)]

for i in range(N):
    if i>0 and A[i]==A[i-1]:
        table[A[i]]=0
        continue
    table[A[i]]=1
    for n in range(2,M):
        if A[i]*n>=M:
            break
        table[A[i]*n]=0
print(sum(table))
a,b = map(input().split())
if a > 9 or b > 9:
  print(-1)
  exit()
print(a*b)

### FIXED CODE ###

a,b = map(int,input().split())
if a > 9 or b > 9:
  print(-1)
  exit()
print(a*b)
# D - Coloring Edges on Tree

N = int(input())
G = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append((b, i))
    G[b].append((a, i))

ans = [-1] * (N - 1)

def dfs(key, color=-1, parent=-1):
    k = 1
    for i in range(len(G[key])):
        if G[key][i][0] == parent:
            continue
        if color == k:
            k += 1
        ans[G[key][i][1]] = k
        dfs(G[key][i][0], k, key)
        k += 1

dfs(0)

print(max(ans))
for a in ans:
    print(a)


### FIXED CODE ###

# D - Coloring Edges on Tree

import sys

sys.setrecursionlimit(10 ** 5)

N = int(input())
G = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append((b, i))
    G[b].append((a, i))

ans = [-1] * (N - 1)

def dfs(key, color=-1, parent=-1):
    k = 1
    for i in range(len(G[key])):
        if G[key][i][0] == parent:
            continue
        if color == k:
            k += 1
        ans[G[key][i][1]] = k
        dfs(G[key][i][0], k, key)
        k += 1

dfs(0)

print(max(ans))
for a in ans:
    print(a)
#coding:utf-8
s = input()
k = int(input())


if len(set(s))==1:
    print ((len(s)*k)//2)
    exit()

old = ""
ans = 0
for i in range(len(s)):
    if(s[i]==old):
        ans+=1
        old = ""
    else:
        old = s[i]



head = 0
for i in range(len(s)):
    if head==0 or s[i]==s[i-1]:
        head+=1
    else:
        break

tail = 0
t = s[::-1]
for i in range(len(t)):
    if tail==0 or t[i]==t[i-1]:
        tail+=1
    else:
        break

print (ans*k-(k-1)*(head//2)+tail//2)-((head+tail)//2)))



### FIXED CODE ###

#coding: utf-8
s = input()
k = int(input())

if len(set(s))==1:
  print((len(s)*k)//2)
  exit()

dup = [1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:
    dup[-1]+=1
  else:
    dup.append(1)
    
ans = 0
for i in dup:
  ans += (i//2)*k

if s[0]==s[-1]:
  ans += ((dup[0]+dup[-1])//2 - (dup[0]//2+dup[-1]//2))*(k-1)

print(ans)
aa

### FIXED CODE ###

n=int(input())
s=input()
for i in range(len(s)):
  ss=(ord(s[i])+n)
  if ss>90:
    ss=ss-26
  print(chr(ss),end="")
def f(D):
    i = 0
    s = 0
    D = D[D.index("1"):]
    for c in D:
        if c=="1": s += i
        i += 1
    p = "ABCDEF"[ptn.index(s)]
    return p
 
i=0
D=""
for s in sys.stdin:
    if i<8:
        i+=1
        D+=s[:-1]
    else:
        print f(D)
        i=0
        D=""
print f(D)

### FIXED CODE ###

import sys
ptn = [18,48,6,30,20,34,16]

def f(D):
    i = 0
    s = 0
    D = D[D.index("1"):]
    for c in D:
        if c=="1": s += i
        i += 1
    p = "ABCDEFG"[ptn.index(s)]
    return p

i=0
D=""
for s in sys.stdin:
    if i<8:
        i+=1
        D+=s[:-1]
    else:
        print f(D)
        i=0
        D=""
print f(D)
s=input()
if s=="AKIHABARA":
    print("YES")
else:
    ans="YES"
    if len(s)>9 or (len(s)==9 and s!="AKIHABARA") or "KIH" not in s:
        ans="NO"
    else:
        s.remove("A")
        if s!="KIHBR":
            ans="NO"
        else:
            k,b,r=s.find("K"),s.find("B"),s.find("R")
            if k>1 or b-k>4 or r-b>2:
                ans="NO"
    print(ans)

### FIXED CODE ###

s=input()
if s=="AKIHABARA":
    print("YES")
else:
    ans="YES"
    if len(s)>=9 or "KIH" not in s:
        ans="NO"
    else:
        t=s.replace("A","")
        if t!="KIHBR":
            ans="NO"
        else:
            k,b,r=s.find("K"),s.find("B"),s.find("R")
            if k>1 or b-k>4 or r-b>2:
                ans="NO"
    print(ans)
abc = sorted(list(map(int, input().split())))
print(`Yes` if abc[0]+abc[1] == abc[2] else `No`)


### FIXED CODE ###

abc = sorted(map(int, input().split()))
print ('Yes' if abc[0]+abc[1] == abc[2] else 'No')
x = input()

if x<1200:
    print("ABC")
else:
    print("ARC")

### FIXED CODE ###

x = int(input())

if x<1200:
    print("ABC")
else:
    print("ARC")
box = list(map(int,input().split()))
box.reverse()
for x in box:
    print(x,end = " \0")
print("\n",end = "\0"

### FIXED CODE ###

box = list(map(int,input().split()))
print("%d %d %d"%(box[2],box[0],box[1]))
N = int(input())
S = input()

I = []
J = []
K = []

for n in range(1,N+1):
  if S[n-1] == "R":
    I.append(n)
  elif S[n-1] == "G":
    J.append(n)
  else:
    K.append(n)
    
cnt = 0
for a in I:
  for b in J:
    for c in K:
      ls = [a,b,c]
      ls.sort()a
      if ls[1] - ls[0] != ls[2] - ls[1]:
        cnt += 1
    
print(cnt)

### FIXED CODE ###

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

ans = S.count("R") * S.count("G") * S.count("B")

for i in range(1,N-1):
  for j in range(i+1,N):
    k = 2 * j - i
    if k > N:
      break
    if S[i-1] != S[j-1] and S[j-1] != S[k-1] and S[k-1] != S[i-1]:
      ans -= 1
      
print(ans)
def sovle(s):
	if len(s) == 0:
		return 0
	l = len(s)
	ans = 0
	for i in range(1, l+1):
		left = s[:i]
		right = s[i:]
		ans += int(left) + solve(right)
	return ans

s = input().strip()
print(solve(s))



### FIXED CODE ###

def solve(s):
	if len(s) == 0:
		return 0, 1
	l = len(s)
	ans = 0
	cnt = 0
	for i in range(1, l+1):
		left = s[:i]
		right = s[i:]
		a, b = solve(right)
		ans += int(left) * b + a
		cnt += b
	return ans, cnt

s = input().strip()
ans, _ = solve(s)
print(ans)
N,Q = list(map(int, input().split(" ")))
v_list = [0 for _ in range(N)] # n-1でやること注意
dic_tree = {}
for i in range(N):
    dic_tree[i+1] = [] 

for i in range(N-1):
    a, b = list(map(int, input().split(" ")))
    dic_tree[a].append(b)

# make tree
for k in reversed(range(N)):
    if len(dic_tree) == 0:
        continue
    
    for node in dic_tree[k+1]:
        dic_tree[k+1].extend(dic_tree[node])
        
# add 1 
dic_tree[1].append(1)
    
for i in range(Q):
    p, x = list(map(int, input().split(" ")))
    
    for i in dic_tree[p]:
        v_list[i-1] += x

print(" ".join(map(str, v_list))

### FIXED CODE ###

from collections import deque

N,Q = list(map(int, input().split()))
tre = [[] for _ in range(N)]
val = [0] * N
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tre[a-1].append(b-1)
    tre[b-1].append(a-1)

for i in range(Q):
    p,x = list(map(int, input().split()))
    val[p-1] += x

stack = deque([0])
visited = [False] * N
visited[0] = True
while stack:
    cur = stack.pop()
    for target in tre[cur]:
        if visited[target]:
            continue
        visited[target] = True
        stack.append(target)
        val[target] += val[cur]

print(*val)
a,b=input()
print(max(a+b,a-b,a*b))


### FIXED CODE ###

a,b=map(int,input().split())
print(max(a + b,a - b,a * b))
N=int(input())
for a in range(0,10):
  if N%a==0 and N/a<=9:
    print("Yes")
    break
  else:
    if a>=10:
      print("No")
    


### FIXED CODE ###

n = int(input())
for i in range(1,10):
  if n%i==0 and n/i < 10:
    print("Yes")
    break
else:
  print("No")
def main():
    def flatten_list(l):
        for el in l:
            if isinstance(el, list):
                yield from flatten_list(el)
            else:
                yield el
    H, W = list(map(int, input().split()))
    n = int(input())
    A = list(map(int, input().split()))
    ans = []
    for i, a in enumerate(A):
        ans .append([str(i + 1)] * a)
    ans = list(flatten_list(ans))
    ans = [ans[i:i + W] if i // W % 2 == 0 else ans[i + W - 1:i - 1:-1] for i in range(0, len(ans), W)]
    [print(' '.join(a)) for a in ans]



if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    def flatten_list(l):
        for el in l:
            if isinstance(el, list):
                yield from flatten_list(el)
            else:
                yield el
    H, W = list(map(int, input().split()))
    n = int(input())
    A = list(map(int, input().split()))
    ans = []
    for i, a in enumerate(A):
        ans .append([str(i + 1)] * a)
    ans = list(flatten_list(ans))
    ans = [ans[i:i + W] if i // W % 2 == 0 else ans[i + W - 1:i - 1:-1] for i in range(0, len(ans), W)]
    [print(' '.join(a)) for a in ans]

if __name__ == '__main__':
    main()
n = input()
for i in range(1,n+1):
    if(i%3==0):
        print('%d'%(i) )


### FIXED CODE ###

n = int(input())
print(" ",end="")
print(*[i for i in range(1,1+n) if i%3==0 or'3' in str(i)])
def lcd(x0, y0):
    lx, ly = len(x0), len(y0)
    memo = [[None] * ly for _ in range(lx)]

    def memoize(x, y):
        if x < 0 or y < 0:
            return 0
        if memo[x][y] is not None:
            return memo[x][y]
        result = memo[x][y] = main(x, y)
        return result

    def main(x, y):
        return memoize(x - 1, y - 1) + 1 if x0[x] == y0[y] else max(memoize(x - 1, y), memoize(x, y - 1))

    return main(lx - 1, ly - 1)


n = int(input())
while n:
    print(lcd(input(), input()))
    n -= 1

### FIXED CODE ###

n = int(input())
for _ in range(n):
    a, b = input(), input()
    indices = []
    for cb in b:
        bgn_idx = 0
        for i, cur_idx in enumerate(indices):
            chr_idx = a.find(cb, bgn_idx) + 1
            if not chr_idx:
                break
            if chr_idx < cur_idx:
                indices[i] = chr_idx
            bgn_idx = cur_idx
        else:
            chr_idx = a.find(cb, bgn_idx) + 1
            if chr_idx:
                indices.append(chr_idx)
    print(len(indices))
s = str(input())
T = str(input())
t_before = ''
for i in range(len(s)):
    t_before += t[i]

if s == t_before:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = str(input())
t = str(input())
t_before = ''
for i in range(len(s)):
    t_before += t[i]

if s == t_before:
    print('Yes')
else:
    print('No')
N = int(input())
nums=[int(input()) for _ in range(N)]
MAX = 10*4
dp = [0] * (MAX+1)
dp[0] = 1
for num in nums:
  for i in range(MAX+1)[::-1]:
    if dp[i] == 1:
      dp[i+num] = 1
ans = 0
for i in range(MAX+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)


### FIXED CODE ###

N = int(input())
INF =101
sum_num = 0
min_num = INF

for _ in range(N):
  num = int(input())
  if num%10 != 0:
    min_num = min(min_num, num)
  sum_num += num
if min_num == INF:
  print(0)
elif sum_num%10 == 0:
  print(sum_num-min_num)
else:
  print(sum_num)