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

n = int(input())
x = int(input(),2)
b = int(2**(n-1))
pc = 0
d = []
c = x
for i in range(n):
    d.append(c&1)
    if c&1 == 1:
        pc += 1
    c=c>>1
# print(pc,d)
for i in range(n):
    if d[-i-1]==0:
        m = 1
    else:
        m = -1
    temppc = pc+m
    temp = x^b
    ans = 0
    # print(temp,x,b)
    while temp:
        # print(temp)
        # print(i,temp,ans,temppc)
        # print(temp)
        # s = str(bin(temp))
        # print(temp,popcount(temp))
        if temppc == 0:
            break
        temp = temp % temppc
        ans += 1
        c = temp
        temppc = 0
        while c:
            if c&1 == 1:
                temppc += 1
            c=c>>1
        # print(temp,s)
        # break
    b=b>>1
    print(ans)

### FIXED CODE ###

n = int(input())
x = int(input(),2)
# b = int(2**(n-1))
pc = 0
d = []
c = x
for i in range(n):
    d.append(c&1)
    if c&1 == 1:
        pc += 1
    c=c>>1

mp =  x%(pc+1)
if pc == 1:
    mm = -1
else:
    mm = x%(pc-1)
# print(x,pc,mp,mm)
for i in range(n):
    if d[-i-1]==0:
        m = 1
        temp = (mp+pow(2,n-i-1,pc+1)) % (pc+1)
        ans = 1
    else:
        if mm == -1:
            temp = 0
            ans = 0
        else:    
            m = -1
            temp = (mm-pow(2,n-i-1,pc-1)) % (pc-1)
            ans = 1
    # temppc = pc+m
    # temp = x^b
    # ans = 1
    # print(temp)
    # print(temp,mm,pc,pow(2,n-i,pc+1),(mm-pow(2,n-i-1,pc+1)) % (pc-1))
    while temp:
        
        c = temp
        temppc = 0
        while c:
            if c&1 == 1:
                temppc += 1
            c=c>>1
        # print(temp)
        # print(i,temp,ans,temppc)
        # print(temp)
        # s = str(bin(temp))
        # print(temp,popcount(temp))
        if temppc == 0:
            break
        temp = temp % temppc
        ans += 1
        # c = temp
        # temppc = 0
        # while c:
        #     if c&1 == 1:
        #         temppc += 1
        #     c=c>>1
        # print(temp,s)
        # break
    # b=b>>1
    print(ans)
### BUGGY CODE ###

N = int(input())

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

sum = 0
for i in range(N-1):
    tmp = 0
    for j in range(i+1, N):
        tmp = (A[j]+tmp)
    sum += (A[i] * tmp) % 1000000007
print(sum % 1000000007)


### FIXED CODE ###

N = int(input())

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

total = 0
for i in range(N):
    total += A[i]

sum = 0
for i in range(N-1):
    total -= A[i]
    sum += (A[i] * total) % 1000000007
print(sum % 1000000007)
### BUGGY CODE ###

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

from itertools import combinations as comb

H,W,A,B = map(int, input().split())

HW = len(list(comb([0] * (H+W-2), H-1)))

h = H - A
w = B + 1
ans = 0
# マスを右上に1つずつずらして、必ず通る場所でパターンを足し合わせていく
while h > 0 and w <= W:
    ans += len(list(comb([0] * (h+w-2), h-1))) * len(list(comb([0] * (H-h+W-w), H-h))) % (10 ** 9 + 7)
    h -= 1
    w += 1

print(ans)

### FIXED CODE ###

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

H,W,A,B = map(int, input().split())
mod = (10 ** 9 + 7)

# 予め組み合わせ計算に必要な階乗と逆元のテーブルを作っておく
factorial = [0] * (H+W)
factorial[0] = 1
factorial[1] = 1
inverse = [0] * (H+W)
inverse[0] = 1
inverse[1] = 1
for i in range(2,H+W):
    factorial[i] = factorial[i-1] * i % mod
    # フェルマーの小定理から(x! ** mod-2 % mod == x! ** -1 % mod)
    # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
    inverse[i] = pow(factorial[i], mod-2, mod)
    
# 組み合わせの数だけ返してくれる関数(自作)
def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    # 分子の計算
    numerator = factorial[n]
    # 分母の計算
    denominator = inverse[r] * inverse[n-r] % mod
    return numerator * denominator % mod

h = H - A
w = B + 1
ans = 0
# マスを右上に1つずつずらして、必ず通る場所でパターンを足し合わせていく
while h > 0 and w <= W:
    ans = (ans + nCr(h+w-2, h-1) * nCr(H-h+W-w, H-h)) % mod
    h -= 1
    w += 1

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

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

candidate1 = []
candidate = {}
for i in range(N):
    if i > 1:
        delete_key = []
        for c in candidate.keys():
            if A[i] % c == 0:
                candidate[c]['atari'] += 1
            else:
                candidate[c]['hazure'] += 1        
    elif i == 0:
        candidate1 = make_divisors(A[i])
    elif i == 1:
        candidate2 = make_divisors(A[i])
        prev = -1
        for c in sorted(candidate1 + candidate2):
            if c != prev and prev != -1 and candidate[prev]['atari'] < 2:
                candidate[prev]['hazure'] += 1
            if c not in candidate:
                candidate[c] = {
                    'atari': 1,
                    'hazure': 0
                }
            else:
                candidate[c]['atari'] += 1
            prev = c
        if candidate[prev]['atari'] < 2:
            candidate[prev]['hazure'] += 1            
max = 0
for c in candidate:
    if candidate[c]['hazure'] < 2 and max < c:
        max = c
print(max)

### FIXED CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

candidate1 = []
candidate = {}
for i in range(N):
    if i > 1:
        delete_key = []
        for c in candidate.keys():
            if A[i] % c == 0:
                candidate[c]['atari'] += 1
            else:
                candidate[c]['hazure'] += 1        
    elif i == 0:
        candidate1 = make_divisors(A[i])
    elif i == 1:
        candidate2 = make_divisors(A[i])
        prev = -1
        for c in sorted(candidate1 + candidate2):
            if c != prev and prev != -1 and candidate[prev]['atari'] < 2:
                candidate[prev]['hazure'] += 1
            if c not in candidate:
                candidate[c] = {
                    'atari': 1,
                    'hazure': 0
                }
            else:
                candidate[c]['atari'] += 1
            prev = c
        if candidate[prev]['atari'] < 2:
            candidate[prev]['hazure'] += 1            
max = 0
for c in candidate:
    if candidate[c]['hazure'] < 2 and max < c:
        max = c
print(max)
### BUGGY CODE ###

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

import sys
def g():
    m_l = [0] * (n+1)

    for a in a_l:
        m_l[a] += 1

    r = 0
    for m in m_l:
        if m != 0: r+= 1


    if r <= k:
        print(0)
        sys.exit(0)

    mn = 0
    
    while True:
        mm = min(i for i in m_l if i > 0)

        for i in range(n+1):
            if mm == m_l[i]:
                mn += mm
                r -= 1
                m_l[i] = 0

                if r <= k: return mn
        
print(g())


### FIXED CODE ###

n, k = map(int, input().split())
a_l = list(map(int, input().split()))
           
import sys
import numpy as np

def g():
    m_l = np.array([0]*(n+1))

    r = 0
    for a in a_l:
        if m_l[a] == 0: r += 1
        m_l[a] += 1

    if r <= k:
        print(0)
        sys.exit(0)

    mn = 0
    while True:
        ma = np.ma.masked_equal(m_l, 0, copy=False)
        a = np.where(m_l == ma.min())[0]

        for i in a:
            mn += m_l[i]
            r -= 1
            m_l[i] = 0

            if r <= k: return mn
        
print(g())
### BUGGY CODE ###

from collections import Counter
N = int(input())
S = [input() for _ in range(N)]

col_S = [Counter(s) for s in S]
check_S = [0]*len(S)

res = 0
for ind, col_s in enumerate(col_S):
    if check_S[ind] == 1: continue
    cnt = 1
    for ref_ind, ref_col_s in enumerate(col_S[ind+1:]):
        if col_s == ref_col_s:
            check_S[ind+ref_ind+1] = 1
            cnt += 1
    res += cnt * (cnt-1) / 2

print(int(res))

### FIXED CODE ###

N = int(input())
lS = [list(input()) for _ in range(N)]
S = [''.join(sorted(s)) for s in lS]
S = sorted(S)

cnt = 1
S.append('end')
last = S[0]
res = 0
for s in S[1:]:
    if last == s:
        cnt += 1
    else:
        res += cnt * (cnt-1) /2
        last = s
        cnt = 1

print(int(res))
### BUGGY CODE ###

N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = 0
for i in range(len(p)-K+1):
    P = p[i:i+K]
    if ans < sum(P):
        ans2 = P
    ans = max(ans,sum(ans2)) 
A = (sum(ans2)+K)/2
print(A)

### FIXED CODE ###

from itertools import accumulate
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
for i in range(N):
    P[i] = 1+(P[i]-1)/2
ruiseki = list(accumulate([0]+P))
ans = 0
for i in range(N-K+1):
    ans = max(ans,ruiseki[i+K]-ruiseki[i])
print(ans)
### BUGGY CODE ###

import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
G = [[int(i in (j,(j+1)%N)) for i in range(N)] for j in range(N)]
kakudai = np.array(G)
X=np.linalg.solve(G,A)
print(*[int(x*2) for x in X])


### FIXED CODE ###

N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)
### BUGGY CODE ###

class Combination:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        l = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            l.append(num)
        self.fac = l.copy()

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        l = [1 for i in range(n+1)]
        l[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            l[i] = num
        self.rec = l.copy()

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod

mod = 10**9 + 7

k = int(input())
s = input()
n = len(s)

c = Combination(k + n, mod)

pow25 = [1]
pow26 = [1]
for _ in range(k):
    pow25.append(25 * pow25[-1] % mod)
    pow26.append(26 * pow26[-1] % mod)

ans = 0
for i in range(k+1):
    ans += c.comb(n+i-1, i) * pow25[i] * pow26[k-i]
    ans %= mod

print(ans)

### FIXED CODE ###

class Combination:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        l = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            l.append(num)
        self.fac = l.copy()

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        l = [1 for i in range(n+1)]
        l[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            l[i] = num
        self.rec = l.copy()

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod

mod = 10**9 + 7

k = int(input())
s = input()
n = len(s)

c = Combination(k + n, mod)

ans = 0
for i in range(k+1):
    ans += c.comb(n + i - 1, i) * pow(25, i, mod) * pow(26, k-i, mod)
    ans %= mod

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

n,q = map( int, input().split() )
s = input()
lr = []
for i in range(q):
    lr.append(list( map( int, input().split() ) ) )

exist = [0]*n
for i in range(1,n-1):
    if s[i-1:i+1] == 'AC':
        exist[i+1] = 1

for i in range(q):
    if lr[i][1] - lr[i][0] < 2:
        print(0)
    else:
        print(sum(exist[lr[i][0]-1:lr[i][1]]))

### FIXED CODE ###

n,q = map( int, input().split() )
s = input()
lr = []
for i in range(q):
    lr.append(list( map( int, input().split() ) ) )

exist = [0]*n
for i in range(1,n):
    if s[i-1:i+1] == 'AC':
        exist[i] = exist[i-1]+1
    else:
        exist[i] = exist[i-1]

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

import numpy as np
flag = True
N, M = map(int, input().split())
for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        flag = False
        break

if flag:
    print(1)


### FIXED CODE ###

import numpy as np
flag = True
N, M = map(int, input().split())
ans = 0
for i in range(1, int(np.sqrt(M)) + 2):
    if M % i == 0:
        if min(M // i, i) >= N:
            ans = max(ans, max(M // i, i))
        elif max(M // i, i) >= N:
            ans = max(ans, min(M // i, i))

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

N = int(input())
A = []
B=[]
ans=0
for i in range(N):
    x="".join(sorted(input()))
    if x in A:
      ii=A.index(x)
      B[ii]+=1
    else:
      A.append(x)
      B.append(1)
ans=0
for b in B:
  ans+=(b-1)*(b)/2
print(int(ans))





### FIXED CODE ###

N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)
### BUGGY CODE ###

def main():
    n,m=map(int,input().split())
    p = [int(i)-1 for i in input().split() ]
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
    
            if x == y:
                return
    
            if self.parents[x] > self.parents[y]:
                x, y = y, x
    
            self.parents[x] += self.parents[y]
            self.parents[y] = x
    
        def size(self, x):
            return -self.parents[self.find(x)]
        
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        def group_count(self):
            return len(self.roots())
    
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
          
    uf = UnionFind(n)
    for i in range(m):
        x,y = map(int,input().split())
        uf.union(x-1,y-1)
    
    ans=0
    groups = uf.all_group_members().values()
    for cand in groups:
        ans+=len(set(cand) & set(p[i] for i in cand) )
    print(ans)
    
main()

### FIXED CODE ###

n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]


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

from collections import deque

groups=[]
been=[0]*n
for i in range(n):
    if been[i]==0:
        group=[i]
        been[i]=1
        q = deque([(i,togo) for togo in tree[i]]) 
        while q:
            parent,x = q.popleft()
            if been[x]==1:
                continue
            been[x]=1
            group.append(x)
            for y in tree[x]:
                if y == parent:#親ノードを飛ばし
                    continue
                q.append((x,y))#子ノードを追加
        groups.append(group)

ans=0
for group in groups:
    ans+= len( set(group) & set(p[g] for g in group) )

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

S= str(input())
A= list(map(int,S))
l = len(A)
cnt=0

for i in range(l-1):
    for j in range(i+1,l):
        T= S[i:j+1]
        t= int(T)
        if t%2019==0:
            cnt+=1
        else:
            cnt+=0
print(cnt)

### FIXED CODE ###

S = input()
S = S[::-1]
#簡単にするためにひっくり返す
N = len(S)

A=[0]*2019
number=0
A[0]=1
#０を２０１９で割った余りは０
d=1

ans=0

for i in S:
  number+=int(i)*d
  A[number%2019]+=1
  d=10*d
  d=d%2019

for i in A:
  ans+=i*(i-1)//2

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

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

if k>=n:
  print(abs(A[n-1]-A[0]))
else:
  dp=list(range(n))
  for i in range(k):
    dp[i]=abs(A[i]-A[0])
  for i in range(n-k):
    temp=list(range(k))
    for j in range(k):
      temp[j]=dp[i+j]+abs(A[i+k]-A[i+j])
    dp[i+k]=min(temp)
  print(dp[n-1])

### FIXED CODE ###

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

if k>=n:
  print(abs(A[n-1]-A[0]))
else:
  dp=list(range(n))
  for i in range(k):
    dp[i]=abs(A[i]-A[0])
  for i in range(n-k):
    temp=list(range(k))
    for j in range(k):
      temp[j]=dp[i+j]+abs(A[i+k]-A[i+j])
    dp[i+k]=min(temp)
  print(dp[n-1])
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
def lcm(x,y):
  return (x*y)//gcd(x,y)
l = 1
mod = 10**9+7
for i in range(n):
  l = lcm(l, a[i])
ans = 0
for i in range(n):
  ans += l // a[i]
  ans %= mod
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)
### BUGGY CODE ###

mod = 1000000007

s= [int(x) if x != "?" else -1 for x in input()]

n=len(s)
T=13
dp=[0]*T
c=s[n-1]
if (c!=-1):
	dp[c]=1
else:
	for i in range(10):dp[i]=1
mul = 10
for i in range(2,n+1):
	c=s[n-i]
	nextdp = [0] * T
	if (c==-1):
		for k in range(10):
			for j in range(T):
				nextdp[(k * mul + j)%T] += dp[j]
				nextdp[(k * mul + j)%T] %= mod
	else:
		k = c
		for j in range(T):
			nextdp[(k * mul + j) % T] += dp[j]
			nextdp[(k * mul + j) % T] %= mod
	mul *= 10
	mul %= T
	dp = nextdp


print (dp[5]%mod)



### FIXED CODE ###

import sys
 
 
def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    ls = [[0] * 13 for _ in range(len(s))]
    for i in range(len(s)):
        if i == 0:
            if s[-i-1] == "?":
                for j in range(10):
                    ls[i][j] += 1
            else:
                ls[i][int(s[-i-1])] += 1
        else:
            mult = pow(10, i, 13)
            if s[-i-1] == "?":
                for j in range(13):
                    for k in range(10):
                        ls[i][(k * mult + j) % 13] += ls[i-1][j]
            else:
                st = int(s[-i-1])
                for j in range(13):
                    ls[i][(st * mult + j) % 13] += ls[i-1][j]
        for j in range(13):
            ls[i][j] = ls[i][j] % mod
    print(ls[-1][5])
 
 
if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import itertools
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
a = [i for i in range(1, k + 1)]
b = [i for i in range(1, k + 1)]
c = [i for i in range(1, k + 1)]

ans = 0
for x, y, z in itertools.product(a, b, c):
  ans += gcd(x, y, z)
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input())
ans = 0
for x in range(1, k + 1):
  for y in range(1, k + 1):
    for z in range(1, k + 1):
      ans += gcd(gcd(x, y), z)
print(ans)
### BUGGY CODE ###

import itertools

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

abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

#print(abcd_list)
list_tmp = []
for i in range(1, M + 1):
    list_tmp.append(i)

comb_A = list(itertools.combinations_with_replacement(list_tmp, N))


max_score = 0
for A in comb_A:
    tmp_score = 0
    #print(A)
    for q in range(Q):
        #print(A)
        a = abcd_list[q][0]
        b = abcd_list[q][1]
        c = abcd_list[q][2]
        d = abcd_list[q][3]

        A_a = A[a - 1]
        A_b = A[b - 1]

        if(A_b - A_a == c):
            tmp_score += d
        
    max_score = max(max_score, tmp_score)

print(max_score)

### FIXED CODE ###

import itertools

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

abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

#print(abcd_list)
list_tmp = []
for i in range(1, M + 1):
    list_tmp.append(i)

comb_A = list(itertools.combinations_with_replacement(list_tmp, N))


max_score = 0
for A in comb_A:
    tmp_score = 0
    for q in range(Q):
        A_a = A[abcd_list[q][0] - 1]
        A_b = A[abcd_list[q][1] - 1]

        if(A_b - A_a == abcd_list[q][2]):
            tmp_score += abcd_list[q][3]
        
    max_score = max(max_score, tmp_score)

print(max_score)
### BUGGY CODE ###

k,s=map(int, input().split())
ans=0
for x in range(k+1):
    for y in range(min(k+1,s+1-x)):
        z=s-x-y
        if x+y<=s and x<=k and y<=k and z<=k:
            ans+=1
print(ans)

### FIXED CODE ###

k,s=map(int, input().split())
ans=0
for x in range(k+1):
    for y in range(min(k+1,s+1-x)):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)
### BUGGY CODE ###

S = input()
T = ""
count = 0
while 1:
    count = 0

    T = "dreamer" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(7):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    T = "dream" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(5):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    T = "eraser" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(6):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    T = "erase" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(5):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    if count == 4:
        break

if T == S:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

S = input()
S = S[::-1]
L = len(S)

d = ["dreamer", "dream", "eraser", "erase"]
for i in range(4):
    d[i] = d[i][::-1]

count = 0
end = False
yes = False

while 1:
    judge = 0
    for i in range(4):
        if S[count:(len(d[i])+count)] == d[i]:
            count += len(d[i])
            if count == L:
                end = True
                yes = True
        else:
            judge += 1
    if end or judge == 4:
        break

if yes:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

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

for i in range(a, b + 1):
    if i - a < k or b - i < k:
        print(i)



### FIXED CODE ###

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

l = []
for i in range(a, min(a + k, b + 1)):
    if i not in l:
        l.append(i)
for i in range(max(a, b - k + 1), b + 1):
    if i not in l:
        l.append(i)

ans = '\n'.join(map(str, l))
print(ans)
### BUGGY CODE ###

while True:
    try:
        n = int(raw_input())
        filter = [1 for i in range(n)]
        filter[0] = 0
        for i in range(2,n//2):
            if filter[i] == 1:
                j = 2
                k = i*j
                while k < n:
                    filter[k-1] = 0
                    j += 1
                    k = i*j
        print filter
        sum = 0
        for i in filter:
            sum += i
        print sum
    except:
        break

### FIXED CODE ###

import math
n = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break
  
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
p[3::2] = [0 for x in range(3,r,2)]
for i in range(2,sqrt,2):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)] 
  
for i in n:
     print sum(p[:i])
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
wa = 0
for i in range(N):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if(L[i] < L[j]+L[k]):
                wa += 1
            
print(wa)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
wa = 0
import bisect
for i in range(N-1,1,-1):
    for j in range(i-1,0,-1):
        diff = L[i]-L[j]
        k = bisect.bisect_right(L, diff)
        wa += j-k if j-k > 0 else 0           
            
print(wa)
### BUGGY CODE ###

k,n=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(k,n,a)
count=1

while n < len(a):
  a=a[n-1:]
  count+=1

print(count)

### FIXED CODE ###

k,n=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(k,n,a)
count=1
lena=len(a)
while n < lena:
  lena=lena-n+1
  count+=1

print(count)