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

# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 15:18:29 2018
ALDS1-4c
@author: maezawa
"""
def can_load(w, k, p):
    n = len(w)
    m = 0
    tk = 0
    i = 0
    while tk < k and i < n:
        if m + w[i] <= p:
            m += w[i]
            i += 1
        else:
            m = 0
            tk += 1
    return i


n, k = list(map(int, input().split()))
w = []
tr = [0 for _ in range(k)]

for i in range(n):
    w.append(int(input()))

maxw = max(w)
for p in range(maxw, maxw*n):
    if can_load(w, k, p) == n:
        print(p)
        break



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 15:18:29 2018
ALDS1-4c
@author: maezawa
"""
def can_load(w, k, p):
    n = len(w)
    m = 0
    tk = 0
    i = 0
    while tk < k:
        if m + w[i] <= p:
            m += w[i]
            i += 1
            if i >= n:
                return n+1
        else:
            m = 0
            tk += 1
    return i


n, k = list(map(int, input().split()))
w = []
tr = [0 for _ in range(k)]

for i in range(n):
    w.append(int(input()))

maxw = max(w)
# =============================================================================
# for p in range(maxw, maxw*n):
#     if can_load(w, k, p) == n:
#         print(p)
#         break
# =============================================================================
right = maxw*n
left = maxw
while left<right:
    mid = (right+left)//2
    cl = can_load(w, k, mid)
#    if cl == n:
#        print(mid)
#        break
#    elif cl < n:
    if cl < n:
        left = mid + 1
    else:
        right = mid
print(right)
### BUGGY CODE ###

N = int(input())
list_a = [int(x) for x in input().split()]

ans = 0

for X in range(min(list_a),max(list_a)+1) :
    ansX = list_a.count(X) + list_a.count(X+1) + list_a.count(X-1)
    ans = max(ans,ansX)

print(ans)


### FIXED CODE ###

N = int(input())
list_a = [int(x) for x in input().split()]

list_X = []

for X in list_a :
    list_X.append(X)
    list_X.append(X+1)
    list_X.append(X-1)

from collections import Counter
print(max(Counter(list_X).values()))
### BUGGY CODE ###

N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
kouho = [i + 1 for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    A = a in kouho
    B = b in kouho
    if A or B:
        if H[a] > H[b] and B:
            kouho.remove(b)
        elif H[a] < H[b] and A:
            kouho.remove(a)
        elif H[a] == H[b]:
            if A:
                kouho.remove(a)
            if B:
                kouho.remove(b)
print(len(kouho))


### FIXED CODE ###

N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
kouho = set([i + 1 for i in range(N)])
hazure = set()
for i in range(M):
    a, b = map(int, input().split())
    Ha = H[a]
    Hb = H[b]
    if Ha >= Hb:
        hazure.add(b)
    if Ha <= Hb:
        hazure.add(a)
ans = kouho - hazure
print(len(ans))
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += A[i] * A[j]
ans %= (10**9+7)
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
B = [A[0]]
for j in range(1,n):
    B.append(A[j]+B[j-1])
for i in range(n-1):
    ans += A[i] * (B[-1]-B[i])
    ans %= M
ans %= M
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
ans = []
rl = []
for i in range(Q):
    a,b = map(int,input().split())
    rl += [[a,b]]

for i in range(Q):
    count = 0
    for j in range(rl[i][0]-1,rl[i][-1]-1):
        if S[j] == "A" and S[j+1] == "C":
            count += 1
    ans.append(count)
    
for i in range(Q):
    print(ans[i])


### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
lr = []
S_temp = []
S_temp.append(0)
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        S_temp.append(S_temp[i-1] + 1)
    else:
        S_temp.append(S_temp[i-1])
for i in range(Q):
    a,b = map(int,input().split())
    lr.append([a-1,b-1])

for i in range(Q):
    print(S_temp[lr[i][-1]] - S_temp[lr[i][0]])
### BUGGY CODE ###


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

y = y // 1000

def find_by_for(v, n):
    """
        the tuple by example
        ((0, 0, 0), (10, 5, 1), 100, 10)
    """
    queue = []
    queue.append(((0, 0, 0), (1, 5, 10), v, n))
    while queue:
        xs, fv, v, n = queue.pop()
        if v == 0 and n == 0:
            return "%d %d %d"%(xs[2], xs[1], xs[0])
        elif not fv or v <= 0 or n <= 0:
            pass
        else:
            queue.append((xs, fv[:-1], v, n))
            z = list(xs) 
            idx = len(fv) -1
            z[idx] +=1
            queue.append((tuple(z), fv, v - fv[idx], n -1))
    return "-1 -1 -1"

print(find_by_for(y, n))
    


### FIXED CODE ###

def find_min(v):
    x = v % 10
    return (x % 5, x//5, v // 10)

def find_max(v):
    return (v, 0, 0)


def conv10to5(xs):
    return (xs[0], xs[1] +2, xs[2] - 1)

def undoconv10to5(xs):
    return (xs[0], xs[1] -2, xs[2] + 1)


def conv5to1(xs):
    return (xs[0]+5, xs[1] -1, xs[2])


def next(xs):
    if xs[2] == 0:
        if xs[1] == 0:
            return None
        else:
            return conv5to1(xs)
    else:
        if xs[1] < 7:
            return conv10to5(xs)
        else:
            return conv5to1(undoconv10to5(undoconv10to5(undoconv10to5(xs))))


def find(v, n):
    xs = find_min(v)
    m = sum(xs)
    if m > n or n > v:
        return (-1, -1, -1)

    while xs:
        if sum(xs) == n:
            return xs
        xs = next(xs)
    return (-1, -1, -1)



if __name__ == "__main__":
    n, y = map(int, input().split())
    y = y // 1000
    print("{2} {1} {0}".format(*find(y, n)))
### BUGGY CODE ###

n=int(input())
lengths=sorted([int(i) for i in input().split()])
import itertools as it
import math as ma

cnt=0
triangle=[list(i) for i in it.combinations(lengths,3)]

for i in range(len(triangle)):
    a=triangle[i].pop(0)
    b=triangle[i].pop(0)
    c=triangle[i].pop(0)
    if  ma.floor(b-a)<c<(b+a):
        cnt+=1

print(cnt)

### FIXED CODE ###

from bisect import bisect_right
n=int(input())
L=[int(i) for i in input().split()]
L.sort()


ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    c=L[i]+L[j]-1
    ans+=bisect_right(L,c)-j-1
    
print(ans)
### BUGGY CODE ###

from itertools import combinations

N,K=list(map(int, input().split()))
P=list(map(int, input().split()))
ans=float('INF')
L=list(combinations(range(N),K))
for a in L:
    sums=0
    for i in range(K):
        sums+=P[a[i]]
    # print(sums)
    ans=min(ans,sums)
print(ans)

### FIXED CODE ###

N,K=list(map(int, input().split()))
P=list(map(int, input().split()))
P.sort()
L=P[:K]
print(sum(L))
### BUGGY CODE ###

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

for i in range(k):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
print(a, b)

### FIXED CODE ###

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

if a >= k:
  print(a-k, b)
elif a + b >= k:
  print(0, a+b-k)
else:
  print(0, 0)
### BUGGY CODE ###

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

s = 0

for i in range(0, n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      
      t = length[i]
      
      if t < length[j]:
        t = length[j]
      if t < length[k]:
        t = length[k]
        
      if t*2 < length[i] + length[j] + length[k]:
        s = s+1      
    
print(s)

### FIXED CODE ###

import bisect
n = int(input())
lst = list(map(int, input().split()))
lst.sort()

ans = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    a = lst[i]
    b = lst[j]
    border = a + b
    dig = bisect.bisect_left(lst, border)
    ans += max(0, dig - j - 1)
    
print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
Queries = [[j for j in input().split()] for i in range(Q)]

for query in Queries:
    if query[0] == "1":
        S = S[::-1]
    else:
        if query[1] == "1":
            S = query[2] + S
        else:
            S = S + query[2]
            
print(S)

### FIXED CODE ###

S = input()
Q = int(input())

front = ""
end = ""
f = 0
for i in range(Q):
    query = input().split()

    if query[0] == "1":
        if f == 0:
            f = 1
        else:
            f = 0
    else:
        if f == 0:
            if query[1] == "1":
                front = query[2] + front
            else:
                end = end + query[2]
        else:
            if query[1] == "2":
                front = query[2] + front
            else:
                end = end + query[2]

S = front + S + end
if f == 1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
  num = int(input())
  if num in A:
    A.remove(num)
  else:
    A.append(num)

ans = len(A)
print(ans)

### FIXED CODE ###

import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))
### BUGGY CODE ###

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

i = 0
score = 1
b_score = None
while i < n:
    score *= a_l[i]
    if i > k-1:
        score = int(score/a_l[i-k])
    if b_score is not None:
        if score > b_score:
            print('Yes')
        else:
            print('No')
    if i >= k-1:
        b_score = score
    i+=1

### FIXED CODE ###

n, k = map(int, input().split())
a_l = list(map(int, input().split()))
i = 0
while i < n:
    if i >= k:
        if a_l[i] > a_l[i-k]:
            print('Yes')
        else:
            print('No')
    i+=1
### BUGGY CODE ###

import sys
from itertools import combinations

def comb_mod(n, r, MOD=10**9+7):
    if n < 0 or r < 0 or n < r:
        return 0

    factrial = [1] * (n+1)
    for k in range(1, n+1):
        factrial[k] = (factrial[k-1] * k) % MOD

    fact_inv = [1] * (n+1)
    fact_inv[n] = pow(factrial[n], MOD - 2, MOD)
    for k in range(n-1, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD

    return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD


def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M, K = map(int, input().split())

    # The number of times that pieces are located on certain two tiles.
    num = comb_mod(N*M-2, K-2)

    ans = 0
    # Column-wise distance
    for a, b in combinations(range(M), 2):
        ans += abs(a - b) * N**2 * num
        ans %= MOD

    # Row-wise distance
    for a, b in combinations(range(N), 2):
        ans += abs(a - b) * M**2 * num
        ans %= MOD

    return ans


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from itertools import combinations

def comb_mod(n, r, MOD=10**9+7):
    if n < 0 or r < 0 or n < r:
        return 0

    factrial = [1] * (n+1)
    for k in range(1, n+1):
        factrial[k] = (factrial[k-1] * k) % MOD

    fact_inv = [1] * (n+1)
    fact_inv[n] = pow(factrial[n], MOD - 2, MOD)
    for k in range(n-1, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD

    return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD


def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M, K = map(int, input().split())

    # The number of times that pieces are located on certain two tiles.
    num = comb_mod(N*M-2, K-2)

    ans = 0
    # Column-wise distance
    for i in range(M):
        ans += i * (M - i) * N**2 * num
        ans %= MOD

    # Row-wise distance
    for i in range(N):
        ans += i * (N - i) * M**2 * num
        ans %= MOD

    return ans


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

import itertools
import collections

# 解説を読んだ。
n, x, y = [int(x) for x in input().split()]

nodes = [i for i in range(1, n + 1)]
patterns = itertools.combinations(nodes, 2)

distannces = []
distannces_append = distannces.append
for p in patterns:
    routes = (
        abs(p[1] - p[0]),
        abs(x - p[0]) + 1 + abs(p[1] - y),
        abs(y - p[0]) + 1 + abs(p[1] - x)
    )
    distannces_append(min(routes))

c = collections.Counter(distannces)

# distannces_count = distannces.count
for k in range(1, n):
    print(c[k])

# 後半 TLE したのでリストの関数をオブジェクトに格納した。


### FIXED CODE ###

from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = {i: 0 for i in range(n)}


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = deque()
    qu_append = qu.append
    qu_popleft = qu.popleft
    qu_append(start_v)
    # 始点からvに移動するまでの最短距離: dist[v]
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        if dist[v] != BIG:
            # 既に訪問済みで距離が求められている。
            return
        dist[v] = d
        qu_append(v)

    push(start_v, 0)

    while len(qu):
        v = qu_popleft()
        # 始点からvの次の頂点へ移動する距離。
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        if dist[i] != 0:
            ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

    for i in range(1, n):
        print(ans[i] // 2)


if __name__ == '__main__':
    main()

# TLE
### BUGGY CODE ###

N, C = map(int, input().split())
TVs = [[] for i in range(C)]
for i in range(N):
    s, t, c = map(int, input().split())
    TVs[c - 1].append((s, t))

periods = [0] * (2 * 10 ** 5)

for c, TVc in enumerate(TVs):
    ps = [0] * (2 * 10 ** 5)

    for s, t in TVc:
        ps[s * 2 - 1: t * 2 - 2 + 1] = list(map(lambda x: x + 1, ps[s * 2 - 1: t * 2 - 2 + 1]))

    for i in range(len(ps) - 1):
        ps[i] = max(ps[i], ps[i + 1])

    periods = list(map(sum, zip(periods, ps)))

print(max(periods))


### FIXED CODE ###

import heapq

N, C = map(int, input().split())
TVs = [[] for i in range(C)]
for i in range(N):
    s, t, ch = map(int, input().split())
    TVs[ch - 1].append((s, t))

pq = []
for ch, TVc in enumerate(TVs):
    if not TVc: continue
    TVc.sort()
    heapq.heappush(pq, (TVc[0][0] - 0.5, ch))

states = [0] * C
iTVs = [0] * C

prev = 0
ans = 0
while pq:
    tm, ch = heapq.heappop(pq)
    if tm != prev:
        ans = max(ans, sum(states))
        prev = tm

    if states[ch] == 0:
        # チャンネルchの番組録画を、時刻tmから開始
        states[ch] = 1
        heapq.heappush(pq, (TVs[ch][iTVs[ch]][1], ch)) # 終了時刻をpqに追加
    else:
        # チャンネルchの番組録画を、時刻tmで終了
        states[ch] = 0
        iTVs[ch] += 1
        if iTVs[ch] >= len(TVs[ch]): continue

        if tm == TVs[ch][iTVs[ch]][0]:
            # 録画範囲が連続しているならば、次の番組録画を開始
            states[ch] = 1
            heapq.heappush(pq, (TVs[ch][iTVs[ch]][1], ch)) # 終了時刻をpqに追加
        else:
            heapq.heappush(pq, (TVs[ch][iTVs[ch]][0] - 0.5, ch)) # 次の開始時刻をpqに追加

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

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

    sum_div = sum(range(1, n+1))
    for i in range(2, n+1):
        sum_div += sum(range(i, n+1, i))
    print(sum_div)

main()

### FIXED CODE ###

n = int(input())

sum_div = sum(range(1, n+1))
for i in range(2, n+1):
    sum_div += sum(range(i, n+1, i))
print(sum_div)
### BUGGY CODE ###

from sys import stdin
input = stdin.readline

def SumOfProductParis(n):
    if n == 0:
        return 0
    elif n == 1:
        return A[0]
    else:
        result = 0
        for i in range(0, n-1):
            for j in range(i+1, n):
                result += A[i]*A[j]
        return result%(10**9+7)

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

print(SumOfProductParis(N))

### FIXED CODE ###

from sys import stdin
input = stdin.readline

def SumOfProductParis(n):
    if n == 0:
        return 0
    elif n == 1:
        return A[0]
    else:
        result = 0
        temp = sum(A)
        result = temp**2
        for i in range(n):
            result -= A[i]**2
        return (result//2)%(10**9+7)

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

print(SumOfProductParis(N))
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i]+l[j] > l[k]:
                ans += 1
            else:
                break

print(ans)

### FIXED CODE ###

import bisect

n = int(input())
l = list(map(int, input().split()))
ans = 0
l.sort()

for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect.bisect_left(l, l[i]+l[j])
        if c_i > j:
            ans += c_i - j - 1
        else:
            continue
print(ans)
### BUGGY CODE ###

N = int(raw_input())
A = []
for n in xrange(N):
  A.append(map(int, raw_input().split(' ')))

answer = 0
for i in xrange(N):
  for j in xrange(i):
    other_route = False
    for k in xrange(N):
      if k == i or k == j:
        continue
      L = A[i][k] + A[k][j]
      if A[i][j] == L:
        other_route = True
      elif A[i][j] > L:
        print -1
        exit()
    if not other_route:
      answer += A[i][j]

print answer

### FIXED CODE ###

N = int(raw_input())
A = []
for n in xrange(N):
  A.append(map(int, raw_input().split(' ')))
  A[n][n] = 1000000001

answer = 0
for i in range(N):
  Ai = A[i]
  for j in range(i):
    Aij = Ai[j]
    L = min(map(sum, zip(Ai, A[j])))
    if Aij < L:
      answer += Aij
    else:
      if Aij > L:
        print -1
        exit()
print answer
### BUGGY CODE ###

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

n_pears = 0
used_balls = []

for i in reversed(range(0, len(A))):
    if i in used_balls:
        continue
    for j in reversed(range(0, i)):
        if j in used_balls:
            continue
        if not ((A[i] + A[j]) & (A[i] + A[j] - 1)):
            n_pears += 1
            used_balls.append(j)
            break

print(n_pears)

### FIXED CODE ###

import math
from collections import Counter


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

n_pears = 0
counter = Counter(A)

for i in reversed(range(0, len(A))):
    if counter[A[i]] <= 0:
        continue
    counter[A[i]] -= 1
    Aj = 2 ** int(math.log2(A[i]) + 1) - A[i]
    if counter[Aj] > 0:
        n_pears += 1
        counter[Aj] -= 1

print(n_pears)
### BUGGY CODE ###

s = input().strip()
t = input().strip()

NS = len(s)
NT = len(t)

dp = [[0] * (NT+2) for i in range(NS+2)]
dp2 = [[""] * (NT+2) for i in range(NS+2)]

for i in range(1,NS+1):
    for j in range(1,NT+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1])
            if dp[i-1][j-1]+1 > dp[i-1][j] and dp[i-1][j-1]+1 > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j-1] + s[i-1]
            elif dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            if dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
print(dp2[NS][NT])


### FIXED CODE ###

input = raw_input
s = input().strip()
t = input().strip()

NS = len(s)
NT = len(t)

dp = [[0] * (NT+2) for i in range(NS+2)]
dp2 = [[""] * (NT+2) for i in range(NS+2)]

for i in range(1,NS+1):
    for j in range(1,NT+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = max(dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1])
            if dp[i-1][j-1]+1 > dp[i-1][j] and dp[i-1][j-1]+1 > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j-1] + s[i-1]
            elif dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            if dp[i-1][j] > dp[i][j-1]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = dp2[i][j-1]
print(dp2[NS][NT])
### BUGGY CODE ###

def main():
	n=int(input())
	src = [int(item) for item in input().split()]
	dst = [int(item) for item in input().split()]
	q=set()
	ans=0
	def	SandQ(i):
		ri=i+1
		li=i-1
		if i==0:li=n-1
		if i==n-1:ri=0
		x=0
		if dst[i]-src[i]>=dst[ri]+dst[li]:
			x=(dst[i]-src[i])//(dst[ri]+dst[li])
			dst[i]-=(dst[ri]+dst[li])*x
			q.add(li)
			q.add(ri)
		return x;
	for i in range(n):
		ans+=SandQ(i)
	while len(q)>0:
		i=q.pop()
		ans+=SandQ(i)
	for i in range(n):
		if src[i]!=dst[i]:
			print(-1)
			exit()
	else:print(ans)
main()


### FIXED CODE ###

def main():
	n=int(input())
	src = [int(item) for item in input().split()]
	dst = [int(item) for item in input().split()]
	ans=0
	def	SandQ(i):
		ri=i+1
		li=i-1
		if i==0:li=n-1
		if i==n-1:ri=0
		x=0
		if dst[i]-src[i]>=dst[ri]+dst[li]:
			x=(dst[i]-src[i])//(dst[ri]+dst[li])
			dst[i]-=(dst[ri]+dst[li])*x
			x+=SandQ(li)
			x+=SandQ(ri)
		return x;
	for i in range(n):
		ans+=SandQ(i)
	for i in range(n):
		if src[i]!=dst[i]:
			print(-1)
			exit()
	else:print(ans)
main()
### BUGGY CODE ###

import numpy as np

mass = int(input())
buildings = np.array(list(int(i) for i in input().split()))
move_history = []

for place in range(mass):
  now = place
  move_num = 0
  for move in range(mass-(place+1)):
    if buildings[now] >= buildings[now+1]:
      move_num += 1
      now += 1
    else:
      break
  move_history.append(move_num)
print(max(move_history))

### FIXED CODE ###

import numpy as np

mass = int(input())
buildings = np.array(list(int(i) for i in input().split()))
move_count = 0
max_move = 0

for i in range(mass-1):
  if buildings[i] >= buildings[i+1]:
    move_count += 1
  else:
    if move_count > max_move:
      max_move = move_count
    move_count = 0
  if move_count > max_move:
    max_move = move_count

print(max_move)
### BUGGY CODE ###

s = input()
s = list(s)
idx = 0
blocks = 0
while idx != len(s) - 1:
    if s[idx] == '0' and s[idx+1] == '1':

        tmp1 = s[idx]
        tmp2 = s[idx+1]

        s.remove(tmp1)
        s.remove(tmp2)

        idx = 0
        blocks += 2

    elif s[idx] == '1' and s[idx+1] == '0':

        tmp1 = s[idx]
        tmp2 = s[idx+1]

        s.remove(tmp1)
        s.remove(tmp2)

        idx = 0
        blocks += 2

    else:
        idx += 1
        
    if len(s) == 0:
        break

print(blocks)


### FIXED CODE ###

s = input()
num_0 = s.count('0')
num_1 = s.count('1')
print(2 * min(num_0, num_1))
### BUGGY CODE ###

N=int(input())
s=input()

sa=s[:N]
sb=s[N:]

import itertools
ALLIST=list(itertools.product((0,1),repeat=N))

from collections import defaultdict
STRA = defaultdict(int)
STRB = defaultdict(int)

for i in ALLIST:
    red_a=""
    blue_a=""
    red_b=""
    blue_b=""
    for j in range(N):
        if i[j]==0:
            red_a+=sa[j]
            red_b+=sb[j]
        else:
            blue_a+=sa[j]
            blue_b+=sb[j]

    STRA[(red_a,blue_a)]+=1
    STRB[(red_b,blue_b)]+=1

ANS=0
for key in STRA:
    key_reverse=(key[0][::-1],key[1][::-1])
    ANS+=STRA[key]*STRB[key_reverse]

print(ANS)

### FIXED CODE ###

N=int(input())
s=input()

sa=s[:N]
sb=s[N:]

import itertools
ALLIST=list(itertools.product((0,1),repeat=N))

from collections import defaultdict
STRA = defaultdict(int)
STRB = defaultdict(int)

for i in ALLIST:
    red_a=""
    blue_a=""
    red_b=""
    blue_b=""
    for j in range(N):
        if i[j]==0:
            red_a+=sa[j]
            red_b+=sb[j]
        else:
            blue_a+=sa[j]
            blue_b+=sb[j]

    STRA[(red_a[::-1],blue_a[::-1])]+=1
    STRB[(red_b,blue_b)]+=1

ANS=0
for key in STRA:
    ANS+=STRA[key]*STRB[key]

print(ANS)
### BUGGY CODE ###

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

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            for k in range(j + 1, N):
                if (S[i] != S[k] and S[j] != S[k]) and j - i != k - j:
                    ans += 1

print(ans)

### FIXED CODE ###

# D - RGB Triplets

N = int(input())
S = input()
cnt_R = S.count('R')
cnt_G = S.count('G')
cnt_B = S.count('B')
total = cnt_R * cnt_G * cnt_B

expt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j + (j - i)
        if k < N and (S[i] != S[j] and S[j] != S[k] and S[i] != S[k]):
            expt += 1

print(total - expt)