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

#単位元を設定
ide = 0

class SegmentTree:
	def __init__(self,n):
        #セグ木の頂点はindex == 1から。index == 0は無視すること。
        #つまり、STtable[0]は無視。頂点はSTtable[1]。
		self.n = n
		tmp = 0
		while True:
			if 2 ** tmp >= self.n:
				break
			tmp += 1
		self.STtable = [ide] * (2*2**tmp)
		self.STtable_size = len(self.STtable)

	def update(self,i,a):
        #更新のためのインデックスの指定は0_indexedで。
		a_bit = 1 << ord(a)-97
		i += self.STtable_size//2
		self.STtable[i] = a_bit
		while i > 0:
			i //= 2
			self.STtable[i] = self.STtable[i*2] | self.STtable[i*2+1]

	def find(self,a,b,k=1,l=0,r=None):
        #kは頂点番号。初期値は1にすること。
		#[a,b)の最小を返す。
		#[l,r)からです。
        #初期値のrは、self.STtable_size//2にすると、ちょうど要素数と同じ値になって[l,r)のrになる。
        #問題に適するように範囲を指定するように注意。大体[l,r]で指定されている。
		if r == None:
			r = self.STtable_size//2        
		if a >= r or b <= l:
			return ide
		elif a <= l and b >= r:
			return self.STtable[k]
		else:
			mid = (l+r)//2
			if b <= mid:
				return self.find(a,b,2*k,l,mid)
			elif a >= mid:
				return self.find(a,b,2*k+1,mid,r)
			else:
				v1 = self.find(a,mid,2*k,l,mid)
				v2 = self.find(mid,b,2*k+1,mid,r)
			return v1 | v2

N = int(input())
solve = SegmentTree(N)
S = input()
for i in range(N):
	solve.update(i,S[i])
Q = int(input())
ans = []
for _ in range(Q):
	a,b,c = map(str, input().split())
	if a == '1':
		solve.update(int(b)-1,c)
	else:
		tmp = solve.find(int(b)-1,int(c))
		cnt = 0
		for i in range(26):
			if tmp >> i & 1 == 1:
				cnt += 1
		ans.append(cnt)

for a in ans:
	print(a)


### FIXED CODE ###

#単位元を設定
ide = 0

class SegmentTree:
	def __init__(self,n):
        #セグ木の頂点はindex == 1から。index == 0は無視すること。
        #つまり、STtable[0]は無視。頂点はSTtable[1]。
		self.n = n
		tmp = 0
		while True:
			if 2 ** tmp >= self.n:
				break
			tmp += 1
		self.STtable = [ide] * (2*2**tmp)
		self.STtable_size = len(self.STtable)

	def update(self,i,a):
        #更新のためのインデックスの指定は0_indexedで。
		a_bit = 1 << ord(a)-97
		i += self.STtable_size//2
		self.STtable[i] = a_bit
		while i > 0:
			i //= 2
			self.STtable[i] = self.STtable[i*2] | self.STtable[i*2+1]

	def find(self,a,b,k=1,l=0,r=None):
        #kは頂点番号。初期値は1にすること。
		#[a,b)の最小を返す。
		#[l,r)からです。
        #初期値のrは、self.STtable_size//2にすると、ちょうど要素数と同じ値になって[l,r)のrになる。
        #問題に適するように範囲を指定するように注意。大体[l,r]で指定されている。
		if r == None:
			r = self.STtable_size//2        
		if a >= r or b <= l:
			return ide
		elif a <= l and b >= r:
			return self.STtable[k]
		else:
			mid = (l+r)//2
			if b <= mid:
				return self.find(a,b,2*k,l,mid)
			elif a >= mid:
				return self.find(a,b,2*k+1,mid,r)
			else:
				v1 = self.find(a,mid,2*k,l,mid)
				v2 = self.find(mid,b,2*k+1,mid,r)
			return v1 | v2

N = int(input())
solve = SegmentTree(N)
S = input()
for i in range(N):
	solve.update(i,S[i])
Q = int(input())
ans = []
for _ in range(Q):
	a,b,c = map(str, input().split())
	if a == '1':
		solve.update(int(b)-1,c)
	else:
		tmp = solve.find(int(b)-1,int(c))
		cnt = 0
		for i in range(26):
			if tmp >> i & 1 == 1:
				cnt += 1
		ans.append(cnt)

for a in ans:
	print(a)
### BUGGY CODE ###

n, m = map(int, input().split())
mod = 10**9 + 7
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
	for j in range(m-1):
		ans += abs(X[i+1] - X[i])%mod * abs(Y[j+1] - Y[j])%mod * ((i+1)%mod) * ((n-i-1)%mod) * ((j+1)%mod) * ((m-j-1)%mod)
		ans %= mod
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
mod = 10**9 + 7
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	ans += X[i]*(n-2*i-1)%mod
t = 0
for j in range(m):
	t += Y[j]*(m-2*j-1)%mod
ans *= t%mod
print(ans%mod)
### BUGGY CODE ###

from statistics import median

N = int(input())
data = list(map(int, input().split(' ')))

for i in range(len(data)):
    temp = [x for j,x in enumerate(data) if j != i]
    print(median(temp))

### FIXED CODE ###

N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

c1 = sorteddata[N // 2]
c2 = sorteddata[N // 2 - 1]

for i in range(N):
    if (data[i] < c1):
        print(c1)
    else:
        print(c2)
### BUGGY CODE ###

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
#print(N)
#case = (N(N-1))/2
com = []
cnt = 0
maxval = A[-1]
'''
if K >= case:
  for i in range(N):
    com.append
  com =

'''

for i in range(N):
  for j in range(i+1, N):
    com.append(A[i]*A[j])

com.sort()
#print(com)
print(com[K-1])

### FIXED CODE ###

def d_pairs():
    # 参考: https://maspypy.com/atcoder-参加感想-2019-02-16abc-155
    import numpy as np
    N, K = [int(i) for i in input().split()]
    A = np.array([int(i) for i in input().split()], np.int64)

    A = np.sort(A)
    zero = A[A == 0]
    positive = A[A > 0]
    negative = A[A < 0]

    def f(c):
        """数列 A から 2 要素を選んで積を取ったとき、c 以下となるようなペアの選び方"""
        count_pair = 0

        # a (数列の要素) == 0 かつ c >= 0 なら、a * x <= c となる x は数列の任意の要素
        if c >= 0:
            count_pair += len(zero) * N
        # a > 0 の場合
        count_pair += np.searchsorted(A, c // positive, side='right').sum()
        # a < 0 の場合 (全体から引くようにすると、見通しがよい)
        count_pair += (N - np.searchsorted(A, (-c - 1) // (-negative), side='right')).sum()
        # 添字の順序に制約があることを反映する
        count_pair -= np.count_nonzero(A * A <= c)  # 「添字が同じ要素を 2 度選んだ場合」を引く
        return count_pair // 2

    # 数列から要素を 2 個選んで積を取ったとき、制約からあり得る値の範囲
    lower, upper = -10 ** 18, 10 ** 18
    while upper - lower > 1:
        x = (lower + upper) // 2
        if f(x) >= K:
            upper = x
        else:
            lower = x
    return upper

print(d_pairs())
### BUGGY CODE ###

s = input()
n = len(s)

memo = [0] * 2019
memo[0] += 1

num = 0
ten = 1
for i in range(n):
    num += int(s[-(i+1)]) * ten
    memo[num%2019] += 1
    ten *= 10

ans = 0
for p in memo:
    ans += p*(p-1)//2

print(ans)

### FIXED CODE ###

s = input()
n = len(s)

memo = [0] * 2019
memo[0] += 1

num = 0
t = 1
for i in reversed(s):
    num += int(i) * t
    num %= 2019
    t *= 10
    t %= 2019
    memo[num] += 1

ans = 0
for p in memo:
    ans += p*(p-1)//2

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

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

diff = -float('inf')
for i in range(n):
  for j in range(i + 1, n):
    diff = max(diff, p[j] - p[i])

print(diff)

### FIXED CODE ###

import sys

n = int(input())

max_diff = - 10 ** 9
min_n = int(input())

for n in map(int, sys.stdin.readlines()):
  max_diff = max(max_diff, n - min_n)
  min_n = min(min_n, n)

print(max_diff)
### BUGGY CODE ###

n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]
for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])

ans=0
for i in range(n):
  ans=(ans+lcm//A[i])%mod
print(ans)


### FIXED CODE ###

n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)
### BUGGY CODE ###

import sys
from itertools import accumulate
readline = sys.stdin.readline

N, M, Q = map(int, readline().split())
direc = [(-1, 0), (1, 0), (0, -1), (0, 1)]
G = [[0]*(M+2)] + [[0] + list(map(int, readline().strip())) + [0] for _ in range(N)] + [[0]*(M+2)]
U = [[0]*(M+2) for _ in range(N+2)]
L = [[0]*(M+2) for _ in range(N+2)]
for i in range(1, N+1):
    for j in range(1, M+1):
        if G[i][j]:
            if G[i-1][j]:
                U[i][j] += 1
            if G[i][j-1]:
                L[i][j] += 1
G = [list(accumulate(k)) for k in G]
G = list(map(list, zip(*G)))
G = [list(accumulate(k)) for k in G]
G = list(map(list, zip(*G)))
U = [list(accumulate(k)) for k in U]
U = list(map(list, zip(*U)))
U = [list(accumulate(k)) for k in U]
U = list(map(list, zip(*U)))
L = [list(accumulate(k)) for k in L]
L = list(map(list, zip(*L)))
L = [list(accumulate(k)) for k in L]
L = list(map(list, zip(*L)))
Ans = [None]*Q 
for qu in range(Q):
    x1, y1, x2, y2 = map(int, readline().split())
    u = U[x1][y1-1] + U[x2][y2] - U[x1][y2] - U[x2][y1-1]
    l = L[x1-1][y1] + L[x2][y2] - L[x1-1][y2] - L[x2][y1]
    g = G[x1-1][y1-1] + G[x2][y2] - G[x1-1][y2] - G[x2][y1-1]
    Ans[qu] = g - u - l
print('\n'.join(map(str, Ans)))

### FIXED CODE ###

import sys
from itertools import accumulate
readline = sys.stdin.readline

def accumulate2d(X):
    N = len(X)
    M = len(X[0])
    
    for i in range(1, N):
        for j in range(1, M):
            X[i][j] += X[i][j-1]
    
    for j in range(1, M):
        for i in range(1, N):
            X[i][j] += X[i-1][j]
    
    return X
    

N, M, Q = map(int, readline().split())
G = [[0]*(M+2)] + [[0] + list(map(int, readline().strip())) + [0] for _ in range(N)] + [[0]*(M+2)]
U = [[0]*(M+2) for _ in range(N+2)]
L = [[0]*(M+2) for _ in range(N+2)]
for i in range(1, N+1):
    for j in range(1, M+1):
        if G[i][j]:
            if G[i-1][j]:
                U[i][j] += 1
            if G[i][j-1]:
                L[i][j] += 1
G = accumulate2d(G)
L = accumulate2d(L)
U = accumulate2d(U)
Ans = [None]*Q 
for qu in range(Q):
    x1, y1, x2, y2 = map(int, readline().split())
    u = U[x1][y1-1] + U[x2][y2] - U[x1][y2] - U[x2][y1-1]
    l = L[x1-1][y1] + L[x2][y2] - L[x1-1][y2] - L[x2][y1]
    g = G[x1-1][y1-1] + G[x2][y2] - G[x1-1][y2] - G[x2][y1-1]
    Ans[qu] = g - u - l
print('\n'.join(map(str, Ans)))
### BUGGY CODE ###

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0 for i in range(n)]
    dp[1] = abs(h[1]-h[0])
    for i in range(2,n):
        m = float('inf')
        for j in range(1,k+1):
            if i-j<0:
                break
            m_ = dp[i-j] + abs(h[i]-h[i-j])
            if m>m_:
                m = m_
        dp[i] = m
    print(dp[n-1])
    

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [float('inf') for i in range(n)]
    dp[0] = 0
    for i in range(1,n):
        for j in range(1,min(i+1,k+1)):
            m = dp[i-j] + abs(h[i]-h[i-j])
            if dp[i]>m:
                dp[i] = m
    print(dp[n-1])
    

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

import sys
input = sys.stdin.readline
N = int(input())
A = tuple(map(int,input().split()))
b = 0
num = 1000000007
A_1 = A[:-1]
A_2 = A[1:]
for i in A_1:
    for j in A_2:
        b += i ^ j
    A_2 = A_2[1:]
    #print(A_2)
print(b%num)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0
for k in range(60):
    A_0 = 0
    A_1 = 0
    for i in range(N):
        if A[i]>>k&1:
            A_1 += 1
        else:
            A_0 += 1
    num = A_1 * A_0
    ans += (num * 2 ** k)
ans %=  mod
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
link = [[] for _ in range(N)]
a = [None] * (N-1)
b = [None] * (N-1)
for i in range(N-1):
    a[i], b[i] = map(int, input().split())

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

for i in range(N-1):
    link[a[i]-1].append([b[i]-1, cost[i]])
    link[b[i]-1].append([a[i]-1, cost[i]])

def dfs(v, c, p):
    for nv in link[v]:
        if nv[0] == p:
            continue
        cost[nv[0]] = c + cost[nv[0]]
        dfs(nv[0], cost[nv[0]], v)
    return

dfs(0, cost[0], -1)

print(*cost)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v, p):
    for u in link[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)

N, Q = map(int, input().split())
link = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

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

dfs(0, -1)

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

N = int(input())
A = list(input().split())
Q = int(input())
for i in range(Q):
    b,c = input().split()
    A = list(map(lambda x:x.replace(b,c),A))
    B = A.copy()
    print(sum(map(int, B)))

### FIXED CODE ###

import collections

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
Q = int(input())
T = collections.Counter(A)
for i in range(Q):
    b, c = map(int, input().split())
    S += T[b]*(c-b)
    T[c] += T[b]
    T[b] = 0
    print(S)
### BUGGY CODE ###

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

def ligh(li):
  for x in range(k):
    if li==[n]*n:
      return li
    ne=[0]*n
    ar=[]
    for (i,a) in zip(range(n),li):
      for j in range(max(0,i-a),min(i+a+1,n)):
        ne[j]+=1
    li=ne
    #print(li)
  return li

for i in ligh(a):
  print(i,end=" ")

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
def ligh(li):
  for x in range(k):
    if li==[n]*n:
      return li
    ne=[0]*(n+1)
    zr=[]
    lis=[]
    for (i,a) in zip(range(n),li):
      if a==0:
        zr.append(i)
      else:
        ne[max(0,i-a)]+=1
        ne[min(i+a+1,n)]-=1

    for i in range(1,n):
      ne[i]+=ne[i-1]
    for i in zr:
      ne[i]+=1
    li=ne[:-1]
    #print(li)
  return li

for i in ligh(a):
  print(i,end=" ")
### BUGGY CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = []
    for i in range(n):
        ans.append(a.index(i + 1) + 1)
    print(*ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def main():
    n = int(input())
    a = [int(i) for i in sys.stdin.readline().split()]
    ans = [0] * n
    for i in range(n):
        ans[a[i] - 1] = i + 1
    print(*ans)


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

import sys,random
input = sys.stdin.readline


def main():
    n = int(input())
    
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    if n <= 10000:
        p = 0
        q = 0
        for eA,eB in zip(a,b):
            p = (p+eA)<<30
            q = (q+eB)<<30
        p = p>>30
        q = q>>30


        for k in range(n):
            hyp = b[0]^a[k]
            judge = p^q
            if (judge^((judge>>30)<<30)) == hyp and (judge^((judge>>60)<<60))>>30 == hyp:
                print(k,hyp)
            q = (q>>30) + (b[n-1-k]<<(30*(n-1)))
    else:
        for k in range(n):
            hyp = b[0]^a[k]
            judge = True
            for _ in [0]*15:
                w = random.randrange(n)
                if b[w] != a[(w+k)%n]^hyp:
                    judge = False
                    break
            if judge:
                print(k,hyp)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

#Z[i]:length of the longest list starting from S[i] which is also a prefix of S
def Z_algorithm(s):
    N = len(s)
    Z_alg = [0]*N

    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_alg[k]<j:
            Z_alg[i+k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg


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


BAA = []
for i in range(n-1):
    BAA.append(b[i]^b[i+1])
BAA.append(b[0]^b[-1])

BAA.append(-1)

for i in range(n-1):
    BAA.append(a[i]^a[i+1])
BAA.append(a[0]^a[-1])
for i in range(n-1):
    BAA.append(a[i]^a[i+1])
BAA.append(a[0]^a[-1])

z = Z_algorithm(BAA)

for k in range(n):
    if z[n+k+1] >= n:
        print(k,b[0]^a[k])
### BUGGY CODE ###

# 日立コン
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, readline().split())

Alist = list(map(int, readline().split()))
Blist = list(map(int, readline().split()))

answer = 10 ** 7
for a in Alist:
    for b in Blist:
        tmp = a + b
        if tmp < answer:
            answer = tmp

for _ in range(0, M):
    x, y, c = map(int, readline().split())
    tmp = Alist[x-1] + Blist[y-1] - c
    if tmp < answer:
        answer = tmp
if answer > 0:
    print(answer)
else:
    print(0)

### FIXED CODE ###

# 日立コン
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

A, B, M = map(int, readline().split())

Alist = list(map(int, readline().split()))
Blist = list(map(int, readline().split()))

min_a = min(Alist)
min_b = min(Blist)
answer = min_a + min_b

for _ in range(0, M):
    x, y, c = map(int, readline().split())
    tmp = Alist[x-1] + Blist[y-1] - c
    answer = min(answer, tmp)

if answer > 0:
    print(answer)
else:
    print(0)
### BUGGY CODE ###


def main():
    t = input()
    if t == "1":
        print(1)
        exit(0)
    li = [int(v) for v in input().split(' ')]
    s_li = sorted(li)
    count = 0
    for v in s_li:
        v_1 = s_li.count(v - 1)
        v_0 = s_li.count(v) + s_li.count(v + 1)
        v_2 = s_li.count(v + 2)
        t_c = v_1 + v_0
        t_c2 = v_2 + v_0

        if t_c > count:
            count = t_c
        if t_c2 > count:
            count = t_c2
        if count > len(s_li):
            break
        s_li = s_li[s_li.index(v):]
    print(count)


if __name__ == '__main__':
    main()



### FIXED CODE ###

n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v+1] += 1
    cnt[v+2] += 1
    
print(max(cnt))
### BUGGY CODE ###

n=input()
a=[int(i) for i in input().split()]
r=1
for i in a:
    r*=i
if 10**18 < r:
    print(-1)
else:
    print(r)


### FIXED CODE ###

n=input()
a=[int(i) for i in input().split()]
t=10**18
r=1
if 0 in a:
    print(0)
else:
    for i in a:
        r*=i
        if t < r:
            print(-1)
            break
    else:
        print(r)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
def rec(i, m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = rec(i + 1, m)
    if m - A[i] >= 0:
        res |= rec(i + 1, m - A[i])
    return res
for m in M:
    if rec(0, m):
        print('yes')
    else:
        print('no')


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
bits = 1
for a in A:
    bits |= bits << a
for m in M:
    print('yes' if (bits >> m) & 1 else 'no')
### BUGGY CODE ###

k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=s*10+7
if(s%k!=0):
    print("-1")
    


### FIXED CODE ###

k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=(s%k)*10+7
if(s%k!=0):
    print("-1")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

lenmax = lambda x, y: x if len(x) > len(y) else y
dp = {("","") : ""}

def lcs(x,y):
    if (x,y) in dp:
        return dp[(x,y)]

    if x == "" or y == "":
        a = ""
    elif x[-1] == y[-1]:
        a = lcs(x[:-1],y[:-1]) + x[-1]
    else:
        a = lenmax(lcs(x[:-1],y), lcs(x,y[:-1]))
    dp[(x,y)] = a
    return a

print(lcs(input(),input()))

### FIXED CODE ###

S,T = input(),input()
x,y = len(S),len(T)

dp = [[0]*(y+1) for _ in range(x+1)]

for i,s in enumerate(S):
  for j,t in enumerate(T):
    dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j], dp[i][j] + int(s==t))
    
a = ""
while x > 0 and y > 0:
  if dp[x][y] == dp[x-1][y]:
    x -= 1
  elif dp[x][y] == dp[x][y-1]:
    y -= 1
  else:
    x -= 1
    y -= 1
    a += S[x]

print(a[::-1])
### BUGGY CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

k,s = na()
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - (x+y)
        if x+y+z == s and z >= 0 and z <= k:
            ans += 1
print(ans)


### FIXED CODE ###

import sys

stdin = sys.stdin
na = lambda: list(map(int, stdin.readline().split()))

k,s = na()
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - (x+y)
        if z >= 0 and z <= k:
            ans += 1
print(ans)
### BUGGY CODE ###

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

graph = [[] for i in range(N)]
is_root = [True] * N
for i in range(M):
  x, y = map(int, input().split())
  graph[x-1].append(y-1)
  is_root[y-1] = False


depth = [0] * N
d = [i for i in range(N) if is_root[i]]
while d:
  node = d.pop()
  children = graph[node]
  _depth = depth[node] + 1
  for child in children:
    if depth[child] < _depth:
      depth[child] = _depth
      d.append(child)

print(max(depth))


### FIXED CODE ###

from collections import deque

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

graph = [[] for i in range(N)]
to_this = [0] * N
for i in range(M):
  x, y = map(int, input().split())
  graph[x-1].append(y-1)
  to_this[y-1] += 1


depth = [0] * N
d = deque([i for i in range(N) if not to_this[i]])
while d:
  l = len(d)
  for i in range(l):
    node = d.popleft()
    children = graph[node]
    for child in children:
      to_this[child] -= 1
      if not to_this[child]:
        d.append(child)
        depth[child] = depth[node] + 1

print(max(depth))