Harryxun/stf_run huggingface dataset:
s, t = input(), input()
ls, lt = map(len,[s,t])

cls_list = [ [ 0 for j in range(lt+1) ] for i in range(ls+1) ]

    

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            cls_list[i+1][j+1] = max(cls_list[i+1][j], cls_list[i][j+1], cls_list[i][j] + 1)
        else:
            cls_list[i+1][j+1] = max(cls_list[i+1][j], cls_list[i][j+1])


ans = []
k = ls - cls_list[-1][-1]

for i in range(lt):
    if cls_list[k][i] != cls_list[k+1][i+1]:
        k += 1
        ans.append(t[i])


print("".join(ans))

### FIXED CODE ###

s = input()
t = input()
ls, lt = len(s), len(t)

dp_list = [ [ 0 for i in range(ls+1) ] for j in range(lt+1) ]
index_list = [ [ None for i in range(ls) ] for j in range(lt) ]

for i in range(lt):
    for j in range(ls):
        if t[i] == s[j]:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            c = dp_list[i][j] + 1 
            p = [a,b,c].index(max(a,b,c))
            dp_list[i+1][j+1] = [a,b,c][p]
            index_list[i][j] = (1,p)

        else:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            p = [a,b].index(max(a,b))
            dp_list[i+1][j+1] = [a,b][p]
            index_list[i][j] = (0,p)

q = dp_list[-1][-1]
r = t   

a = 10**5

ans = ""
y, x = lt-1, ls-1
while y != -1 and x != -1:
    if index_list[y][x][1] == 2:
        x -= 1
        y -= 1
        ans += s[x+1]
    elif index_list[y][x][1] == 1:
        y -= 1
    elif index_list[y][x][1] == 0:
        x -= 1

print(ans[::-1])
string,string2=map(str,input().split())
string2=string2[0:len(string2)-1]
print("Yes" if string==string2 else "No")

### FIXED CODE ###

string,string2=input(),input()
string2=string2[0:len(string2)-1]
print("Yes" if string==string2 else "No")
import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)+np.array([1,0]*(N/2))==0):
        flag = True
    else:print(0)

if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)

### FIXED CODE ###

import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
    if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
else:
    if np.all(L-np.arange(N)-np.array([1,0]*(N//2))==0):
        flag = True
    else:
        print(0)
if flag:
    a=1
    for i in range(N//2):
        a = (a*2)%(10**9+7)
    print(a)
n = int(input())
lists = list(map(int, input().split()))

lists.sorted()
print(lists[-1] - lists[0])

### FIXED CODE ###

import numpy as np

n = int(input())
lists = list(map(int, input().split()))

arr = np.array(lists)
maximum = arr.max()
minimum = arr.min()
print(maximum - minimum)
# ABC 067 D
import sys
sys.setrecursionlimit(100000)

N = int(input())
G = [[] for k in range(N+1)]
for k in range(N-1):
    a, b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

kyori1 = [100000 for k in range(N+1)]
kyori2 = [100000 for k in range(N+1)]

def dfs1(now, dist):
    for tsugi in G[now]:
        if kyori1[tsugi] == 100000:
            kyori1[tsugi] = dist + 1
            dfs1(tsugi, dist+1)

def dfs2(now, dist):
    for tsugi in G[now]:
        if kyori2[tsugi] == 100000:
            kyori2[tsugi] = dist + 1
            dfs2(tsugi, dist+1)

kyori1[1] = 0
dfs1(1,0)

kyori2[N] = 0
dfs2(N,0)

s = 0
f = 0
for k in range(1,N+1):
    if kyori1[k] <= kyori2[k]:
        f += 1
    else:
        s += 1

print("Fennec" if f > s else "Snuke")


### FIXED CODE ###

# ABC 067 D
import sys
sys.setrecursionlimit(200000)

N = int(input())
G = [[] for k in range(N+1)]
for k in range(N-1):
    a, b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

kyori1 = [100000 for k in range(N+1)]
kyori2 = [100000 for k in range(N+1)]

def dfs1(now, dist):
    for tsugi in G[now]:
        if kyori1[tsugi] == 100000:
            kyori1[tsugi] = dist + 1
            dfs1(tsugi, dist+1)

def dfs2(now, dist):
    for tsugi in G[now]:
        if kyori2[tsugi] == 100000:
            kyori2[tsugi] = dist + 1
            dfs2(tsugi, dist+1)

kyori1[1] = 0
dfs1(1,0)

kyori2[N] = 0
dfs2(N,0)

s = 0
f = 0
for k in range(1,N+1):
    if kyori1[k] <= kyori2[k]:
        f += 1
    else:
        s += 1

print("Fennec" if f > s else "Snuke")
a = input()
b = input()
print a * b

### FIXED CODE ###

str = raw_input()
a = str.split(' ')

n1 = int(a[0])
n2 = int(a[1])

print n1 * n2, (n1 + n2) * 2
n=int(input())
a=list(map(int,input().split()))
a.sort()

b=len(a)
Z=a[-1]
X=0
for i in range(1,N-1):
  if abs((Z/2)-A[X])>abs((Z/2)-A[i]):
    X=i



print(a[-1],a[l])

### FIXED CODE ###

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

b=len(a)
Z=a[-1]
X=0
for i in range(1,n-1):
  if abs((Z/2)-a[X])>abs((Z/2)-a[i]):
    X=i



print(a[-1],a[X])
N, M = map(int, input().split())
L, R = 1, N

import math

def merge_list(list):
    L = list[-1][0]
    R = sorted(data, key=lambda x: x[1])[-1][1]
    return (L, R)

data = []
for i in range(0, M):
    l, r = input().split()
    data.append((int(l), int(r)))
data = sorted(data, key=lambda x: x[0])

print(1)

import numpy as np
def saiki(totyuu):
    D = 2 # ぶんかつすう
    if len(totyuu) < 100:
        return merge_list(list(totyuu))
    else:
        return merge_list(np.array_split(totyuu, D))

data = saiki(data)

print(max(0, data[1]-data[0]+1))

### FIXED CODE ###

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

Ls = []
Rs = []
for i in range(0, M):
    l, r = input().split()
    Ls.append(int(l))
    Rs.append(int(r))

maxL = max(Ls)
minR = min(Rs)
result = max(0, minR-maxL+1)

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

count_list = [[0,0]]*(n*10**9+1)
s = 0
for i in range(n):
  s += a[i]
  if s > 0:
    count_list[s][0] += 1
  elif s < 0:
    count_list[s][1] += 1
  else:
    count_list[s][0] += 1
count = 0
count += count_list[0][0] * (count_list[0][0] + 1) // 2
for i in range(1, len(count_list)):
  count+= count_list[i][0] * count_list[i][1]
print(count)

### FIXED CODE ###

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

count_list = {}
s = 0
for i in range(n):
  s += a[i]
  count_list[s] = count_list.get(s, 0) + 1

count = 0
count += count_list.get(0, 0) * (count_list.get(0, 0)+1)
for i in count_list.keys():
  if i!=0:
    #count+= count_list[i] * count_list.get(-i, 0)
    count += count_list[i] * (count_list[i]-1)
print(count//2)
a, b = map(int, raw_input().split())

if a>b:
????print "a > b"
if a<b:
????print "a < b"
if a==b:????
  print "a == b"

### FIXED CODE ###

a, b = map(int, raw_input().split())

if a>b:
  print "a > b"
if a<b:
  print "a < b"
if a==b:
  print "a == b"
n=int(input)
for i in range(n):
  keep.append(int(input()))

print(len(set(keep)))

### FIXED CODE ###

n=int(input())
keep=[]
for i in range(n):
  keep.append(int(input()))

print(len(set(keep)))
from collections import defaultdict
from bisect import bisect_left

s = input()
t = input()

indices = defaultdict(list)
for i, v in enumerate(s):
    indices[v].append(i)

cnt = 0
cur = -1
mod = len(s)
flag = False
for v in t:
    if v not in indices:
        flag = True
        break

    i = bisect_right(indices[v], cur)
    if i == len(indices[v]):
        j = indices[v][0]
    else:
        j = indices[v][i]

    if cur >= j:
        cnt += 1
    cur = j

if flag:
    print(-1)
else:
    print(cnt * mod + cur + 1)


### FIXED CODE ###

from collections import defaultdict
from bisect import bisect_left

s = input()
t = input()

if set(s) >= set(t):
    d = defaultdict(list)
    for i, x in enumerate(s * 2):
        d[x].append(i)
    
    ans = 0
    cur = 0
    N = len(s)
    for x in t:
        cur_new = d[x][bisect_left(d[x], cur)]
        ans += cur_new - cur + 1
        cur = (cur_new + 1) % N

    print(ans)
else:
    print(-1)
def retry(list_S, ans, start_ii=0):
    for start_i in range(start_ii, len(list_S) - 3):
        for last_i in range(start_i + 3, len(list_S)):
            tmp = ''.join(list_S[start_i:last_i + 1])

            if (int(tmp) % 2019) == 0:
                ans += 1
                retry(list_S, ans, last_i)

    return ans


def resolve():
    S = input()
    list_S = list(S)
    ans = 0

    if len(list_S) <= 3:
        print(ans)
        return

    ans = retry(list_S, ans)

    print(ans)


resolve()

### FIXED CODE ###

from collections import defaultdict


def resolve():
    s = input()

    cnt = defaultdict(int)
    cnt[0] += 1
    tmp = 0
    for i, c in enumerate(s[::-1]):
        c = int(c)
        tmp = (tmp + c * pow(10, i, 2019)) % 2019
        cnt[tmp] += 1

    ans = sum(c * (c - 1) // 2 for c in cnt.values())
    print(ans)


resolve()
N,K=map(int,input().split())
S=[]
b=0

for i in (K):
    d=input()
    A=list(map(int,input().split()))
    for i in A:
        S[i]+=1

for i in (len(S)):
    if S[i]==0:
        b+=1
print(b)

### FIXED CODE ###

N,K=map(int,input().split())
S=[0]*N
b=0

for i in range(K):
    d=input()
    A=list(map(int,input().split()))
    for j in A:
        S[j-1]+=1

for i in range(len(S)):
    if S[i]==0:
        b+=1
print(b)
import os
N= int(input())
S=input().strip()
T=input().strip()
ans=[]
for i in range(N):
    ans.append(S[i])
    ans.append(T[i])

print(''.join(ans))

### FIXED CODE ###

import os
N= int(input())
nyu = input().split()
S=nyu[0].strip()
T=nyu[1].strip()
ans=[]

for i in range(N):
    ans.append(S[i])
    ans.append(T[i])
print(''.join(ans))
import sys
if sys.version_info[0] == 2:
    input = raw_input
sys.setrecursionlimit(2 ** 31 -1)

res = none
g = none

def dfs(jibun_v, p, jibun_c):
    global res
    global g

    res[jibun_v] = jibun_c
    #print(jibun_v, p, jibun_c)

    tonari_nodes = g[jibun_v]
    for tonari_v, w in tonari_nodes:
        #if tonari_v == p: # only no loop
        #if tonari_v == p or res[tonari_v] != -1:
        if res[tonari_v] != -1:
            continue

        else:
            if w % 2 == 0:
                tonari_c = jibun_c
            else:
                tonari_c = 1 - jibun_c

            dfs(tonari_v, jibun_v, tonari_c)
    

def main():
    n= int(input())

    global g
    g = [[] for _ in range(n)]

    for i in range(n-1):
        u, v, w = map(int, input().split(" "))
        u -= 1
        v -= 1
        w = w % 2
        g[u].append([v, w])
        g[v].append([u, w])

    global res
    res = [-1 for _ in range(n)]
    
    jibun_v = 0
    p = -1
    jibun_c = 0
    dfs(jibun_v, p, jibun_c)

    for i in range(n):
        print(res[i])

main()
        

### FIXED CODE ###

import sys
if sys.version_info[0] == 2:
    input = raw_input
sys.setrecursionlimit(2 ** 31 -1)

res = None
G = None

def dfs(jibun_v, p, jibun_c):
    global res
    global G

    res[jibun_v] = jibun_c
    #print(jibun_v, p, jibun_c)

    tonari_nodes = G[jibun_v]
    for tonari_v, w in tonari_nodes:
        #if tonari_v == p: # only no loop
        #if tonari_v == p or res[tonari_v] != -1:
        if res[tonari_v] != -1:
            continue

        else:
            if w % 2 == 0:
                tonari_c = jibun_c
            else:
                tonari_c = 1 - jibun_c

            dfs(tonari_v, jibun_v, tonari_c)
    

def main():
    N= int(input())

    global G
    G = [[] for _ in range(N)]

    for i in range(N-1):
        u, v, w = map(int, input().split(" "))
        u -= 1
        v -= 1
        w = w % 2
        G[u].append([v, w])
        G[v].append([u, w])

    global res
    res = [-1 for _ in range(N)]
    
    jibun_v = 0
    p = -1
    jibun_c = 0
    dfs(jibun_v, p, jibun_c)

    for i in range(N):
        print(res[i])

main()
a

### FIXED CODE ###

r=input()
ans= r**2*3
print ans
a , b = map(int(),input().split())
 
X = 0
Y = 0

for i in b:
  X = 'X' + 'a'
  
for v in a:
  Y = 'Y' + 'b'
  
if 'X' < 'Y':
  print(X)
else:
  print(Y)

### FIXED CODE ###

a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))
roman = "abcdefghijklmnopqrstuvwxyz"
num_to_roman = {}
for i in range(26):
  num_to_roman[i+1] = roman[i]

n = int(input())
ans = []
while(n):
  ans.insert(0, num_to_roman[n%26])
  n = n//26
  
ans_str = ''.join(ans)
print(ans_str)

### FIXED CODE ###

roman = "abcdefghijklmnopqrstuvwxyz"
num_to_roman = {}
for i in range(26):
  num_to_roman[i] = roman[i]

n = int(input())
ans = []
while(n):
  n-=1
  ans.insert(0,num_to_roman[n%26])
  n = n//26
  
ans_str = ''.join(ans)
print(ans_str)
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

R = N - K + 1
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, R + 2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))


# 重複組み合わせ
def nHk(n, k):
    value = 1
    nk = n + k - 1
    k = min(nk - k, k)
    for i in range(k):
        value = (value * nk) % MOD
        nk -= 1
    for x in range(1, k + 1):
        value = (value * pow(x, MOD - 2, MOD)) % MOD
    return value


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


for i in range(1, K + 1):
    if i != K:
        print(nCr(R, i) * nCr(K - 1, i - 1) % MOD)
    if i == K:
        print(nCr(R, i) % MOD)


### FIXED CODE ###

N, K = map(int, input().split())
MOD = 10 ** 9 + 7

R = N - K + 1
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, 2000 + 2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


for i in range(1, K + 1):
    if i != K:
        print(nCr(R, i) * nCr(K - 1, i - 1) % MOD)
    if i == K:
        print(nCr(R, i) % MOD)
a,b,c,d=list(int ,input().split())
if a==b==c or b==c==d:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a=list(input())
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:
  print("Yes")
else:
  print("No")
A, B = int(input())
if (A+B) % 2 == 0:
  print((A+B)//2)
else:
  print('IMPOSSIBLE')

### FIXED CODE ###

A, B = map(int,input().split())
if (A+B) % 2 == 0:
    print((A+B)//2)
else:
    print('IMPOSSIBLE')
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def myinput():
    return map(int,readline().split())

n = int(readline())
a = list(myinput())
mod = 10**9 + 7
ans = 0

m = math.floor(math.log(max(a),2))+1

if max(a)==0:
  print(0)
  exit()

for j in range(m):
    one = 0
    zero = 0
    for i in range(n):
        b = str(bin(a[i]))[2:]
        c = b.zfill(m)
        s = int(c[m-j-1])
        if s==0:
            zero += 1
        else:
            one += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**j) 
    ans %= mod
print(ans%mod)

### FIXED CODE ###

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

def myinput():
    return map(int,readline().split())

n = int(readline())
a = list(myinput())
mod = 10**9 + 7
ans = 0

for j in range(60):
    k = 2**j
    one = 0
    zero = 0
    for i in range(n):
        if (a[i]&k):
            one += 1
        else:
            zero += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**j) 
    ans %= mod   

print(ans%mod)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

maxcost = -float('inf')
for pi in p:    # O(n^2)
    curr, costs = pi, [0]
    while pi != p[curr-1]:
        costs.append(costs[-1]+c[curr-1])
        curr = p[curr-1]
    costs.append(costs[-1]+c[curr-1])
    l = len(costs)-1
    if costs[-1] > 0:
        maxcost = max(maxcost, costs[-1]*(k//l)+max(costs[1:k % l+1]))
    else:
        maxcost = max(maxcost, max(costs[1:min(k, l)+1]))

print(maxcost)


### FIXED CODE ###

import numpy as np
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
 
cycles, check = [], [False]*n
for pi in p:
    if not check[pi-1]:
        curr, cycle = pi, []
        check[pi-1] = True
        while pi != p[curr-1]:
            check[curr-1] = True
            cycle.append(c[curr-1])
            curr = p[curr-1]
        check[curr-1] = True
        cycles.append(cycle + [c[curr-1]])
 
scores = []
for cycle in (np.array(cycle) for cycle in cycles):
    for i in range(cycle.size):
        cum = np.roll(cycle, i).cumsum()
        if cum[-1] > 0 and k > cycle.size:
            scores.append(cum[-1]*(k//cycle.size-1) + np.concatenate([cum, cum[:k % cycle.size]+cum[-1]]).max())
        else:
            scores.append(cum[:min(k, cum.size)].max())
print(max(scores))
x　＝ input
print (x ** 3)

### FIXED CODE ###

x = input()
print(x ** 3)
import os
import statistics

def quick_sort(arr):
 left = []
 right = []
 if len(arr) <= 1:
  return arr
 ref = arr[0]
 ref_count = 0
 for ele in arr:
  if ele < ref:
   left.append(ele)
  elif ele > ref:
   right.append(ele)
  else:
   ref_count += 1
 left = quick_sort(left)
 right = quick_sort(right)
 return left + [ref] * ref_count + right

def binary_search1(list,target):
 result = -1
 left = 0
 right = len(list) - 1
 while left <= right:
  center = (left + right)//2
  if list[center] >= target:
   if list[center-1] < target:
    result = center
    break
   else: right = center - 1
  elif list[center] < target:
   if center==N-1:
    result = N
    break
   else:
    left = center + 1
 if result == -1:
  return 0
 else:
  return str(result)

def binary_search2(list,target):
 result = -1
 left = 0
 right = len(list) - 1
 while left <= right:
  center = (left + right)//2
  if list[center] <= target:
   if list[center+1] > target:
    result = N-center-1
    break
   else:  left = center + 1
  elif list[center] > target:
   if center==0:
    result = N-center
    break
   else:
    right =center - 1
 if result == -1:
  return 0
 else:
  return str(result)

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A=quick_sort(A)
C=quick_sort(C)
K=0
for i in range(N):
 L=int(binary_search1(A,B[i]))
 M=int(binary_search2(C,B[i]))
 K+=L*M
print(K)

### FIXED CODE ###

import bisect
N=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
d=0
for i in B:
 d+=bisect.bisect_right(A,i-0.1)*(N-bisect.bisect_left(C,i+0.1))
print(d)
n,d=map(int,input())
if n%(2*d+i)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)

### FIXED CODE ###

n,d=map(int,input().split())
if n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)
import numpy as np
import sys 
input = sys.stdin.readline

N, W = list(map(int, input().split()))
wvList = [list(map(int, input().split())) for _ in range(N)]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

l = wvlist[0][0]
for wv in wvlist():
	l = lcm(wv[0],l)
  
dp = np.zeros((N,W+1))
for i, wv in enumerate(wvList):
    for j in range(1, W + 1,l):
        if j - wv[0] >= 0:
            dp[i][j] = np.max(dp[i-1][j-wv[0]] + wv[1], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

print(np.max(dp))


### FIXED CODE ###

N, W = list(map(int, input().split()))
wvList = [list(map(int, input().split())) for _ in range(N)]


from collections import defaultdict
dp = defaultdict(int)
dp[0]=0

for wv in wvList:
    w,v = wv
    tp = defaultdict(int,{ i[0]+w : i[1]+v  for i in dp.items() if i[0]+w<=W})
    for i in set(list(dp.keys())+list(tp.keys())):
        dp[i] = max(dp[i],tp[i])

print(max(dp.values()))
H,W,M = map(int,input().split())
l = [[0]*W for _ in range(H)]
tate,yoko = [0]*W,[0]*H
ans = 0
memo = []
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  l[h][w] = 1
  memo.append([h,w])
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if [i,j] in memo:
      pass
    else:
      print(t+y)
      exit()
print(t+y-1)

### FIXED CODE ###

H,W,M = map(int,input().split())
tate,yoko = [0]*W,[0]*H
ans = 0
memo = set([])
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  memo.add((h,w))
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if (i,j) not in memo:
      print(t+y)
      exit()

print(t+y-1)
print(N ** 3)

### FIXED CODE ###

N = int(input())
print(N ** 3)
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
 
In = np.array(list(itertools.product([0,1] , repeat=H)) , dtype = "int")
Out = np.array(list(itertools.product([0,1] , repeat=W)) , dtype = "int")
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
    
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
    
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
    
    if ICO.count(1) == K:
      ans += 1
      
print(ans)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
input()
a = list(map(int, input().split()))
a.sort(reversed=True)
print(sum(a[::2]) - sum(a[1::2]))

### FIXED CODE ###

input()
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[::2]) - sum(a[1::2]))
import math
A = int(input())
B = int(math.sqrt(A))
count = 0
for i in reversed(range(1,B)):
	if count == 0:
    	if A % i == 0:
			print(i+A/i-2)
        	count += 1

### FIXED CODE ###

import math
A = int(input())
B = int(math.sqrt(A))
count = 0
for i in reversed(range(1,B+1)):
	if count == 0:
		if A % i == 0:
			print(int(i+A/i-2))
			count += 1
n = int(input())
h = [list(map(int, input().split()) for _ in range(n)]

dp = np.zeros([n+1, 3])

for i, val in enumerate(h):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1, j] = max(dp[i+1, j], dp[i, j] + val[k])

print(np.max(dp[n, :], axis=1))

### FIXED CODE ###

import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template

def retmax(a, b):
    if a > b:
        return a
    else:
        return b

def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]

    dp = np.zeros([3, n+1])

    for i, a_l in enumerate(a):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[k, i+1] = retmax(dp[k, i+1], dp[j, i] + a_l[k])

    print(int(np.max(dp[:, n], axis=0)))


if __name__ == "__main__":
    main()