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

# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

#main
n=int(input())
#A,B,C=map(int,input().split())
S=[]
C={}
for a in range(n):
    s=input()
    if not s in C:
        C[s]=1
    else:
        C[s]+=1
A=[]
for a,b in C.items():
    A.append([b,a])
A.sort(key=lambda x:(-x[0],x[1]))
max_=A[0][0]
for a in A:
    if(a[0]!=max_):break
    print(a[1])
    




### FIXED CODE ###

n=int(input())
#A,B,C=map(int,input().split())
S=[]
C={}
for a in range(n):
    s=input()
    if not s in C:
        C[s]=1
    else:
        C[s]+=1
A=[]
for a,b in C.items():
    A.append([b,a])
A.sort(key=lambda x:(-x[0],x[1]))
max_=A[0][0]
for a in A:
    if(a[0]!=max_):break
    print(a[1])
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
cl=[int(i) for i in input().split()]
lst=[]
for i in al:
  for j in bl:
    lst.append(i+j)
lst.sort(reverse=True)
num=min(x*y,k)
lst=lst[:num]
L=[]
for i in cl:
  for j in lst:
    L.append(i+j)
L.sort(reverse=True)
for i in range(k):
  print(L[i])

### FIXED CODE ###

x,y,z,k=map(int,input().split())
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
cl=[int(i) for i in input().split()]
lst=[i+j for i in al for j in bl]
lst.sort(reverse=True)
num=min(x*y,k)
lst=lst[:num]
L=[i+j for i in cl for j in lst]
L.sort(reverse=True)
for i in range(k):
  print(L[i])
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
a.sort()
count = 0
ans = []
for i in range(n):
  for j in range(n-1):
    if j >= i and a[j]-a[i] <= 2:
      #print(i,j)
      count += 1
    else:
      ans.append(count)
      count = 0
if n == 1:
  print(1)
else:
  print(max(ans))

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
a.sort()
count = 0
p1 = []
for i in range(n):
  p1.append(a[i]-1)
p2 = []
for i in range(n):
  p2.append(a[i]+1)
chk = a+p1+p2
chk.sort()
#print(chk)
ans =[]
count = 0
for i in range(3*n-1):
  if chk[i+1] == chk[i]:
    count += 1
  else:
    ans.append(count)
    count = 0
print(max(ans)+1)
### BUGGY CODE ###

N, M = map(int, input().split())
P = [[] for _ in range(N+1)]
ite = []

for _ in range(M):
    p, y = map(int, input().split())
    P[p].append(y)
    ite.append([p, y])

for i in range(N+1):
    P[i] = sorted(P[i])

for i in range(M):
    p, y = ite[i]
    #print(P[p])
    num = P[p].index(y)+1
    idx = '{}{}'.format(str(p).zfill(6), str(num).zfill(6))
    print(idx)

### FIXED CODE ###

N, M = map(int, input().split())
P = [[] for _ in range(N+1)]
ite = []

for _ in range(M):
    p, y = map(int, input().split())
    P[p].append(y)
    ite.append([p, y])

dic = {}
for p in range(N+1):
    P[p] = sorted(P[p])
    for i, y in enumerate(P[p]):
        i += 1
        dic[y] = '{}{}'.format(str(p).zfill(6), str(i).zfill(6))

for i in range(M):
    p, y = ite[i]
    print(dic[y])
### BUGGY CODE ###

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

import math
K = min(K, 43)
for k in range(K):
  light = [0] * (N+1)
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    light[start] += 1
    light[end+1] -= 1
  for i in range(1,N):
    light[i] += light[i-1]
    
  A = light

light.pop()
print(" ".join(map(str,light)))


### FIXED CODE ###

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

import math
K = min(K, 43)
for k in range(K):
  light = [0] * (N+1)
  for i in range(N):
    start = max(0,i-A[i])
    end = min(N-1, i+A[i])
    light[start] += 1
    light[end+1] -= 1
  for i in range(1,N):
    light[i] += light[i-1]
    
  A = light

light.pop()
print(" ".join(map(str,light)))
### BUGGY CODE ###

# すべて1のところ
# 毎回calc(x)を計算しているから遅い
MOD = 10 ** 9 + 7
L = list(input())
N = len(L)

lst = [-1] * N
def calc(x): #1が続いている桁数
    if x == 0:
        return 1
    tmp_ans = 1
    tmp = 1
    for i in range(1, x):
        tmp = (tmp * (x + 1 - i))//i
        tmp_ans += pow(2, i, MOD) * tmp
        tmp_ans %= MOD

    tmp_ans += pow(2, x, MOD)
    tmp_ans %= MOD
    return tmp_ans

def calc1(x):
    return pow(3, x, MOD)

#ここまでで一番上の桁が0の場合を処理済み（N - 1桁で書ける場合）
ans = calc(N - 1) + 2
# print (ans)

# 1xxxxxxのxxxxxxの部分を足す必要がある

count = 1
for i in range(1, N):
    if L[i] == '1':
        ans += (2 ** count) * (calc1(N - 1 - i) + 1)
        count += 1
        ans %= MOD
    
print (ans % MOD)


### FIXED CODE ###

# すべて1のところ
# 毎回calc(x)を計算しているから遅い
MOD = 10 ** 9 + 7
L = list(input())
N = len(L)

lst = [-1] * N
def calc(x): #1が続いている桁数
    if x == 0:
        return 1
    tmp_ans = 1
    tmp = 1
    for i in range(1, x):
        tmp = (tmp * (x + 1 - i))//i
        tmp_ans += pow(2, i, MOD) * tmp
        tmp_ans %= MOD

    tmp_ans += pow(2, x, MOD)
    tmp_ans %= MOD
    return tmp_ans

def calc1(x):
    return pow(3, x, MOD)

#ここまでで一番上の桁が0の場合を処理済み（N - 1桁で書ける場合）
ans = calc1(N - 1) + 2
# print (ans)

# 1xxxxxxのxxxxxxの部分を足す必要がある

count = 1
for i in range(1, N):
    if L[i] == '1':
        ans += pow(2, count, MOD) * (calc1(N - 1 - i) + 1)
        count += 1
        ans %= MOD
    
print (ans % MOD)
### BUGGY CODE ###

x=int(input())
a=1
b=0
s=0
while(1):
    while(1):
        if(a==b):
            break
        if x%(a-b)==0:
            A=a**5
            B=b**5
            if(A-B==x):
                print(a,b)
                s=1
                break
            elif (-A-B==x):
                print(-a,b)
                s=1
                break
            elif (A+B==x):
                print(a,-b)
                s=1
                break
        b+=1
    if(s==1):
        break
    a+=1

### FIXED CODE ###

import sys

x=int(input())
for i in range(-120,120):
    for j in range(-120,120):
        if(i**5-j**5==x):
            print(i,j)
            sys.exit()
### BUGGY CODE ###

h, w = map(int, input().split())

s = [[j for j in list(str(input()))] for i in range(h)]

board = [[[0 for _ in range(2)] for _ in range(w)] for _ in range(h)]

# 右、左、上、下の順に走査
for i in range(h):
    cnt_continue = 0
    for j in range(w):
        if s[i][j] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board[i][j][0] = cnt_continue

for i in range(h):
    for j in reversed(range(w-1)):
        if board[i][j][0] == 0:
            continue
        board[i][j][0] = max(board[i][j][0], board[i][j+1][0])

for i in range(w):
    cnt_continue = 0
    for j in range(h):
        if s[j][i] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board[j][i][1] = cnt_continue

for i in range(w):
    for j in reversed(range(h-1)):
        if board[j][i][1] == 0:
            continue
        board[j][i][1] = max(board[j][i][1], board[j+1][i][1])

ans = 0

for i in range(h):
    for j in range(w):
        v = sum(board[i][j]) - 1
        ans = max(ans, v)

print(ans)


### FIXED CODE ###

h, w = map(int, input().split())

s = [input() for i in range(h)]

board_w = [[0 for _ in range(w)] for _ in range(h)]
board_h = [[0 for _ in range(w)] for _ in range(h)]

# 右、左、上、下の順に走査
for i in range(h):
    cnt_continue = 0
    for j in range(w):
        if s[i][j] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board_w[i][j] = cnt_continue

    for j in reversed(range(w-1)):
        if board_w[i][j] == 0:
            continue
        board_w[i][j] = max(board_w[i][j], board_w[i][j+1])

for i in range(w):
    cnt_continue = 0
    for j in range(h):
        if s[j][i] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board_h[j][i] = cnt_continue

    for j in reversed(range(h-1)):
        if board_h[j][i] == 0:
            continue
        board_h[j][i] = max(board_h[j][i], board_h[j+1][i])


ans = 0

for i in range(h):
    for j in range(w):
        v = board_w[i][j] + board_h[i][j] - 1
        ans = max(ans, v)

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

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

X = [str(A.index(i)+1) for i in range(1, N+1)] 
print(" ".join(X))


### FIXED CODE ###

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

X = [None for _ in range(N)]
for i, a in enumerate(A):
    X[a-1] = str(i+1)
print(" ".join(X))
### BUGGY CODE ###

n, k = map(int, input().split())
p_list = list(map(int, input().split()))
max_val = 0
vals = []
for i in range(n-k+1):
    val = sum(p_list[i:i+k])
    vals.append(val)
        
print((max(vals) + k )/2)

### FIXED CODE ###

n, k = map(int, input().split())
p_list = list(map(int, input().split()))

for i in range(n):
    p_list[i] = (1 + p_list[i]) / 2

wa = sum(p_list[0:k])
ans = wa

for j in range(n-k):
    wa = wa + p_list[j+k] - p_list[j]
    ans = max(ans, wa)
    
print(ans)
### BUGGY CODE ###

n, m, r = list(map(int, input().split()))
rs = set(map(int, input().split()))
abcs = []
for _ in range(m):
    abcs.append(list(map(int, input().split())))

# construct graph
roads = [[] for _ in range(n + 1)]
for a, b, c in abcs:
    roads[a].append((b, c))
    roads[b].append((a, c))
# road from sky
for rr in rs:
    roads[0].append((rr, 0))

import heapq
import copy
# distance, town, rest-town-list
Q = [(0, 0, rs)]
while len(Q) > 0:
    d, u, rest = heapq.heappop(Q)
    if len(rest) == 0:
        ans = d
        break
    for v, dd in roads[u]:
        heapq.heappush(Q, (d + dd, v, rest - {v}))

print(ans)

### FIXED CODE ###

n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0

from itertools import product, permutations
for i, k in product(range(1, 1 + n), repeat=2):
    dists[:, k] = np.minimum(dists[:, k], dists[:, i] + dists[i, k])

ans = float('inf')
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val

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

# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    S = lines.pop(0)
    RS = S[::-1]
    S = 'x' + S
    RS = 'x' + RS
    slist = []
    rslist = []
    ss = 0
    rss = 0
    for i in range(N):
        if S[i] == 'W':
            ss += 1
        if RS[i] == 'E':
            rss += 1
        slist.append(ss)
        rslist.insert(0,rss)
    #print(S)
    #print(RS)
    #print(list( zip(slist, rslist)))
    print(min([s + r for s, r in zip(slist, rslist)]))

#
# main
#
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    S = lines.pop(0)
    RS = S[::-1]
    S = 'x' + S
    RS = 'x' + RS
    slist = []
    rslist = []
    ss = 0
    rss = 0
    for i in range(N):
        if S[i] == 'W':
            ss += 1
        if RS[i] == 'E':
            rss += 1
        slist.append(ss)
        #rslist.insert(0,rss)
        rslist.append(rss)
    #print(S)
    #print(RS)
    #print(list( zip(slist, rslist)))
    rslist.reverse()
    print(min([s + r for s, r in zip(slist, rslist)]))

#
# main
#
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
### BUGGY CODE ###

import Queue
import copy

def main():
    H, W = map(int, raw_input().split())
    S = []

    for i in range(H):
        S.append(list(raw_input()))


    def bfs(start, S2):
        q = Queue.Queue()
        q.put(start)
        candidates = [[0, 1], [1, 0], [0, -1], [-1, 0]]
        dist = [[0]*W for _ in range(H)]
        while not q.empty():
            i = q.get()
            x = i[0]
            y = i[1]
            S2[x][y] = "#"

            for candi in candidates:
                x_new = x + candi[0]
                y_new = y + candi[1]

                if x_new < H and x_new >= 0:
                    if y_new < W and y_new >=0:
                        if S2[x_new][y_new] == ".":
                            dist[x_new][y_new] = dist[x][y] + 1
                            q.put([x_new, y_new])

        ans = 0
        for i in range(H):
            ans = max(ans, max(dist[i]))

        return ans

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                S2 = copy.deepcopy(S)
                ans = max(ans, bfs([i, j], S2))

    print ans


if __name__ == "__main__":
    main()



### FIXED CODE ###

import Queue
import copy

def main():
    H, W = map(int, raw_input().split())
    S = []

    for i in range(H):
        S.append(list(raw_input()))


    def bfs(start, S2):
        q = Queue.Queue()
        q.put(start)
        candidates = [[0, 1], [1, 0], [0, -1], [-1, 0]]
        dist = [[0]*W for _ in range(H)]
        S2[start[0]][start[1]] = "#"
        while not q.empty():
            i = q.get()
            x = i[0]
            y = i[1]

            for candi in candidates:
                x_new = x + candi[0]
                y_new = y + candi[1]

                if x_new < H and x_new >= 0:
                    if y_new < W and y_new >=0:
                        if S2[x_new][y_new] == ".":
                            dist[x_new][y_new] = dist[x][y] + 1
                            S2[x_new][y_new] = "#"
                            q.put([x_new, y_new])

        ans = 0
        for i in range(H):
            ans = max(ans, max(dist[i]))

        return ans

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                S2 = copy.deepcopy(S)
                ans_temp = bfs([i, j], S2)
#                print i, j, ans_temp                                                                                                                     
                ans = max(ans, ans_temp)


    print ans


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

combNum = [0]*10000
inNum = 0
while True:
    n,x = map(int, input().split())
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    if n is x is 0:
        break
    else:
        
        for index1 in range(n):
            for index2 in range(n):
                for index3 in range(n):
                    #index = [numList1[index1], numList2[index2], numList3[index3]]
                    if numList1[index1] is numList2[index2] or numList1[index1] is numList3[index3] or numList2[index2] is numList3[index3] or numList1[index1] is numList2[index2] is numList3[index3]:
                    #if index.count(numList1[index1])>1 or index.count(numList1[index2])>1 or index.count(numList1[index3])>1:
                        pass                
                    else:
                        if numList1[index1]<numList2[index2]<numList3[index3]:
                            calcResult = numList1[index1] + numList2[index2]+numList3[index3]
                            if calcResult == x:
                                combNum[inNum] =combNum[inNum]+1
                                
                        else:
                            pass
        inNum = inNum+1
for index in range(inNum):
    print(combNum[index])


### FIXED CODE ###

dataNum = 0
combNum = [0] * 100
while True:
    n,x=map(int, input().split())
    if n is x is 0:
        break
    else:
        for a in range(1,n-1):
            for b in range(a+1,n):
                for c in range(b+1,n+1):
                    calcResult = a + b + c
                    if calcResult == x:
                        combNum[dataNum] += 1
                    else:
                        pass
    dataNum += 1

for index in range(dataNum):
    print(combNum[index])
### BUGGY CODE ###


import math
K = int(input())

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


### FIXED CODE ###

import math
K = int(input())

# table = np.zeros((K,K), dtype="int16")
table = [[0] * K for i in range(K)]

for a in range(K):
    for b in range(a, K):
        tmp = math.gcd(a+1, b+1)
        table[a][b] = tmp
        table[b][a] = tmp

res = 0
for a in range(K):
    for b in range(K):
        for c in range(K):
            res += table[table[a][b]-1][c]
print(res)
### BUGGY CODE ###

N = int(input())
N = N+1
sum = 0

import math
from functools import reduce

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

for i in range(1, N):

    for j in range(1, N):
        for k in range(1, N):
            # print(i, j, k, ' : ', gcd(i, j, k))
            sum += (gcd(i, j, k))

print( sum )


### FIXED CODE ###

N = int(input())
N = N+1
sum = 0

from math import gcd

for i in range(1, N):
    for j in range(1, N):
        for k in range(1, N):
            sum += gcd(gcd(i, j), k)

print( sum )
### BUGGY CODE ###

s,t=[tuple(input()) for u in (1,1)]
l=[['' for i in range(len(s)+1)] for j in range(len(t)+1)]
for j in range(len(t)):
  for i in range(len(s)):
    if t[j]==s[i]:
      l[j+1][i+1]=l[j][i]+t[j]
    else:l[j+1][i+1]=l[j][i+1] if len(l[j][i+1])>len(l[j+1][i]) else l[j+1][i]
print(l[len(t)][len(s)])

### FIXED CODE ###

s,t=input(),input()
n,m=len(s),len(t)
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
ans=""
while m>0 and n>0:
  if s[n-1]==t[m-1]:ans=s[n-1]+ans;n-=1;m-=1
  elif dp[n][m]==dp[n-1][m]:n-=1
  else:m-=1
print(ans)
### BUGGY CODE ###

n,k = map(int,input().split()) 
t = list(str(input()))
t = [int(s) for s in t]
last = t[0]
temp_c = 0
s = []
con_c = 0
temp_con_c = 0
corrent_p = 0
for i in range(n):
    if last == t[i]:
        temp_c += 1
    else:
        last = t[i]
        s.append(temp_c)
        temp_c = 1
s.append(temp_c)
if t[0] == 0:
    start_n = 0
else:
    start_n = 1
l = len(s)
if k*2 <= l:
    if start_n == 0:
        for i in range(0,k*2):
            temp_con_c += s[i]
        con_c = temp_con_c
        temp_con_c = 0
        corrent_p = 1
    for i in range(corrent_p,l,2):
        for m in range(k*2+1):
            if i+m >= l:
                break
            temp_con_c += s[i+m]
        if temp_con_c > con_c:
            con_c = temp_con_c
        temp_con_c = 0
        
else:
    con_c = n
print(con_c)

### FIXED CODE ###

'''
WA
'''
n,k = map(int,input().split()) 
t = list(str(input()))
t = [int(s) for s in t]
last = t[0]
temp_c = 0
s = []
con_c = 0
temp_con_c = 0
corrent_p = 0
sum_t = []
for i in range(n):
    if last == t[i]:
        temp_c += 1
    else:
        last = t[i]
        s.append(temp_c)
        temp_c = 1
s.append(temp_c)
if t[n-1] == 0:
    s.append(0)
l = len(s)
if k*2 <= l:
    sum_t.append(0)
    for i in range(l):
        sum_t.append(sum_t[i]+s[i])
    l = len(sum_t)
    if t[0] == 0:
        for i in range(l-k*2-1):
            if i%2 == 0:
                temp_con_c = sum_t[i+k*2]-sum_t[i]
            else:
                temp_con_c = sum_t[i+k*2+1]-sum_t[i]
            if temp_con_c > con_c:
                con_c = temp_con_c
    else:
        for i in range(l-k*2-1):
            if i%2 ==0:
                temp_con_c = sum_t[i+k*2+1]-sum_t[i]
            else:
                temp_con_c = sum_t[i+k*2]-sum_t[i]
            if temp_con_c > con_c:
                con_c = temp_con_c
else:
    con_c = n

print(con_c)
### BUGGY CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
 
ans = 0
dame = []
 
for i in range(m):
    if h[a[i] - 1] < h[b[i] - 1] and (not a[i] in dame):
        dame.append(a[i])
    elif h[a[i] - 1] > h[b[i] - 1] and (not b[i] in dame):
        dame.append(b[i])
    elif h[a[i] - 1] == h[b[i] - 1] and (not a[i] in dame):
        dame.append(a[i])
    if h[a[i] - 1] == h[b[i] - 1] and (not b[i] in dame):
        dame.append(b[i])
 
 
print(n - len(dame))

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())

ans = 0
dame = []

for i in range(m):
    if h[a[i] - 1] < h[b[i] - 1] and (not a[i] in dame):
        dame.append(a[i])
    elif h[a[i] - 1] > h[b[i] - 1] and (not b[i] in dame):
        dame.append(b[i])
    elif h[a[i] - 1] == h[b[i] - 1] and (not a[i] in dame):
        dame.append(a[i])
    if h[a[i] - 1] == h[b[i] - 1] and (not b[i] in dame):
        dame.append(b[i])


print(n - len(dame))
### BUGGY CODE ###


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

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

inds=sorted(range(len(As)), key=lambda k: As[k])[::-1]

ds=[[0 for j in range(N+1-i)] for i in range(N+1)]

ds[0][0]=0
for i in range(1,N+1):
    ds[i][0]=ds[i-1][0]+As[inds[i-1]]*(inds[i-1]-(i-1))
    ds[0][i]=ds[0][i-1]+As[inds[i-1]]*(N-i-inds[i-1])

for xy in range(2,N+1):
    for x in range(1,xy):
        y=xy-x
        c1=ds[x-1][y]+As[inds[xy-1]]*(inds[xy-1]-(x-1))
        c2=ds[x][y-1]+As[inds[xy-1]]*(N-y-inds[xy-1])
        ds[x][y]=max(c1,c2)

ans=0
for x in range(0,N+1):
    y=N-x
    c=ds[x][y]
    ans=max((c,ans))
print(ans)
#print(ds)
#print(inds)




### FIXED CODE ###


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

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

inds=sorted(range(len(As)), key=lambda k: As[k])[::-1]
#ds=[[0 for j in range(N+1-i)] for i in range(N+1)]

ds=[0]
for xy in range(1,N+1):
    i=inds[xy-1]
    a=As[i]
    nds=[0]*(xy+1)
    nds[-1]=ds[-1]+a*(i-(xy-1))
    nds[0]=ds[0]+a*(N-xy-i)

    for x in range(1,xy):
        y=xy-x
        c1=ds[x-1]+a*abs(i-(x-1))
        c2=ds[x]+a*abs(N-y-i)
        nds[x]=max(c1,c2)
    ds=nds.copy()
    #print(ds)


print(max(ds))
#print(ds)
#print(inds)