Harryxun/stf_run huggingface dataset:
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*(n+1)
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i+1]=ans[i]+1
  else:
    ans[i+1]=ans[i]
#ti =「S の 1 文字目から i 文字目までに出現する a の数」として数列 t = {t0, t1, . . . , tN } を考えると、問 i の答えは tri−1 − tli−1
for i in range(q):
  l, r = map(int, input().split()) #ループ内で一行ずつ読み込む
  print(ans[r-1]-ans[l-1])

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
s = list[]
print(s.count("1"))

### FIXED CODE ###

s=input()
print(s.count("1"))
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    # print (a, b, inv)

    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


### FIXED CODE ###

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

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)
import sys
X,n=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]

nai=[]
if n==0:
  print(X)
  sys.exit()
else:
  if X not in p:
    print(X)
    sys.exit()
  else:
    for i in range(-100,101):
      if i not in p:
        nai.append(i)
    nai.append(X)
    nai.sort()

    for i in range(len(nai)):
      if nai[i]==X:
        if abs(nai[i-1]-X)<=abs(nai[i+1]-X):
          print(nai[i-1])
        else:
          print(nai[i+1])
          sys.exit()



### FIXED CODE ###

import sys
X,n=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]

nai=[]
if n==0:
  print(X)
  sys.exit()
else:
  if X not in p:
    print(X)
    sys.exit()
  else:
    for i in range(-200,301):
      if i not in p:
        nai.append(i)
    nai.append(X)
    nai.sort()

    ind=nai.index(X)
    
    if abs(nai[ind-1]-X)<=abs(nai[ind+1]-X):
      print(nai[ind-1])
      sys.exit()
    else:
      print(nai[ind+1])
      sys.exit()
X=input()

if int(X)>=30:
  print('Yes')
  else :
    print('No')

### FIXED CODE ###

X=input()
 
if int(X)>=30:
  print('Yes')
else :
  print('No')
import math

# Combination
MOD = 10**9+7
MAX = 2*10**5
fac = [1,1] + [0]*MAX
finv = [1,1] + [0]*MAX
inv = [0,1] + [0]*MAX
for i in range(2,MAX+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

from collections import defaultdict

N = int(input())
dic = defaultdict(int)
gp = []
for i in range(N):
    a,b = map(int, input().split())
    g = math.gcd(a, b)
    a //= g
    b //= g
    dic[str(a)+":"+str(b)] += 1
    gp.append((a, b))
cnt = 0
print(dic)
for a,b in gp:
    if (a >= 0 and b >= 0) or (a <= 0 and b <= 0):
        cnt += dic[str(b)+":"+str(-a)]
        cnt += dic[str(-b)+":"+str(a)]
    else:
        cnt += dic[str(b)+":"+str(a)]
        cnt += dic[str(-b)+":"+str(-a)]
#print(cnt)
cnt //= 2
ans = N
for i in range(2,N+1):
    c = comb(N, i) - cnt*comb(N-2, i-2)
    c = max(0, c)
    #print(i, comb(N, i), cnt*comb(N-2, i-2))
    if c < 0:
        c += MOD
    ans += c
    ans %= MOD
print(ans)


### FIXED CODE ###

import sys
import math
from fractions import Fraction
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
gp = []
zero = 0
left_zero = 0
right_zero = 0
for i in range(N):
    a,b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b != 0:
        left_zero += 1
    elif a != 0 and b == 0:
        right_zero += 1
    elif a == 0 and b == 0:
        zero += 1
    else:
        g = math.gcd(a, b)
        a //= g
        b //= g
        dic[str(Fraction(a, b))] += 1
        gp.append((a, b))
done = defaultdict(bool)
ans = 1
for a,b in gp:
    k = str(Fraction(a, b))
    if done[k]: continue
    rk = str(Fraction(-b, a))
    done[k] = True
    done[rk] = True
    cnt1 = pow(2, dic[k], MOD)-1
    cnt2 = pow(2, dic[rk], MOD)-1
    c = cnt1+cnt2+1
    ans *= c
    ans %= MOD
c1 = pow(2, left_zero, MOD)-1
c2 = pow(2, right_zero, MOD)-1
c = c1+c2+1
ans *= c
ans += zero
ans %= MOD
print((ans-1)%MOD)
N,K = map(int,input().split())
a =list(map(int,input().split()))

ans = []
for i in range(K):
  k = 1
  for s in range(K):
    k *= a[s+i] 
  ans.append(k)
  

for s in range(N-K):
  if ans[s]<ans[s+1]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

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


for i in range(N-K):
  if a[i]<a[i+K]:
    print("Yes")
  else:
    print("No")
n = int(input())
cnt = [ int(1e9) for i in range(26) ]
for i in range(n):
    s = input()
    nw = [ 0 for j in range(26) ]
    for j in s:
        nw[ord(j) - ord('a')]+=1
    for j in range(26):
        cnt[j] = min( cnt[j], nw[j] )
ans = ""
for i in range(26):
    if cnt[i] != int(1e9):
        ans += chr(i+97) * int(cnt[i])
print(ans)


### FIXED CODE ###

n = int(input())
cnt = [ int(1e9) for i in range(26) ]
for i in range(n):
    s = input()
    nw = [ 0 for j in range(26) ]
    for j in s:
        nw[ord(j) - ord('a')]+=1
    for j in range(26):
        cnt[j] = min( cnt[j], nw[j] )
ans = ""
for i in range(26):
    if cnt[i] != int(1e9):
        ans += chr(i+97) * int(cnt[i])
print(ans)
N=int(input())
ans=float('inf')

for i in range(1,N**0.5+1):
    if N%i==0:
        ans=min(ans,len(str(N//i)))
print(ans)

### FIXED CODE ###

N=int(input())
ans=float('inf')

for i in range(1,int(N**0.5+1)):
    if N%i==0:
        ans=min(ans,len(str(N//i)))
print(ans)
from collections import defaultdict

N = int(input())


def fun(x, y, z):
  return x**2 + y**2 + z**2 + x*y + y*z + z*x

res = defaultdict(int)

for x in range(1, 50):
  for y in range(1, 50):
    for z in range(1, 50):
      dict[fun(x, y, z)] += 1
        
for n in range(1, N):
  print(dict[n])

 

### FIXED CODE ###

from collections import defaultdict

N = int(input())


def fun(x, y, z):
  return x**2 + y**2 + z**2 + x*y + y*z + z*x

res = defaultdict(int)

for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      res[fun(x, y, z)] += 1
        
for n in range(1, N+1):
  print(res[n])
A, B = int(input()), float(input())
print(int(A * B))


### FIXED CODE ###

from decimal import Decimal
A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A * B))
n,k=map(int,input().split())
l=[int(_) for _ in input().split()]
l.sort()

ans=0
for i in range(k):
  ans+=l[k]

print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
l=[int(_) for _ in input().split()]
l.sort()
 
ans=0
for i in range(k):
  ans+=l[i]
print(ans)
import numpy as np
N,a,b = np.array(input().split()).astype(int)
for i in range(1,N+1):
  S = 0
  if((i!=a)&(i!=b)):
    S += math.factorial(N)/(math.factorial(i)*math.factorial(N-1))
print(S%(10**9+7))

### FIXED CODE ###

import numpy as np
N,a,b = np.array(input().split()).astype(int)
mod = 10**9+7
def power(x, n):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = ans*x%mod
        x = (x*x)%mod
        n = n >> 1 #ビットシフト
    return ans
def fact(m, n):
    val = 1
    for i in range(m, n+1):
        val = val*i % mod
    return val
    
def cmb1(N, r):
    A = fact(N-r+1, N)%mod
    B = fact(1, r)%mod
    return A, B, (A*power(B, mod-2))%mod
def cmb2(a, b, A, B):
    A = fact(N-a+1, N-b)*A%mod
    B = fact(b+1, a)*B%mod
    return (A*power(B, mod-2))%mod
if(a>N//2):
    a = N-a
if(b>N//2):
    b = N-b
tmp = max(a,b)
b = min(a,b)
a = tmp
A, B, K1 = cmb1(N, b)
K2 = cmb2(a, b, A, B)
print((power(2, N)-1-K1-K2)%mod)
import math
N, K = map(int, input().split())

#M=N

#for i in range(100000):
#    M = min(N,M)
#    N = abs(N-K)

#print(M)


k = math.gcd(N, K)

if K == 1:
    print(0)
else:
    print(k)


### FIXED CODE ###

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

if N > K:
    N = N - K*(N//K)

if N==K:
    print(0)
else:
    print(min(N,K-N))
a=input()
b=input()
if len(a)+1==len(b) and a==b[0:a]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a=input()
b=input()
if len(a)+1==len(b) and b[:len(a)]==a:
  print("Yes")
else:
  print("No")
n = int(input())
a = list(map(int, input().split()))
sadlist = []
for h in range(n):
    a[h] = a[h] - (h + 1)
for i in a:
    sad = 0
    for j in range(n):
        sad = sad + abs(a[j] - i)
    sadlist.append(sad)
print(min(sadlist))

### FIXED CODE ###

n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n * 2)
def main():
  l = input().split()
  A, B = int(l[0]), int(l[1])
  print(int(A*(B*100)/100))

main()

### FIXED CODE ###

import math
import decimal
a, b = input().split()
a = decimal.Decimal(a)
b = decimal.Decimal(b)
print(math.floor(a * b))
a = int(input())
b = int(input())
if a >= 13:
    print(b)
elif a >= 6:
    print(b / 2)
else:
    print(0)

### FIXED CODE ###

# coding: utf-8
# Your code here!
a, b = map(int, input().split())
if a >= 13:
	print(b)
elif a >= 6:
	print(b // 2)
else:
	print(0)
a = [int(input()) for i in range(3)]
if a[0] == 1:
	print("Hello World")
else:
	print(a[1] + a[2])

### FIXED CODE ###

a = int(input())
if a == 1:
  print("Hello World")
else:
  b = int(input())
  c = int(input())
  print(b + c)
k,s=map(int,input().split())

count=0

for i in range(k+1):
    for j in range(k+1):
        z=s-(i+j)
        
        if nums.count(z):
            count+=1
print(count)


### FIXED CODE ###

k,s=map(int,input().split())

count=0

for i in range(k+1):
    for j in range(k+1):
        if s-k<=i+j<=s:
            count+=1
print(count)
import datetime
S = input()
if datetime.datetime.strptime(S, "%Y/%m/%d") <= datetime.datetime(2019, 4, 30, 0 ,0 ,0):
  print('Heisei')
else:
  print('TBD'

### FIXED CODE ###

import datetime
S = input()
if datetime.datetime.strptime(S, "%Y/%m/%d") <= datetime.datetime(2019, 4, 30, 0 ,0 ,0):
  print('Heisei')
else:
  print('TBD')
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(_m)]
cands = set(b if a == 1 else a for a, b in AB if a == 1 or b == 1)
if any(a in cands and b == n or b in cands and a == n for a, b in AB):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

from collections import deque

def solve(n, m, AB):
    g = [[] for _ in range(n)]
    for a, b in AB:
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)

    q = deque(maxlen = n)
    q.append((0, 0))
    used = {0}
    while len(q) > 0:
        i, d = q.popleft()
        if d >= 2:
            break
        for c in g[i]:
            if c in used:
                continue
            if d == 1 and c == n - 1:
                return 'POSSIBLE'
            q.append((c, d + 1))
            used.add(c)
    return 'IMPOSSIBLE'

_n, _m = map(int, input().split())
_AB = [map(int, input().split()) for _ in range(_m)]
print(solve(_n, _m, _AB))
x = int(input())
import math
a = math.sqrt(x)
b = a - a%1
ans = []
for i in range(b):
  for j in range(b):
    if i**j < x and x < i**(j+1):
      ans.append(int(i**j))
print(max(ans))

### FIXED CODE ###

x=int(input())
c=1
for b in range(1,32):
    for p in range(2,10):
        if b**p<=x:
          c=max(c,b**p)
        else:break
print(c)
I = input()
I = I.split(" ")
N = int(I[0])
K = int(I[1])
Q = int(I[2])

A = [0] * Q

for i in range(Q):
	A[i] = int(input())

point = [0] * N

for i in range(Q):
	point[A[i]-1] = point[A[i]-1] + 1

for i in range(N):
	if point[i] > k:
		print("yes")
	else:
		print("no")


### FIXED CODE ###

I = input()
I = I.split(" ")
N = int(I[0])
K = int(I[1])
Q = int(I[2])

A = [0] * Q

for i in range(Q):
	A[i] = int(input())

point = [0] * N

for i in range(Q):
	point[A[i]-1] = point[A[i]-1] + 1

for i in range(N):
	if Q - point[i] < K:
		print("Yes")
	else:
		print("No")
n = int(input())
s = input()

# the number of '#'
p0 = s.count('#')

# the number of '.'
p1 = n - p0

p_min = min(p0, p1)

wb_ = 0
bw_ = 0
for i in range(n):

    if s[i] == '.':
        bw = bw_ 
        wb = p1
    else:
        bw = bw_ + 1
        wb = p1 - 1
    
    p_min = min(p_min, (bw + wb))

print(p_min)

### FIXED CODE ###

a, b, c = [int(n) for n in input().split()]

if a < c < b or b < c < a:
    print('Yes')
else:
    print('No')
n,x=map(int,input().split())
li=input().split()
d=0
c=0
for l in li:
	if d>x:
		break
	d=d+l
	c=c+1
	
print(c)


### FIXED CODE ###

x, a=map(int, input().split())
if	x < a:
	l = 0
else:
	l = 10
print(l)
K,N=map(int,input().split())
A=list(map(int,input().split()))
List=[]
for i in range(N):
  b=abs(A[i]-A[i-1])
  List.append(b)
SL=sorted(List)
print(K-SL[-1])

### FIXED CODE ###

S=input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
K = int(input())
Subj = input()
 
if len(Subj) <= K:
  print(Subj)
elif len(Subj) > K:
  print(Subj[0:K-1]+"...")

### FIXED CODE ###

num = int(input()[-1])
 
if num == 3:
  print("bon")
elif num == 0 or num ==1 or num ==6 or num ==8:
  print("pon")
else:
  print("hon")
n,m = map(int,input().split())

ls = [0 for _ in range(n+1)]

pen = 0

for _ in range(m):
  p,s = input().split()
  p = int(p)
  
  if ls[p] == None:
    pass
  elif s == "WA":
    ls[p] += 1
  else:
    pen += ls[p]
    ls[p] = None
print(sum(ls),pen)
  



### FIXED CODE ###

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

ls = [0 for _ in range(n+1)]

ans = 0
pen = 0

for _ in range(m):
  p,s = input().split()
  p = int(p)
  
  if ls[p] == None:
    pass
  elif s == "WA":
    ls[p] += 1
  else:
    pen += ls[p]
    ls[p] = None
    ans +=1
print(ans,pen)
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 解説

N, T = list(map(int, sys.stdin.buffer.readline().split()))
A, B = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

A = np.array(A, dtype=int)
B = np.array(B, dtype=int)

# 移動時間を考えなくて良いようにする
A += 1
B += 1
T += 1

# 使う店を決めたとき、(a - 1) / b の大きい順に使うのが最適
I = np.argsort((A - 1) / B)[::-1]
A = A[I]
B = B[I]

idx_zero = np.searchsorted((A == 1).astype(int), 1, side='left')
MAX_COUNT = 1 << ((2 * 10 ** 5).bit_length() + 2)
# dp[i][x]: i まで見て、x こ使うときの t の最小値
dp = np.full((idx_zero + 1, MAX_COUNT), IINF, dtype=int)
dp[0, 0] = 1
for i in range(len(dp) - 1):
    dp[i + 1, :] = np.minimum(dp[i + 1, :], dp[i, :])
    dp[i + 1, 1:] = np.minimum(dp[i + 1, 1:], dp[i, :-1] * A[i] + B[i])

#: :type: list of int
B_A0 = np.msort(B[idx_zero:]).tolist()
ans = 0
# idx_zero 以降で、B を小さい順に使えるだけ使う
for cnt, t in enumerate(dp[idx_zero].tolist()):
    if t > T:
        break
    i = 0
    while i < len(B_A0) and t + B_A0[i] <= T:
        t += B_A0[i]
        i += 1
        cnt += 1
    ans = max(ans, cnt)
print(ans)


### FIXED CODE ###

import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 解説

N, T = list(map(int, sys.stdin.buffer.readline().split()))
A, B = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

A = np.array(A, dtype=int)
B = np.array(B, dtype=int)

# 移動時間を考えなくて良いようにする
A += 1
B += 1
T += 1

# 使う店を決めたとき、(a - 1) / b の大きい順に使うのが最適
I = np.argsort((A - 1) / B)[::-1]
A = A[I]
B = B[I]

idx_zero = np.searchsorted((A == 1).astype(int), 1, side='left')
A1 = A[:idx_zero]
B1 = B[:idx_zero]
B2 = np.msort(B[idx_zero:])

MAX_COUNT = (10 ** 9).bit_length() + 2
# dp[i][x]: i まで見て、x こ使うときの t の最小値
dp = np.full((idx_zero + 1, MAX_COUNT), T + 1, dtype=int)
dp[:, 0] = 1
for x in range(MAX_COUNT - 1):
    next_col = dp[:-1, x] * A1 + B1
    np.minimum(next_col, T + 1, out=next_col)
    np.minimum.accumulate(next_col, out=next_col)
    dp[1:, x + 1] = next_col

# idx_zero 以降で、B を小さい順に使えるだけ使う
cum = B2.cumsum()
counts = np.searchsorted(cum, T - dp[idx_zero], side='right')
ans = counts + np.arange(dp.shape[1])
print(ans[dp[idx_zero] <= T].max())
from functools import reduce

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return x2, y2, n

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod

MOD = 10**9 + 7
N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A, key=abs, reverse=True)
cand = []
minus = False
last_plus, last_minus = None, None
for a in A[:K]:
    cand.append(a)
    if a < 0: minus = not minus; last_minus = a
    elif a > 0: last_plus = a
    else: minus = False
ans = reduce(lambda x, y: x * y % MOD, cand)
if minus and K != N:
    non_neg, neg = None, None
    for a in A[K:]:
        if a >= 0 and non_neg is None: non_neg = a
        elif a < 0 and neg is None: neg = a
        if non_neg is not None and neg is not None: break
    if non_neg is None:
        if last_plus:
            ans *= modular_inverse(last_plus, MOD) * neg; ans %= MOD
        else:
            ans = reduce(lambda x, y: x * y % MOD, A[::-1][:K])
    elif neg is None:
        ans *= modular_inverse(last_minus, MOD) * non_neg; ans %= MOD
    else:
        if abs(last_plus * non_neg) < abs(last_minus * neg):
            ans *= modular_inverse(last_plus, MOD) * neg; ans %= MOD
        else:
            ans *= modular_inverse(last_minus, MOD) * non_neg; ans %= MOD
print(ans)

### FIXED CODE ###

from functools import reduce

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return x2, y2, n

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod

MOD = 10**9 + 7
N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A, key=abs, reverse=True)
cand = []
minus = False
last_plus, last_minus = None, None
for a in A[:K]:
    cand.append(a)
    if a < 0: minus = not minus; last_minus = a
    elif a > 0: last_plus = a
    else: minus = False
ans = reduce(lambda x, y: x * y % MOD, cand)
if minus and K != N:
    non_neg, neg = None, None
    for a in A[K:]:
        if a >= 0 and non_neg is None: non_neg = a
        elif a < 0 and neg is None: neg = a
        if non_neg is not None and neg is not None: break
    if non_neg is None:
        if last_plus:
            ans *= modular_inverse(last_plus, MOD) * neg; ans %= MOD
        else:
            ans = reduce(lambda x, y: x * y % MOD, A[::-1][:K])
    elif neg is None:
        ans *= modular_inverse(last_minus, MOD) * non_neg; ans %= MOD
    else:
        if last_plus and abs(last_plus * non_neg) < abs(last_minus * neg):
            ans *= modular_inverse(last_plus, MOD) * neg; ans %= MOD
        else:
            ans *= modular_inverse(last_minus, MOD) * non_neg; ans %= MOD
print(ans)
mountain = [[]] * int(raw_input())
removed = []
while True:
    command = raw_input().split()
    if command[0] == 'push':
        mountain[int(command[1])].append(command[2])
    elif command[0] == 'pop':
        removed.append(mountain[int(command[1])][-1])
        mountain[int(command[1])].pop(-1)
    elif command[0] == 'move':
        mountain[int(command[2])].append(mountain[int(command[1])][-1])
        mountain[int(command[1])].pop(-1)
    elif command[0] == 'quit':
        break
for block in removed:
    print block

### FIXED CODE ###

mountain = map(lambda x:[], range(int(raw_input())))
removed = []
while True:
    command = raw_input().split()
    if command[0] == 'push':
        mountain[int(command[1]) - 1].append(command[2])
    elif command[0] == 'pop':
        removed.append(mountain[int(command[1]) - 1][-1])
        mountain[int(command[1]) - 1].pop(-1)
    elif command[0] == 'move':
        mountain[int(command[2]) - 1].append(mountain[int(command[1]) - 1][-1])
        mountain[int(command[1]) - 1].pop(-1)
    elif command[0] == 'quit':
        break
for block in removed:
    print block
WHITE = 0
GRAY = 1
BLACK = 2
color, d, f = [WHITE for i in range(n)]
t = 1

def visit(u):
    color[u] = GRAY
    d[u] += t
    t += 1
    for v in range(n):
        if (M[u-1][v-1] == 0):
            continue
        if (color[v] == WHITE):
            visit(v)
    color[u] = BLACK
    f[u] = t
    t += 1

for u in range(n):
    if (color[u] == WHITE):
        visit(u)
for u in range(n):
    print(str(u+1), str(d[u]), str(f[u]), sep = " ")

n = int(input())
M = [[[0] for i in range(n)] for i in range(n)]
for i in range(n):
    temp = list(map(int, input().split()))
    for i in range(temp[1]):
        M[temp[0]-1][temp[i+2]-1] = 1

### FIXED CODE ###

def dfs(u):
    global dfs_color, d, f, t
    color[u] = GRAY
    d[u] += t
    t += 1
    for v in range(n):
        if (M[u][v] == 0):
            continue
        else:
            if (color[v] == WHITE):
               dfs(v)
    color[u] = BLACK
    f[u] = t
    t += 1

n = int(input())
M = [[False for i in range(n)] for j in range(n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    for j in range(tmp[1]):
        M[tmp[0]-1][tmp[j+2]-1] = True

WHITE = 0
GRAY = 1
BLACK = 2
color = [WHITE for i in range(n)]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
t = 1

for u in range(n):
    if (color[u] == WHITE):
        dfs(u)
for u in range(n):
    print(str(u+1), str(d[u]), str(f[u]), sep = " ")
r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(list(map(int, input(),split())))
for line in arr:
    line.append(sum(line))
arr.append([sum([line[i] for line in arr]) for i in range(c+1)])
for line in arr:
    print(*line)
    


### FIXED CODE ###

n,m=map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
    a[i]+=[sum(a[i])]
    print(*a[i])
a=list(zip(*a[::-1]))
for i in range(m):print(sum(a[i]),end=' ')
print(sum(a[m]))
W, a, b = map(int,input().split())
 
if a+W<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(b-a)
elif (a<=b+W) and(b+W<a+W):
  print(a-b)
elif (b+W)<a:
  print(a-(b+W))

### FIXED CODE ###

a, b = map(str,input().split())

if a == b:
  print("H")
else:
  print("D")
N, A, B = map(int, input().split())
count = 0
for i in range(1, N + 1):
  sum = 0
  number = str(i)
  for j in number:
    sum += int(j)
    count += 1 if A <= sum <= B
print(count)

### FIXED CODE ###

N, A, B = map(int, input().split())
result = 0
for i in range(1, N + 1):
  sum = 0
  number = str(i)
  for j in number:
    sum += int(j)
  if A <= sum <= B:
    result += i
print(result)