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

import sys
sys.setrecursionlimit(10**7)
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
INF=10**6
dy=[0,0,1,-1]
dx=[1,-1,0,0]
m=[[INF]*W for i in range(H)]

from collections import deque

q=deque()
for y in range(H):
  for x in range(W):
    if A[y][x]=='#':
      q.append((y,x))
      m[y][x]=0      

      
def bfs(q,m):
  d=0
  while q:
    y,x=q.popleft()
    d=m[y][x]
    for i in range(4):
      ny=y+dy[i]
      nx=x+dx[i]
      if 0<=ny<H and 0<=nx<W and m[ny][nx]==INF and A[ny][nx]!='#':
        q.append((ny,nx))
        m[ny][nx]=m[y][x]+1
            
bfs(q,m)
ans=0
for i in range(H):
  for j in range(W):
    ans=max(ans,m[i][j])
    
print(ans)    

### FIXED CODE ###

from subprocess import call
call(('pypy3','-c',"""
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
dy=[0,0,1,-1]
dx=[1,-1,0,0]
m=[[-1]*W for i in range(H)]

from collections import deque
q=deque()
for y in range(H):
  for x in range(W):
    if A[y][x]=='#':
      q.append((y,x))
      m[y][x]=0      
      
def bfs(q,m):
  d=0
  while q:
    y,x=q.popleft()
    d=m[y][x]
    for i in range(4):
      ny=y+dy[i]
      nx=x+dx[i]
      if 0<=ny<H and 0<=nx<W and m[ny][nx]==-1 and A[ny][nx]!='#':
        q.append((ny,nx))
        m[ny][nx]=m[y][x]+1            
bfs(q,m)
ans=0
for i in range(H):
  for j in range(W):
    ans=max(ans,m[i][j])    
print(ans)     
"""))
### BUGGY CODE ###

while 1:
    n = input()
    if n==0: break
    s = [0 for i in range(7)]
    for i in range(n):
        age = input()
        s[min(6, age/10)] += 1
    for i in range(7):
        print s[i]

### FIXED CODE ###

while 1:
    n = input()
    if n==0: break
    s = [0 for i in range(13)]
    for i in range(n):
        s[int(raw_input())/10] += 1
    for i in range(6):
        print s[i]
    print sum(s[6:])
### BUGGY CODE ###

import fractions
N = int(input())
T = list(map(int, input().split()))
lcm = T[0]
ans = 0
MOD = 1000000007
for i in range(1, N):
  lcm = lcm * T[i] // fractions.gcd(lcm, T[i])
for i in range(N):
  ans = (ans + lcm//T[i]) % MOD
print(ans)

### FIXED CODE ###

import fractions
N = int(input())
T = list(map(int, input().split()))
lcm = T[0]
ans = 0
MOD = 1000000007
for i in range(1, N):
  lcm = lcm * T[i] // fractions.gcd(lcm, T[i])
for x in T:
  ans += lcm // x
print(ans % MOD)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
ans = 1
for a in As:
    ans *= a
if ans>10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
ans = 1
if 0 in As:
    print(0)
else:
    for a in As:
        ans *= a
        if ans>10**18:
            break
    if ans>10**18:
        print(-1)
    else:
        print(ans)
### BUGGY CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
sum1 = 0
sumMax = 0
for i in range(N-K+1):
    Sik = sum(p[:i+K])
    Si = sum(p[:i])
    sum1 = Sik-Si
    if(sumMax < sum1):
        sumMax = sum1
result = 0.5*K + 0.5*(sumMax)
print(result)

### FIXED CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
a = 0
sum1 = 0
sumMax = 0
for i in range(N):
    a += p[i]
    S.append(a)
for i in range(N-K+1):
    sum1 = S[i+K] - S[i]
    if(sumMax < sum1):
        sumMax = sum1
result = 0.5*K + 0.5*(sumMax)
print(result)
### BUGGY CODE ###

# sys.stdin.readline()
import sys
input = sys.stdin.readline
import math

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

for i in range(M):
    A[0] = A[0] // 2
    A.sort(reverse=True)

print(sum(A))

### FIXED CODE ###

# sys.stdin.readline()
import sys
import time
input = sys.stdin.readline
import math
import heapq

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A = [-i for i in A]
# print(A)
heapq.heapify(A)
# print(heapq.heappop(A))

# t1 = time.time()
for i in range(M):
    a = -heapq.heappop(A) // 2
    heapq.heappush(A, -a)
    # j = A.index(max(A))
    # A[j] = a
    # A[0] = A[0]//2
    # A.sort(reverse=True)
    # if sum(A) <1:
    #     break

print(-sum(A))
### BUGGY CODE ###

H, W = map(int, input().split())
C = [input() for i in range(H)]

import sys
sys.setrecursionlimit(500000)


def search(x, y, z):
    if y >= H or x >= W or x < 0 or y <  0:
        return
    elif C[y][x] == z:
        return
    elif itta[y][x] == 1:
        return
    else:
        itta[y][x] = 1 # appendすると遅くなる
        prez = C[y][x]
        if C[y][x] == '.':
            itta_white[y][x] = 1
    
    search(x+1, y, prez)
    search(x-1, y, prez)
    search(x, y+1, prez)
    search(x, y-1, prez) 

ans = 0
# #を探しに行く
for y in range(H):
    for x in range(W):
        if C[y][x] != '#':
            pass
        else:
            itta = [[0] * W for i in range(H)]
            itta_white = [[0] * W for i in range(H)]
            search(x, y, '.')
            ans += sum(map(sum, itta_white)) 
            # 入れ子リスト（２次元配列）の合計値
            # https://maku77.github.io/python/numstr/sum.html

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
C = [input() for i in range(H)]

import sys
sys.setrecursionlimit(500000)

itta = [[0] * W for i in range(H)]

def search(x, y, z):
    if y >= H or x >= W or x < 0 or y <  0:
        return
    elif C[y][x] == z:
        return
    elif itta[y][x] == 1:
        return
    elif C[y][x] == z:
        return
    else:
        itta[y][x] = 1
        
        if C[y][x] == '.':
            bw_count[0] += 1
        else:
            bw_count[1] += 1
        
        prez = C[y][x]
        
    search(x+1, y, prez)
    search(x-1, y, prez)
    search(x, y+1, prez)
    search(x, y-1, prez) 

ans = 0

for y in range(H):
    for x in range(W):
        if itta[y][x] ==1:
            pass
        else:
            bw_count = [0, 0]
            search(x, y, '-')
            
            ans += bw_count[0] * bw_count[1]  

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

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edgesが与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  import copy
  d=copy.deepcopy(A)
  for k in range(N):
    for i in range(N):
      for j in range(i):
        if d[i][j]>d[i][k]+d[k][j]: return 1
  return 0
 
import sys
from sys import stdin
input = stdin.readline
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i in range(N):
  for j in range(i):
    need=1
    for k in range(N):
      if k!=i and k!=j:
        if A[i][j]==A[i][k]+A[k][j]:
          need=0
          break
    ans+=need*A[i][j]
print(ans)

### FIXED CODE ###

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k, i, j in itertools.product(range(N), range(N),range(N)):
    if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
import itertools
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i, j in itertools.product(range(N),range(N)):
  need=1
  for k in range(N):
    if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
      need=0
      break
  if need:ans+=A[i][j]
print(ans//2)
### BUGGY CODE ###

import itertools

max_range, sum_ = map(int, input().split())

count = 0
for x, y, z in itertools.product(range(max_range + 1), repeat=3):
    if x + y + z == sum_:
        count += 1
print(count)


### FIXED CODE ###

max_range, sum_ = map(int, input().split())

count = 0
for x in range(0, min(max_range + 1, sum_ + 1)):
    for y in range(0, min(max_range + 1, sum_ - x + 1)):
        if sum_ - x - y <= max_range:
            count += 1

print(count)
### BUGGY CODE ###

import sys
from itertools import combinations 
input = sys.stdin.readline

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

l.sort()
cnt = 0

for n,i in enumerate(l):
    for m,j in enumerate(l[n+1:],n+1):
        lst=[]
        lst = list([c for c in set(l[m+1:]) if c<=i+j-1])
        cnt += len(lst)
       
print(cnt)


### FIXED CODE ###

import sys
from bisect import bisect_left
from itertools import combinations 

input = sys.stdin.readline
 
N = int(input())
l= list(map(int, input().split()))
 
l.sort()
cnt = 0
 
for n,i in enumerate(l[:N-2]):
    for m,j in enumerate(l[n+1:N-1],n+1):
        cnt += max(0,bisect_left(l,i+j)-(m+1)) 
        
print(cnt)
### BUGGY CODE ###

from itertools import combinations
n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
    if len(str(i)) == 1:
        tmp = '00' + str(i)
        lst[i] = tmp
    elif len(str(i)) == 2:
        tmp = '0' + str(i)
        lst[i] = tmp
    else:
        lst[i] = str(i)



com = list(combinations(s, 3))
com = list(set([''.join(x) for x in com]))
cnt = 0
for x in lst:
    if x in com:
        cnt += 1

print(cnt)

### FIXED CODE ###

n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
    if len(str(i)) == 1:
        tmp = '00' + str(i)
        lst[i] = tmp
    elif len(str(i)) == 2:
        tmp = '0' + str(i)
        lst[i] = tmp
    else:
        lst[i] = str(i)

cnt = 0
for v in lst:
    id_1 = s.find(v[0])
    if id_1 == -1:
        continue
    id_2 = s.find(v[1], id_1 + 1)
    if id_2 == -1:
        continue
    id_3 = s.find(v[2], id_2 + 1)
    if id_3 == -1:
        continue
    cnt += 1

print(cnt)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
INF = 10 ** 9
memo = [-1]*n

def dp(i):
    if (i < 0):
        return INF
    if (i == 0):
        return 0
    if (memo[i] != -1):
        return memo[i]
    ans = INF
    for j in range (max(0, i-k),i):
        ans = min(ans, dp(j) + abs(h[i] - h[j]))
    memo[i] = ans
    return memo[i]

print(dp(n-1))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
memo = [0]*n
for i in range(1, n):
    min_k = float('inf') 
    min_k=min([memo[j] +abs(h[i]-h[j]) for j in range(max(0, i-k), i)])
    memo[i] = min_k

print(memo[-1])
### BUGGY CODE ###

import math
import numpy as np
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
#print(A)

for i in range(M):
  max_i =  np.argmax(A)
  A[max_i] = A[max_i]//2

ans = sum(A)
print(ans)

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1), A)) 

heapq.heapify(A) # リストを優先度付きキューへ

for i in range(M):
  num = heapq.heappop(A)
  num = ((-1)*num) //2
  num = -num
  heapq.heappush(A,num) 

ans = -sum(A)
print(ans)
### BUGGY CODE ###

job = list()
day = list()
salary = list()
m_total = 0
count = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
job.sort()
job.reverse()
for i in range(n):
    a,b = job[i]
    day.append(a)
    salary.append(b)
    if a + i - count > m :
        count += 1
        salary.remove(min(salary))
k = n - count
for l in range(k):
    m_total += salary[l]
print(m_total)


### FIXED CODE ###

import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

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

from collections import Counter
n = int(input())
S = Counter()
ans = 0
for _ in range(n):
    s = str(sorted(list(input())))
    if S[s] > 0:
        ans += S[s]
    S[s] += 1

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
S = Counter()
ans = 0
for _ in range(n):
    s = "".join(sorted(input()))
    if S[s] > 0:
        ans += S[s]
    S[s] += 1

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

def div_count(N):
    divs = 0
    for i in range(1, int(N**0.5) + 1):
        if not N % i:
            divs += 1
            if i != N // i:
                divs += 1
    return divs

def solve():
    ret = 0
    for k in range(1, N + 1):
        ret += k * div_count(k)
    print(ret)

if __name__ == "__main__":
    N = int(input())
    solve()

### FIXED CODE ###

def solve():
    ret = 0
    for k in range(1, N + 1):
        y = N // k
        ret += k * y * (y + 1) // 2
    print(ret)

if __name__ == "__main__":
    N = int(input())
    solve()
### BUGGY CODE ###

#ABC116D-VariousSushi.py

import numpy as np
import bisect

INPUT1 = [int(n) for n in input().split()]

N, K = INPUT1[0], INPUT1[1]
Parameters = [[None for col in range(2)] for row in range(N)]
Score= 0
kind = []
kindnumber = 0

for i in range(N):
    INPUT2 = [int(m) for m in input().split()]
    Parameters[i] = [INPUT2[0], INPUT2[1]]

Parameters = sorted(Parameters, key=lambda x: x[1], reverse=True)

def SearchNew(List, K, kind):
    newkind = -1
    kindset = kind[:]
    oldkindnumber = 0
    newkindnumber = 0
    for i in range(len(List)-K):
        oldkindnumber = len(set(kindset))
        kindset.append(List[K+i][0])
        newkindnumber = len(set(kindset))
        if oldkindnumber != newkindnumber:
            newkind = K+i
            break
    return newkind

def SearchDouble(List, K, kind):
    result = -1
    testkind = kind[:]
    oldkindnumber = len(set(testkind))
    testkindPop = testkind.pop
    for i in range(K):
        testkindPop(K-1-i)
        newkindnumber = len(set(testkind))
        if oldkindnumber == newkindnumber:
            result = K-1-i
            break
        oldkindnumber = newkindnumber
    return result

kindAppend = kind.append

for i in range(K):
    kindAppend(Parameters[i][0])
kindnumber = len(set(kind))
Score = np.sum(Parameters[:K], axis=0)[1] + kindnumber**2
kind.clear()

Test1, Test2 = 0, Score

for t in Parameters:
    for i in range(K):
        kindAppend(Parameters[i][0])
    kindnumber = len(set(kind))
    i = SearchNew(Parameters, K, kind)
    j = SearchDouble(Parameters, K, kind)
    Parameters[i], Parameters[j] = Parameters[j], Parameters[i]
    if i != -1 and j != -1:
        kindnumber += 1
    else:
        break
    Test1 = Test2 - Parameters[i][1] + Parameters[j][1] + kindnumber * 2 - 1
    Test2 = Test1
    if Score <= Test2:
        Score = Test2
    kind.clear()

print(Score)


### FIXED CODE ###

#ABC116D-VariousSushi.py

from sys import stdin
#from numpy import sum

input = stdin.readline

N, K = list(map(int, input().split()))
List1= []
kind = set()
point1, point2 = 0, 0

INPUT = [tuple(map(int, input().split())) for _ in range(N)]

INPUT.sort(key = lambda x: -x[1])

for ti, di in INPUT[:K]:
    point1 += di
    if ti in kind:
        List1.append(di)
    kind.add(ti)

point2 = len(kind)

Score = point1 + point2**2
Test = Score

List1POP = List1.pop

for ti, di in INPUT[K:]:
    if 0 >= len(List1):
        break
    if ti in kind:
        continue
    Test = Test - List1POP() + di + 2 * point2 + 1
    point2 += 1
    kind.add(ti)
    Score = max(Score, Test)

print(Score)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
a=0
for i,b in enumerate(B):
    heappush(q,(-b,i))
while len(q)>0:
    b,i=heappop(q)
    if B[i]<A[i]:
        a=-1
        break
    elif B[i]==A[i]:
        continue
    elif B[i]>B[i-1]+B[i+1-N]:
        B[i]-=B[i-1]+B[i+1-N]
        if B[i]<A[i]:
            a=-1
            break
        heappush(q,(-B[i],i))
        a+=1
    else:
        a=-1
        break
print(a)

### FIXED CODE ###

N=int(input())
A=tuple(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
a=0
for i,b in enumerate(B):
    heappush(q,(-b,i))
while len(q)>0:
    b,i=heappop(q)
    ba=-b-A[i]
    bb=B[i-1]+B[i+1-N]
    if ba<0:
        a=-1
        break
    elif ba==0:
        continue
    elif -b>bb:
        x,y=divmod(ba,bb)
        if x==0:
            a=-1
            break
        B[i]-=bb*x
        if y>0:
            heappush(q,(-B[i],i))
        a+=x
    else:
        a=-1
        break
print(a)
### BUGGY CODE ###

import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
 
lst_2 = lst[:]
res = 0
for i in range(n):
    lst_2 = lst[:]
    lst_2.pop(i)
    res = max(res, functools.reduce(gcd, lst_2))
print(res)

### FIXED CODE ###

import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
lst_forward = []
a = lst[0]
for i in lst:
    a = gcd(a, i)
    lst_forward.append(a)

lst_backward = []
a = lst[-1]
for i in lst[::-1]:
    a = gcd(a, i)
    lst_backward.append(a)
lst_backward = list(reversed(lst_backward))

s = max(lst_backward[1], lst_forward[-2])
for i in range(1, n-1):
    s = max(s, gcd(lst_forward[i-1], lst_backward[i+1]))
print(s)
### BUGGY CODE ###

N=int(input())
A=[int(i) for i in input().split()]
score=[0]*(N+1)
score[0]=sum(A[0:N])-sum(sorted(A[N:3*N])[0:N])
former=sorted(A[0:N-1])
latter=A[N:3*N]
for i in range(1,N+1):
  score[i]=score[i-1]+A[N+i-1]-A[N+i-2]
  if former!=[]:
    if former[0]<A[N+i-2]:
      score[i]+=A[N+i-2]-former[0]
      del former[0]
      former.append(A[N+i-2])
      former.sort(key=lambda x:x)
  if sorted(latter)[N-1]>=A[N+i-1]:
    score[i]+=A[N+i-1]-sorted(latter)[N]
  del latter[0]
print(max(score))


### FIXED CODE ###

import heapq
import copy
N=int(input())
A=list(map(int,input().split()))
ca=copy.deepcopy(A)
fsl=[0 for i in range(N+1)]
f=ca[:N]
heapq.heapify(f)
fs=sum(f)
fsl[0]=fs
for i in range(N,2*N):
    heapq.heappush(f,A[i])
    fs=fs+A[i]-heapq.heappop(f)
    fsl[i-N+1]=fs
lsl=[0 for i in range(N+1)]
l=list(map(lambda x:-x,ca[2*N:]))
heapq.heapify(l)
ls=sum(l)
lsl[-1]=ls
for i in range(N,2*N):
    heapq.heappush(l,-A[3*N-i-1])
    ls=ls-A[3*N-i-1]-heapq.heappop(l)
    lsl[2*N-i-1]=ls
ans=-10**20
for i in range(N+1):
  ans=max(ans,fsl[i]+lsl[i])
print(ans)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
check = set(a)
ans = len(check)

for i in check:
    if a.count(i) % 2 == 0:
        ans -= 1

print(ans)

### FIXED CODE ###

n = int(input())
array = {}

for i in range(n):
    a = int(input())
    if a not in array:
        array[a] = 1
    elif array[a] == 1:
        array[a] -= 1
    else:
        array[a] += 1

print(sum(array.values()))
### BUGGY CODE ###

def main():
    n,m = map(int, input().split())

    ac_list = []
    correct = 0
    wrong = [0] * n
    penalty = 0

    for i in range(m):
        p,s = input().split()
        if s == 'AC' and p not in ac_list:
            ac_list.append(p)
            correct += 1
            penalty += wrong[int(p)-1]
        elif s == 'WA' and p not in ac_list:
            wrong[int(p)-1] += 1 
        else:
            continue
    
    print('{} {}'.format(correct,penalty))


if __name__ == '__main__':
    main()

### FIXED CODE ###

n, m = map(int, input().split())
ac = 0
wa = 0
 
ac_tf = [0] * n
wa_num = [0] * n
 
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac_tf[p] == 0:
            ac += 1
            wa += wa_num[p]
            ac_tf[p] = 1
    else:
        wa_num[p] += 1
            
print(ac, wa)
### BUGGY CODE ###

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

road = []
x_list = []

for i in range(N):
    s,t,x = list(map(int,input().split()))
    road.append([0,s-x,x])
    road.append([1,t-x,x])

for i in range(Q):
    road.append([2,int(input()),i])

from collections import defaultdict

counter = defaultdict(int)
counter[10**27] = 1
ans = [0]*Q

#road.sort(key=lambda x:x[0])
road.sort(key=lambda x:x[1])

q = [10**27]

from heapq import heappop,heappush

for id,_,x in road:
    if id==0:
        heappush(q,x)
        counter[x]+=1
    elif id==1:
        counter[x]-=1
    else:
        while counter[q[0]]==0:
            heappop(q)
        #print(q)
        if q[0]<10**27:
            ans[x] = q[0]
        else:
            ans[x] = -1
print(*ans,sep="\n")

### FIXED CODE ###

import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    N,Q = list(map(int,input().split()))

    road = []
    x_list = []

    for i in range(N):
        s,t,x = list(map(int,input().split()))
        road.append([0,s-x,x])
        road.append([1,t-x,x])

    for i in range(Q):
        road.append([2,int(input()),i])

    from collections import defaultdict

    counter = defaultdict(int)
    counter[10**27] = 1
    ans = [0]*Q

    road.sort(key=lambda x:x[0])
    road.sort(key=lambda x:x[1])

    q = [10**27]

    from heapq import heappop,heappush

    for id,_,x in road:
        if id==0:
            heappush(q,x)
            counter[x]+=1
        elif id==1:
            counter[x]-=1
        else:
            while counter[q[0]]==0:
                heappop(q)
            #print(q)
            if q[0]<10**27:
                ans[x] = q[0]
            else:
                ans[x] = -1
    print("\n".join(map(str,ans)))

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

from collections import deque
s=input()
q=int(input())
t=[input() for i in range(q)]

l=deque()

for i in range(int(len(s))):
  l.append(s[i])

for i in range(q):

  if int(t[i][0])==1:
    l.reverse()

  else:   
    if int(t[i][2])==1:
      l.appendleft(t[i][4]) 
    
    else:
      l.append(t[i][4])

print(''.join(l))

### FIXED CODE ###

from collections import deque
s=input()
q=int(input())
t=[input() for i in range(q)]
l=deque(list(s))
m=0
for i in range(q):
  if int(t[i][0])==1:
    m+=1
  else:
    if m%2==0:
      if int(t[i][2])==1:
        l.appendleft(t[i][4]) 
      else:
        l.append(t[i][4])
    else:
      if int(t[i][2])==2:
        l.appendleft(t[i][4]) 
      else:
        l.append(t[i][4])
if m%2==1:
  l.reverse()
print(''.join(l))
### BUGGY CODE ###

from math import gcd
from functools import reduce


def gcd_kai(*numbers):
    return reduce(gcd, numbers)


K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd_kai(i + 1, j + 1, k + 1)
print(ans)


### FIXED CODE ###

from math import gcd
from functools import reduce


def gcd_kai(*numbers):
    return reduce(gcd, numbers)


K = int(input())
ans = 1
if K == 1:
    next
else:
    ans += (K - 1) * K * 3
    ans_sub = 0
    for i in range(2, K):
        for j in range(i + 1, K + 1):
            for k in range(i, K + 1):
                ans_sub += gcd_kai(i, j, k)
    ans += ans_sub * 3
    for i in range(2, K + 1):
        ans += i
print(ans)
### BUGGY CODE ###

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

    s_list = []
    for i in range(n):
        s = sorted(input())
        s_list.append("".join(s))

    count = 0
    for s in list(set(s_list)):
        i = s_list.count(s)
        if i == 1:
            continue
        else:
            count += i * (i-1) // 2

    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

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

    s_dict = {}
    count = 0
    
    for i in range(n):
        s = sorted(input())
        _s = "".join(s)
        
        if not _s in s_dict:
            s_dict[_s] = 1
        else:
            count += s_dict[_s]
            s_dict[_s] += 1
    print(count)


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

N = int(input())
H = list(map(int, input().split()))
H.append(10**10)
Res = [0 for _ in range(N)]
for i in range(N-1):
  for j in range(i,N):
    if H[j+1] <= H[j]:
      Res[i] += 1
    else:
      break
print(max(Res))

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
H.append(10**10)
num = 0
ans = 0
for i in range(N):
  if H[i] >= H[i+1]:
    num += 1
  else:
    ans = max(num, ans)
    num = 0
print(ans)