Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
S = input()
left = S[:N]
right = S[:N-1:-1]

# leftの(blue, red)のパターンを全列挙
br_pattern = defaultdict(int)

for bit in range(1<<N):
    blue = ""
    red = ""
    for isb in range(N):
        if bit & (1<<isb):
            blue = blue + left[isb]
        else:
            red = red + left[isb]
            
    br_pattern[(blue, red)] += 1

# rightの(red, blue)のパターンをひとつずつ調べ、br_patternに一致する数だけansに足す
ans = 0
for bit in range(1<<N):
    red = ""
    blue = ""
    for isr in range(N):
        if bit & (1<<isr):
            red = red + right[isr]
        else:
            blue = blue + right[isr]
            
    ans += br_pattern[(red, blue)]
        
print(ans)

Fixed submission:
from collections import defaultdict

N = int(input())
S = input()
left = S[:N]
right = S[:N-1:-1]

# leftの(blue, red)のパターンを全列挙
br_pattern = defaultdict(int)

for bit in range(1<<N):
    blue = ""
    red = ""
    for isb in range(N):
        if bit & (1<<isb):
            blue = blue + left[isb]
        else:
            red = red + left[isb]
            
    br_pattern[(blue, red)] += 1

# rightの(red, blue)のパターンをひとつずつ調べ、br_patternに一致する数だけansに足す
ans = 0
for bit in range(1<<N):
    red = ""
    blue = ""
    for isr in range(N):
        if bit & (1<<isr):
            red = red + right[isr]
        else:
            blue = blue + right[isr]
            
    ans += br_pattern[(red, blue)]
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq as hq

#0 input
INF = 10**16
OKANE = 10**15

N, M, S, T = map(int, input().split())

graph_yen = [[] for _ in range(N+1)]
graph_snk = [[] for _ in range(N+1)]

for i in range(M):
    u, v, a, b = map(int, input().split())
    graph_yen[u].append((v, a))
    graph_yen[v].append((u, a))
    graph_snk[u].append((v, b))
    graph_snk[v].append((u, b))


def dijkstra(st, ryogae, graph):
    dist = [INF]*(N+1)
    hasVisited = [False]*(N+1)
    hasVisited[0] = True
    
    dist[st] = 0
    hasVisited[st] = True
    
    # ryogaeをvisitするまで続く
    cand_list = []
    cr_point = st
    while not hasVisited[ryogae]:
        # 次の候補をheapに入れる
        for neighb in graph[cr_point]:
            if not hasVisited[neighb[0]]:
                cand_list.append([dist[cr_point]+neighb[1], neighb[0]])
            
        #print("cand_list:{}".format(cand_list))
        # 次の候補を確定
        hq.heapify(cand_list)
        while 1:
            next_node = hq.heappop(cand_list)
            if not hasVisited[next_node[1]]:
                break
         
        #print(next_node)
        # distの更新
        cr_point = next_node[1]
        dist[cr_point] = next_node[0]
        hasVisited[cr_point] = True
        
        #print("dist:{}".format(dist))
    
    return dist[ryogae]


min_list = [INF]*(N+1)
for i in range(N-1,-1,-1):
    min_after_i = dijkstra(S,i+1,graph_yen) + dijkstra(T,i+1,graph_snk)
    min_list[i] = min(min_after_i,min_list[i+1])



for i in range(N):
    print(OKANE - min_list[i])

Fixed submission:
import heapq
n,m,s,t=map(int,input().split())
s-=1
t-=1
Gyen=[dict() for i in range(n)]
Gsnu=[dict() for i in range(n)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    u-=1
    v-=1
    Gyen[u][v]=a
    Gyen[v][u]=a
    Gsnu[u][v]=b
    Gsnu[v][u]=b
def dijkstra(adj, start):
    num = n          # グラフのノード数
    dist = [10**15 for i in range(num)] # 始点から各頂点までの最短距離を格納する
   
    dist[start] = 0
    q = []                  # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
    heapq.heappush(q, (0, start)) # 始点をpush
    while (len(q) != 0):
        prov_cost, src = heapq.heappop(q) # pop
        # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
        if dist[src] < prov_cost:
            continue
        # 他の頂点の探索
        for dest in adj[src]:
            cost = adj[src][dest]
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost # distの更新
                heapq.heappush(q, (dist[dest], dest)) # キューに新たな仮の距離の情報をpush                  
    return dist
CostYen=dijkstra(Gyen,s)
CostSnu=dijkstra(Gsnu,t)
Cost=[0 for i in range(n)]
for i in range(n):
    Cost[i]=CostYen[i]+CostSnu[i]
ans=[0 for i in range(n)]
ans[-1]=Cost[-1]
for i in list(range(n-1))[::-1]:
    ans[i]=min(ans[i+1],Cost[i])
for i in range(n):
    print(10**15-ans[i])
Buggy python submission (verdict: Runtime Error):
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int n = sc.nextInt();
		
		int ans;
		
		if(n<100) {
			ans = n * (int)Math.pow(100, d);
		}else {
			ans = (n+1) * (int)Math.pow(100,d);
		}
		
		System.out.println(ans);

		sc.close();
	}

}

Fixed submission:
def main():
    D, N = map(int, input().split())
    if N==100:
        print((N+1)*100**D)
    else:    
        print(N*100**D)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def summation(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return n + summation(n-1)


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)

    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    num = int(input())
    if num<1000:
        ans = 'ABC'
    elif num < 1999:
        ans = 'ABD'
    else:
        print("error")
        
    print(ans)
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def summation(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return n + summation(n-1)


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)
    
    return 0

    
if __name__ == "__main__":
    main()

Fixed submission:
def summation(n):
    ans = 0
    for i in range(n+1):
        ans += i
        
    return ans


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)
    
    return 0

    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def summation(n):
    if n == 1:
        return 1
    else:
        return n + summation(n-1)


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)

    
if __name__ == "__main__":
    main()

Fixed submission:
def summation(n):
    ans = 0
    for i in range(n+1):
        ans += i
        
    return ans


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)
    
    return 0

    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    
    N = int(input())
    
    POW6 = []
    POW9 = []
    for i in range(7):
        POW6.append(6**i)
        
    for i in range(6):
        POW9.append(9**i)
        
    
    dp = [N]*(N+1)
    dp[0] = 0
    for i in range(1, N+1):
        cnt = 0
        while i-POW6[cnt] >= 0:
            dp[i] = min(dp[i], dp[i-POW6[cnt]]+1)
            cnt += 1
        cnt = 0
        while i-POW9[cnt] >= 0:
            dp[i] = min(dp[i], dp[i-POW9[cnt]]+1)
            cnt += 1

    
    print(dp[N])
    
    
if __name__ == "__main__":
    main()

Fixed submission:
# ある数Nのみで割っていく関数
def div_by_N(inpt, N):
    if inpt < N:
        return inpt
    else:
        ans = 0
        while inpt>0:
            ans += inpt%N
            inpt = inpt // N
        return ans
        
def main():
    inpt = int(input())
    ans = 1000000
    for i in range(inpt+1):
        ans = min(ans, div_by_N(i,6)+div_by_N(inpt-i,9))
    print(ans)
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    #0. input
#    N,C = 2, 3
#    D = [[0, 1, 1], [1, 0, 1], [1, 4, 0]] 
#    c_init = [[1, 2],[3, 3]]
    
#    N, C = 4, 3
#    D = [[0, 12, 71],
#             [81, 0, 53],
#             [14, 92, 0]]
#    c_init = [[1, 1, 2, 1],
#                   [2, 1, 1, 2],
#                   [2, 2, 1, 3],
#                   [1, 1, 2, 2]]
    
    N, C = map(int, input().split())
    
    D = []
    for i in range(C):
        D.append(list(map(int,input().split())))
        
    c_init = []
    for i in range(N):
        c_init.append(list(map(int, input().split())))
    
    iwakan = []
    
    for color0 in range(C):
        
        for color1 in range(C):
            if color1 == color0:
                continue
            
            for color2 in range(C):
                if color2 == color0 or color2 == color1:
                    continue
                
                # calculate diff
                iwakan_temp = 0
                for i in range(N):
                    for j in range(N):
                        if (i+j)%3 == 0:
                            iwakan_temp += D[c_init[i][j] - 1][color0 - 1]
                        elif (i+j)%3 == 1:
                            iwakan_temp += D[c_init[i][j] - 1][color1 - 1]
                        else:
                            iwakan_temp += D[c_init[i][j] - 1][color2 - 1]
                            
                iwakan.append(iwakan_temp)
                
    ans = min(iwakan)
    print(ans)
                


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, C = map(int, input().split())
    D = []
    for i in range(C):
        D.append(list(map(int, input().split())))
        
    c_init = []
    for i in range(N):
        c_init.append(list(map(int,input().split())))
    
    group0 = [0]*C
    group1 = [0]*C
    group2 = [0]*C
    
    
    #1. 各グループに何色がどれだけあるかチェック
    for i in range(N):
        for j in range(N):
            if (i+j+2)%3==0:
                group0[c_init[i][j] - 1] += 1
            elif (i+j+2)%3 == 1:
                group1[c_init[i][j] - 1] += 1
            else:
                group2[c_init[i][j] - 1] += 1
    
    #2. 違和感の大きさをチェック
    iwakan =[]
    for color0 in range(C):
        for color1 in range(C):
            if color1 == color0:
                continue
            
            for color2 in range(C):
                if color2==color0 or color2==color1:
                    continue
                
                iwakan_temp = 0
                for colorN in range(C):
                    iwakan_temp += group0[colorN]*D[colorN][color0]
                    iwakan_temp += group1[colorN]*D[colorN][color1]
                    iwakan_temp += group2[colorN]*D[colorN][color2]
                
                iwakan.append(iwakan_temp)
                
    print(min(iwakan))
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
for left in range(N):
    digit = [0]*20
    for right in range(left+1, N+1):
        cur = A[right-1]
        if cur == 0:
            ans += 1
            continue
        res = []
        while cur>0:
            res.append(cur%2)
            cur = cur//2
        res = res[::-1]
        res = [0]*(20-len(res))+res
        
        digit = [digit[i] + res[i] for i in range(20)]
        
        if 2 in digit:
            break
        
        ans += 1
        
print(ans)

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

ans = 0
total = 0
right = 1
for left in range(N):
    while right < N+1:
        cur = A[right-1]
        if total & cur == 0:
            right += 1
            total += cur
        else:
            total -= A[left]
            break
        
        ans += right-left-1

        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def count_ans(n,a):
    n = len(a)
    count = 0
    
    for l in range(n):
        sum_from_l = 0
        r = l
        while r < n:
            if sum_from_l & a[r] == 0:
                sum_from_l += a[r]
                count += 1
                r += 1
            else:
                break
            
    return count



def main():
    
    #0. input
    n = int(input())
    a = list(map(int, input().split()))
    
    #1. judge
    ans = count_ans(n,a)
    print(ans)



if __name__ == "__main__":
    main()

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

ans = 0
total = 0
right = 1
for left in range(N):
    while right < N+1:
        cur = A[right-1]
        if total & cur == 0:
            right += 1
            total += cur
        else:
            total -= A[left]
            break
        
        ans += right-left-1

        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
N = int(input())
len_s = len(s)

sub_set = set()

for frm in range(len_s):
    for to in range(frm+1, len_s+1):
        sub_set.add(s[frm:to])
        

sub_list = list(sub_set)
sub_list.sort()

print(sub_list[N-1])

Fixed submission:
def main():
    #0.input
    s = input()
    K = int(input())
    
    #1. make subset
    subset = set()
    for k in range(1, min(len(s)+1, K+1)):
        start = 0
        while start <= len(s)-k:
            subset.add(s[start:start+k])
            start += 1
    
    subset_list = sorted(list(subset))
    print(subset_list[K-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def isPrefix(str1, str2):
    if str2[:len(str1)] == str1:
        return True
    else:
        return False

def isEarlier(str1, str2):
    for s1, s2 in zip(list(str1), list(str2)):
        if s1 != s2:
            if ord(s1) < ord(s2):
                return True
            else:
                return False

def main():
    #0.input
    s = input()
    K = int(input())
    
    #1. make subset
    subset = set()
    for k in range(1, len(s)+1):
        start = 0
        while start <= len(s)-k:
            subset.add(s[start:start+k])
            start += 1

    #2. get earliest one
    s_list = set(s)
    earliest = "z"
    for char in s_list:
        if ord(char) < ord(earliest):
            earliest = char
            
    #3. if K=1, end
    #    else, the get K-th one
    if K==1:
        print(earliest)
    else:
        k=1
        subset.remove(earliest)
        while True:
            subset_list = list(subset)
            earliest=subset_list[0]
            for element in subset_list[1:]:
                if (not isPrefix(earliest, element)) and (not isEarlier(earliest, element)):
                    earliest = element
            subset.remove(earliest)
            k += 1
                
            if k==K:
                print(earliest)
                break

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    #0.input
    s = input()
    K = int(input())
    
    #1. make subset
    subset = set()
    for k in range(1, min(len(s)+1, K+1)):
        start = 0
        while start <= len(s)-k:
            subset.add(s[start:start+k])
            start += 1
    
    subset_list = sorted(list(subset))
    print(subset_list[K-1])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n,c = li()
x_cw = []
v_cw = []
x_ccw = []
for _ in range(n):
    x,v = li()
    x_cw.append(x)
    v_cw.append(v)
    x_ccw.append(c-x)
    
x_ccw = [0] + sorted(x_ccw)
v_ccw = [0] + v_cw[::-1]
x_cw = [0] + x_cw
v_cw = [0] + v_cw
    
for i in range(1,n+1):
    v_cw[i] += (v_cw[i-1] - (x_cw[i]-x_cw[i-1]))
    v_ccw[i] += (v_ccw[i-1] - (x_ccw[i]-x_ccw[i-1]))
    
    
cw = []
ccw = []

ans = 0
for cw in range(n+1):
    for ccw in range(n+1):
        if cw + ccw > n:
            continue
        
        temp = v_cw[cw] + v_ccw[ccw] - min(x_cw[cw],x_ccw[ccw])
        ans = max(temp, ans)
        
print(ans)



Fixed submission:
from itertools import accumulate
import sys
sdin = sys.stdin.readline

n,c = map(int, sdin().split())
x_cw = [0]
v_cw = [0]
for _ in range(n):
    x, v =  map(int, sdin().split())
    x_cw.append(x)
    v_cw.append(v)
    
v_cw_acc = list(accumulate(v_cw))    

# 反時計回りの距離と栄養価
x_ccw = [0]
v_ccw = [0]
for i in range(n):
    x_ccw.append(c-x_cw[n-i])
    v_ccw.append(v_cw[n-i])
    
v_ccw_acc = list(accumulate(v_ccw))

# cw, ccwそれぞれでの各寿司ナンバーまでのmaxを求める
total_cw_max = [0]
total_ccw_max = [0]
for i in range(1,n+1):
    tmp_cw = v_cw_acc[i] - x_cw[i]
    total_cw_max.append(max(total_cw_max[-1], tmp_cw))
    
    tmp_ccw = v_ccw_acc[i] - x_ccw[i]
    total_ccw_max.append(max(total_ccw_max[-1], tmp_ccw))
    
# b側を固定する
ans_b_static = 0
for b in range(n,-1, -1):
    tmp_b_static = total_cw_max[n-b] + v_ccw_acc[b] - 2*x_ccw[b]
    ans_b_static = max(ans_b_static, tmp_b_static)
    
# a側を固定する
ans_a_static = 0
for a in range(n, -1, -1):
    tmp_a_static = total_ccw_max[n-a] + v_cw_acc[a] - 2*x_cw[a]
    ans_a_static = max(ans_a_static, tmp_a_static)
    
# その大きい方が答え
print(max(ans_a_static, ans_b_static))
Buggy python submission (verdict: Time Limit Exceeded):
# 1.input
n = int(input())
x = list(map(int, input().split()))

# 2.delete i-th component
for i in range(n):
    xi_res = x[:i] + x[i+1:]

    # 3.print median
    half = int(n/2)
    print(sorted(xi_res)[half-1])

Fixed submission:
# 1.input
n = int(input())
x = list(map(int, input().split()))

# 2.check half- and half+
x_copy = sorted(x, reverse=False)
half = int(n/2)
half_minus = x_copy[half-1]
half_plus = x_copy[half]


# 3. judge
#    if removed number is smaller than or equal to half- -> half+
#    else -> half-
for xi in x:
    if xi <= half_minus:
        print(half_plus)
    else:
        print(half_minus)
Buggy python submission (verdict: Time Limit Exceeded):
# 1.input
n = int(input())
a = list(map(int, input().split()))

#2. choose maximum number as a_i and remove
ai = max(a)
a.remove(ai)

# 3. choose the nearest number from (a_i/2) as a_j
ideal = int(ai/2)
dist = 0
while 1:
    if (ideal-dist) in a:
        aj = ideal-dist
        break
    if (ideal+1+dist) in a:
        aj = ideal+1+dist
        break
    dist += 1
    
print("{} {}".format(ai, aj))

Fixed submission:
# 1.input
n = int(input())
a = list(map(int, input().split()))

#2. choose maximum number as a_i and remove
ai = max(a)
a.remove(ai)

# 3. choose the nearest number from (a_i/2) as a_j
abs_dist = [abs(a_temp-(ai/2)) for a_temp in a]
chosen_temp = min(abs_dist)
aj = a[abs_dist.index(chosen_temp)]

print("{} {}".format(ai, aj))
Buggy python submission (verdict: Runtime Error):
import numpy as np

def main():
    #1. make master list
    N = int(input())
    A = list(map(int, input().split()))

    A.append(0)
    A.insert(0,0)

    A = np.array(A)
    
    cost = np.abs(A[1:] - A[:-1])    
    total = sum(cost)    
    #2. remove i-th componet
    for i in range(N):

        #3. output
        print(total - cost[i] - cost[i+1] + abs(A[i+2]-A[i]))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
#1. input
    A, B, C = map(int, input().split())

#2. if min<mid => min+2
#    if min==mid => min+1, mid+1
#    else break
    cnt = 0
    nums = sorted([A,B,C])
    min_num = nums[0]
    mid_num = nums[1]
    max_num = nums[2]
    
    while 1:
        nums = sorted([min_num, mid_num, max_num])
        min_num = nums[0]
        mid_num = nums[1]
        max_num = nums[2]

        if (min_num == mid_num) and (mid_num == max_num):
            break
        elif min_num == mid_num:
            min_num += 1
            mid_num += 1
        else:
            min_num += 2
        
        cnt += 1     

#3. output
    print(cnt)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#1. input
n = int(input())
red_list = []
blue_list = []

for i in range(n):
    x, y = map(int, input().split())
    red_list.append([x, y])
for i in range(n):
    x, y = map(int, input().split())
    blue_list.append([x, y])

#2. search
#2.1 red:descending order in y
red_list.sort(key=lambda x:(x[1], x[0]), reverse=True)

#2.2 blue: ascending order
blue_list.sort(key=lambda x:(x[1], x[0]), reverse=False)

#2.3 search a blue point such as [x_r, y_r] < [x_b, y_b]
ans = 0
for red in red_list:
    for blue in blue_list:
        if (red[0]<blue[0]) and (red[1]<blue[1]):
            blue_list.remove(blue)
            ans += 1
            break


#3. print the result
print(ans)
logger.log(30, ans)

Fixed submission:
n = int(input())
red_list = []
blue_list = []

for i in range(n):
    x, y = map(int, input().split())
    red_list.append([x, y])
for i in range(n):
    x, y = map(int, input().split())
    blue_list.append([x, y])

#2. search
#2.1 red:descending order in y
red_list.sort(key=lambda x:(x[1], x[0]), reverse=True)

#2.2 blue: ascending order
blue_list.sort(key=lambda x:(x[0], x[1]), reverse=False)

#2.3 search a blue point such as [x_r, y_r] < [x_b, y_b]
ans = 0
for red in red_list:
    for blue in blue_list:
        if (red[0]<blue[0]) and (red[1]<blue[1]):
            blue_list.remove(blue)
            ans += 1
            break

#3. print the result
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    #1. input
    a = int(input())
    b = int(input())
    
    ans = 0
    counter=0
    
    #2. from A to B
    for i in range(a, b+1):
        counter = counter+1
        #2.1. judge if the number is palindromic
        if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]):
            ans = ans+1
        
    #3. output
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    #1. input
    a, b = map(int, input().split())
    
    ans = 0
    
    #2. from A to B
    for i in range(a, b+1):
        #2.1. judge if the number is palindromic
        if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]):
            ans = ans+1
        
    #3. output
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    #1. input
    a = int(input())
    b = int(input())
    
    ans = 0
    counter=0
    
    #2. from A to B
    for i in range(a, b+1):
        counter = counter+1
        #2.1. judge if the number is palindromic
        if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]):
            ans = ans+1
        
    #3. output
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    #1. input
    a, b = map(int, input().split())
    
    ans = 0
    
    #2. from A to B
    for i in range(a, b+1):
        #2.1. judge if the number is palindromic
        if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]):
            ans = ans+1
        
    #3. output
    print(ans)


if __name__ == '__main__':
    main()