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

n = int(input())
a_lst = list(map(int,input().split()))
seq_lst = []

for i in range(n):
    for j in range(n):
        if a_lst[j]==i+1:
            seq_lst.append(j+1)
            break

for i in range(n):
    print(seq_lst[i],end=' ')

### FIXED CODE ###

n = int(input())
a_lst = list(map(int,input().split()))
seq_lst = [0]*n

for i in range(n):
    seq = a_lst[i]
    seq_lst[seq-1] = i+1

for i in range(n):
    print(seq_lst[i], end=' ')
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if S[i] == S[j]:
                break
            if S[i] == S[k] or S[j] == S[k]:
                pass
            else:
                if j-i != k-j:
                    ans += 1
print(ans)

### FIXED CODE ###

import copy
N = int(input())
S = input()

R = set()
G = set()
B = set()

for i in range(N):
    if S[i] == "R":
        R.add(i)
    elif S[i] == "G":
        G.add(i)
    else:
        B.add(i)

ans = len(R)*len(G)*len(B)

for r in R:
    for g in G:
        L = g - r
        if g + L in B:
            ans -= 1
        if r - L in B:
            ans -= 1
        if L % 2 == 0 and L//2 + r in B:
            ans -= 1
            



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

S = input()

n = len(S)
ans = 0
for i in range(n):
    for j in range(i, n):
        if int(S[i:j + 1]) % 2019 == 0:
            ans += 1
            
print(ans)


### FIXED CODE ###


S = list(map(int, list(input())))

mod = 2019
ctr = [0] * mod
t = 0
for i, v in enumerate(reversed(S)):
    t = (t + int(v) * pow(10, i, mod)) % mod
    ctr[t] += 1

ans = ctr[0]
for v in ctr:
    ans += v * (v - 1) // 2
print(ans)
### BUGGY CODE ###

N=int(input())

A=list(map(int,input().split()))
B=[]

for i in range(N):
    B.append(A[i])
    B.reverse()

for i in range(N):
    print(B[i] if i==0 else " "+str(B[i]),end="")
print()


### FIXED CODE ###

N=int(input())

A=list(map(int,input().split()))
B=[]
C=[]

for i in range(N):
    if(N%2==0):
        if(i%2==0):
            B.append(A[i])
        else:
            C.append(A[i])
    else:
        if(i%2==0):
            C.append(A[i])
        else:
            B.append(A[i])

C.reverse()
for i in range(len(B)):
    C.append(B[i])

for i in range(N):
    print(C[i] if i==0 else " "+str(C[i]),end="")
print()
### BUGGY CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,-1),(0,1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)
### BUGGY CODE ###

# coding: utf-8
# Here your code !
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
C = 0

def binary_search(A,n):
    l = len(A)
    if l==0:
        return False
    elif A[l/2] > n: 
        return binary_search(A[:l/2],n)
    elif A[l/2] == n:
        return True
    elif A[l/2]<n:
        return binary_search(A[(l/2)+1:],n)

for item in T:
    if binary_search(S,item):
        C += 1
print C

### FIXED CODE ###

# coding: utf-8
# Here your code !
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())
C = 0

def binary_search(A,n):
    """no recursion version"""
    l = len(A)
    left = l/2
    right = l-1
    while A[left] != n:
        if left == right and A[left] != n:
            #print left,right,"if"
            return False
        elif A[left] > n: # n????????????????????´???
            right = left
            left = left/2
            #print left,right,"elif1"
        elif A[left] < n: # n????????????????????´???
            right = right
            left = (left + right-1)/2 + 1
            #print left,right,"elif2"
    else:
        return True

for item in T:
    if binary_search(S,item):
        C += 1
print C
### BUGGY CODE ###

import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
a_values = collections.Counter(a)

while len(a_values) > k:
    a_most = a_values.most_common()[0]
    a_least = a_values.most_common()[-1]

    a.remove(a_least[0])
    a.append(a_most[0])
    a_values = collections.Counter(a)
    ans += 1
else:
    print(ans)


### FIXED CODE ###

import collections
n, k = map(int, input().split())
a = list(map(int, input().split()))

a_values = collections.Counter(a)

o = len(a_values) - k
values, counts = zip(*a_values.most_common()[::-1])

if o <= 0:
    print(0)
else:
    print(sum(counts[:o]))
### BUGGY CODE ###

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 前からと後ろからでcandに入れて両方に入るところ
N, K, C = lr()
S = sr()
cand1 = set()
cand2 = set()

def F(S):
    cand = set()
    count = 0
    cur = 0
    while cur < len(S):
        if S[cur] == 'o':
            count += 1
            cand.add(cur)
            cur += C+1            
        else:
            cur += 1
        if count >= K:
            break
    return cand

cand1 = F(S)
cand2 = F(S[::-1])
cand2 = set(N-1-x for x in cand2)
s = cand1 & cand2
s = sorted(list(s))
s = [x+1 for x in s]

def check(S):
    count = 0
    cur = 0
    while cur < len(S):
        if S[cur] == 'o':
            count += 1
            cur += C+1            
        else:
            cur += 1
        if count >= K:
            return True
    return False

for x in s:
    T = list(S)
    T[x-1] = 'x'
    if not check(T):
        print(x)


### FIXED CODE ###

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 前からと後ろからでgreedyにcandに入れて両方の一致したところ
N, K, C = lr()
S = sr()

def choose(S):
    cand = []
    count = 0
    cur = 0
    while cur < len(S):
        if S[cur] == 'o':
            count += 1
            cand.append(cur)
            cur += C+1            
        else:
            cur += 1
        if count >= K:
            break
    return cand

cand1 = choose(S)
cand2 = choose(S[::-1])[::-1]
cand2 = [N-1-x for x in cand2]

for x, y in zip(cand1, cand2):
    if x == y:
        print(x+1)
### BUGGY CODE ###

N,K = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
#DPテーブル作成
dp = [10**10]*(len(H)+K)

dp[0]=0

for i in range(N):
    for j in range(1,K+1):
        if(i+j<N):
            dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))

print(dp[N-1])
#print(dp)

### FIXED CODE ###

N,K = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
#DPテーブル作成
dp = [10**10]*(N)

dp[0]=0

for i,hi in enumerate(H):
    if i ==0:
        continue
    s = i-K if i-K>=0 else 0
    dp[i] = min([dpk+abs(hi-hk) for dpk,hk in zip(dp[s:i],H[s:i])])
print(dp[-1])
#print(dp)
### BUGGY CODE ###

s = input()
q = int(input())
 
cnt = 0
for _ in range(q):
  t = input()
  if t[0] == "1":
    cnt += 1
  else:
    if cnt%2 == 1:
      s = "".join(list(reversed(s)))
      cnt = 0
    _,f,c = t.split(" ")
    if f == "1":
      s = c + s
    else:
      s = s + c
if cnt%2 == 1:
  s = "".join(list(reversed(s)))
  cnt = 0
print(s)

### FIXED CODE ###

from collections import deque
def main():
  s = deque(list(input()))
  q = int(input())
  sr = s.reverse
  sa = s.append
  sal = s.appendleft

  cnt = 0
  for _ in range(q):
    t = input()
    if t[0] == "1":
      cnt += 1
    else:
      _,f,c = t.split(" ")
      if f == "1":
        if cnt%2==1:
          sa(c)
        else:
          sal(c)
      else:
        if cnt%2==1:
          sal(c)
        else:
          sa(c)
  if cnt%2 == 1:
    sr()
  print("".join(list(s)))

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

import sys
from collections import deque


def bfs01(s, t, links):
    q = deque([(0, s, -1)])  # cost, station, last-company
    costs = [10 ** 9] * n
    corporations = [set() for _ in range(n)]
    while q:
        d, v, e = q.popleft()
        if v == t:
            return d
        if costs[v] < d or e in corporations[v]:
            continue
        costs[v] = d
        corporations[v].add(e)
        for u, c in links[v]:
            if c == e:
                nd = d
                func = q.appendleft
            else:
                nd = d + 1
                func = q.append
            if costs[u] < nd or c in corporations[u]:
                continue
            costs[u] = nd
            func((nd, u, c))
    return -1


readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

n, m = map(int, readline().split())
links = [set() for _ in range(n)]
pqc = list(map(int, read().split()))
for p, q, c in zip(pqc[0::3], pqc[1::3], pqc[2::3]):
    p -= 1
    q -= 1
    links[p].add((q, c))
    links[q].add((p, c))

print(bfs01(0, n - 1, links))


### FIXED CODE ###

import sys
from collections import deque, defaultdict


def bfs01(s, t, links):
    q = deque([(0, s, -1)])  # cost, station, last-company
    visited = set()
    while q:
        d, v, e = q.popleft()
        if v == t:
            return d
        if (v, e) in visited:
            continue
        visited.add((v, e))
        if e == 0:
            for c in links[v]:
                for u in links[v][c]:
                    if (u, c) in visited:
                        continue
                    q.append((d + 1, u, c))
        else:
            for u in links[v][e]:
                if (u, e) in visited:
                    continue
                q.appendleft((d, u, e))
            if (v, 0) not in visited:
                q.appendleft((d, v, 0))

    return -1


readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

n, m = map(int, readline().split())
links = [defaultdict(set) for _ in range(n)]
pqc = list(map(int, read().split()))
for p, q, c in zip(pqc[0::3], pqc[1::3], pqc[2::3]):
    p -= 1
    q -= 1
    links[p][c].add(q)
    links[q][c].add(p)

print(bfs01(0, n - 1, links))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import heapq
X, Y, A, B, C = map(int, input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

red = p[:X]
green = q[:Y]
heapq.heapify(red)
heapq.heapify(green)

while True :
    if not r :
        break
    if red[0] > green[0] :
        if green[0] < r[0] :
            heapq.heapreplace(green, r[0])
            r.pop(0)
        else :
            break
    else :
        if red[0] < r[0] :
            heapq.heapreplace(red, r[0])
            r.pop(0)
        else :
            break

print(sum(red)+sum(green))

### FIXED CODE ###

import sys
input = sys.stdin.readline
X, Y, A, B, C = map(int, input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

p.sort(reverse = True)
q.sort(reverse = True)
red = p[:X]
green = q[:Y]
ans = red + green + r
ans.sort(reverse = True)
print(sum(ans[:X+Y]))
### BUGGY CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def restore(s):
    s = s.replace("AAA", "")
    s = s.replace("BBB", "")
    while len(s) > 1:
        s = s.replace("AA", "B")
        s = s.replace("BB", "A")
        s = s.replace("AB", "")
        s = s.replace("BA", "")
    return s


S = input()
T = input()
q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    r_s = restore(S[a - 1 : b])
    r_t = restore(T[c - 1 : d])
    print("YES") if r_s == r_t else print("NO")


### FIXED CODE ###

import sys
from itertools import accumulate


def input():
    return sys.stdin.readline().strip()


def acc(li, n):
    res = [0] * (n + 1)
    for i in range(n):
        if li[i] == "A":
            res[i + 1] = 1
        elif li[i] == "B":
            res[i + 1] = 2
    return list(accumulate(res))


def restore(x, y, li):
    return (li[y] - li[x - 1]) % 3


S = input()
T = input()
N = len(S)
M = len(T)

acc_S = acc(S, N)
acc_T = acc(T, M)

q = int(input())
for _ in range(q):
    a, b, c, d = map(int, input().split())
    v_S = restore(a, b, acc_S)
    v_T = restore(c, d, acc_T)
    print("YES") if v_S == v_T else print("NO")
### BUGGY CODE ###

def main():
  from collections import defaultdict
  from heapq import heappush,heappop,heapify
  inf=2**31-1
  n,m,*t=map(int,open(0).read().split())
  edge=defaultdict(list)
  used=defaultdict(bool)
  d={}
  l=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    x,y=a+n*c,b+n*c
    if b==n:
      l.append(y)
      d[y]=inf
    edge[a].append((1,x))
    edge[b].append((1,y))
    ex,ey=edge[x].append,edge[y].append
    ex((0,a))
    ex((0,y))
    ey((0,b))
    ey((0,x))
  used[1]=True
  edgelist=edge[1]
  heapify(edgelist)
  while edgelist:
    m=heappop(edgelist)
    if used[m[1]]:
      continue
    d[m[1]]=m[0]
    used[m[1]]=True
    for e in edge[m[1]]:
      if not used[e[1]]:
        heappush(edgelist,(e[0]+m[0],e[1]))
  a=min([d[i]for i in l]or[inf])
  print([a,-1][a==inf])
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  from heapq import heappush,heappop,heapify
  inf=2**31-1
  n,m,*t=map(int,open(0).read().split())
  z=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    z.extend([a,b,a+n*c,b+n*c])
  z={i:v for v,i in enumerate(sorted(set(z)))}
  try:
    z[1]
  except:
    print(-1)
    exit()
  edge=[[]for _ in range(len(z))]
  d={}
  l=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    i,j,x,y=z[a],z[b],z[a+n*c],z[b+n*c]
    if b==n:
      l.append(y)
    edge[i].append((1,x))
    edge[j].append((1,y))
    edge[x].extend([(0,i),(0,y)])
    edge[y].extend([(0,j),(0,x)])
  used=[False]+[True]*~-len(z)
  d=[0]+[inf]*~-len(z)
  edgelist=edge[0]
  heapify(edgelist)
  while edgelist:
    m=heappop(edgelist)
    if not used[m[1]]:
      continue
    d[m[1]]=m[0]
    used[m[1]]=False
    for e in edge[m[1]]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+m[0],e[1]))
  a=min([d[i]for i in l]or[inf])
  print([a,-1][a==inf])
if __name__=='__main__':
  main()
### BUGGY CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import itertools

# DEBUG = True
DEBUG = False

N = int(read())


    
def answer(*args):
    print('!', *args, flush=True)
    exit()

answer('RRBBRB')

### FIXED CODE ###

import sys
readline = sys.stdin.readline

import itertools

#DEBUG = True
DEBUG = False

N = int(readline())

class Interactive:
    def __init__(self):
        self.ques_cnt = 0
        self.create_data()
        
    def create_data(self):
        import random
        A = ['B']*N + ['R']*N
        random.shuffle(A)
        self.A = [None] + A
        
    def resp_ques(self, *args):
        self.ques_cnt += 1
        assert len(args) == N
        from collections import Counter
        A = self.A
        selected = [A[i] for i in args]
        counter = Counter(selected)
        resp = 'Red' if counter['R'] > counter['B'] else 'Blue'
        return resp
    
    def resp_ans(self, *args):
        if len(args) != 1 or not isinstance(args[0], str):
            raise ValueError('Answer must be a string')
        if list(args[0]) == self.A[1:]:
            print('AC!')
            print('num of questions:', self.ques_cnt)
        else:
            print('WA!')
            
if DEBUG:
    interactive = Interactive()
    
def question(*args):
    print('?', *args, flush=True)
    if DEBUG:
        resp = interactive.resp_ques(*args)
        print(resp)
        return resp
    else:
        return readline()
    
def answer(*args):
    print('!', *args, flush=True)
    if DEBUG:
        interactive.resp_ans(*args)
    else:
        exit()

def make_LR_range(L,R):
    return itertools.chain(range(1,L+1), range(N+N-R+1, N+N+1))

def f(L):
    return question(*make_LR_range(L, N-L)).rstrip()

# f(L) != f(R)
L = 0
R = N
cL = f(L)
while L + 1 < R:
    x = (L + R) // 2
    if cL == f(x):
        L = x
    else:
        R = x

inv = {'B':'R', 'R':'B'}

C = [None] * (N+N+1)
C[L+1] = inv[cL[0]]
C[L+N+1] = cL[0]

A = list(range(1,L+1)) + list(range(L+N+2,N+N+1))
B = list(range(L+2,L+N+1))
for b in B:
    resp = question(b, *A)
    C[b] = resp[0]
for a in A:
    resp = question(a, *B)
    C[a] = resp[0]

answer(''.join(C[1:]))
### BUGGY CODE ###

N = int(input())
A_list = list(map(int, input().split()))
for i in range(len(A_list)):
    for j in range(i+1, len(A_list)):
        if A_list[i] == A_list[j]:
            print("NO")
            exit()
print("YES")

### FIXED CODE ###

N = int(input())
A_list = list(map(int, input().split()))
A_set = set(A_list)
if len(A_list) == len(A_set):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

N,K=map(int,input().split())
H=list(map(int,input().split()))
t=list()
for i in range(N-K):
    t.append(sorted(H)[i])
print(sum(t))

### FIXED CODE ###

N,K=map(int,input().split())
H=list(map(int,input().split()))
t=sorted(H)
n=list()
for i in range(N-K):
    n.append(t[i])
print(sum(n))
### BUGGY CODE ###

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

ans = []
for k in range(0,len(A)):
    ans.append(A.index(k+1))
    
ans = list(map(lambda x:x+1, ans))
ans = list(map(str, ans))
L = " ".join(ans)

print(L)

### FIXED CODE ###

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

sort = [1]*N
for k in range(0,len(A)):
    sort[A[k]-1] = k + 1
    
sort = list(map(str, sort))
ans = " ".join(sort)

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

from scipy.sparse import lil_matrix, csr_matrix
import numpy as np

s = input()
n = len(s)
a = lil_matrix((n,n), dtype=int)

for i in range(n):
    if s[i] == 'R':
        a[i+1, i] = 1
    else:
        a[i-1, i] = 1
a = a.tocsr()
a10 = a
for i in range(9):
    a10 = a.dot(a10)
a10_10 = a10
for _ in range(9):
    a10_10 = a10.dot(a10_10)
a10_10_10 = a10_10
for _ in range(9):
    a10_10_10 = a10_10.dot(a10_10_10)


v = np.ones(n, dtype=int)
vv = a10_10_10.dot(v)
ans = vv.tolist()
print(*ans)

### FIXED CODE ###

s = input()
ss = []

tmp = ''
for i in range(len(s)-1):
    tmp += s[i]
    if s[i] == 'L' and s[i+1] == 'R':
        ss.append(tmp)
        tmp = ''
ss.append(tmp+'L')

ans = []
for sss in ss:
    l = len(sss)
    for i in range(l):
        if sss[i] == 'R' and sss[i+1] == 'L':
            ri = i
            break
    rn = ri//2 + 1 + (l-ri-1)//2
    ln = l-rn
    for i in range(l):
        if i == ri:
            ans.append(rn)
        elif i == (ri+1):
            ans.append(ln)
        else:
            ans.append(0)
print(*ans)
### BUGGY CODE ###

from collections import Counter

N = int(input())

s = [input() for _ in range(N)]
s_dict = Counter(s)

max_keys = [k for k, v in s_dict.items() if v == max(s_dict.values())]
max_keys.sort()
for k in max_keys:
  print(k)

### FIXED CODE ###

from collections import Counter

N = int(input())

d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1

m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)
### BUGGY CODE ###

S = str(input())
Q = int(input())
querry = [list(map(str, input().split())) for i in range(Q)]
for i in range(Q):
    if querry[i][0] == '1':
        S = S[::-1]
    elif querry[i][0] == '2':
        if querry[i][1] == '1':
            S = querry[i][2] + S
        elif querry[i][1] == '2':
            S += querry[i][2]

print(S)

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
querry = [list(map(str, input().split())) for i in range(Q)]
reverse = False
for i in range(Q):
    if querry[i][0] == '1':
        reverse = not reverse
    elif querry[i][0] == '2':
        if querry[i][1] == '1':
            if reverse:
                S.append(querry[i][2])
            else:
                S.appendleft(querry[i][2])
        elif querry[i][1] == '2':
            if reverse:
                S.appendleft(querry[i][2])
            else:
                S.append(querry[i][2])

ans=list(S)

if reverse:
    print("".join(reversed(ans)))
else:
    print("".join(ans))
### BUGGY CODE ###

N = int(input())
num = 2
idx = 1
nums = [1]
while True:
  if num**idx > N:
    if idx == 2:
      break
    else:
      num += 1
      idx = 0
      continue
  else:
    nums.append(num**idx)
    idx += 1
nums.sort(key=lambda x:-x)
print(nums[0])


### FIXED CODE ###

N = int(input())
num = 2
idx = 1
nums = [1]
while True:
  if num**idx > N:
    if idx == 2 or N in range(1, 5):
      break
    else:
      num += 1
      idx = 0
      continue
  else:
    nums.append(num**idx)
    idx += 1
nums.sort(key=lambda x:-x)
print(nums[0])
### BUGGY CODE ###

N = int(input())

s = list(input())

res = 0

for i in range(1000):
    if 99 < i:
        v = list(str(i))
    elif 9 < i:
        v = list('0'+str(i))
    else:
        v = list('0'+'0'+str(i))
    
    # ステップ1
    p1 = -1
    for j in range(N):
        if s[j] == v[0]:
            p1 = j
            break
    
    if p1 < 0: continue

    # ステップ2
    p2 = -1
    for j in range(p1+1,N):
        if s[j] == v[1]:
            p2 = j
            break
    
    if p2 < 0: continue

    # ステップ3
    p3 = -1
    for j in range(p2+1,N):
        if s[j] == v[2]:
            res += 1
            break
print(res)            


### FIXED CODE ###

N = int(input())

s = input()

res = 0

search = [("00"+str(s))[-3:] for s in range(0,1000)]

for v in search:
    tmp = s
    if v[0] in tmp:
        tmp = tmp[tmp.index(v[0])+1:]
    else:
        continue
    if v[1] in tmp:
        tmp = tmp[tmp.index(v[1])+1:]
    else:
        continue
    if v[2] in tmp:
        res += 1
print(res)
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
c=list(range(1,a+1))
for i in c:
    print(b.count(i))

### FIXED CODE ###

import collections
a=int(input())
b=list(map(int,input().split()))

c=collections.Counter(b)
n,m=zip(*c.most_common())
n,m=list(n),list(m)
o=c.most_common()

result=[0]*a
for i in range(len(o)):
    result[o[i][0]-1]=o[i][1]

for i in result:
    print(i)
### BUGGY CODE ###

N,M,Q=map(int,input().split())
x=[[0]*N for _ in range(N)]
for i in range(M):
    L,R=map(int,input().split())
    L,R=L-1,R-1
    x[L][R]+=1

c=[[0]*N for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        if j==0:
            c[i][0]=x[i][0]
        else:
            c[i][j]=c[i][j-1]+x[i][j]

for i in range(Q):
    p,q=map(int,input().split())
    ans=0
    for i in range(p-1,q):
        if p==1:
            ans+=c[i][q-1]
        else:
            ans+=c[i][q-1]-c[i][p-2]
    print(ans)

### FIXED CODE ###

import sys
import numpy as np

input=sys.stdin.readline

N,M,Q=map(int,input().split())

x=np.zeros((N+1,N+1),dtype=np.int32)
for _ in range(M):
    l,r=map(int,input().split())
    x[l,r]+=1

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

from sys import stdin
from collections import defaultdict
n, w = [int(i) for i in stdin.readline().split(' ')]
weights = []
values = []
for i in range(0, n):
    cur = [int(i) for i in stdin.readline().split(' ')]
    weights.append(cur[0])
    values.append(cur[1])

dp = defaultdict(lambda: defaultdict(int))
dp[0][0] = 0
for minInd in range(0, n):
    for allowed in range(0, w):
        dp[minInd+1][allowed] = max(dp[minInd+1][allowed], dp[minInd][allowed])
        if allowed+weights[minInd] <= w:
            dp[minInd+1][allowed+weights[minInd]] = max(dp[minInd+1][allowed+weights[minInd]], dp[minInd][allowed]+values[minInd])

print(max(dp[n].values()))

### FIXED CODE ###

import numpy as np 
IN = lambda:map(int, input().split())
 
n, k = IN()
dp = np.zeros(k + 1)
 
for i in range(n):
    w, c = IN()
    dp[w:] = np.maximum(dp[w:], dp[:-w] + c)
    
print(int(dp[-1]))