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

r, c, k = map(int, input().split())
grid = [[0] * c for _ in range(r)]
dp = [[[0] * 4 for _ in range(c+1)] for _ in range(r+1)]

for _ in range(k):
    y, x, v = map(int, input().split())
    grid[y-1][x-1] = v

for y in range(1, r+1):
    for x in range(1, c+1):
        v = grid[y-1][x-1]
        prev_y_max = max(dp[y-1][x][:])
        dp[y][x][0] = max(prev_y_max, dp[y][x-1][0])
        if v != 0:
            dp[y][x][1] = max(prev_y_max + v, dp[y][x-1][0] + v, dp[y][x-1][1])
            dp[y][x][2] = max(dp[y][x-1][1] + v, dp[y][x-1][2])
            dp[y][x][3] = max(dp[y][x-1][2] + v, dp[y][x-1][3])
        else:
            for i in range(1, 4):
                dp[y][x][i] = dp[y][x-1][i]
print(max(dp[r][c]))


### FIXED CODE ###

r, c, k = map(int, input().split())
dp = [[[0] * (c+1) for _ in range(r+1)] for _ in range(4)]

v_dict = dict()
for _ in range(k):
    y, x, v = map(int, input().split())
    v_dict[(y, x)] = v

for y in range(1, r+1):
    for x in range(1, c+1):
        prev_y_max = 0
        for i in range(4):
            prev_y_max = max(dp[i][y-1][x], prev_y_max)
        dp[0][y][x] = max(prev_y_max, dp[0][y][x-1])
        if (y, x) in v_dict:
            v = v_dict[(y, x)]
            dp[1][y][x] = max(prev_y_max + v, dp[0][y][x-1] + v, dp[1][y][x-1])
            dp[2][y][x] = max(dp[1][y][x-1] + v, dp[2][y][x-1])
            dp[3][y][x] = max(dp[2][y][x-1] + v, dp[3][y][x-1])
        else:
            for i in range(1, 4):
                dp[i][y][x] = dp[i][y][x-1]
ans = 0
for i in range(4):
    ans = max(dp[i][r][c], ans)
print(ans)
### BUGGY CODE ###

N,M,*a=map(int,open(0).read().split())

dp=[0]*(N+1)
dp[0]=1

for n in range(1,N+1):
	
  if n  in a:
    dp[n]=0
    
  else:
    dp[n]=(dp[n-1]+dp[n-2])%1000000007

print(dp[N])
    

### FIXED CODE ###

N,M,*a=map(int,open(0).read().split())

dp=[1]*(N+1)

for i in a:
  	dp[i]=0

for n in range(2,N+1):
    dp[n]=(dp[n-1]+dp[n-2])%1000000007*dp[n]

print(dp[N])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
s=1
for x in l:
    s *= x
    
if s>1000000000000000000:
    print(-1)
else:
    print(s)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)
### BUGGY CODE ###

#c
n = int(input())
a = list(map(int, input().split()))
import itertools
ans = 0
for i in list(itertools.combinations(a,2)):
    ans += i[0]*i[1]
print(ans % (10**9 + 7))

### FIXED CODE ###

#cやり直し
import numpy
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9 +7

before = a[-1]
for i in range(n-1,0,-1):
    
    ans += (a[i-1]*before)%mod
    before += a[i-1]
    
print(ans%mod)
### BUGGY CODE ###


s = input()
res = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        if int(s[i:j])%2019==0:
            res += 1

print(res)

### FIXED CODE ###

s=input()

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

ans=0
for i in range(2019):
    c=counter[i]
    ans+=c*(c-1)/2
print(int(ans))
### BUGGY CODE ###

import itertools

def main():
    N, M, R = map(int, input().split())
    RR = tuple(map(int, input().split()))
    ABC = (tuple(map(int, input().split())) for _ in range(M))

    dist = [[float('inf')] * N for _ in range(N)]
    for a, b, c in ABC:
        dist[a-1][b-1] = dist[b-1][a-1] = c
        dist[a-1][a-1] = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = dist[i][j] if dist[i][j] < dist[i][k] + dist[k][j] else dist[i][k] + dist[k][j]

    ans = float('inf')
    for r in itertools.permutations(RR):
        move = 0
        for i in range(R - 1):
            a = r[i] - 1
            b = r[i+1] - 1
            move += dist[a][b]
        ans = ans if ans < move else move

    print(ans)

main()


### FIXED CODE ###

import itertools

def main():
    N, M, R = map(int, input().split())
    RR = tuple(map(int, input().split()))
    ABC = {tuple(map(int, input().split())) for _ in range(M)}

    dist = [[float('inf')] * (N + 1) for j in range(N + 1)]
    for a, b, c in ABC:
        dist[a][b] = dist[b][a] = c
        dist[a][a] = dist[b][b] = 0
    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    ans = float('inf')
    for r in itertools.permutations(RR):
        move = 0
        for i in range(R - 1):
            a = r[i]
            b = r[i+1]
            move += dist[a][b]
        ans = min(ans, move)

    print(ans)

main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import heapq

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

h = list()
for val in a:
    heapq.heappush(h, val)

for _ in range(m):
    b, c = map(int, input().split())
    for _ in range(b):
        heapq.heappush(h, c)

print(sum(heapq.nlargest(n, h)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import defaultdict
n, m = map(int, input().split())
a = list(map(int, input().split()))

cards = defaultdict(int)
for num in a:
    cards[num] += 1

for _ in range(m):
    b, c = map(int, input().split())
    cards[c] += b

count = n
ans = 0
for key, val in sorted(cards.items(), key=lambda x: -x[0]):
    if count - val < 0:
        ans += key * count
        break
    else:
        ans += key * val
        count -= val
print(ans)
### BUGGY CODE ###

member = int(input())
member_array = sorted(list(map(int,input().split())))
result = 0

for i in range(member):
    for x in range(3):
        if x == 2:
            member_array.pop(0)
        else:
            power = member_array.pop()

    result += power
print(result)

### FIXED CODE ###

member = int(input())
member_array = sorted(list(map(int, input().split())),reverse=True)
result = 0
count = 1

for i in range(member):
    result += member_array[count]
    count += 2

print(result)
### BUGGY CODE ###

n,m = map(int,input().split())
a = [1]*(n+1)
b = [0]*(n+1)
for i in range(m):
  x,y = map(int,input().split())
  u = x
  while a[u]==0:
    u = b[u]
  v = y
  while a[v]==0:
    v = b[v]
  if u!=v:
    b[v] = u
    a[u] += a[v]
    a[v] = 0
print(max(a))

### FIXED CODE ###

n,m = map(int,input().split())
a = [1]*(n+1)
b = [0]*(n+1)
for i in range(m):
  x,y = map(int,input().split())
  u = x
  while a[u]==0:
    u = b[u]
  v = y
  while a[v]==0:
    v = b[v]
  if u!=v:
    b[v] = u
    b[y] = u
    b[x] = u
    a[u] += a[v]
    a[v] = 0
print(max(a))
### BUGGY CODE ###

from bisect import bisect,bisect_left
N = int(input())
A = list(map(lambda x:(29-len(bin(int(x))[2:]))*'0'+bin(int(x))[2:],input().split()))
B = list(map(lambda x:(29-len(bin(int(x))[2:]))*'0'+bin(int(x))[2:],input().split()))

a_d = {}
for k in range(29):
    a_d[k] = sorted(list(map(lambda x:int(x[-k-1:],2),A)))

ans_d = {}
for k in range(29):
    ans_d[k] = 0

for b in B:
    for k in range(29):
        b_k = int(b[-k-1:],2)
        ans_d[k] += bisect(a_d[k],2**(k+1)-1-b_k)-bisect_left(a_d[k],2**k-b_k)
        ans_d[k] += N-bisect_left(a_d[k],3*2**k-b_k)
        ans_d[k] %= 2

ans = 0
for k in range(29):
    ans += 2**k*ans_d[k]

print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans_arr = np.zeros(29,int)
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans_arr[k] += np.sum(np.searchsorted(a,2**(k+1)-1-b,side='right')-np.searchsorted(a,2**k-b))
    ans_arr[k] += np.sum(N-np.searchsorted(a,3*2**k-b))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

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

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
import heapq
q=a[:n]
rq=[-a[i] for i in range(2*n,3*n)[::-1]]
d=[sum(q)]
rd=[sum(rq)]

heapq.heapify(q)
heapq.heapify(rq)

for i in range(n,2*n):
 heapq.heappush(q, a[i])
 heapq.heappop(q)
 d.append(sum(q))
for i in range(n,2*n)[::-1]:
 heapq.heappush(rq, -a[i])
 heapq.heappop(rq)
 rd.append(sum(rq))
c=-float("inf")
for i in range(len(d)):
  c=max(c,d[i]+rd[len(rd)-1-i])
print(c)

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
import heapq
q=a[:n]
rq=[-a[i] for i in range(2*n,3*n)[::-1]]
dd=sum(q)
rdd=sum(rq)
d=[dd]
rd=[rdd]

heapq.heapify(q)
heapq.heapify(rq)

for i in range(n,2*n):
 heapq.heappush(q, a[i])
 x=heapq.heappop(q)
 dd=dd+a[i]-x
 d.append(dd)
for i in range(n,2*n)[::-1]:
 heapq.heappush(rq, -a[i])
 x=heapq.heappop(rq)
 rdd=rdd-a[i]-x
 rd.append(rdd)
c=-float("inf")
for i in range(len(d)):
  c=max(c,d[i]+rd[len(rd)-1-i])
print(c)
### BUGGY CODE ###

def Q3(x):
    N = x[0][0]
    lst = x[1][:]
    absolute = float('inf')
    allsum = sum(lst)
    for k in range(1, N):
        sunuke = sum(lst[:k])
        a = abs(allsum - sunuke * 2)
        if a < absolute:
            absolute = a
    return absolute

l = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
n = [l,m]
print(Q3(n))

### FIXED CODE ###

def Q3(x):
    N = x[0][0]
    lst = x[1][:]
    s = lst[0]
    allsum = sum(lst)
    minimum = abs(allsum - s * 2)
    
    for k in range(1, N - 1):
        s += lst[k]
        a = abs(allsum - s * 2)
        minimum = min(minimum, a)
    return minimum

l = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
n = [l,m]
print(Q3(n))
### BUGGY CODE ###

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

from math import hypot,acos,atan2,cos,sin
def circles_cross_points(x1,y1,r1,x2,y2,r2):
    d = hypot(x1-x2, y1-y2)
    if r1 + r2 < d or abs(r1 - r2) >= d: return []
    x = (r1**2 + d**2 - r2**2) / (2*r1*d)
    if not -1 <= x <= 1: return []
    a = acos(x)
    t = atan2(y2-y1, x2-x1)
    return [
        (x1+cos(t+a)*r1, y1+sin(t+a)*r1),
        (x1+cos(t-a)*r1, y1+sin(t-a)*r1)
    ]

eps = 10e-10
def is_ok(t):
    cands = []
    for x,y,_ in XYC:
        cands.append((x,y))
    for i,(x1,y1,c1) in enumerate(XYC[:-1]):
        for x2,y2,c2 in XYC[i+1:]:
            ps = circles_cross_points(x1,y1,t/c1,x2,y2,t/c2)
            cands += ps
    for cx,cy in cands:
        k = 0
        for x,y,c in XYC:
            d = hypot(cx-x,cy-y)
            if c*d <= t + eps:
                k += 1
                if k >= K:
                    return True
    return False

ok = 10**10
ng = 0
for _ in range(80):
    m = (ok+ng)/2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

### FIXED CODE ###

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

from math import hypot,acos,atan2,cos,sin
def circles_cross_points(x1,y1,r1,x2,y2,r2):
    d = hypot(x1-x2, y1-y2)
    if r1 + r2 < d or abs(r1 - r2) >= d: return []
    x = (r1**2 + d**2 - r2**2) / (2*r1*d)
    if not -1 <= x <= 1: return []
    a = acos(x)
    t = atan2(y2-y1, x2-x1)
    return [
        (x1+cos(t+a)*r1, y1+sin(t+a)*r1),
        (x1+cos(t-a)*r1, y1+sin(t-a)*r1)
    ]

eps = 10e-10
def is_ok(t):
    cands = []
    for x,y,_ in XYC:
        cands.append((x,y))
    for i,(x1,y1,c1) in enumerate(XYC[:-1]):
        for x2,y2,c2 in XYC[i+1:]:
            ps = circles_cross_points(x1,y1,t/c1,x2,y2,t/c2)
            cands += ps
    for cx,cy in cands:
        k = 0
        for x,y,c in XYC:
            d = hypot(cx-x,cy-y)
            if c*d <= t + eps:
                k += 1
                if k >= K:
                    return True
    return False

ok = 10**10
ng = 0
for _ in range(100):
    m = (ok+ng)/2
    if is_ok(m):
        ok = m
    else:
        ng = m
    if ok-ng < 10e-7: break
print(ok)
### BUGGY CODE ###

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

def solve():
    m = 1
    a,b = [],[]
    while m*m <= N:
        a.append(m)
        b.append(N//m)
        m += 1
    if a[-1] == b[-1]:
        b.pop()
    a += b[::-1]
    w = [b-a for a,b in zip([0]+a, a)]
    
    L = len(a)
    dp = [1]*L
    for _ in range(K-1):
        dp2 = [0]*L
        c = 0
        for i,v in enumerate(w):
            c += dp[i] * v
            dp2[L-1-i] += c
            dp2[L-1-i] %= MOD
        dp = dp2
    return sum(a*b for a,b in zip(w,dp)) % MOD
print(solve())

### FIXED CODE ###

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

m = 1
a,b = [],[]
while m*m <= N:
    a.append(m)
    b.append(N//m)
    m += 1
if a[-1] == b[-1]:
    b.pop()
a += b[::-1]
w = [b-a for a,b in zip([0]+a, a)]

L = len(a)
dp = [1]*L
for _ in range(K-1):
    dp2 = [0]*L
    c = 0
    for i,v in enumerate(w):
        c += dp[i] * v
        dp2[L-1-i] += c
        dp2[L-1-i] %= MOD
    dp = dp2
ans = sum(a*b for a,b in zip(w,dp))
print(ans%MOD)
### BUGGY CODE ###

def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1

a = int(input())
while True:
    a += 1
    if isPrime(a): print(a)

### FIXED CODE ###

def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1
    return True

a = int(input())
while True:
    if isPrime(a):
        print(a)
        break
    a += 1
### BUGGY CODE ###



N = int(input())
jobs = []
for i in range(N):
    jobs.append(list(map(int, input().split())))
           
time = 0
result = "Yes"
jobs.sort(key=lambda x:x[1])

while jobs:
    job = jobs.pop(0)
    time += job[0]
    if(time > job[1]):
        result = "No"


print(result)

    


### FIXED CODE ###



N = int(input())
jobs = []
for i in range(N):
    jobs.append(list(map(int, input().split())))
           
time = 0
result = "Yes"
jobs.sort(key=lambda x:x[1])

for job in jobs:
    time += job[0]
    if(time > job[1]):
        result = "No"
        break

print(result)
### BUGGY CODE ###

import math

h,n=map(int,input().split())
arr=[]
brr=[]
for i in range(n):
	a,b=map(int,input().split())
	arr.append(a)
	brr.append(b)
dp=[1000000000000000]*(h+1)
dp[0]=0
for i in range(1,h+1):
	for j in range(n):
		if ((i-arr[j])>=0):
			dp[i]=min(dp[i],dp[i-arr[j]]+brr[j])
		else:
			dp[i]=min(dp[i],brr[j])
print(dp[h])

### FIXED CODE ###

import math

h,n=map(int,input().split())
arr=[]
brr=[]
for i in range(n):
	a,b=map(int,input().split())
	arr.append(a)
	brr.append(b)
dp=[1000000000000000]*(h+1)
dp[0]=0
for i in range(1,h+1):
	for j in range(n):
		if ((i-arr[j])>=0):
			dp[i]=min(dp[i],dp[i-arr[j]]+brr[j])
		else:
			dp[i]=min(dp[i],brr[j])
print(dp[h])
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(E[i:i+K]))
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
tmp = sum(E[0:K])
ans = tmp
for i in range(1, N-K+1):
    tmp = tmp - E[i-1] + E[i+K-1]
    ans = max(ans, tmp)
print(ans)
### BUGGY CODE ###

import sys
import numpy as np

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

N, K = lr()
A = lr()
A_np = np.array(A)
product = []
for i in range(N-1):
    l = A[i] * A_np[i+1:]
    product.extend(l)

product.sort()
print(product[K-1])


### FIXED CODE ###

import sys
import numpy as np

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

N, K = lr()
A = np.array(lr())
A.sort()
pos = A[A>0]
zero = A[A==0]
neg = A[A<0]

def check(x):
    # x以下の数がK個以上ある時、Trueを返す
    count = 0 #最後に２で割る
    if x >= 0:
        count += len(zero) * N
    count += (np.searchsorted(A, x//pos, side='right')).sum()
    count += (N - np.searchsorted(A, (-x-1)//(-neg), side='right')).sum()
    count -= np.count_nonzero(A * A <= x) #ペアなので自分自身は駄目
    assert count % 2 == 0
    count //= 2
    return count >= K

left = - 10 ** 19 # NG
right = 10 ** 19 # OK
while right > left + 1:
    mid = (left+right) // 2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)
# 46
### BUGGY CODE ###

import collections
x = int(input())
dd = collections.defaultdict(int)
for i in range(-100,100,1):
    dd[i**5]=i
for i in range(x):
    if(dd[i**5-x]!=0):
        print(i, dd[(i**5-x)])
        exit()


### FIXED CODE ###

x = int(input())
a = [0]*1000
for i in range(1000):
    tmp = i**5
    a[i] = tmp
for i in range(1000):
    for j in range(1000):
        if((a[i]-x) == (a[j])):
            print(i,j)
            exit()
        elif(x-a[i]==a[j]):
            print(i,-j)
            exit()
### BUGGY CODE ###

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

import collections

for k in range(n):
    b = a[:k]
    c = a[k+1:]
    d = b + c
    e = collections.Counter(d)
    count = 0
    for i in e.keys():
        m = e[i]
        count += m*(m-1)//2
    print(count)

### FIXED CODE ###

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

import collections

e = collections.Counter(a)

count = 0
for i in e.keys():
    m = e[i]
    count += m*(m-1)//2

for k in range(n):
    b = a[k]
    c = e[b] - 1
    ans = count - c
    print(ans)
### BUGGY CODE ###

a=int(input())
i=100//a
f=0
while i<1:
  i=i+i//100
  f=f+1
print(f)


### FIXED CODE ###

a=int(input())
i=100
f=0
while i<a:
  i=i+i//100
  f=f+1
print(f)
### BUGGY CODE ###

import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from heapq import heapify, heappush, heappop

def main():
    n, m = MII()
    a_lst = MII()
    heapify(a_lst)
    for i in range(m):
        b, c = MII()
        for i in range(b):
            minv = a_lst[0]
            if minv < c: heappop(a_lst); heappush(a_lst, c)
            else: break
    print(sum(a_lst))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from heapq import heapify, heappush, heappop

def main():
    n, m = MII()
    a_lst = MII()
    a_lst.sort()
    bc = []
    for i in range(m):
        b, c= MII()
        bc.append((b,c))
    bc.sort(key=lambda x: x[1], reverse=True)
    index = 0
    cnt = 0
    for i in range(n):
        if a_lst[i] > bc[index][1]: break
        a_lst[i] = bc[index][1]
        cnt += 1
        if cnt == bc[index][0]:
            cnt = 0
            index += 1
            if index == m:
                break
    print(sum(a_lst))

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

def calc_sub(arg, start):
  global n,k
  sub = 0
  for i in range(n):
    if i != 0:
      idx = start + i
      if idx < n:
        sub += arg[idx] - arg[idx-1]
      else:
        idx = idx - n
        if idx == 0:
          sub += arg[0] + (k - arg[n-1])
        else:
          sub += arg[idx] - arg[idx-1]
        
  return sub

def calc_sub_r(arg, start):
  global n,k
  sub = 0
  for i in reversed(range(0, n)):
    idx = start + i
    idx = idx - n if idx >= n else idx
    if idx == n-1:
      sub += (k - arg[idx]) + arg[0]
    else:
      sub += arg[idx+1] - arg[idx]
  return sub


k, n = map(int, input().split())
a = input().split()
l_si_i = [int(s) for s in a]
#print(l_si_i)

#aaa = calc_sub(l_si_i, 2)
#bbb = calc_sub_r(l_si_i, 2)
#print(aaa)
#print(bbb)


min = 10000000
for i in range(n):
  ret = calc_sub(l_si_i,i)
  if min > ret:
    min = ret
    
  ret = calc_sub_r(l_si_i, i)
  if min > ret:
    min = ret
    
  l_si_i.append(l_si_i.pop(0))

print(min)


### FIXED CODE ###

k, n = map(int, input().split())
a = input().split()
l_si_i = [int(s) for s in a]
#print(l_si_i)

num_list = []
for i in range(n):
  if i == 0:
    sub = l_si_i[0] + (k - l_si_i[n-1])
  else:
    sub = l_si_i[i] - l_si_i[i-1]
  
  num_list.append(sub)
  
#print(num_list)
#print(sum(num_list))

idx = num_list.index(max(num_list))
#print(idx)
num_list.pop(idx)
print(sum(num_list))
### BUGGY CODE ###

N = int(input())
A = []

for i in range(0, N):
    tmp = int(input())
    A.append(tmp)

for i in range(0, N):
    tmp = A.pop(i)
    print(max(A))
    A.insert(i, tmp)

### FIXED CODE ###

import numpy
N = int(input())
A = []

for i in range(0, N):
    tmp = int(input())
    A.append(tmp)

MAX = max(A)
MAX_i = numpy.argmax(A)
tmp = A.pop(MAX_i)
MAXsecond = max(A)
A.insert(MAX_i, tmp)

for i in range(0, N):
    if A[i] == MAX:
        print(MAXsecond)
    else:
        print(MAX)
### BUGGY CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                ans+=1
print(ans)



### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            ans+=1
print(ans)
### BUGGY CODE ###

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

A = [0]
B = [0]
for i in range(len(a)):
    A.append(A[i]+a[i])
for i in range(len(b)):
    B.append(B[i]+b[i])

cnt = 0
for i, a_ in enumerate(A):
    m = k-a_
    j = len(B)-1
    t = 0
    if m < 0:
        break
    while m < B[j]:
        j-=1
    t = i+j
    cnt = max(cnt, t)
print(cnt)

### FIXED CODE ###

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

A = [0]
B = [0]
for i in range(n):
    A.append(A[i]+a[i])
for i in range(m):
    B.append(B[i]+b[i])

cnt, j = 0, m#ここをfor文に入れなくていい。
for i, a_ in enumerate(A):
    d = k-a_
    t = 0
    if d < 0:
        break
    while d < B[j]:
        j-=1
    t = i+j
    cnt = max(cnt, t)
print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()

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

dp = [[[] for _ in range(m + 1)] for _ in range(n + 1)]

for i in range(1, n + 1):
    s_ = s[i - 1]
    for j in range(1, m + 1):
        t_ = t[j - 1]
        if s_ != t_:
            if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = dp[i][j - 1]
        else:
            dp[i][j] = dp[i - 1][j - 1] + [s_]

print("".join(dp[-1][-1]))

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

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

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()