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

n, m = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(n)]
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索する過程で親を更新
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

u = UnionFind(n)
for i in range(1,m+1):
    p = 0
    for j in range(n):
        if p == 0 and i in data[j][1:]:
            q = j
            p = 1
        elif i in data[j][1:] and not u.same_check(j,q):
            u.union(j,q)

if u.size(0) == n:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

import sys
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索する過程で親を更新
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

N,M=map(int,input().split())
K=[set() for i in range(M)]
tree=UnionFind(N)
for i in range(N):
    L=[int(i)-1 for i in input().split()]
    for m in L[1:]:
        K[m].add(i)
for i in range(M):
    Ki=list(K[i])
    if len(Ki)==0:
        continue
    for h in range(len(Ki)):
        tree.union(Ki[h],Ki[0])
for i in range(N):
    if not tree.same_check(0,i):
        print('NO')
        sys.exit()
print('YES')
### BUGGY CODE ###

N, M, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())

sum_A = [0, A[0]]
sum_B = [0, B[0]]

for a in A[1:]:
  sum_A.append(sum_A[-1] + a)

for b in B[1:]:
  sum_B.append(sum_B[-1] + b)

ans = 0
for i in range(N+1):
  for j in range(M+1):
    if sum_A[i] + sum_B[j] <= K:
      ans = max(ans, i+j)

print(ans)


### FIXED CODE ###

N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

for i in range(1, N+1):
  A[i] += A[i-1]

for i in range(1, M+1):
  B[i] += B[i-1]


ans = 0
b_count = M
for a_count in range(N+1):
  if A[a_count] > K:
    continue

  while A[a_count] + B[b_count] > K:
    b_count -= 1

  ans = max(ans, a_count + b_count)
print(ans)
### BUGGY CODE ###

import numpy as np

n, m = map(int, input().strip().split())
dp = [float('inf')] * (2**n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().strip().split())
    c = list(map(int, input().strip().split()))
    mask = 0
    for i in c:
        mask += 2**(i - 1)

    for j in range(2**n):
        dp[j | mask] = min(dp[j] + a, dp[j | mask])

print(dp[2**n - 1] if dp[2**n - 1] < float('inf') else -1)

### FIXED CODE ###

n,m = input().split(' ')
n = int(n)
m = int(m)
dp = [float('inf')]*2**n
dp[0] = 0
for i in range(m):
    a,b = input().split(' ')
    a = int(a)
    b = int(b)
    ngo = 0
    for j in input().split(' '):
        ngo += 2**(int(j)-1)
    for j in range(2**n):
        if dp[j|ngo] > dp[j]+a:
            dp[j|ngo] = dp[j]+a
    
if dp[2**n-1] == float('inf'):
    print(-1)
    exit(0)
print(dp[2**n-1])
### BUGGY CODE ###

N, K, Q = map(int, input().split()) 
Alist =  [int(input()) for i in range(Q)] 
ans = 0

# Aiの最終得点は　K+(正解数)-Q
for i in range(1,N+1):
    if K+Alist.count(i)-Q > 0 :
        print('Yes') 
    else :
        print('No')

### FIXED CODE ###

from collections import Counter
 
N, K, Q = list(map(int, input().split()))
Alist = [int(input()) for i in range(Q)] 
cnt = Counter(Alist)
 
for i in range(1, N + 1):
    print('Yes' if Q - cnt[i] < K else 'No')
### BUGGY CODE ###

import collections

def prime_factorize(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a

n = int(input())
ans = 0

for j in range(1,n):
	c = collections.Counter(prime_factorize(j)) 
	cnt = 1
	for i in c.values():
		cnt = cnt * (i+1)
	ans = ans + cnt

print(ans)

### FIXED CODE ###

n = int(input())
 
ans = 0
for i in range(1,n):
  ans += (n-1)//i
print(ans)
### BUGGY CODE ###

N = int(input())
alist = list(map(int, input().split()))
alen = len(alist)

n = 0
i = 1
i2 = 0
all = 0
while True:
    if alist[i2] != i:
        n += 1
        alist.pop(i2)
    else:
        i += 1
        i2 += 1
    all += 1
    if all >= alen: break

if len(alist) == 0:
    print(-1)
else:
    print(n)

### FIXED CODE ###

N = int(input())
alist = list(map(int, input().split()))
blist = []
alen = len(alist)

n = 0
i = 1

for a in alist:
    if a == i:
        i += 1
    else:
        blist.append(a)
        n += 1

if len(blist) == len(alist):
    print(-1)
else:
    print(n)
### BUGGY CODE ###

S = input()
Q = int(input())
for i in range(Q):
    arr = list(input().split())
    if len(arr) == 1:
        S = S[::-1]
    else:
        if arr[1] == '1':
            S = arr[2] + S
        else:
            S = S + arr[2]
print(S)

### FIXED CODE ###

S = input()
Q = int(input())
count = 0
right = ''
left = ''
for i in range(Q):
    arr = list(input().split())
    if len(arr) == 1:
        count += 1
    else:
        if arr[1] == '1':
            if count%2==0:
                left = arr[2] + left
            else:
                right = right + arr[2]
        else:
            if count%2!=0:
                left = arr[2] + left
            else:
                right = right + arr[2]
S = left + S + right
if count%2 == 0:
    print(S)
else:
    print(S[::-1])
### BUGGY CODE ###

import math

def main():
    n = int(input())
    s = input()
    ans = solve(n, s)
    print(ans)


def solve(n, s):
    ans = 0
    for i in range(n - 1):
        tmp = Z(s[i:])
        tmp = tmp[math.ceil(len(tmp) / 2):]
        if len(tmp):
            ans = max(ans, max(tmp))
        #print(tmp)
    return ans

def Z(s):
    l = len(s)
    ans = [l for _ in range(l)]

    i, j = 1, 0
    while i < l:
        while i + j < l and s[j] == s[i + j] :
            j += 1
        ans[i] = j

        if j == 0:
            i += 1
            continue

        k = 1
        while k < j and k + ans[k] < j:
            ans[i + k] = ans[k]
            k += 1
        i += k
        j -= k
    return ans

if __name__ == '__main__':
    main()

### FIXED CODE ###

import math

def main():
    n = int(input())
    s = input()
    ans = solve(n, s)
    print(ans)


def solve(n, s):
    ans = 0
    for i in range(n - 1):
        tmp = Z(s[i:])
        t = [min(tmp[j], j)for j in range(n - i)]
        ans = max(ans, max(t))
        #print(tmp)
    return ans

def Z(s):
    l = len(s)
    ans = [l for _ in range(l)]

    i, j = 1, 0
    while i < l:
        while i + j < l and s[j] == s[i + j] :
            j += 1
        ans[i] = j

        if j == 0:
            i += 1
            continue

        k = 1
        while k < j and k + ans[k] < j:
            ans[i + k] = ans[k]
            k += 1
        i += k
        j -= k
    return ans

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

# AtCoder DP Task D - Knapsack 1
def knapsack(target, W, V): # target=knapsack weight
    P = [[0] * (target + 1) for _ in range(len(V))]
    for vi in range(len(V)):
        row, prev = P[vi], P[vi - 1]
        for w in range(target + 1):
            if vi > 0:
                row[w] = prev[w] # same value without vi-th item
                if w >= W[vi]:
                    new = P[vi - 1][w - W[vi]] + V[vi]
                    if new > P[vi][w]: # most value
                        row[w] = new
            else:
                if w >= W[vi]:
                    row[w] = V[vi]
    return P[len(V) - 1][target]

def knapsack_rec(target, W, V): # target=knapsack weight
#    P = [[-1] * (target + 1) for _ in range(len(V))]
    P = {}

    def rec(w, index):
        if index == 0 and w >= W[index]:
            return V[index]
        elif index > 0:
            if (index, w) in P: # P[index][w] != -1:
                return P[(index,w)]
            r = rec(w, index - 1)
            if w >= W[index]:
                y = rec(w - W[index], index - 1) + V[index]
                r = r if r > y else y
            P[(index,w)] = r
            return r
        return 0

    ret = rec(target, len(V) - 1)
    return ret

assert knapsack_rec(15, [6, 5, 6, 6, 3, 7], [5, 6, 4, 6, 5, 2]) == 17

if __name__ == "__main__":
    n, w = map(int, input().split())
    W, V = [], []
    for _ in range(n):
        weight, value = map(int, input().split())
        W.append(weight)
        V.append(value)
    ans = knapsack_rec(w, W, V)
    print(ans)


### FIXED CODE ###

# AtCoder DP Task D - Knapsack 1
def knapsack(target, W, V): # target=knapsack weight
    P = [[0] * (target + 1) for _ in range(len(V))]
    for vi in range(len(V)):
        row, prev = P[vi], P[vi - 1]
        for w in range(target + 1):
            if vi > 0:
                row[w] = prev[w] # same value without vi-th item
                if w >= W[vi]:
                    new = P[vi - 1][w - W[vi]] + V[vi]
                    if new > P[vi][w]: # most value
                        row[w] = new
            else:
                if w >= W[vi]:
                    row[w] = V[vi]
    return P[len(V) - 1][target]

def knapsack_rec(target, W, V): # target=knapsack weight
    P = [-1] * (target + 1)
    P[target] = 0 # default + max

    for vi in range(len(V)):
        we = W[vi]
        va = V[vi]
        for i in range(we, target + 1):
            if P[i] != -1 and P[i - we] < P[i] + va:
                P[i - we] = P[i] + va

    return max(P)

assert knapsack_rec(15, [6, 5, 6, 6, 3, 7], [5, 6, 4, 6, 5, 2]) == 17

if __name__ == "__main__":
    import sys
    n, w, *r = map(int, sys.stdin.read().split())
    W, V = r[::2], r[1::2]
    ans = knapsack_rec(w, W, V)
    print(ans)
### BUGGY CODE ###

N,K = [int(i) for i in input().split()]
mod = 998244353
LR = []
S = []
dp = [0]*(N+1)
for i in range(K):
  LR.append([int(i) for i in input().split()])
for i in range(N):
  for lr in LR:
    if lr[0] <= i and i <= lr[1]:
      S.append(i)
S = list(set(S))
#print(S)

for i in range(1,N):
  if i in S:
    dp[i] = 1
  T = [S[j] for j in range(len(S)) if S[j] <= i]
  #print(i, T)
  for j in range(len(T)):
    #print(i, T[j], i-T[j])
    dp[i] += 1*dp[i-T[j]]
    dp[i] %= mod

print(dp[-2])

### FIXED CODE ###

N,K = [int(i) for i in input().split()]
mod = 998244353
LR = []
S = []
dp = [0]*(N+1)
dps = [0]*(N+1)
dps[1] = 1
dp[1] = 1
for i in range(K):
  LR.append([int(i) for i in input().split()])

for i in range(1,N+1):
  for l,r in LR:
    l,r = i - r,i - l
    #print(l,r)
    if r < 1:
      continue
    l = max(1,l)
    dp[i] += dps[r] - dps[l-1]
    dp[i] %= mod
    #print(dp[i])
    
  dps[i] = dps[i-1] + dp[i]
  #print(dp, dps)
print(dp[-1])
### BUGGY CODE ###

n = int(input())
cnt = 0

for i in range(1,n):
    for j in range(1, n):
        if i * j < n:
            cnt += 1

print(cnt)

### FIXED CODE ###

n = int(input())
cnt = 0

for i in range(1,n):
    b = n//i
    c = n%i
    if c:
        cnt += b
    else:
        cnt += b-1
    

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

# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

dic = {}
ans = [0 for _ in range(N)]
for i in range(N):
    tmp = N - i
    if tmp in dic:
        if dic[tmp] % 2 != A[tmp-1]:
            dic[tmp] += 1
            ans[tmp - 1] = 1
            divs = divisor(tmp)
            for div in divs:
                if div in dic:
                    dic[div] += 1
                else:
                    dic[div] = 1

    else:
        if A[tmp-1] == 1:
            dic[tmp] = 1
            ans[tmp - 1] = 1
            divs = divisor(tmp)
            for div in divs:
                if div in dic:
                    dic[div] += 1
                else:
                    dic[div] = 1
        else:
            dic[tmp] = 0

print(sum(ans))
ans_list = ""
for i in range(N):
    if ans[i] == 1:
        ans_list += str(i + 1)
        if i != N - 1:
            ans_list += " "

print(ans_list)

### FIXED CODE ###

# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

ans = [0 for _ in range(N)]

ans_num = 0
ans_list = ""
for i in range(N):
    tmp = N - i
    s = 0
    for j in range(tmp, N+1, tmp):
        s += ans[j-1]

    if s % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        ans_num += 1
        ans_list += str(tmp)
        ans_list += " "


print(ans_num)
print(ans_list[:-1])
### BUGGY CODE ###

def solve():

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

    m = max(a) 
   # print("max:" + str(m))

    ans = 0

    for i in range(m+1):
        tmp = 0
        for k in range(N):
            x = a[k] + 1
            y = a[k] - 1
            z = a[k]
            if i == x or i == y or i == z:
                tmp += 1
        if tmp >= ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    solve()

                




### FIXED CODE ###

def solve():
    
    N = int(input())
    a  = list(map(int, input().split()))

    lists = [0] * ((10**5)+2)

    for i in a:
        lists[i] += 1
        lists[i+1] += 1
        lists[i-1] += 1

    print(max(lists))    

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

# import time 

H, W = map(int, input().split())

#t1 = time.time()

status = [10000]*H*W
targets = []
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == "#":
            targets.append((i, j))
            status[i*W+j] = 0

#t2 = time.time()
#c = 0
while True:
    #print("---")
    #for s_i in range(H):
    #    print(status[s_i*W:(s_i+1)*W])
    #print(targets)
    try:
        i, j = targets.pop(0)
    except IndexError:
        break
    
    d = status[i*W+j] + 1
    
    if j != 0 and status[i*W+j-1] > d:
        status[i*W+j-1] = min(status[i*W+j-1], d) # left
        targets.append((i, j-1))

    if j != W-1 and status[i*W+j+1] > d:
        status[i*W+j+1] = min(status[i*W+j+1], d) # right
        targets.append((i, j+1))

    if i != 0 and status[(i-1)*W+j] > d:
        status[(i-1)*W+j] = min(status[(i-1)*W+j], d) # up
        targets.append((i-1, j))

    if i != H-1 and status[(i+1)*W+j] > d:
        status[(i+1)*W+j] = min(status[(i+1)*W+j], d) # down
        targets.append((i+1, j))
    
#   c += 1
#t3 = time.time()

#print("count", c)
print(max(status))
#print(t2 - t1, t3 - t2)

### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())

status = np.full((H, W), H*W, dtype=int)
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == "#":
            status[i,j] = 0

for h in range(1, H):
    status[h, :] = np.minimum(status[h, :], status[h-1, :] + 1)
for h in range(0, H-1)[::-1]:
    status[h, :] = np.minimum(status[h, :], status[h+1, :] + 1)
for w in range(1, W):
    status[:, w] = np.minimum(status[:, w], status[:, w-1] + 1)
for w in range(0, W-1)[::-1]:
    status[:, w] = np.minimum(status[:, w], status[:, w+1] + 1)

print(np.max(status))
### BUGGY CODE ###

import math
A, B, N = map(int, input().split())
ans = []
for x in range(N//10**7, N+1):
    cal = math.floor((A*x)/B) - (int(A) * math.floor(x/B))
    ans.append(cal)
print(max(ans))

### FIXED CODE ###

a, b, n = map(int, input().split())
n = min(n, b-1)
 
print(int((a * n) / b) - a * int(n / b))
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        d[i][j] = abs(a[i][j]-b[i][j])
dp=[[[False for i in range(80*160)] for j in range(w)] for k in range(h)]
dp[0][0][d[0][0]] = True
for i in range(h):
    for j in range(w):
        for dis in range(80*(h+w)):
            if dp[i][j][dis]:
                if i+1<h:
                    dp[i+1][j][dis+d[i+1][j]]=True
                    dp[i+1][j][abs(dis-d[i+1][j])]=True
                if j+1<w:
                    dp[i][j+1][dis+d[i][j+1]]=True
                    dp[i][j+1][abs(dis-d[i][j+1])]=True
for dis in range(80*(h+w)):
    if dp[-1][-1][dis]:
        print(dis)
        break


### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d=[[0 for i in range(w)] for j in range(h)]
maxd=1
for i in range(h):
    for j in range(w):
        d[i][j] = abs(a[i][j]-b[i][j])
        maxd=max(maxd,d[i][j])
dp=[[0 for j in range(w)] for k in range(h)]
c=20000
dp[0][0] |= 1 << c+d[0][0]
for i in range(h):
    for j in range(w):
        if i+1<h:
            dp[i+1][j] |= dp[i][j] << d[i+1][j]
            dp[i+1][j] |= dp[i][j] >> d[i+1][j]
        if j+1<w:
            dp[i][j+1] |= dp[i][j] << d[i][j+1]
            dp[i][j+1] |= dp[i][j] >> d[i][j+1]
m=1000000
cnt = 0
for x in bin(dp[h-1][w-1])[2:][::-1]:
    if x=='1':
        m=min(m,abs(cnt-c))
    cnt+=1
print(m)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = sum(h)*2
dp = [0 for _ in range(N)]

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

print(dp[N-1])


### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0 for _ in range(N)]

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

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

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

c=[i for i in range(a,b+1) if i<=(a+k-1) or i>=(b-k+1) ]

for j in c:
    print(j)

### FIXED CODE ###

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

for i in range(a,min(b,a+k-1)+1):
    print(i)

for j in range(max(b-k+1,a+k),b+1):
    print(j)
### BUGGY CODE ###

def main():
    N, K = [int(i) for i in input().split()]
    h = [int(i)for i in  input().split()]

    d=[1e16]*N
    d[0]=0
    for i in range(1,N):
        from_num=max(0, i-K)
        for j in range(from_num, i):
            d[i]=min([d[i], abs(h[i]-h[j])+d[j]])
            
    print(d[-1])

if __name__=="__main__":
    main()


### FIXED CODE ###

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

d=[1e16]*N
d[0]=0
for i in range(1,N):
    from_num=max(0, i-K)
    for j in range(from_num, i):
        d[i]=min([d[i], abs(h[i]-h[j])+d[j]])

print(d[-1])
### BUGGY CODE ###

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

ans = 1
for i in range(1,N):
    if min(P[:i]) > P[i]:
        ans += 1
print(ans)

### FIXED CODE ###

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

rec = N
ans = 0

for i in range(N):
    if i == 0:
        rec = P[i]
        ans += 1
    else:
        if rec > P[i]:
            ans += 1
        rec = min(rec, P[i])
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
sum = 1
for i in range(n):
    sum *= a[i]

print(sum if sum <= 10 ** 18 else -1)


### FIXED CODE ###

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

N = int(input())
power = 1

for i in range(N):
    power *= (i+1)
print(power % (10**9+7))

### FIXED CODE ###

import math
N = int(input())
power = math.factorial(N)
print(power % (10**9+7))
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    for k in range(K):
        A_temp=[0]*(N+1)
        for i in range(N):
            A_temp[max(0,i-A[i])]+=1
            if i+A[i]+1<=N-1:
                A_temp[i+A[i]+1]-=1
            
        A[0]=A_temp[0]
        for j in range(1,N):
            A_temp[j]+=A_temp[j-1]
            A[j]=A_temp[j]
        for ai in A:
            if ai != N:
                break
        else:
            break
                
    print(' '.join([str(a) for a in A]))
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    for k in range(K):
        A_temp=[0]*(N+1)
        for i in range(N):
            A_temp[max(0,i-A[i])]+=1
            if i+A[i]+1<=N-1:
                A_temp[i+A[i]+1]-=1
            
        A[0]=A_temp[0]
        for j in range(1,N):
            A_temp[j]+=A_temp[j-1]
            A[j]=A_temp[j]
        for ai in A:
            if ai != N:
                break
        else:
            break
                
    print(' '.join([str(a) for a in A]))
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import itertools
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
L = [0 for _ in range(1,N)] + [1]
PL = list(itertools.permutations(L,N))
MAX = 0
for P in PL:
    now = (0,0)
    total = A[0][0]
    for p in P:
        if p == 0:
            now = (now[0],now[1]+1)
        else:
            now = (now[0]+1,now[1])
        total += A[now[0]][now[1]]
    MAX = max(MAX,total)
print(MAX)

### FIXED CODE ###

N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
MAX = 0
for i in range(N):
    MAX = max(MAX,sum(A[0][:i+1])+sum(A[1][i:]))
print(MAX)