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

import sys
input = sys.stdin.readline

class segtree:
    x_unit=0 # 単位元
    x_func=sum  # 関数
    def __init__(self,n):
        self.n=n
        self.x=[self.x_unit]*(2*n)
    def build(self, seq):
        for i,j in enumerate(seq, self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func([self.x[i*2], self.x[i*2+1]])
    def set_val(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func([self.x[i*2], self.x[i*2+1]])
    def fold(self,l,r): # 区間[l, r)の最小値などを取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func([val_l,self.x[l]])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func([val_r,self.x[r]])
            l //= 2
            r //= 2
        return self.x_func([val_l,val_r])

from collections import defaultdict,deque
n,q=map(int, input().split())
c=list(map(int, input().split()))
c=[i-1 for i in c]
lr=[]
for i in range(q):
    l,r=map(int, input().split())
    lr.append((l-1,r-1))
lrsort=sorted(lr, key=lambda x:x[0])
lrsort=sorted(lr, key=lambda x:x[1])
lrsort=deque(lrsort)
#print(lrsort)
goodpos=[-1]*n
isgood=[0 for x in range(n)]
d=defaultdict(int)
s=0
seg=segtree(n)
seg.build(isgood)

while lrsort:
    l,r=lrsort.popleft()
    for i in range(s,r+1):
        if goodpos[c[i]]!=-1:
            seg.set_val(goodpos[c[i]],0)
        goodpos[c[i]]=i
        seg.set_val(i,1)
    s=r+1
    d[(l,r)]=seg.fold(l,n)

for l,r in lr:
    print(d[(l,r)])

### FIXED CODE ###

import sys
input = sys.stdin.readline
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

n,q=map(int,input().split())
c=list(map(int,input().split()))
ques=[]
from collections import defaultdict
ans=defaultdict(int)
for _ in range(q):
    l,r=map(int,input().split())
    ques.append((l,r))

sortques=sorted(ques, key=lambda x:x[1])

good=BIT(n+1)
goodind=[-1]*n
last=0
for x in range(q):
    l,r=sortques[x]
    if last!=r:
        for i in range(last, r):
            if goodind[c[i]-1]==-1:
                goodind[c[i]-1]=i
                good.add(i+1, 1)
            else:
                j=goodind[c[i]-1]
                good.add(j+1, -1)
                goodind[c[i]-1]=i
                good.add(i+1, 1)
    ans[(l,r)]=good.get(l-1,r)
    last=r

for i in range(q):
    print(ans[ques[i]])
### BUGGY CODE ###

n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
a=0
for i,m in enumerate(s):
    for j,M in enumerate(s[:i]):
        if m!=M:
            k=3-"RGB".index(m)-"RGB".index(s[j])
            if 2*i-j<=n-1:
                if s[2*i-j]=="RGB"[k]:
                    a-=1
print(r*g*b+a)

### FIXED CODE ###

n=int(input())
s=input()
c=s.count
a=c("R")*c("G")*c("B")
for i in range(n-2):
    for j in range((n-i+1)//2):
        if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i+2*j]!=s[i]:
            a-=1
print(a)
### BUGGY CODE ###

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

for i in range(n-1):
    if a[i] == 0:
        continue
    c = 0
    for j in range(i+1, n):
        c += a[j]
    ans += a[i] * c
ans %= 1000000007
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
b = 0
c = 0
for i in range(n):
    b += a[i]
    c += a[i] * a[i]
ans = (b * b - c) // 2
ans %= 1000000007
print(ans)
### BUGGY CODE ###

S = input()
ans = {0:1}
memo = [0]
for ind, s in enumerate(S[::-1]):
    memo.append((memo[-1]+int(s)*(10**ind))%2019)
    if(memo[-1] in ans):
        ans[memo[-1]] += 1
    else:
        ans[memo[-1]] = 1

res = 0
for key in ans.keys():
    res += ans[key]*(ans[key]-1)//2
print(res)






### FIXED CODE ###

S = input()
ans = {0:1}
memo = [0]
last = 1
for ind, s in enumerate(S[::-1]):
    memo.append((int(s) * last + memo[-1]) % 2019)
    last *= 10
    last %= 2019
    if(memo[-1] in ans):
        ans[memo[-1]] += 1
    else:
        ans[memo[-1]] = 1

res = 0
for key in ans.keys():
    res += ans[key]*(ans[key]-1)//2
print(res)
### BUGGY CODE ###

A = int(input())
total = 0
for i in range(A):
    total += i
print(total)

### FIXED CODE ###

r = int(input())
r = r * (r-1) // 2 
print(int(r))
### BUGGY CODE ###

import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
h_list = [int(elem) for elem in fin().split()]
original_h_list = [x for x in h_list]

flag = True
result = 'Yes'
h_list = [-1] + h_list + [10**10]
for i in range(1, len(h_list)-1):
    # print(h_list[i])
    min_right_h = min(h_list[i+1:])
    if h_list[i] <= min_right_h:
        # 右側最小値以下の場合
        if h_list[i] >= h_list[i-1]:
            # 左側の値以上の場合
            continue
    else:
        # 右側最小値以上の場合
        h_list[i] -= 1
        if min_right_h >= h_list[i] >= h_list[i - 1]:
            continue
        else:
            result = 'No'
            flag = False
    if not flag:
        break

print(result)


### FIXED CODE ###

import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
h_list = [int(elem) for elem in fin().split()]
original_h_list = [x for x in h_list]

flag = True
result = 'Yes'
h_list = [-1] + h_list + [10**10]
min_h_list = min(h_list[1:-1])
for i in range(1, len(h_list)-1):
    if h_list[i] - 1 >= h_list[i-1]:
        h_list[i] -= 1

for i in range(1, len(h_list)-1):
    if not (h_list[i-1] <= h_list[i] <= h_list[i+1]):
        result = 'No'

print(result)
### BUGGY CODE ###


# 初期入力
from collections import deque
import sys
input = sys.stdin.readline
N = int(input())
H = list(map(int, input().split()))

#
differ =0
ans="Yes"
max_h   =max(H)
max_index =H.index(max_h)
#最大値-1 と最大値の右側の最小値を比較,この時はfor不要
if max_index +1 <= N-1:
    if H[max_index]-1 > min(H[max_index+1:]):
        ans ="No"
        print(ans)
        sys.exit()

dq    =deque(H)
before  =dq.popleft()
for i in range(N-1):
    after   =dq.popleft()
    differ    =after - before
    #differ = H[i+1] -H[i]
    if differ <-1:      #右側が小さのは１までOK
        ans ="No"
        break
    elif differ ==-1:
        if before -1 > min(dq) :
            ans ="No"
            break
        else:
            before = after
    else:
        before = after

print(ans)

### FIXED CODE ###


# 初期入力
from collections import deque
import sys
#input = sys.stdin.readline
N = int(input())
H = list(map(int, input().split()))

#
differ =0
ans="Yes"
max_h   =max(H)
max_index =H.index(max_h)
#最大値-1 と最大値の右側の最小値を比較,この時はfor不要
if max_index +1 <= N-1:
    if H[max_index]-1 > min(H[max_index+1:]):
        ans ="No"
        print(ans)
        sys.exit()

dq    =deque(H)
before  =dq.popleft()
for i in range(N-1):
    after   =dq.popleft()
    differ    =after - before
    #differ = H[i+1] -H[i]
    if differ <-1:      #右側が小さのは１までOK
        ans ="No"
        break
  
    else:
        before = after

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

n = int(input())
a = list(map(int,input().split()))
x = 9e11
s = sum(a)
for i in range(1,n):
    x=min(x,abs(s-sum(a[:i]*2)))
print(x)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)

x = 0
for i in range(n):
    x += a[i]
    if i+1 < n:
        ans = min(ans,abs(X-2*x))
print(ans)
### BUGGY CODE ###

def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*w for _ in range(h))
    d=tuple([0]*w for _ in range(h))
    for i in range(h):
        a[i][0]=int(s[i][0]=='.')
        for j in range(w-1):
            a[i][j+1]=a[i][j]+1if s[i][j+1]=='.'else 0
        b[i][-1]=int(s[i][-2]=='.')
        for j in range(1,w):
            b[i][~j]=b[i][-j]+1if s[i][-j-2]=='.'else 0
    for j in range(w):
        c[0][j]=int(s[0][j]=='.')
        for i in range(h-1):
            c[i+1][j]=c[i][j]+1if s[i+1][j]=='.'else 0
        d[-1][j]=int(s[-1][j]=='.')
        for i in range(1,h-1):
            d[~i][j]=d[-i][j]+1if s[~i][j]=='.'else 0
    print(max(sum(u)-3for t in zip(a,b,c,d)for u in zip(*t)))
main()

### FIXED CODE ###

def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*w for _ in range(h))
    d=tuple([0]*w for _ in range(h))
    for i in range(h*w):
        i,j=divmod(i,w)
        a[i][j]=a[i][j-1]+1if s[i][j]=='.'else 0
        b[i][~j]=b[i][-j]+1if s[i][-j-2]=='.'else 0
        c[i][j]=c[i-1][j]+1if s[i][j]=='.'else 0
        d[~i][j]=d[-i][j]+1if s[~i][j]=='.'else 0
    print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in range(h)for j in range(w)))
main()
### BUGGY CODE ###

n = int(input())

for i in range(1, n + 1):
    cnt = 0
    
    for x in range(1, i + 1):
        
        for y in range(1, i + 1):
        
            for z in range(1, i + 1):

                ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if ans > i:
                    break
                elif  ans == i:
                    cnt += 1

    print(cnt)

### FIXED CODE ###

#!/usr/bin/env python3
import math

n = int(input())
arr = [0] * n

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])
### BUGGY CODE ###

h, w = map(int, input().split())
lst = [input() for _ in range(h)]

res = 0
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if lst[j][i] == '.':
            if i == 0:
                L[j][i] = 1
            else:
                L[j][i] = L[j][i-1] + 1

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

for i in reversed(range(w)):
    for j in reversed(range(h)):
        if lst[j][i] == '.':
            if i == w-1:
                R[j][i] = 1
            else:
                R[j][i] = R[j][i+1] + 1

                
for i in range(h):
    for j in range(w):
        res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
        
print(res)

### FIXED CODE ###

h, w = map(int, input().split())
lst = [input() for _ in range(h)]

res = 0
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]

for i in range(w):
    for j in range(h):
        if lst[j][i] == '.':
            if i == 0:
                L[j][i] = 1
            else:
                L[j][i] = L[j][i-1] + 1

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in reversed(range(h)):
    for j in reversed(range(w)):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

for i in reversed(range(w)):
    for j in reversed(range(h)):
        if lst[j][i] == '.':
            if i == w-1:
                R[j][i] = 1
            else:
                R[j][i] = R[j][i+1] + 1

                
for i in range(h):
    for j in range(w):
        res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
        
print(res)
### BUGGY CODE ###

import itertools

n = int(input())
a = list(map(int,input().split()))
c = itertools.combinations(a, 2)
ini = [v[0]*v[1] for v in c]
print(sum(ini)%(10**9+7))

### FIXED CODE ###

import itertools

n = int(input())
a = list(map(int,input().split()))
s = sum(a)
ini = []
for i in range(n):
    s -= a[i]
    tmp = a[i]*s
    ini.append(tmp)
print(sum(ini)%(10**9+7))
### BUGGY CODE ###

import itertools

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

count = 0
for i, a in enumerate(L[:-2]):
    count += sum([(a < b + c) * (b < c + a) * (c < a + b) for b, c in itertools.combinations(L[(i+1):], 2)])

print(count)



### FIXED CODE ###

N = int(input())
L = sorted([int(x) for x in input().split(' ')], reverse=True)

count = 0
while len(L) > 2:
    a = L.pop(0)
    ic = len(L) - 1
    for ib, b in enumerate(L):
        diff = a - b
        while L[ic] <= diff and ib < ic:
            ic -= 1
        count += ic - ib
        if ib >= ic:
            break

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

n,m=map(int,input().split(" "))
l=[]
bone=[]
ans="IMPOSSIBLE"
f=False
for i in range(m):
	if f==False:
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)
		if len(l) != 0:
			for i in l:
				for j in bone:
					if i == j:
						ans="POSSIBLE"
						f=True
	else:a=input()
		
print(ans)


### FIXED CODE ###

n,m=map(int,input().split(" "))
l=[]
bone=[]
for i in range(m):
		a,b=input().split(" ")
		if a=="1":l.append(b)
		if b==str(n):bone.append(a)

ans=list(set(l) & set(bone))
if len(ans)!=0:
	print("POSSIBLE")
else:			
	print("IMPOSSIBLE")
### BUGGY CODE ###

S = list(input())
ans = 0

for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        N = "".join(S[i:j])
        N = int(N)
        if N%2019 == 0:
            ans += 1

print(ans)

### FIXED CODE ###

S = list(input())
L = [0]*2019
L[0]=1
digit = 1
x = 0

for i in S[::-1]:
    x += digit*int(i)
    digit *= 10
    x %= 2019
    digit %= 2019 
    L[x] += 1

ans = 0

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

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

def resolve():
    from scipy.sparse.csgraph import dijkstra
    from scipy.sparse import csr_matrix
    import numpy as np
    n, m = map(int, input().split())
    edge = np.array([input().split() for _ in range(m)], dtype=np.int64).T
    a = csr_matrix(([1] * m, (edge - 1)), shape=(n, n))
    p = dijkstra(a, return_predecessors=True, min_only=True, limit=n+1, indices=0, directed=False, unweighted=True)
    if min(p[1][1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1][1:]:
            print(i + 1)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

def resolve():
    def Dijkstra(s, n, edge, inf=float("inf")):
        import heapq
        d = [inf] * n
        used = [False] * n
        d[s] = 0
        used[s] = True
        queue = []
        path = [-9999] * n
        for e in edge[s]:
            heapq.heappush(queue, e + [s])
        while len(queue):
            dist, point, before = heapq.heappop(queue)
            if used[point]:
                continue
            d[point] = dist
            used[point] = True
            path[point] = before
            for nextdist, nextp in edge[point]:
                if not used[nextp]:
                    heapq.heappush(queue, [dist + nextdist, nextp, point])
        return d, path
    n, m = map(int, input().split())
    inf = 10 ** 10
    edge = [[] for _ in range(n)]
    for _ in range(m):
        x, y = [int(x) - 1 for x in input().split()]
        edge[x].append([1, y])
        edge[y].append([1, x])
    l, p = Dijkstra(0, n, edge, inf)
    if min(p[1:]) < -1:
        print("No")
    else:
        print("Yes")
        for i in p[1:]:
            print(i + 1)


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

[n,a,b] = list(map(int,input().split()))
mod = 10**9+7

def ore_comb(n,r,mod):
    '''
    return nCr
    O(min{n-r, r})
    '''
    bunsi=1 
    bunbo=1 
    for i in range(n,n-r,-1):#分子
      bunsi = bunsi*i%mod
    for i in range(r):#分母
      bunbo = bunbo*(i+1)%mod

    ans = (bunsi*pow(bunbo,mod-2,mod))%mod
    return ans

ans = ( (pow(2,n)-1)  - ore_comb(n,a,mod) -ore_comb(n,b,mod) )%mod
if ans != 0:
  print(ans)
else:
  print(0)   

### FIXED CODE ###

def ore_comb(n,r,mod):
    '''
    return nCr
    O(min{n-r, r})
    '''
    bunsi=1 
    bunbo=1 
    r = min(r,n-r)
    for i in range(r):#分子
      bunsi = bunsi*(n-i)%mod
      bunbo = bunbo*(i+1)%mod

    ans = (bunsi*pow(bunbo,mod-2,mod))%mod
    return ans

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

mod = 10**9+7

ans = pow(2, N, mod) -1
ans -= ore_comb(N,a,mod)
if ans<0:
    ans += mod
ans -= ore_comb(N,b,mod)
if ans<0:
    ans += mod

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

def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    a = list(map(int, r.split()))
    #a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    res = 1
    for i in range(1,len(a)):
        b = a[:i]
        if min(b) >= a[i]:
            res += 1
    print(res)

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    a = list(map(int, r.split()))
    #a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    res = 1
    bk = a[0]
    for i in range(1,n):
        if bk >= a[i]:
            bk = a[i]
            res += 1
    print(res)


#    b = [0]*n
#    for i in range(n):
#        b[a[i]-1] = i

#    res = 0
#    mem = b[0]
#    for i in range(1,n):
#        if mem <= b[i]:
#            print(b[i])
##            mem = b[i]
#        else:
#            res += 1
#    print(res)

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

def main():
    n = int(input())
    s = list(str(n))
    s.reverse()
    s += ['0']
    s = [int(c) for c in s]
    m = len(s)

    dp = [[10**18, 10**18] for _ in range(len(s)+5)]
    # dp[i][0]: 繰り下がりなし
    # dp[i][1]: 繰り下がりあり

    dp[0][0] = 0

    for i in range(m):
        for j in range(2):
            nd = s[i]
            if j == 1:
                nd += 1
            for a in range(10):
                ni = i+1
                nj = 0
                b = a-nd
                if b < 0:
                    nj = 1
                    b += 10
                if dp[ni][nj] >= dp[i][j]+a+b:
                    dp[ni][nj] = dp[i][j]+a+b
    #print(dp)
    print(dp[m][0])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    s = list(str(input()))
    s.reverse()
    for i in range(len(s)):
        s[i] = int(s[i])
    s += [0]
    m = len(s)

    dp = [[10**7, 10**7] for _ in range(len(s)+5)]
    # dp[i][0]: 繰り下がりなし
    # dp[i][1]: 繰り下がりあり

    dp[0][0] = 0

    for i in range(m):
        for j in range(2):
            nd = s[i]
            if j == 1:
                nd += 1
            if dp[i+1][0] >= dp[i][j]+nd:
                dp[i+1][0] = dp[i][j]+nd
            if dp[i+1][1] >= dp[i][j]+10-nd:
                dp[i+1][1] = dp[i][j]+10-nd
    #print(dp)
    print(dp[m][0])

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

n, k = map(int, input().split())
p = list(map(int, input().split()))
p_exp = [(p[i] + 1)/2 for i in range(n)]
ans = -1


for i in range(0, n-k+1):
    k_start = i
    k_end = i + k - 1
    sum_exp = sum(p_exp[k_start: k_end+1])
    ans = max(sum_exp, ans)

print(ans)

### FIXED CODE ###

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

p_exp = [(p[i] + 1)/2 for i in range(n)]

s = [0]
for i in range(n):
    s.append(s[i] + p_exp[i])

ans = -1

for i in range(0, n-k+1):
    k_start = i
    k_end = i + k
    
    sum_exp = s[k_end] - s[k_start]
    
    ans = max(sum_exp, ans)

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

n, a, b = (int(i) for i in input().split())
s=0
h=0
for i in range(1,n):
  j=0
  s=0
  while j<5:
    s += i%10
    i = i%10
  if s>=a and s<=b:
    h += s
    

print(h)

### FIXED CODE ###

n, a, b = (int(i) for i in input().split())
s=0
h=0
f=0
for i in range(1,n+1):
  j=0
  s=0
  f=i
  while j<5:
    s += i%10
    i = int(i/10)
    j=j+1
    #if i==0:
     # break
  if s>=a and s<=b:
    h = h + f
    
print(h)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

color = [a[0]]
for i in range(1,n):
    color.sort(reverse=True)
    for j in range(len(color)):
        if color[j] < a[i]:
            color[j] = a[i]
            break
    else:
        color.append(a[i])

print(len(color))

### FIXED CODE ###

from bisect import *
n = int(input())
a = [int(input()) for i in range(n)]

color = [-a[0]]
for i in range(1,n):
    if -a[i] >= color[-1]:
        color.append(-a[i])
    else:
        idx = bisect_right(color,-a[i])
        color[idx] = -a[i]

print(len(color))
### BUGGY CODE ###

n, q = [int(x) for x in input().split()]
vs   = []
us   = [1]
xs   = None
fs   = None
	
for _ in range(0, n + 1):
	vs.append([])
	xs = [0]     * (n + 1)
	fs = [False] * (n + 1)

for _ in range(0, n - 1):
	a, b = [int(x) for x in input().split()]
	vs[a].append(b)
	vs[b].append(a)

for _ in range(0, q):
	p, x   = [int(x) for x in input().split()]
	xs[p] += x
	
while 0 < len(us):
	u     = us.pop(0)
	x     = xs[u]
	fs[u] = True
	for n in vs[u]:
		if fs[n] == False:
			xs[n] += x
			us.append(n)

print(" ".join(str(x) for x in xs[1:]))


### FIXED CODE ###

n, q = [int(x) for x in input().split()]
vs   = []
	
for _ in range(0, n + 1):
	vs.append([])
	
xs    = [0]     * (n + 1)
fs    = [False] * (n + 1)
us    = [0]     * n
fs[1] = True
us[0] = 1
ui    = 0

for _ in range(0, n - 1):
	a, b = [int(x) for x in input().split()]
	vs[a].append(b)
	vs[b].append(a)

for _ in range(0, q):
	p, x   = [int(x) for x in input().split()]
	xs[p] += x
	
for i in range(0, n):
	x = xs[us[i]]
	for v in vs[us[i]]:
		if fs[v] == False:
			xs[v] += x
			ui    += 1
			us[ui] = v
			fs[v]  = True

print(" ".join(str(x) for x in xs[1:]))
### BUGGY CODE ###

S = input()
while True:
    if S == S.replace('ST',''):
        break
    else:
        S = S.replace('ST','')
print(len(S))

### FIXED CODE ###

S = input()
tcount = 0
scount = 0
for i in S:
    if i == 'T':
        if scount > 0:
            scount -= 1
        else:
            tcount += 1
    else:
        scount += 1
print(tcount + scount)
### BUGGY CODE ###

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
a = a.astype(np.object)
ans = np.prod(a)
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
  print(0)
  exit()
for i in a:
  ans*=i
  if ans>10**18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

n, k = [int(i) for i in input().split()]
s = input() + 'E'
top = int(s[0])
now = s[0]
idx = 0
ranges = []
for i, v in enumerate(s):
	if now != v:
		ranges.append(i - idx)
		idx = i
		now = v
zero = (k * 2) * [0]
ranges = zero + ranges + zero
targetIdx = 1 if top % 2 == 0 else 0 
ret = 0
for i, v in enumerate(ranges):
	if i % 2 == targetIdx:
		ret = max(sum(ranges[i:i+(k*2)+1]), ret)
print(ret)

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
s = input() + 'E'
top = int(s[0])
now = s[0]
idx = 0
ranges = []
for i, v in enumerate(s):
	if now != v:
		ranges.append(i - idx)
		idx = i
		now = v
zero = (k * 2) * [0]
ranges = zero + ranges + zero
targetIdx = 1 if top % 2 == 0 else 0 
ret = 0
tmp = 0
for i, v in enumerate(ranges):
	tmp += v
	if i > (k * 2 + 1):
		tmp -= ranges[i - (k * 2 + 1)]
	if i % 2 == targetIdx:
		ret = max(tmp, ret)
print(ret)