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

from collections import deque

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

cnt = 0
n = 1
i = 0

while(True):
    if a[i] != n:
        a.pop(i)
        cnt += 1
    else:
        n += 1
        i += 1

    if len(a) == 0:
        print(-1)
        exit()

    if i >= len(a):
        break

print(cnt)


### FIXED CODE ###

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

cnt = 0
n = 1

for i in range(N):
    if a[i] == n:
        n += 1
    else:
        cnt += 1

if cnt == N:
    print(-1)
    exit()

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

import heapq

n = int(input())
array = [int(i) for i in input().split()]
ans=-1e14
l_array = []
r_array = []
l_sum = [0]*(n+1)
r_sum = [0]*(n+1)

# left-n and right-n numbers
for i in range(n):
    heapq.heappush(l_array, array[i])
    heapq.heappush(r_array, (-array[3*n-1-i], array[3*n-1-i]))

l_sum[0] = sum(l_array)
r_sum[n] = sum([i[1] for i in r_array])

for i in range(n, 2*n):
    heapq.heappush(l_array, array[i])
    heapq.heappush(r_array, (-array[3*n-1-i], array[3*n-1-i]))
    heapq.heappop(l_array)
    heapq.heappop(r_array)

    l_sum[i-n+1] = sum(l_array)
    r_sum[2*n-1-i] = sum([j[1] for j in r_array])

for i in range(n+1):
    ans = max(ans, l_sum[i]-r_sum[i])

print(ans)

### FIXED CODE ###

import heapq

n = int(input())
array = [int(i) for i in input().split()]
ans=-1e14
l_array = []
r_array = []
l_sum = [0]*(n+1)
r_sum = [0]*(n+1)

# left-n and right-n numbers
for i in range(n):
    heapq.heappush(l_array, array[i])
    heapq.heappush(r_array, (-array[3*n-1-i], array[3*n-1-i]))

l_sum[0] = sum(l_array)
r_sum[n] = sum([i[1] for i in r_array])

for i in range(n, 2*n):
    heapq.heappush(l_array, array[i])
    heapq.heappush(r_array, (-array[3*n-1-i], array[3*n-1-i]))
    l_min = heapq.heappop(l_array)
    r_max = heapq.heappop(r_array)[1]

    # l_sum[i-n+1] = sum(l_array)
    # r_sum[2*n-1-i] = sum([j[1] for j in r_array])
    l_sum[i-n+1] = l_sum[i-n] - l_min + array[i]
    r_sum[2*n-1-i] = r_sum[2*n-i] - r_max + array[3*n-1-i]

for i in range(n+1):
    ans = max(ans, l_sum[i]-r_sum[i])

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

n= int(input())
s = input()
R = []
G = []
B = []
import bisect
def func(l1,l2,l3):
  res =0
  for i in l1:
    for j in l2:
      if i>j:
        continue
      a = l3[bisect.bisect_left(l3,j):]
      res += len(a)
      if j*2-i in a:
        res -=1
  return res

for i in range(n):
  if s[i] == 'R':
    R.append(i+1)
  elif s[i] == 'G':
    G.append(i+1)
  else:
    B.append(i+1)
    
ans = func(R,G,B)+func(R,B,G)+func(G,R,B)+func(G,B,R) + func(B,R,G)+func(B,G,R)
print(ans)
  


### FIXED CODE ###

import sys
input = sys.stdin.readline

n= int(input())
s = input()
R = []
G = []
B = []
import bisect
def func(l1,l2,l3,l3set):
  res =0
  for i in l1:
    for j in l2[bisect.bisect_left(l2,i):]:
      a = l3[bisect.bisect_left(l3,j):]
      res += len(a)
      if j*2-i in l3set:
        res -=1
  return res

for i in range(n):
  if s[i] == 'R':
    R.append(i+1)
  elif s[i] == 'G':
    G.append(i+1)
  else:
    B.append(i+1)
    
    
R_set = set(R)
G_set = set(G)
B_set = set(B)
ans = func(R,G,B,B_set)+func(R,B,G,G_set)+func(G,R,B,B_set)+func(G,B,R,R_set) + func(B,R,G,G_set)+func(B,G,R,R_set)
print(ans)
### BUGGY CODE ###

import sys
import bisect
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)
B = [[A[i], F[i]] for i in range(N)]
B.sort(reverse=True, key=lambda x: x[0]*x[1])


for i in range(K):
    B.sort(key=lambda x: x[0]*x[1])
    if B[N-1][0] > 0:
        tmp = B.pop()
        tmp[0] -= 1
        bisect.insort_left(B, tmp)
    else:
        break
B.sort(reverse=True, key=lambda x: x[0]*x[1])
print(B[0][0]*B[0][1])


### FIXED CODE ###

import sys
import bisect
import math
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

B = [(A[i]*F[i], F[i]) for i in range(N)]
B.sort(reverse=True)
L = 0
R = B[0][0]
if sum(A) <= K:
    print(0)
    exit(0)
while(1):
    ans = (L+R) // 2
    flag = True
    tmp = 0
    for i in range(N):
        tmp += math.ceil(max(B[i][0] - ans, 0) / B[i][1])
        if tmp > K:
            flag = False
            break
    if flag:
        R = ans
    else:
        L = ans
    if L == R or L+1 == R:
        print(R)
        break
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())
cx, cy = map(lambda x: int(x) - 1, input().split())
dx, dy = map(lambda x: int(x) - 1, input().split())
s = [input() for _ in range(h)]
c = [[10**6] * w for _ in range(h)]


def bfs():
    d = ((1, 0), (-1, 0), (0, 1), (0, -1))
    q = deque([(cx, cy)])

    c[cx][cy] = 0

    while q:
        x, y = q.pop()
        cp = c[x][y]
        if (x, y) == (dx, dy):
            c[x][y] = cp
            break
        for i, j in d:
            nx = x + i
            ny = y + j
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and c[nx][
                    ny] > cp:
                q.append((nx, ny))
                c[nx][ny] = cp
        cp += 1
        for i in range(-2, 3):
            for j in range(-2, 3):
                nx = x + i
                ny = y + j
                if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and c[nx][
                        ny] > cp:
                    c[nx][ny] = cp
                    q.appendleft((nx, ny))

    return -1 * (c[dx][dy] == 10**6) or c[dx][dy]


print(bfs())


### FIXED CODE ###

from collections import deque


h, w = map(int,input().split())
ch, cw = map(lambda x: int(x) - 1, input().split())
dh, dw = map(lambda x: int(x) - 1, input().split())

G = []
for i in range(h):
    G.append(list(input()))

queue = deque([(ch, cw)])
S = [[float("inf")]*w for _ in range(h)]
S[ch][cw] = 0

while queue:
    y, x = queue.popleft()
    dx_dy = ((1,0),(0,1),(-1,0),(0,-1))
    ans = S[y][x]

    if (y, x) == (dh, dw):
            S[y][x] = ans
            break

    for j, i in dx_dy:
        if 0 <= x+i < w and 0 <= y+j < h and S[y+j][x+i] > ans and G[y+j][x+i] == ".":
            queue.appendleft((y+j, x+i))
            S[y+j][x+i] = ans
            

    ans += 1
    for i in range(-2, 3):
        for j in range(-2, 3):
            if 0 <= x+i < w and 0 <= y+j < h and S[y+j][x+i] > ans and G[y+j][x+i] == ".":
                S[y+j][x+i] = ans
                queue.append((y+j, x+i))


if S[dh][dw] == float("inf"):
    print(-1)
else:
    print(S[dh][dw])
### BUGGY CODE ###

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

from functools import reduce
import fractions

def gcd(num_list):
    #return reduce(math.gcd, num_list)
    return reduce(fractions.gcd, num_list)

max_kys = 0

for i in range(N):
    B = A.copy()
    B.pop(i)
    max_kys = max(max_kys, gcd(B))

print(max_kys)

### FIXED CODE ###

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

index = list(range(N))
L = index.copy()

L[0] = 0
for i in index[:-1]:
    #print(i)
    L[i+1] = gcd(L[i], A[i])

R = index.copy()
R.append(0)
for i in reversed(index):
    #print(i)
    R[i] = gcd(R[i+1], A[i])

# confirm
#print(L)
#print(R)

M = []
for j in range(len(L)):
    m = gcd(L[j], R[j+1])
    #print(m)
    M.append(m)

# Confirm
#print(M)

# Answer
print(max(M))
### BUGGY CODE ###

from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    len_S = len(S)
    memo = set()
    cnt = 0
    for i in range(len_S):
        for j in range(i+3,len_S):
            if j == i+3:
                mod = int(S[len_S-j-1:len_S-i])%3
            else:
                mod = (mod+int(S[len_S-j-1]))%3
            if mod == 0:
                _ = int(S[len_S-j-1:len_S-i])
                if _ in memo:
                    cnt += 1
                elif _%673==0:
                    cnt += 1
                    memo.add(_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    len_S = len(S)
    cnt = 0
    for i in range(len_S):
        for j in range(i+3,len_S):
            if j == i+3:
                mod = int(S[len_S-j-1:len_S-i])%3
            else:
                mod = (mod+int(S[len_S-j-1]))%3
            if mod == 0:
                _ = int(S[len_S-j-1:len_S-i])
                if _%673==0:
                    cnt += 1
                    break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    mod_arr = [0] * 2019
    mod_arr[0] += 1

    num, dec = 0, 1
    for s in S[::-1]:
        num += int(s)*dec
        num %= 2019
        dec *= 10
        dec %= 2019
        mod_arr[num] += 1

    for i in range(2019):
        if mod_arr[i] > 0:
            cnt += mod_arr[i]*(mod_arr[i]-1)//2
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    s = input()
    ans = float('inf')
    for i in range(n):
        tmp = s[:i].count('W') + s[i:].count('E')
        if ans > tmp:
            ans = tmp

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    s = input()
    cnt = s.count('E')
    m = cnt
    for i in s:
        if i == 'E':
            cnt -= 1
        else:
            cnt += 1
        m = min(m, cnt)
    print(m)


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

# coding: utf-8
# Your code here!
n=int(input())
a = [int(i) for i in input().split()]
import sys
sys.setrecursionlimit(10**7)

ko = [0]*4
for i in a:
    ko[i] += 1

dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]

cc=ko[1]+ko[2]+ko[3]
ccc=ko[2]+ko[3]
for k in range(ko[3]+1):
    for j in range(ccc+1):
        for i in range(cc+1):
            t=i+j+k
#            print(i,j,k)
            if i != 0:
                dp[i][j][k] += (dp[i-1][j][k] + n/t)*i/t
            if j != 0 and i < n:
                dp[i][j][k] += (dp[i+1][j-1][k] + n/t)*j/t
            if k != 0 and j < n:
                dp[i][j][k] += (dp[i][j+1][k-1] + n/t)*k/t
#print(dp)
print(dp[ko[1]][ko[2]][ko[3]])


### FIXED CODE ###

# coding: utf-8
# Your code here!
n=int(input())
a = [int(i) for i in input().split()]
import sys
sys.setrecursionlimit(10**7)

ko = [0]*4
for i in a:
    ko[i] += 1

dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]

cc=ko[1]+ko[2]+ko[3]
ccc=ko[2]+ko[3]
for k in range(ko[3]+1):
    for j in range(ccc+1-k):
        for i in range(cc+1-k-j):
            t=i+j+k
#            print(i,j,k)
            if i != 0:
                dp[i][j][k] += (dp[i-1][j][k] + n/t)*i/t
            if j != 0 and i < n:
                dp[i][j][k] += (dp[i+1][j-1][k] + n/t)*j/t
            if k != 0 and j < n:
                dp[i][j][k] += (dp[i][j+1][k-1] + n/t)*k/t
#print(dp)
print(dp[ko[1]][ko[2]][ko[3]])
### BUGGY CODE ###

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

MOD = 10**9 + 7

X,Y = map(int, input().split())

if not (X+Y) % 3:
    m = (2*X - Y)//3
    n = (2*Y - X)//3
    if n >= 0 and m >= 0:
        print(comb(n+m,min(n,m)) % MOD)
    else:
        print(0)
else:
    print(0)


### FIXED CODE ###

MOD = 10**9 + 7

def comb(n,r):
  if (r<0 and r>n):
    return 0
  r = min(r,n-r)
  return g1[n] * g2[r] * g2[n-r] % MOD

N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N+1):
  g1.append((g1[-1]*i)%MOD)
  inverse.append((-inverse[MOD%i]*(MOD//i))%MOD)
  g2.append((g2[-1]*inverse[-1])%MOD)
  
X,Y = map(int, input().split())


if not (X+Y) % 3:
    m = (2*X - Y)//3
    n = (2*Y - X)//3
    if n >= 0 and m >= 0:
        print(comb(n+m,n))
    else:
        print(0)
else:
    print(0)
### BUGGY CODE ###

S = input()
N = len(S)
q = []
A = 13-5
for i in range(N-1,-1,-1):
    if S[i] == '?':
        q.append(N-i-1)
    else:
        A = (A+int(S[i])*(10**(N-i-1)))%13
DP= [[0]*13 for i in range(len(q)+1)]
DP[0][A] = 1
B = [[0]*13 for i in range(13)]
for i in range(13):
    for j in range(13):
        B[i][j] = (i*j)%13
T = [1,10,9,12,3,4]
for i in range(len(q)):
    for j in range(13):
        for k in range(10):
            DP[i+1][(j+k*T[q[i]%6])%13] = (DP[i+1][(j+k*T[q[i]%6])%13]+DP[i][j])%(10**9+7)
print(DP[-1][0])
        


### FIXED CODE ###

S = input()
N = len(S)
DP =[0]*13
DP[0] = 1
A = 0
MOD = 10**9+7

T = [1,10,9,12,3,4]
A = 0
for i in range(N):
    A*=10
    if S[i] == "?":
        hoge = [0]*13
        for j in range(13):
            for k in range(10):
                hoge[(j+k*T[(N-i-1)%6])%13] = (hoge[(j+k*T[(N-i-1)%6])%13] + DP[j])%MOD
        DP = hoge[:]
    else:
        A += int(S[i])
    A = A%13
print(DP[(5-A)%13])
### BUGGY CODE ###

n,m = map(int,input().split())
a = []
b = []
ans = ""
for i in range(m):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)

xton = []
#nへ向かう便が出てる島を確認する
for i in range(m):
    if b[i] == n:
        xton.append(a[i])
#nへ向かう便が出ている島へ1から向かう便があるか確認する
for i in range(m):
    if a[i] == 1 and b[i] in xton:
        ans = "POSSIBLE"
        break
    else:
        ans = "IMPOSSIBLE"
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = []
b = []
ans = ""
for i in range(m):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)

xton = set()
#nへ向かう便が出てる島を確認する
for i in range(m):
    if b[i] == n:
        xton.add(a[i])
#nへ向かう便が出ている島へ1から向かう便があるか確認する
for i in range(m):
    if a[i] == 1 and b[i] in xton:
        ans = "POSSIBLE"
        break
    else:
        ans = "IMPOSSIBLE"
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
tmp=[]
for i in range(n):
    aa = a.copy()
    aa.pop(i)
    ans = aa[0]
    for j in range(1,len(aa)):
        ans ^= aa[j]
    tmp.append(ans)

print(*tmp)
  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = []
tmp = 0
for i in range(n):
    tmp ^= a[i]

for i in range(n):
    ans.append(tmp ^ a[i])

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

# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

for i in s:
    if i in g:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
s = []
g = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1 and b == N:
        print("POSSIBLE")
        sys.exit()
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)

if len(set(s) & set(g)) != 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

def main():
  xs,ys,xt,yt=map(int,input().split())
  n=int(input())
  xyr=[list(map(int,input().split())) for _ in range(n)]
  xyr.append([xs,ys,0])
  xyr.append([xt,yt,0])
  def dist(xyr,i,j):
    x,y,r=xyr[i]
    x1,y1,r1=xyr[j]
    d=max(0,((x-x1)**2+(y-y1)**2)**0.5-r-r1)
    return d
  from heapq import heappop,heappush
  todo=[[0,n]]
  ka=set(())
  seen=[float('inf')]*(n+2)
  seen[n]=0
  while todo:
    d,v=heappop(todo)
    if v in ka:continue
    if v==n+1:
      print(d)
      exit()
    ka.add(v)
    for nv in range(n+2):
      if v==nv or nv in ka:continue
      nd=dist(xyr,v,nv)
      if seen[nv]>d+nd:
        heappush(todo,[d+nd,nv])
        seen[nv]=d+nd
if __name__=='__main__':
  main()


### FIXED CODE ###

from heapq import heappop,heappush
from math import sqrt
def distf(xyr,i,j):
  x,y,r=xyr[i]
  x1,y1,r1=xyr[j]
  d=max(0,sqrt((x-x1)**2+(y-y1)**2)-r-r1)
  return d

def main():
  xs,ys,xt,yt=map(int,input().split())
  n=int(input())
  xyr=[list(map(int,input().split())) for _ in range(n)]
  xyr.append([xs,ys,0])
  xyr.append([xt,yt,0])
  inf=float('inf')
  dist=[[inf]*(n+2) for _ in range(n+2)]
  for i in range(n+2):
    dist[i][i]=0
  for i in range(n+1):
    for j in range(i+1,n+2):
      dist[i][j]=distf(xyr,i,j)
      dist[j][i]=dist[i][j]
  seen=[inf]*(n+2)
  seen[n]=0
  mi=set(range(n+2))
  while mi:
    d,v=inf,-1
    for j in mi:
      if d>seen[j]:
        d=seen[j]
        v=j
    mi.remove(v)
    for nv in mi:
      nd=dist[v][nv]
      if seen[nv]>seen[v]+nd:
        seen[nv]=seen[v]+nd
  print(seen[n+1])
if __name__=='__main__':
  main()
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

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

dist = [[0]*(W+1) for i in range(H+1)]
for i in range(H):
    dist[i][W] = 1
for i in range(W):
    dist[H][i] = 1
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
que = []
push = que.append
for i in range(H):
    di = dist[i]
    Ai = A[i]
    for j in range(W):
        if Ai[j] == '#':
            di[j] = 1
            push((i, j))

d = 0
que1 = []
push1 = que1.append
while que:
    for dx, dy in dd:
        for y, x in que:
            nx = x + dx; ny = y + dy
            if dist[ny][nx]:
                continue
            dist[ny][nx] = 1
            push1((ny, nx))
    que.clear()
    que, que1 = que1, que
    push, push1 = push1, push
    d += 1
sys.stdout.write("%d\n" % (d-1))

### FIXED CODE ###

from collections import deque

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

dist = [[-1]*W for i in range(H)]
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            dist[i][j] = 0
            que.append((i, j))

d = 0
while que:
    y, x = que.popleft()
    d = dist[y][x]
    for dx, dy in dd:
        nx = x + dx; ny = y + dy
        if not 0 <= nx < W or not 0 <= ny < H or dist[ny][nx] != -1:
            continue
        dist[ny][nx] = d+1
        que.append((ny, nx))
print(d)
### BUGGY CODE ###

from bisect import bisect, bisect_left

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = a[::-1]

ok, ng = -10**19, 10**19
while abs(ng-ok) > 1:
	x = (ng+ok)//2
	res = 0
	for c in a:
		if c*c < x:
			res -= 1
		if c == 0:
			if x > 0:
				res += n
		elif c > 0:
			#res += bisect(a, x/c - 1e-18)
			if c * a[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if a[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
		else:
			#res += n - bisect(a, x/c + 1e-18)
			if c * b[0] >= x:
				pass
			else:
				l, r = 0, n
				while r-l > 1:
					y = (l+r)//2
					if b[y]*c < x:
						l = y
					else:
						r = y
				res += l+1
	res //= 2
	#print(x, res)
	if res < k:
		ok = x
	else:
		ng = x

print(ng-1)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
plus, zero, minus = [], [], []
for x in a:
	if x > 0:
		plus.append(x)
	elif x == 0:
		zero.append(x)
	else:
		minus.append(x)
m, z, p = len(minus), len(zero), len(plus)
mm, zz, pp = m * p, z * (m + p) + (z * (z - 1)) // 2, (m * (m-1)) // 2 + (p * (p-1)) // 2
plus.sort()
plus2 = plus[::-1]
minus.sort()
minus2 = minus[::-1]
#print(mm, zz, pp)

if mm + zz >= k and mm < k:
	print(0)
elif mm >= k:
	ok, ng = -10**19, 0
	while ng-ok > 1:
		x = (ng+ok)//2
		res = 0
		l = 0
		for c in plus:
			if l == m:
				res += m
			elif minus[l] * c >= x:
				res += l
			else:
				while minus[l] * c < x:
					l += 1
					if l == m:
						break
				res += l
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)
else:
	ok, ng = 0, 10**19
	while ng-ok > 1:
		x = (ng+ok)//2
		lm, lp = 0, 0
		res = 0
		for c in minus:
			if c*c < x:
				res -= 1
			if lm == m:
				res += m
			elif minus2[lm] * c >= x:
				res += lm
			else:
				while minus2[lm] * c < x:
					lm += 1
					if lm == m:
						break
				res += lm
		for c in plus2:
			if c*c < x:
				res -= 1
			if lp == p:
				res += p
			elif plus[lp] * c >= x:
				res += lp
			else:
				while plus[lp] * c < x:
					lp += 1
					if lp == p:
						break
				res += lp
		res //= 2
		res += zz + mm
		#print(x, res)
		if res < k:
			ok = x
		else:
			ng = x
	print(ng-1)
### BUGGY CODE ###

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, X, Y = map(int, input().split())

def wf(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

d = [[float('inf')] * N for i in range(N)]

for i in range(N-1):
    d[i][i] = 0
    d[i][i+1] = 1
    d[i+1][i] = 1
d[X-1][Y-1] = 1
d[Y-1][X-1] = 1

d = wf(d)

dd = defaultdict(int)
for i in range(N):
    for j in range(i+1, N):
        dd[d[i][j]] += 1 

for k in range(1, N):
    print(dd[k])



### FIXED CODE ###

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
import heapq
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, X, Y = map(int, input().split())

def dijkstra_heap(s,edge):
    d = [10**20] * N
    used = [True] * N #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
# n,w = map(int,input().split()) #n:頂点数　w:辺の数

edge = [[] for i in range(N)]

for i in range(1, N-1):
    edge[i].append([1, i+1])
    edge[i].append([1, i-1])
edge[0].append([1, 1])
edge[N-1].append([1, N-2])
edge[X-1].append([1, Y-1])
edge[Y-1].append([1, X-1])

dd = defaultdict(int)
for i in range(N):
    dists = dijkstra_heap(i, edge)
    for j in dists[i+1:]:
        dd[j] += 1

for k in range(1, N):
    print(dd[k])
### BUGGY CODE ###

import sys
N = list(input())


N_rev = N[::-1]
#print(N_rev)

while len(N_rev) > 0:
  if N_rev[0] == "m":
    if N_rev[1] == "a" and N_rev[2] == "e" and N_rev[3] == "r" and N_rev[4] == "d":
      N_rev = N_rev[5:]
      #print("subscript[dream]",N_rev)
    else:
      print("NO")
      sys.exit()
  elif N_rev[0] == "r":
    if N_rev[1] == "e" and N_rev[2] == "m" and N_rev[3] == "a" and N_rev[4] == "e" and N_rev[5] == "r" and N_rev[6] == "d":
      N_rev = N_rev[7:]
      #print("subscript[dreamer]",N_rev)
    elif N_rev[1] == "e" and N_rev[2] == "s" and N_rev[3] == "a" and N_rev[4] == "r" and N_rev[5] == "e":
      N_rev = N_rev[6:]
      #print("subscript[eraser]",N_rev)
    else:
      print("NO")
      sys.exit()
  elif N_rev[0] == "e":
    if N_rev[1] == "s" and N_rev[2] == "a" and N_rev[3] == "r" and N_rev[4] == "e":
      N_rev = N_rev[5:]
      #print("subscript[erase]",N_rev)
    else:
      print("NO")
      sys.exit()
  else:
    print("NO")
    sys.exit()

if len(N_rev) == 0:
  print("YES")


### FIXED CODE ###

import re
S = input()
'''
メタ文字：
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
    print('YES')
else:
    print('NO')