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

import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = max(max(a),max(b)).bit_length()+1
ans = 0
for i in range(1,x+1):
  c = sorted([a[j]&((1<<i)-1) for j in range(n)])
  d = sorted([b[j]&((1<<i)-1) for j in range(n)])
  t = 1<<(i-1)
  anstmp = 0
  for j in range(n):
    t1 = bisect.bisect_left(d,t-c[j])
    t2 = bisect.bisect_left(d,2*t-c[j])
    t3 = bisect.bisect_left(d,3*t-c[j])
    t4 = bisect.bisect_left(d,4*t-c[j])
    anstmp += (t2-t1)+(t4-t3)
  if anstmp%2:
    ans += t
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = max(max(a),max(b)).bit_length()+1
a = np.array(a,dtype=np.int32)
b = np.array(b,dtype=np.int32)
ans = 0
for i in range(1,x+1):
  c = a&(1<<i)-1
  d = b&(1<<i)-1
  d.sort()
  t = 1<<(i-1)
  anstmp = 0
  t1 = np.searchsorted(d,t-c).sum()
  t2 = np.searchsorted(d,2*t-c).sum()
  t3 = np.searchsorted(d,3*t-c).sum()
  anstmp += (t2-t1)+(n-t3)
  if anstmp%2:
    ans += t
print(ans)
### BUGGY CODE ###

import itertools
n = int(input())
cnt = 0
l = list(map(int, input().split()))
for a, b, c in itertools.combinations(l, 3):
    if abs(b - c) < a < b + c:
        cnt += 1
print(cnt) 

### FIXED CODE ###

import bisect
n = int(input())
cnt = 0
l = sorted(list(map(int, input().split())))
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        c_min = b + 1
        c_max = bisect.bisect_left(l, l[a] + l[b]) - 1
        cnt += c_max - c_min + 1
print(cnt)
### BUGGY CODE ###

n, m = map(int, input().split())
gate = []
for i in range(m):
    li, ri = map(int, input().split())
    gate.append([li, ri])

l_inside = list(range(1, n+1))
for i in range(m):
    l_inside = [j for j in l_inside if gate[i][0] <= j and j <= gate[i][1]]

print(len(l_inside))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n, m = map(int, input().split())

l_max = 1
r_min = n
for i in range(m):
    li, ri = map(int, input().split())
    if l_max < li:
        l_max = li
    if r_min > ri:
        r_min = ri

print(r_min-l_max+1 if r_min-l_max >= 0 else 0)
### BUGGY CODE ###

# D - AtCoder Express 2

import bisect, copy

N, M, Q = map(int, input().split())
LRidx = [list(map(int, input().split())) + [i] for i in range(M)]
p, q = [], []
for _ in range(Q):
    tmp_p, tmp_q = map(int, input().split())
    p.append(tmp_p)
    q.append(tmp_q)

# l,rはそれぞれ高々500通りなので、l,rの値に対して探索結果をメモしておく
LRidx = sorted(LRidx, key = lambda x: x[0])
tmp_L = [LRidx[idx][0] for idx in range(M)]
l_memo = [[-1] for _ in range(N+1)]
l_ok_idx = [[] for _ in range(Q)]
for i in range(Q):
    if l_memo[p[i]] and l_memo[p[i]][0] == -1:
        b_idx = bisect.bisect_left(tmp_L, p[i])
        try:
            tmp = [LRidx[j][2] for j in range(b_idx, M)]
            l_ok_idx[i] = copy.deepcopy(tmp)
            l_memo[p[i]] = copy.deepcopy(tmp)
        except:
            pass
    else:
        l_ok_idx[i] = copy.deepcopy(l_memo[p[i]])
    
LRidx = sorted(LRidx, key = lambda x: x[1])
tmp_R = [LRidx[idx][1] for idx in range(M)]
r_memo = [[-1] for _ in range(N+1)]
r_ok_idx = [[] for _ in range(Q)]
for i in range(Q):
    if r_memo[q[i]] and r_memo[q[i]][0] == -1:
        b_idx = bisect.bisect_right(tmp_R, q[i])
        tmp = [LRidx[j][2] for j in range(b_idx)]
        r_ok_idx[i] = copy.deepcopy(tmp)
        r_memo[q[i]] = copy.deepcopy(tmp)
    else:
        r_ok_idx[i] = copy.deepcopy(r_memo[q[i]])
    
for i in range(Q):
    print(len(set(l_ok_idx[i]) & set(r_ok_idx[i])))

### FIXED CODE ###

# D - AtCoder Express 2

import numpy as np

N, M, Q = map(int, input().split())
LR = np.zeros((N+1, N+1))

for _ in range(M):
    l, r = map(int, input().split())
    LR[l,r] += 1

np.cumsum(LR, axis = 0, out = LR)
np.cumsum(LR, axis = 1, out = LR)
    
for _ in range(Q):
    p, q = map(int, input().split())
    print(int(LR[q,q] - LR[p-1,q] - LR[q,p-1] + LR[p-1,p-1]))
### BUGGY CODE ###

n=int(input())
s=[int(input()) for i in range(n)]
#print(n,s)

t=[0]
for j in range(n):
    for i in range(len(t)):
        t.append(t[i]+s[j])
        
for i in range(len(t)):
    if t[i]%10==0:
        t[i]=0
        
print(max(t))


### FIXED CODE ###

n=int(input())
s=[int(input()) for i in range(n)]
#print(n,s)
t=[[float('-inf') for i in range(10000+1)] for i in range(n+1)]

t[0][0]=0
for j in range(1,n+1):
    t[j]=t[j-1]
    tmp=[]
    for i in range(10000+1):
        if t[j-1][i]>=0:
            tmp.append(t[j-1][i])
    for i in tmp:
        t[j][i+s[j-1]]=i+s[j-1]

for i in range(len(t[n])):
    if t[n][i]%10==0:
        t[n][i]=0

print(max(t[n]))
### BUGGY CODE ###

from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

h,w = inpl()
s = [[0] * w for i in range(h)]
r = [[0] * w for i in range(h)]
l = [[0] * w for i in range(h)]
u = [[0] * w for i in range(h)]
d = [[0] * w for i in range(h)]

for i in range(h):
    s[i] = input()

# cal l
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            l[i][j] = 0
        elif j == 0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1
# cal r
for i in range(h):
    for j in range(w)[::-1]:
        if s[i][j] == '#':
            r[i][j] = 0
        elif j == w-1:
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
# cal u
for i in range(w):
    for j in range(h):
        if s[j][i] == '#':
            u[j][i] = 0
        elif j == 0:
            u[j][i] = 1
        else:
            u[j][i] = u[j-1][i] + 1
# cal d
for i in range(w):
    for j in range(h)[::-1]:
        if s[j][i] == '#':
            d[j][i] = 0
        elif j == h-1:
            d[j][i] = 1
        else:
            d[j][i] = d[j+1][i] + 1
ans = 0
# print(l,r,u,d)
for i in range(h):
    for j in range(w):
        ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j])
print(ans-3)


### FIXED CODE ###

from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

h,w = inpl()
s = [[0] * w for i in range(h)]
r = [[0] * w for i in range(h)]
l = [[0] * w for i in range(h)]
u = [[0] * w for i in range(h)]
d = [[0] * w for i in range(h)]

for i in range(h):
    s[i] = input()

# cal l
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            l[i][j] = 0
        elif j == 0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1
# cal r
for i in range(h):
    for j in range(w)[::-1]:
        if s[i][j] == '#':
            r[i][j] = 0
        elif j == w-1:
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
# cal u
for i in range(w):
    for j in range(h):
        if s[j][i] == '#':
            u[j][i] = 0
        elif j == 0:
            u[j][i] = 1
        else:
            u[j][i] = u[j-1][i] + 1
# cal d
for i in range(w):
    for j in range(h)[::-1]:
        if s[j][i] == '#':
            d[j][i] = 0
        elif j == h-1:
            d[j][i] = 1
        else:
            d[j][i] = d[j+1][i] + 1
ans = 0
# print(l,r,u,d)
for i in range(h):
    for j in range(w):
        ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j])
print(ans-3)
### BUGGY CODE ###

import sys
import numpy as np
n = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()

#動的計画法 dp
dp =np.array([[0 for j in range(n+1)] for i in range(n+1)])

for i in range(n-1, -1, -1):
    for j in range(n-1, -1, -1):
        if i <j:
            if S[i] != S[j]:
                dp[i][j] = 0
            elif S[i] == S[j]:
                dp[i][j] = 1 + dp[i+1][j+1]
                if dp[i][j] >=n/2:
                    dp[i][j] = 0

#print(dp)
print(np.max(dp))

### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()


dp = [[0 for i in range(n)] for j in range(n)]
#初期条件
for j in range(1, n):
    if S[0] == S[j]:
        dp[0][j] = 1

#print(dp)

for i in range(1, n-1):
    for j in range(i+1, n):
        if S[i] ==S[j]:
            dp[i][j] = min(dp[i-1][j-1] +1, j-i)

maxp = 0
for i in range(n-1):
    for j in range(i+1, n):
        if maxp < dp[i][j]:
            maxp = dp[i][j]
#print(dp)
print(maxp)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

for i in range(n):
    pnt = a.count(i+1) - q + k
    if pnt > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
t = k - q
a = [0 for _ in range(n)]

for i in range(q):
    a[int(input())-1] += 1

for i in range(n):
    pnt = a[i] + t
    if pnt > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * 60
c = [0] * 60
ans = 0
for i in range(n):
    for j in range(60):
        c[j] += i - b[j] if a[i] >> j & 1 else b[j]
        b[j] += a[i] >> j & 1
for j in range(60):
    ans += c[j] << j
    ans %= 10**9 + 7
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * 60
ans = 0
for i in range(n):
    for j in range(60):
        ans += (i - b[j] if a[i] >> j & 1 else b[j]) << j
    ans %= 10**9 + 7
    for j in range(60):
        b[j] += a[i] >> j & 1
print(ans)
### BUGGY CODE ###

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

i = 1
ans = 1
while P >= i**N:
	if P % i**N == 0:
		ans = i
	i += 1
print(ans)



### FIXED CODE ###

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

ans = 1
R = int(P**(1/N)) + 1
if N == 1:
	ans = P
elif N > 40:
	ans = 1
else:
	for l in range(R):
		if P % (R-l)**N == 0:
			ans = R-l
			break
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
h = []
[h.append(int(input())) for i in range(N)]

l = []
for i in range(N):
    a = []
    for j in range(N):
        if i != j and h[i]-h[j]>=0:
            a.append(h[i]-h[j])
    if len(a) >= K-1:
        l.append(a)

l2 = []
for i in range(len(l)):
    a = min(l[i])
    if len(l[i]) > 1:
        l[i].remove(a)
    l2.append(min(l[i]))
print(min(l2))

### FIXED CODE ###

N, K = map(int, input().split())
h = []
[h.append(int(input())) for i in range(N)]

h.sort()
l = []
for i in range(N-K+1):
    l.append(h[i+K-1] - h[i])
print(min(l))
### BUGGY CODE ###

n = int(input())
x,y = [],[]
for i in range(n):
    a,b = map(int,input().split())
    x.append([a,i])
    y.append([b,i])
x.sort()
y.sort()
g = [[] for _ in range(n)]
for i in range(n-1):
    g[x[i][1]].append([abs(x[i+1][0]-x[i][0]),x[i+1][1]])
    g[x[i+1][1]].append([abs(x[i+1][0]-x[i][0]),x[i][1]])
    g[y[i][1]].append([abs(y[i+1][0]-y[i][0]),y[i+1][1]])
    g[y[i+1][1]].append([abs(y[i+1][0]-y[i][0]),y[i][1]])
import heapq
hq = []
for d,e in g[0]:
    heapq.heappush(hq,[d,e])
cnt = 1
visit = [False]*n
visit[0] = True
ans = 0
while cnt <n:
    cost, end = heapq.heappop(hq)
    if not visit[end]:
        ans += cost
        visit[end] = True
        cnt += 1
        for d,e in g[end]:
            heapq.heappush(hq,[d,e])
print(ans)
        


### FIXED CODE ###

n = int(input())
x,y = [],[]
for i in range(n):
    a,b = map(int,input().split())
    x.append([a,i])
    y.append([b,i])
x.sort()
y.sort()
g = [[] for _ in range(n)]
for i in range(n-1):
    g[x[i][1]].append([abs(x[i+1][0]-x[i][0]),x[i+1][1]])
    g[x[i+1][1]].append([abs(x[i+1][0]-x[i][0]),x[i][1]])
    g[y[i][1]].append([abs(y[i+1][0]-y[i][0]),y[i+1][1]])
    g[y[i+1][1]].append([abs(y[i+1][0]-y[i][0]),y[i][1]])
import heapq
hq = []
for d,e in g[0]:
    heapq.heappush(hq,[d,e])
cnt = 1
visit = [False]*n
visit[0] = True
ans = 0
while cnt <n:
    cost, end = heapq.heappop(hq)
    if visit[end]: continue
    ans += cost
    visit[end] = True
    cnt += 1
    for d,e in g[end]:
        if not visit[e]:
            heapq.heappush(hq,[d,e])
print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
count = 1

for i in range(1,N):
    flag = True
    for j in range(i):
        if P[j] < P[i]:
            flag = False
            break
    if flag:
        #print(i)
        count += 1            

print(count)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
count = 0
min_P = P[0]

for i in range(0,N):
    if P[i] < min_P:
        min_P = P[i]
    if min_P >= P[i]:
        count += 1

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

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans = ans*a[i]
if ans > 1e18:
    print("-1")
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
if a[0]==0:
  print("0")
else:
  ans = 1
  for i in range(n):
    ans = ans*a[i]
    if ans > 1e18:
      print("-1")
      break
  else:
    print(ans)
### BUGGY CODE ###

import heapq


N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

event_list.sort()
event_list.append([10**10, 1, 10**10])
i = 0
x_set = set()
x_list = []
time = 0
for q in range(Q):
  d = int(input())
  while time <= d:
    time, event, x = event_list[i]
    if time <= d:
      if event == 1:
        x_set.add(x)
        heapq.heappush(x_list, x)
      else:
        x_set.remove(x)
      i += 1
  
  while x_list and x_list[0] not in x_set:
    _ = heapq.heappop(x_list)
  if x_list:
    print(x_list[0])
  else:
    print(-1)

### FIXED CODE ###

import sys
from heapq import heappop, heappush

input = sys.stdin.readline
N, Q = map(int, input().split())
event_list = []
for i in range(N):
  s, t, x = map(int, input().split())
  event_list.append([s-x, 1, x])
  event_list.append([t-x, -1, x])

for i in range(Q):
  event_list.append([int(input()), 2, 0])

ans = []
event_list.sort()
x_set = set()
x_list = []
for time, event, x in event_list:
  if event == 1:
    x_set.add(x)
    heappush(x_list, x)
  elif event == -1:
    x_set.remove(x)
  else:
    while x_list and x_list[0] not in x_set:
      heappop(x_list)
    if x_list:
      ans.append(x_list[0])
    else:
      ans.append(-1)

print(*ans, sep='\n')
### BUGGY CODE ###

N = int(input())


for i in range(1, N+1):
    sum = 0

    range_x = int((i-5)**0.5)+1 if i-5 >0 else 0
    s = set()
    for x in range(1, range_x):
        if x in s:
            continue
        range_y = int((i-x**2-x-3)**0.5)+1 if i-x**2-2*x-2 > 0 else 0
        for y in range(x, range_y):
            if y in s:
                continue
            range_z = int((i-x**2-y**2-x*y-x-y)**0.5)+1 if i-x**2-y**2-x*y-x-y > 0 else 0
            for z in range(y, range_z):
                if z in s:
                    continue
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    num = len(set([x,y,z]))
                    sum += 6 if num == 3 else 3 if num==2 else 1
                    s = s | set([x,y,z])
                    break

    print(sum)

### FIXED CODE ###

N = int(input())

ans = [0]*(10**4+1)

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

for i in range(1, N+1):
    print(ans[i])
### BUGGY CODE ###

from collections import defaultdict
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
s = S()
sa = s[:n]
sb = s[n:][::-1]

A = defaultdict(int)
B = defaultdict(int)

for bit in range(1<<n):
    red_A = []
    red_B = []
    blue_A = []
    blue_B = []
    for i in range(n):
        if bit & 1<<i:
            red_A.append(sa[i])
            blue_B.append(sb[i])
        else:
            blue_A.append(sa[i])
            red_B.append(sb[i])
    a_key = (''.join(red_A), ''.join(blue_A))
    b_key = (''.join(blue_B), ''.join(red_B))
    A[a_key] += 1
    B[b_key] += 1

ans = 0
for key in A.keys():
    if key in B.keys():
        ans += A[key]*B[key]

print(ans)


### FIXED CODE ###

from collections import defaultdict
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def S(): return input()
# ----------------------------------------------------------- #

n = I()
s = S()
sa = s[:n]
sb = s[n:][::-1]

A = defaultdict(int)
B = defaultdict(int)

for bit in range(1<<n):
    red_A = []
    red_B = []
    blue_A = []
    blue_B = []
    for i in range(n):
        if bit & 1<<i:
            red_A.append(sa[i])
            blue_B.append(sb[i])
        else:
            blue_A.append(sa[i])
            red_B.append(sb[i])
    a_key = ''.join(red_A) + ',' + ''.join(blue_A)
    b_key = ''.join(blue_B) + ',' + ''.join(red_B)
    A[a_key] += 1
    B[b_key] += 1

ans = 0
for key in A.keys():
    if key in B:
        ans += A[key]*B[key]

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

N = int(input())
a = list(map(int, input().split()))
mindif = 1e100
minidx=0
for i in range(1,N):
    dif = abs(sum(a[:i])-sum(a[i:]))
    if dif<mindif:
        mindif = dif
        minidx = i
    else:
        break
print(mindif)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
r = sum(a)
ra = 0
result = 1e30
for i in range(0,N):
    ra += a[i]
    r -= a[i]
    result = min(result, abs(ra-r))
print(int(result))
### BUGGY CODE ###

n, m = map(int, input().split())
ab_list = list()
for _ in range(m):
    a, b = map(int, input().split())
    ab_list.append([a, b])
ab_list = sorted(ab_list, key=lambda x: x[1])
n_list = [1 for i in range(n)]
for a, b in ab_list:
    t_list = n_list[a:b]
    v = t_list.count(0)
    if v == 0:
        n_list[b-1] = 0
print(n_list.count(0))

### FIXED CODE ###

n, m = map(int, input().split())
ab_list = list()
for _ in range(m):
    a, b = map(int, input().split())
    ab_list.append([a, b])
ab_list = sorted(ab_list, key=lambda x: x[1])
x = -1
ans = 0
for a, b in ab_list:
    if a <= x:
        continue
    else:
        x = b-1
        ans += 1
print(ans)
### BUGGY CODE ###

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

n = int(input())
s = input()

counter = 0
for p in range(n):
    for q in range(n):
        for r in range(n):
            if p >= q or q >= r:
                continue
            a = s[p]
            b = s[q]
            c = s[r]
            if a != b and b != c and c != a and r - q != q - p:
                # print(a, b, c, p, q, r)
                counter += 1
print(counter)

### FIXED CODE ###

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

n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

counter = r_cnt * g_cnt * b_cnt

for i in range(n):
    for p in range(n):
        j = i + p
        k = j + p
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            counter -= 1
print(counter)
### BUGGY CODE ###

n,*d=map(int,open(0).read().split())
e=[0]*n
for i in d:e[i]+=1
a=d[0]<1==e[0]
for x,y in zip(e,e[1:]):a*=x**y
print(a%998244353)

### FIXED CODE ###

_,d=open(0)
*d,=map(int,d.split())
e=[0]*-~max(d)
for i in d:e[i]+=1
a=d[0]<1==e[0]
for x,y in zip(e,e[1:]):a*=x**y
print(a%998244353)
### BUGGY CODE ###

s = input()
t = input()

len_s = len(s)
dp = [[-1 for _ in range(len_s)] for _ in range(26)]
# dp[i][j] = いまsのj文字目にいる。次に探しているのはアルファベットのi文字目であるとき、次までの必要文字数。
# print(len(dp))
# print(len(dp[0]))

for idx in range(len_s):

	ch = s[idx]
	i = ord(ch)-ord("a")
	for j in range(len_s):
		if dp[i][j] == -1 or (dp[i][j] < j < idx):
			dp[i][j] = idx

ans = 0
j = 0
first = True
for ch in t:

	i = ord(ch)-ord("a")

	if dp[i][j] < 0:
		print(-1)
		exit()

	distance = dp[i][j] - j
	if (not first )and distance <= 0 :
		distance += len_s
	ans += distance
	j = dp[i][j]

	first = False

print(ans + 1)


### FIXED CODE ###

# https://img.atcoder.jp/abc138/editorial.pdf
# https://www.youtube.com/watch?v=lWETOlGiuaI
# このコードは公式解説動画をまんまpythonにしたものです。

# 解説動画
# s = abacaababc (10文字)の場合は
# a: [0, 2, 4, 5, 7, 10, 12, 14, 15, 17]
# b: [1, 6, 8, 11, 16, 18]
# c: [3, 9, 13, 19]
# という二重配列をまず作る。

# 例えばt = 'bbcca'だと
# 現在位置0、bを探す→1
# 現在位置1、bを探す→6
# 現在位置6、cを探す→9
# 現在位置9、cを探す→13(3に戻す)
# 現在位置3、aを探す→4
# で答えは14。


# 解説pdf曰く：
# next(ch, i):=「s'のi文字目以降で文字種chが最初に現れる位置」を
# をO(文字種数×|S|)かけて事前に全て求める

# 文字の先頭に戻る可能性があるので、2回連結しておくと処理が楽になる

from bisect import bisect_left

s = input()
t = input()
n = len(s)
m = len(t)

index_list = [[] for _ in range(26)]

for i in range(n):
    index_list[ord(s[i]) - ord('a')].append(i)
for i in range(n):
    index_list[ord(s[i]) - ord('a')].append(i+n)

p = 0  # p以降
ans = 0
for j in range(m):
    ch = ord(t[j]) - ord('a')
    if len(index_list[ch]) == 0:
        # t内に出現する文字が、sに全く登場しないので、不可
        print(-1)
        exit()
    next_pos = bisect_left(index_list[ch], p)
    p = index_list[ch][next_pos] + 1
    if p >= n:
        p -= n
        ans += n
    # print(p)

ans += p
print(ans)
### BUGGY CODE ###

import re
N = int(input())
al = "abcdefghijklmnopqrftuvwxyz"
S = []
for n in range(N):
    s = input()
    S.append(''.join(sorted(s)))

# print (S)
cnt = 0
for n in range(N):
    for n2 in range(n + 1, N):
        if (S[n] == S[n2]): cnt += 1

print (cnt)


### FIXED CODE ###

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

# print(S)

D = {}
for s in S:
    if not(s in D.keys()):
        D[s] = 1
    else:
        # print(s)
        D[s] += 1


cnt = 0
for c in D.values():
    if c != 1:
        cnt += (c * (c - 1)) // 2

print (cnt)
### BUGGY CODE ###

input_line=int(input())
count=0
input_list=[]
while count < input_line:
  input_list.append(input())
  count+=1
ans={}
max_appeard=0
ans_list=[]
for item in input_list:
    appeard=input_list.count(item)
    ans[item]=appeard
    if appeard > max_appeard:
        max_appeard=appeard
for key,value in ans.items():
    if value==max_appeard:
        ans_list.append(key)
ans_list.sort()
for item in ans_list:
  print (item)

### FIXED CODE ###

from collections import defaultdict

H=int(input())
d = defaultdict(int)
for _ in range(H):
    d[input()] += 1
max_appeard=max(d.items(), key=lambda x: x[1])[1]
ans=[k for k,v in d.items() if v == max_appeard]
ans.sort()
for item in ans:
  print (item)
### BUGGY CODE ###

A, B, K = map(int, input().split())
print(*[i for i in range(A,B+1) if i<A+K or B-K<i],sep="\n")

### FIXED CODE ###

A, B, K = map(int, input().split())
if A+K-1>=B-K+1:
    print(*list(range(A,B+1)),sep="\n")
else:
    print(*(list(range(A,A+K))+list(range(B-K+1,B+1))),sep="\n")