Harryxun/stf_run huggingface dataset:
N,M=map(int,input().split())
LR=list(map(int,input().split()) for _ in range(M) )
L=0
R=N
for i in range(M):
    L=max(L,LR[i][0])
    R=min(R,LR[i][1])
print(R-L+1 if R<=L else 0)

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
BC.sort(key = lambda x: -x[1])

for B, C in BC:
  A.extend([C]*B)
  if len(A) > N*2:
    break
A.sort(reverse = True)
print(sum(A[:N]))
import math
import numpy as np
N,K=map(int,input().split())
a=[0]*N
a=list(map(int,input().split()))
A=np.array(a)
b=np.zeros(N)
for i in range(K):
    if(K*N==np.sum(A)):
        break
    b=np.zeros(N)
    for j in range(N):

        minmin=max(0,math.ceil(j-A[j]-0.5))

        maxmax=min(N,math.floor(j+A[j]+0.5)+1)

        if(minmin==maxmax):
            maxmax=maxmax+1
            if(N<=maxmax):
                minmin=N-1
                maxmax=N

        for k in range(minmin,maxmax):
            b[k]=b[k]+1

    A=b
A=A.astype(np.int)
da=list(A)
L=[str(a) for a in da]

da=" ".join(L)
print(da)


### FIXED CODE ###

import math
N,K=map(int,input().split())
A=[0]*N
A=list(map(int,input().split()))

da=[0 for i in range(N)]
for k in range(K):
    B=[0 for i in range(N)]
    for i in range(N):
        l=max(0,i-A[i])
        r=min(N-1,i+A[i])
        B[l]=B[l]+1
        if(r+1<N):
            B[r+1]=B[r+1]-1
    for i in range(1,N):
        B[i]=min(N,B[i]+B[i-1])
    if(A==B):
        break
    A=B
b=[str(i) for i in B]
b=" ".join(b)
print(b)
N,M = map(int, input().split())
"""
if M == 0:
    print(-1)
    exit()
"""
pqcs = [list(map(int, input().split())) for _ in range(M)]
c_max = max(list(map(lambda x: x[2],pqcs)))
node_num = (c_max+1)*N
unsearached_nodes = list(range(node_num))#0～N-1(n-1)が乗換経由ノード/路線iの駅nは3*i+(n-1)番ノード
#opt_nodes = [-1]*node_num
distance = [float('inf')]*node_num
distance[0] = 0
cost = 0
edges = [[float('inf')]*node_num for _ in range(node_num)]
#辺へ重み付け
for p,q,c in pqcs:
    edges[3*c+(p-1)][3*c+(q-1)] = 0
    edges[3*c+(q-1)][3*c+(p-1)] = 0
    edges[p-1][3*c+(p-1)] = 1
    edges[q-1][3*c+(q-1)] = 1
    edges[3*c+(p-1)][p-1] = 0
    edges[3*c+(q-1)][q-1] = 0

while (distance[N-1] == float('inf')):
    temp_min_dist = float('inf')
    for unsearched_ind in unsearached_nodes:
        if temp_min_dist > distance[unsearched_ind]:
            temp_min_dist = distance[unsearched_ind]
            target_min_ind = unsearched_ind
    unsearached_nodes.remove(target_min_ind)
    target_node = edges[target_min_ind]
    flag = False
    for index, rota_dist in enumerate(target_node):
        if rota_dist != float('inf'):
            if distance[index] > distance[target_min_ind] + rota_dist:
                distance[index] = distance[target_min_ind] + rota_dist
                #opt_nodes[index] = target_min_ind

print(distance[N-1] if distance[N-1] != float('inf') else -1)

### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
F_C_of_S = [{} for i in range(N)]
#Companies of Station
C_of_S = {}

#def Union-find
parent = [-1]*M
def root(x):
	if (parent[x] < 0): return x
	else:
		parent[x] = y = root(parent[x])
		return y

def unite(x, y):
	px = root(x)
	py = root(y)
	if (px == py): return False
	if (parent[px] > parent[py]):
		px = root(y)
		py = root(x)
	parent[px] += parent[py]
	parent[py] = px
	return True


#Union-find
pqcs = []
for i in range(M):
	p, q, c = map(int, input().split())
	p -= 1; q -= 1;
	pqcs += [(p, q, c)]
	
	#The first
	if not c in F_C_of_S[p]: F_C_of_S[p][c] = i
	#else
	else: unite(F_C_of_S[p][c], i)
	C_of_S.setdefault(p, set()).add(c)
	
	#The first
	if not (c in F_C_of_S[q]):F_C_of_S[q][c] = i
	#else
	else: unite(F_C_of_S[q][c], i)
	C_of_S.setdefault(q, set()).add(c)

#stations of company
S_of_C = {}
for i in range(M):
	p, q, c = pqcs[i]
	c_set = S_of_C.setdefault(root(i), set())
	c_set.add(p)
	c_set.add(q)


Q = deque([(0, 0, 0)])
#cost to go to the stations from station_0
dist = [float('inf')]*N
dist[0] = 0

gdist = [float('inf')]*M

while Q:
	cost, v, flag = Q.popleft()
	
	if not (flag):#(flag == 0) then gdist_update
		if (dist[v] < cost) or (v not in C_of_S):
			continue
		for l in F_C_of_S[v].values():
			l = root(l)
			if (cost < gdist[l]):
				gdist[l] = cost
				Q.appendleft((cost, l, 1))
	
	else:#(flag == 1) then dist_update
		if (gdist[v] < cost) or (v not in S_of_C):
			continue
		for s in S_of_C[v]:
			if (cost+1 < dist[s]):
				dist[s] = cost+1
				Q.append((cost+1, s, 0))

print(dist[N - 1] if dist[N - 1] < float('inf') else -1)
n, m= map(int, input().split())
high = list(map(int, input().split()))
ans = [0]*n

for i in range(m):
    a =list(map(int, input().split()))
    if high[a[0]]-1 > high[a[1]-1]:
        if ans[a[0]-1] == 0:
            ans[a[0]-1] = 1
        ans[a[1]-1] = -1
    elif high[a[0]]-1 < high[a[1]-1]:
        if ans[a[1]-1] == 0:
            ans[a[1]-1] = 1
        ans[a[0]-1] = -1
    else:
        ans[a[1]-1] = -1
        ans[a[0]-1] = -1
print(ans.count(0) + ans.count(1))

### FIXED CODE ###

n, m= map(int, input().split())
high = list(map(int, input().split()))
ans = [1]*n

for i in range(m):
    a, b = map(int, input().split())
    if high[a-1] > high[b-1]:
        ans[b-1] = 0
    elif high[a-1] < high[b-1]:
        ans[a-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0
print(sum(ans))
a = list(map(int, input().split()))
a = [i for i in a if i != 1 else 14]
if a[0] > a[1]:
    print('Alice')
elif a[0] == a[1]:
    print('Draw')
else:
    print('Bob')

### FIXED CODE ###

a = list(map(int, input().split()))
a = [i if i != 1 else 14 for i in a]
if a[0] > a[1]:
    print('Alice')
elif a[0] == a[1]:
    print('Draw')
else:
    print('Bob')
from collections import Counter

def main():
    N = int(input())
    *A, = map(int, input().split())
    A.sort()
    C = Counter(A)

    MAX = 2000005
    T = [0]*MAX

    ans = 0
    for a in A:
        if T[a]:
            continue
        else:
            if C[a] == 1:
                ans += 1
            for i in range(2*a, MAX, a):
                T[i] += 1
    print(ans)

@jit()

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

for i, a in enumerate(A):
    if a == 0:
        print(i+1)
# -*- coding: utf-8 -*-
a, b = map(int, raw_input().split())
s = raw_input()
ok = False
if len(s) == (a+b+1):
  n = s.count('-')
  if n <= 1:
    x,y = map(str, s.split('-'))
    if len(x) == a:
      if len(y) == b:
        ok = True

if ok:
  print 'Yes'
else:
  print 'No'

### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, raw_input().split())
s = raw_input()
ok = False
if len(s) == (a+b+1):
  n = s.count('-')
  if n == 1:
    x,y = map(str, s.split('-'))
    if len(x) == a:
      if len(y) == b:
        ok = True

if ok:
  print 'Yes'
else:
  print 'No'
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())

    T = next(it)
    ans = []
    for i in range(T):
        N = next(it)

        val = 0; a1 = []; a2 = []
        for i, v1, v2 in ((next(it), next(it), next(it)) for i in range(N)):
            diff = v1 - v2
            a, v, diff = (a1, v2, diff) if diff >= 0 else (a2, v1, -diff)
            a.append((diff, i))
            val += v
        a1.sort(reverse=True); a2.sort(reverse=True)

        ls = len(a1)
        vis = [None]*N
        for diff, i in a1:
            j = min(i, ls) - 1
            v2 = [[None]]
            while j >= 0:
                v1 = vis[j]
                if v1 == None:
                    val += diff
                    v2[0][0] = j-1
                    vis[j] = v2
                    break
                j, v1[0] = v1[0][0], v2[0]


        for diff, i in a2:
            j, v2 = max(i, ls), [[None]]
            while j < N:
                v1 = vis[j]
                if not v1:
                    val += diff
                    v2[0][0] = j + 1
                    vis[j] = v2
                    break
                j, v1[0] = v1[0][0], v2[0]

        ans.append(val)

    print(*ans, sep="\n")



if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
sys.setrecursionlimit(1000000000)

def resolve():
    it = map(int, sys.stdin.read().split())

    T = next(it)
    ans = []
    for i in range(T):
        N = next(it)

        val = 0; a1 = []; a2 = []
        for i, v1, v2 in ((next(it), next(it), next(it)) for i in range(N)):
            diff = v1 - v2
            a, v, diff = (a1, v2, diff) if diff >= 0 else (a2, v1, -diff)
            a.append((diff, i))
            val += v
        a1.sort(reverse=True); a2.sort(reverse=True)

        ls = len(a1)
        vis = [None]*(N+1)
        def root(x):
            if vis[x] == None: return x

            vis[x] = root(vis[x])
            return vis[x]
        def root(x):
            a = []
            while True:
                y = vis[x]
                if y == None:
                    break
                a.append(x)
                x = y
            for i in a:
                vis[i] = x
            return x

        for diff, i in a1:
            j = min(i, ls) - 1
            k = root(j)
            #print(diff, i, j, k,  vis)
            if k < 0: continue
            val += diff
            vis[k] = k - 1


        for diff, i in a2:
            j, v2 = max(i, ls), [[-1]]
            k = root(j)
            #print(diff, i, j, k,  vis)
            if k >= N: continue
            val += diff
            vis[k] = k + 1

        ans.append(val)

    print(*ans, sep="\n")



if __name__ == "__main__":
    resolve()
while True:
    x,y = map(int, input().split())
    if x == 0 and y == 0:
        break;
    elif x => y:
        print (y,x)
    else:
        print (x,y)

### FIXED CODE ###

while True:
    x,y = map(int, input().split())
    if x == 0 and y == 0 :
        break
    elif x <= y :
        print (x,y)
    else :
        print (y,x)
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

n,k = map(int,input().split())
S = input()+'!'

get = [0]
tmp = 1
for i in range(1,n+1):
    if S[i] == S[i-1]:
        tmp += 1
    else:
        get.append(tmp)
        tmp = 1

get = get + [0]

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

res = 0
if S[0] == '0':
    for i in range(len(get)-2*k):
        if i%2 == 0:
            ans = get[i+2*k]-get[i]
        else:
            ans = get[min(i+2*k+1,len(get))]-get[i]
        if res <= ans:
            res = ans
else:
    for i in range(len(get)-2*k):
        if i%2 == 0:
            ans = get[min(len(get),i+2*k+1)]-get[i]
        else:
            ans = get[i+2*k]-get[i]
        if res <= ans:
            res = ans

print(res)

### FIXED CODE ###

n,k = map(int,input().split())
S = input()+'!'
A = [0]
tmp = 1
for i in range(1,n+1):
    if S[i] == S[i-1]:
        tmp += 1
    else:
        A.append(tmp)
        tmp = 1
for i in range(1,len(A)):
    A[i] += A[i-1]
#print(A)
res = 0
if S[0] == '0':
    for i in range(len(A)):
        if i%2 == 0:
            ans = A[min(i+2*k,len(A)-1)]-A[i]
        else:
            ans = A[min(i+2*k+1,len(A)-1)]-A[i]
        if res <= ans:
            res = ans
else:
    for i in range(len(A)):
        if i%2 == 0:
            ans = A[min(len(A)-1,i+2*k+1)]-A[i]
        else:
            ans = A[min(i+2*k,len(A)-1)]-A[i]
        if res <= ans:
            res = ans

print(res)
import itertools

N= int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
p = list(itertools.permutations(P))
a = p.index(P)
b = p.index(Q)
print(abs(a - b))

### FIXED CODE ###

import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
U = list(itertools.permutations(range(1, N+1)))
a = U.index(P)
b = U.index(Q)
print(abs(a-b))
def make_prime(n):
    prime = []
    temp = n
    for i in range(2, int(n**0.5) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            prime.append([i, cnt])
    if temp!=1:
        prime.append([temp, 1])
    if prime==[]:
        prime.append([n, 1])

    return prime
def factional_for(n):
    result = 1
    for i in range(n, 0, -1):
        result *= i
    return result
num = int(input())
w=10**9+7
s=0
prime_num_list = make_prime(factional_for(num))
for i in range(len(prime_num_list)):
    s += (prime_num_list[i][1]+1)%w
print(s)

### FIXED CODE ###

def make_prime(n):
    prime = []
    temp = n
    for i in range(2, n):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            prime.append([i, cnt])
    if temp!=1:
        prime.append([temp, 1])
    if prime==[]:
        prime.append([n, 1])

    return prime


from collections import defaultdict
d=defaultdict(lambda :1)
num = int(input())
w=10**9+7
for i in range(2,num+1):
    prime_num_list = make_prime(i)
    for j in range(len(prime_num_list)):
        key = prime_num_list[j][0]
        d[key] += prime_num_list[j][1]
cnt=1
for val in d.values():
    cnt*=val%w
print(cnt%w)
A,B,C = map(int,input().split())
x = C-A+B
print(X)
if X < 0
print(X)

### FIXED CODE ###

A,B,C = map(int,input().split())
X = C - A + B
if X < 0:
    X = 0
print(X)
#14:23
a,b = map(int,input())
if b >= a:
  print(a)
else:
  print(a-1)

### FIXED CODE ###

#14:23
a,b = map(int,input().split())
if b >= a:
  print(a)
else:
  print(a-1)
N,K,S = map(int, input().split())

sa = N-K+1
a = [1 for i in range(N)]

if S-sa+1 >0:
        
    a[0] = S - sa + 1

    for i in range(1,sa):
        a[i] = 1
    j = 0
    for i in range(sa,N):
        a[i] = a[j]

        j +=1
        j %= 3

    for x in a:
        print(x, end = " ")
else:
    for i in range(K):
        a[i] = S
    
    for x in a:
        print(x, end = " ")

### FIXED CODE ###

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

sa = N-K+1
a = [1 for i in range(N)]
if S-sa+1 >0:
        
    a[0] = S - sa + 1

    for i in range(1,sa):
        if i < N:
    
            a[i] = 1
    j = 0
    for i in range(sa,N):
        a[i] = a[j]

        j +=1
        j %= sa

    for x in a:
        print(x, end = " ")


else:
    for i in range(K):
        a[i] = S
    if S != 10**9:    
        for i in range(K,N):
            a[i] = 10**9
    else:
        for i in range(K,N):
            a[i] == 10**9 -1
    for x in a:
        print(x, end = " ")
import sys

sys.setrecursionlimit(10 ** 6)

inf = 10 ** 4


def larger(x, y):
    lx, ly = len(x), len(y)
    if lx > ly:
        return x
    elif lx < ly:
        return y
    else:
        x.sort(reverse=True)
        y.sort(reverse=True)
        for xx, yy in zip(x, y):
            if xx > yy:
                return x
            elif xx < yy:
                return y
        return x


def dfs(rest):
    if memo[rest] is not None:
        return memo[rest]

    res = []
    for use, number in d.items():
        if dp[rest - use] == dp[rest] - 1:
            res = larger(res, [number] + dfs(rest - use))

    memo[rest] = res
    return res


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

needs = [inf, 2, 5, 5, 4, 5, 6, 3, 7, 6]
# needs[i] : 数字iを作るのに必要なマッチの本数

for i in range(1, 10):
    if i not in a:
        needs[i] = inf

d = {needs[i]: i for i in range(1, 10) if needs[i] != inf}
# d[本数] = その本数で作れる最大の数値

dp = [-inf] * (n + 1)
dp[0] = 0
# dp[j] : j本から構成できる桁数の最大値

for j in range(2, n + 1):
    for use, number in d.items():
        if j - use >= 0:
            dp[j] = max(dp[j], dp[j - use] + 1)

# print(dp)

memo = [None] * (n + 1)

ans = dfs(n)
ans.sort(reverse=True)
print(*ans, sep='')

### FIXED CODE ###

def chmax(x, y):
    if x == '-':
        return y

    lx = len(x)
    ly = len(y)
    if lx < ly:
        return y
    elif lx == ly:
        if x < y: return y
        else: return x
    else:
        return x


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

cnt = [N + 1, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = ['-' for _ in range(N + 10 + 1)]
dp[0] = ''
# dp[j]: j 本使ってできる最大の数

for i in range(N + 1):
    # print(dp)
    if dp[i] == '-': continue
    for aa in a:
        dp[i + cnt[aa]] = chmax(dp[i + cnt[aa]], dp[i] + str(aa))

print(dp[N])
N = int(input())
S = [input() for _ in range(N)]

dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for i in dic.keys():
  if dic[keys] == maxim:
    ans.apend(keys)
    
ans.sort()

for i in ans:
  print(ans[i])

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]

dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for keys in dic.keys():
  if dic[keys] == maxim:
    ans.append(keys)
    
ans.sort()

for i in range(len(ans)):
  print(ans[i])
s=input()

if s[2]==s[3] and s[4]=s[5]:
  print ('Yes')

else:
  print('No')

### FIXED CODE ###

s=input()

if s[2]==s[3] and s[4]==s[5]:
  print ('Yes')

else:
  print('No')
import math
while(True):
    if input() == '0':
        break
    a = map(int, input().split())
    m = sum(a) / len(a)
    b = 0
    for i in a:
        b += (i - m) ** 2.0
    stddev = math.sqrt(b / n)
    print(stddev)


### FIXED CODE ###

import math
while(True):
    if input() == '0':
        break
    a = list(map(int, input().split()))
    m = sum(a) / len(a)
    b = 0
    for i in a:
        b += (i - m) ** 2.0
    stddev = math.sqrt(b / len(a))
    print(stddev)
n,a,b=map(int,input().split())
ans1=(k-1)//2+1
ans2=min(b-1,n-a)
print(min(ans1,ans2))

### FIXED CODE ###

n,a,b=map(int,input().split())
k=b-a-1
if k%2!=0:#間の卓が奇数
    ans=(k+1)//2
    print(ans)    
else:#偶数
    ans=min(b-1,n-a)
    ans1=min(a-1,n-b)+1+k//2
    print(min(ans,ans1))
#提出の際にmathをfractionsにする(2020/1/17現在)
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
if (N == 1):
   print(ans)
   exit(0)
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)


### FIXED CODE ###

from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
if (N == 1):
   print(ans)
   exit(0)
for i in range(1, len(x)):
    ans = gcd(abs(x[i] - x[i - 1]), ans)
print(ans)
import numpy as np

A,B,C,D = map(int,input().split())

ns = np.arange(A,B+1)

print(((ns%C!=0)*(ns%D!=0)).sum())

### FIXED CODE ###

import fractions

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

A,B,C,D = map(int,input().split())

AtoB =  B - (A-1)

div_C = (B//C) - ((A-1)//C)
div_D = (B//D) - ((A-1)//D)
div_CD = (B//lcm(C,D)) - ((A-1)//lcm(C,D))

print(AtoB - div_C - div_D + div_CD)
a=int(input())
import itertools
b=list(map(int,input().split()))
c=0
for d,e in combinations(b,2):
  
    c+=d*e
print(c)



### FIXED CODE ###

a=int(input())
import itertools 
b=list(map(int,input().split()))
c=0
for d,e in itertools.combinations(b,2):
  c+=d*e
print(c)
# 変数宣言
int A;
int B;

#計算結果の出力
print(A * B)

### FIXED CODE ###

# 1行に数値の複数入力後各変数に整数型で格納
A,B = map(int, input().split())

# 計算結果を変数に格納
result = A * B

# 計算結果の出力
print(result)
S = input()
ans = 0
if len(S) % 2 == 0:
    a = S[:len(S) // 2]
    b = S[len(S) // 2:]

    for i in range(len(a)):
        if a[i] != b[-i - 1]
            ans += 1

else:
    mid = len(S) // 2
    a = S[:mid]
    b = S[mid:]
    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

print(ans)

### FIXED CODE ###

S = input()
ans = 0
if len(S) % 2 == 0:
    a = S[:len(S) // 2]
    b = S[len(S) // 2:]

    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

else:
    mid = len(S) // 2
    a = S[:mid]
    b = S[mid:]
    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

print(ans)
a,b,c=input().split()

print(c+" "+a+" " + b " ")

### FIXED CODE ###

a,b,c=input().split()
 
print(str(c)+" "+str(a)+" " + str(b) + " ")
def main():
    def pre(n,mod):
        an=[1]*(n+1)
        a=1
        for i in range(1,n+1):
            a=(a*i)%mod
            an[i]=a
        b=pow(a,mod-2,mod)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%mod
            bs[i-1]=b
        return an,bs

    n,k=map(int,input().split())
    a=sorted(list(map(int,input().split())))
    mod=10**9+7
    an,bs=pre(n,mod)
    ans=0
    for i in range(k,n+1):
        for j in range(0,n-i+1):
            s=a[i+j-1]-a[j]
            s=(s*an[i-2]*bs[k-2]*bs[i-k])%mod
            ans=(ans+s)%mod
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

a='abcdefghijklmnopqrstuvwxyz'
s=input()
cnt=0
while s!=a[cnt]:
	cnt+=1
print(a[cnt+1])
import fractions
from functools import reduce

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

m1 = [0] * (N + 1)
m2 = [0] * (N + 1)
for i in range(1, N + 1):
  m1[i] = fractions.gcd(m1[i - 1], a_list[i - 1])
  m2[n - i] = fractions.gcd(m2[n - i + 1], a_list[n - i])

m = [0] * N
for i in range(N):
  m[i] = fractions.gcd(m1[i], m2[i + 1])

print(max(m))


### FIXED CODE ###

import fractions
from functools import reduce

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

m1 = [0] * (N + 1)
m2 = [0] * (N + 1)
for i in range(1, N + 1):
  m1[i] = fractions.gcd(m1[i - 1], a_list[i - 1])
  m2[N - i] = fractions.gcd(m2[N - i + 1], a_list[N - i])

m = [0] * N
for i in range(N):
  m[i] = fractions.gcd(m1[i], m2[i + 1])

print(max(m))
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
cnt = 0
sum = 0
flag = 0
for i in range(N):
    if i == 0:
        cnt = x[i][0]
        sum = x[i][1]
    else:
        cnt = x[i][0] - x[i-1][0]
        sum = x[i][1]+x[i][2] - x[i-1][1]+x[i-1][2]
    if cnt >= sum and cnt % sum == 0:
        flag = 0
    else:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
cnt = 0
sum = 0
flag = 0
T = X = Y = 0
for i in range(N):
    cnt = x[i][0] - T
    sum = abs(x[i][1]- X) + abs(x[i][2]- Y)
    T = x[i][0]
    X = x[i][1]
    Y = x[i][2]
    if cnt < sum or cnt % 2 != sum % 2:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")
n,m=map(int,input().split())

l=[0 for i in range(n)]
t=""
w=0
ww=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):
        w+=1
        ww+=1
    if(s=="AC"):
        ww=0
        a+=1
        l[int(p-1)]=1
print(a,w-ww)

### FIXED CODE ###

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

l=[0 for i in range(n)]
ll=[0 for i in range(n)]
w=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):ll[int(p)-1]+=1
    if(s=="AC"):
        l[int(p)-1]=1
        w+=ll[int(p)-1]
        a+=1
print(a,w)
a,b= input().split()
print(a*b)

### FIXED CODE ###

a,b= input().split()
print(int(a)*int(b))
import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())

    if L == 0:
        return 0

    if (R // 2019) > ((L-1) // 2019):
        return 0

    if (R // 673) > ((L-1) // 673):
        if R - L >= 2:
            return 0
        if (R % 3) == 0 or (L % 3) == 0:
            return 0

    left = L % 2019
    return (left * (left + 1)) % MOD


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


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    R = min(R, L + 2019)

    ans = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)

    return ans


if __name__ == '__main__':
    print(main())
s = raw_input()
length = len(s)

T = []
for i in range(length-1):
    if s[i] != s[i+1]:
    	T.append(max(i+1, length-(i+1)))
print min(T)

### FIXED CODE ###

s = raw_input()
length = len(s)
if length == 1:
    print 1
    exit()
T = []
for i in range(length-1):
    if s[i] != s[i+1]:
    	T.append(max(i+1, length-(i+1)))
if len(T) == 0:
    print length
else:
    print min(T)