jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int S = sc.nextInt();
			
			int[] DP = new int[S + 1];
			int[] nextDP = new int[S + 1];
			DP[0] = 1;
			
			final long MOD = 1000000007;
			
			long answer = 0;
			for(int times = 0; times < S; times++) {
				Arrays.fill(nextDP, 0);

				boolean updated = false;
				for(int pos = 0; pos <= S; pos++) {
					if(DP[pos] == 0) { continue; }
					if(DP[pos] > 0) { updated = true; }
					
					for(int i = 3; i + pos <= S; i++) {	
						nextDP[pos + i] += DP[pos];
						nextDP[pos + i] %= MOD;
					}
				}
				
				if(!updated) { break; }
				
				answer += nextDP[S];
				answer %= MOD;
				
				{
					int[] tmp = DP;
					DP = nextDP;
					nextDP = tmp;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}
//  [java]
import java.util.*;

public class Main {
    static int MAX = 10010017;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        COMinit();
        
        int n = sc.nextInt();
        
        if (n < 3) {
            System.out.println(0);
            return;
        }
        
        int possible = n / 3;
        
        long ans = 0;
        for (int i = 1; i <= possible; i++) {
            int m = n - 3 * i;
        //     k+n-1Ck
        //  - = k個のボールとn-1個の仕切り
        //  m個のボールとi-1この仕切
            long tmp = nCkMOD(m+(i)-1, m);
            // System.out.println(i + " " + tmp + " " + (m+i-1) + " " + m);
            ans += tmp;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    // nCk = n! / (k! * (n-k)!)
    public static long nCkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
    // 順列計算
    // nPk = n! / (n-k)!
    public static long nPkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return (fac[n] * finv[n - k]) % MOD;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}
//  [java]
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int s = sc.nextInt();

        int cnt = s / 3;
        int remain = s % 3;
        int mod = (int)1e9 + 7;

        Comb comb = new Comb(s, mod);

        long res = 0;

        while (0 < cnt) {
            int div = cnt - 1;
            long tmp = comb.nCk2(div+remain, remain);
            res += tmp;
            res %= mod;
            cnt--;
            remain += 3;
        }

        System.out.print(res % mod);

    }


    public class Comb {
        int n;   //　要素数
        int MOD = (int)1e9+7;
        long[] facts;

        public Comb(int n, int MOD){
            this.n = n;
            this.MOD = MOD;
            facts = new long[n+1];
            facts[0] = 1;
            for (int i=1; i<n+1; i++){
                facts[i] = facts[i-1] * i % MOD;
            }
        }

        // O(log(MOD))
        public long modpow(long a, long b){
            if (b==0) return 1;
            else if (b==1) return a;
            long x = modpow(a, b/2);
            return b%2 == 0 ? x * x % MOD : x * (x*a%MOD) % MOD;
        }

        // 逆元。x^(-1)≡x^(p-2) (MOD p) xとpは互いに素。
        public long inv(long n){
            return modpow(n, MOD-2);
        }

        public long nCk1(int n, int k){
            return n < k ? 0: facts[n] * (inv(facts[n-k]) * inv(facts[k]) % MOD) % MOD;
        }

        // O(k)
        public long nCk2(int n, int k) {
            long ret = 1;
            for (int i=0; i<k; i++) {
                ret = ret * (n - i) % MOD * inv(k - i);
                ret %= MOD;
            }
            return ret % MOD;
        }

    }


}
//  [cpp]
#include<bits/stdc++.h>

using namespace std;

const int mod=1e9+7;
long long dp[700][2002];

long long DP(int cur,long long sum)
{
    if(sum == 0)return dp[cur][0]=1;
    if(sum < 3)return dp[cur][sum]=0;
    long long &ans=dp[cur][sum];
    if(ans > -1)return ans;
    ans=0;
    for(int i=3;i<=sum;i++)ans=(ans+DP(cur+1,sum-i))%mod;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    memset(dp,-1,sizeof(dp));
    cin >> n;
    cout << DP(1,n);
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[2005][2005];
int solve(int i,int sum){
  if(sum==0)return 1;
  if(dp[i][sum]!=-1)return dp[i][sum];
  int ans=0;
  rep(j,3,sum+1){
      ans+=solve(i+1,sum-j);
      ans%=mod;
  }
  dp[i][sum]=ans;
  return ans;
}
int32_t main(){
    clr(dp,-1);
    int n; cin>>n;
    cout<<solve(0,n);
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/
//  [cpp]
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 1;
const int MOD = 1000000007;

int mem[2000][666];

int sum(int a, int b){
    return (a%MOD + b%MOD)%MOD;
}

int f(int x, int y){
    if (mem[x][y] != -1) return mem[x][y];
    if (y == 1) return mem[x][y] = 1;
    if (x == 0) return mem[x][y] = 1;
    int ret = 0;
    for (int i = 0; i <= x; i++) ret = sum(ret, f(x-i, y-1));
    return mem[x][y] = ret;
}

int s;
int sol;

int main(){

    memset(mem, -1, sizeof mem);

    cin >> s;
    for (int i = 1; i <= s/3; i++){
        sol = sum(sol, f(s-(i*3), i));
    }

    cout << sol;

    return 0;

}
//  [c]
#include<stdio.h>
#define mod 1000000007
long long ans=0;
long long s[3000][2000]={0};

int main(){
	int n;int i,j;
	scanf("%d",&n);
    for (i=3;i<=n;i++){
     s[i][1]=1;
     for (j=2;j<=i/3;j++)
     	for (int k=i-3;k>=0;k--){
     		s[i][j]=(s[i][j]+s[k][j-1])% mod;
     		if (s[k][j-1]==0) break;
		 }
		 }	 
	long long ans=0;	 
    for (i=1;i<=n/3;i++){
    	ans=(ans+s[n][i])%mod;
	}
	printf("%lld",ans);
}
//  [c]
#include<stdio.h>
#define mod 1000000007
long long ans=0;
long long a[1005];
long long s[3000][2000]={0};

int main(){
	int n;int i,j;
	a[0]=1;
	for (int i=1;i<=1000;i++)
	  a[i]=a[i-1]*i%mod;
	scanf("%d",&n);
    for (i=3;i<=n;i++){
     s[i][1]=1;
     for (j=2;j<=i/3;j++)
     	for (int k=i-3;k>=0;k--){
     		s[i][j]=(s[i][j]+s[k][j-1])% mod;
     		if (s[k][j-1]==0) break;
		 }
		 }	 
	long long ans=0;	 
    for (i=1;i<=n/3;i++){
    	long long temp=(s[n][i])%mod;
    	ans=(ans+temp)%mod;
	}
	printf("%lld",ans);
}
//  [c]
#include <stdio.h>

int main() {
	const int m = 667, n = 2001, mod = 1e9 + 7;
	long long int s, t[m][n],ans[n];
	scanf("%lld", &s);
	for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) t[i][j] = 0;
	for (int j = 0; j < n; j++) ans[j] = 0;

	//i==1
	for (int j = 3; j < n; j++)t[1][j] = 1;

	for (int i = 2; i < m; i++) for (int j = 3 * i; j < n; j++) {
		int I = i - 1;
		for (int J = 3 * I; J <= j - 3; J++) {
			t[i][j] += t[I][J];
			t[i][j] = t[i][j] % mod;
		}
	}

	/*for (int i = 0; i < m; i++) {
		printf("\n%d\n",i); 
		for (int j = 0; j < n; j++)printf(" %d %d\n",j, t[i][j]); 
	}*/

	for (int j = 0; j < n; j++) {
		for (int i = 0; i < m; i++) {
			ans[j] += t[i][j];
			ans[j] = ans[j] % mod;
		}

	}
	printf("%lld\n",ans[s]);
	
	return 0;
}
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
let S = lines[0].trim() - 0

const mod = 1000000007
const map = Array(S).fill().map(_ => Array(S).fill(1))

for (let i = 1; i < S; i++) {
    for (let j = 1; j < S; j++) {
        map[i][j] = (map[i - 1][j] + map[i][j - 1]) % mod
    }
}

let sum = 0
const l = Math.floor(S / 3)
for (let i = 0; i < l; i++) {
    sum += map[i][S - (i + 1) * 3]
}

console.log(sum % mod)
//  [javascript]
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var S = nextInt();
  var dp = new Array(2001).fill(0);
  var mod = 1000000007;
  for(var i = 3; i <= S; i++){
    dp[i]++;
    for(var j = 3; j <= i - 3; j++){
      dp[i] += dp[j];
      dp[i] %= mod;
    }
  }
  myout(dp[S]);
}
//  [go]
package main

import "fmt"

const M = 1000000007

func main() {
	var s int
	fmt.Scan(&s)
	fmt.Println(solve(s))
}

func solve(s int) int64 {
	dp0 := make([]int64, s+1)

	for i := 3; i <= s; i++ {
		dp0[i] = 1
	}

	for min := 3; min < s; min += 3 {
		dp1 := make([]int64, s+1)
		dp1[s] = dp0[s]

		for i := min; i <= s-3; i++ {
			for j := 3; i+j <= s; j++ {
				dp1[i+j] = (dp1[i+j] + dp0[i]) % M
			}
		}
		dp0 = dp1
	}

	return dp0[s]
}
//  [ruby]
def factorial(n)
  i = 1
  k = 1
  while i < n
    k *= i+1
    i += 1
  end
  k
end

s = gets.to_i
max = s/3#数列が取り得る最大の長さ
i = 1
ans = 0

while i <= max#数列の長さ毎に考える。
  n = s - (i * 3)#この値をiに分配する場合の数
  ans +=  factorial(n + i -1) / (factorial(n) * factorial(i-1))
  i += 1
end
ans %= 10**9 + 7
puts ans
//  [ruby]
class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*) / k.factorial
  end

  def factorial
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end

s = gets.to_i
sum = 0
(1..s/3).each do |e|
  sum += (e+(s-e*3)-1).combination(s-e*3)
  sum = sum % 1000000007
end

p sum
//  [ruby]
s = gets.to_i

if s < 3
  puts 0
else
  size = s / 3
  answer = 1
  (2..size).each do |n|
    rest = s - (3 * n)
    if rest.zero?
      answer += 1
    else
      a = n + rest - 1
      b = rest
      answer += (a - b + 1..a).inject(1, :*) / (1..b).inject(1, :*)
    end
  end

  puts answer % (10 ** 9 + 7)
end
//  [rust]
use proconio::input;

#[proconio::fastout]
fn main() {
    input! {
        n: usize
    }

    let m: i64 = 1000000007;
    let mut dp: Vec<i64> = vec![0; n + 1];
    dp[0] = 1;

    for k in 0..n {
        let mut dp2 = vec![0; n + 1];
        dp2[n] = dp[n];
        for i in (3 * k)..(n + 1) {
            for j in (3..(n + 1 - i)).rev() {
                dp2[j + i] += dp[i];
                dp2[j + i] %= m;
            }
        }
        dp = dp2;
    }

    println!("{}", dp[n]);
}
//  [swift]
let s = Int(readLine()!)!
let mod = 1000000007

var dp = Array(repeating: 0, count: s+1)
if s >= 3 {
    dp[0] = 1
    for i in 3..<s+1 {
        dp[i] = dp[i-1] + dp[i-3]
        dp[i] %= mod
    }
}
print(dp[s])
//  [python]
n = int(input())
grid = [list(map(int, input().split())), list(map(int, input().split()))]
dist = [[0 for _ in range(n)] for _ in range(2)]
dist[0][0] = grid[0][0]
for i in range(2):
  for j in range(n):
    if j < n - 1:
      dist[i][j + 1] = max(dist[i][j + 1], dist[i][j] + grid[i][j + 1])
    if i == 0:
      dist[1][j] = max(dist[1][j], dist[0][j] + grid[1][j])
print(dist[-1][-1])
//  [python]
N = int(input())
a_list = []
a_list.append(list(map(int,input().split(" "))))
a_list.append(list(map(int,input().split(" "))))

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

for i in range(2):
    for j in range(1,N+1):
        if i == 0:
            dp[i][j] = dp[i][j-1] + a_list[i][j-1]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]) + a_list[i][j-1]
print(dp[1][N])
//  [python]
n=int(input())
a=[]
for i in range(2):
  a.append(list(map(int,input().split())))
ans=0
for i in range(n):
  tmp=0
  tmp+=sum(a[0][0:i+1])
  tmp+=sum(a[1][i:])
  ans=max(ans,tmp)
print(ans)
//  [python]
import numpy as np

N=int(input())

a=[[],[]]
a[0]=list(map(int,input().split()))
a[1]=list(map(int,input().split()))

s=np.array(a)

s[1]=np.cumsum(s[1][::-1])[::-1]

s[0][-1]+=s[1][-1]

for i in range(N-2,-1,-1):
    s[0][i]+=max(s[1][i],s[0][i+1])
print(s[0][0])
//  [python]
import numpy as np
n = int(input())
u = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
ma = 0
for i in range(n):
    ma = max(np.sum(u[:i+1]) + np.sum(b[i:]), ma)
print(ma)
//  [python]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = A1[0] + sum(A2)
cur = ans
for i in range(N-1):
    cur -= A2[i]
    cur += A1[i+1]
    ans = max(ans, cur)
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S = null;
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	int N = 0;
//	int K = 0;
//	char[] c = null;
	int[] A = null;
	int ans = 0;
	
	public void input() throws IOException {
		N = in.nextInt();
		A = in.nextInt(new int[2*N]);
	}
	
	private int idx(int i, int j) {
		return i*N + j;
	}
	
	public void solve() throws IOException {
		int[] A1 = new int[N];
		int[] A2 = new int[N];
		A1[0] = A[idx(0,0)];
		A2[N-1] = A[idx(1,N-1)];
		for (int j=1; j<N; j++) {
			A1[j] += A1[j-1] + A[idx(0,j)];
			A2[N-j-1] += A2[N-j] + A[idx(1,N-j-1)];
		}
		ans = -1;
		for (int j=0; j<N; j++) {
			ans = Math.max(ans, A1[j]+A2[j]);
		}
	}
	
	public void output() {
		out.println(ans);
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] a1 = IntStream.range(0,N).map(i->scan.nextInt()).toArray();
        int[] a2 = IntStream.range(0,N).map(i->scan.nextInt()).toArray();
        int ans = 0;
        for(   int i=0;i<N;++i){
            int res=0;
            for(int j=0;j<=i;j++){
                res+=a1[j];
            }
            for(int j=i;j<N;++j){
                res+=a2[j];
            }
            ans = Math.max(res,ans);
        }
        System.out.println(ans);

    }
}
//  [java]
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{

	private void solve(){
		int n=gInt();
		int[][]f=new int[3][n+1];
		for(int i:rep(1,2))
			for(int j:rep(1,n))
				f[i][j]=gInt();
		for(int i:rep(1,2))
			for(int j:rep(1,n))
				f[i][j]+=Math.max(f[i-1][j],f[i][j-1]);
		System.out.println(f[2][n]);
	}


	public static void main(String[]$){
		new Main().solve();
	}

	static Scanner s=new Scanner(System.in);


	static int gInt(){
		return s.nextInt();
	}
	static long gLong(){
		return s.nextLong();
	}
	static long gDouble(){
		return s.nextLong();
	}


	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

	static class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{

		int to,cur,d;

		Range(int from,int to,int d){
			this.cur=from-d;
			this.to=to;
			this.d=d;
		}

		Range(int n){
			this(0,n-1,1);
		}

		@Override
		public Iterator<Integer> iterator(){
			return this;
		}

		@Override
		public boolean hasNext(){
			return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
		}

		@Override
		public int nextInt(){
			return cur+=d;
		}
	}


	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}

	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}


	static IntStream ints(int n){
		return REPS(n).map(i->gInt());
	}

	static Stream<String> strs(int n){
		return REPS(n).mapToObj(i->s.next());
	}

}
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.IntStream;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            final List<Integer> firstRow = Arrays.stream(args.get(1).split(" ")).map(Integer::valueOf).collect(toList());
            final List<Integer> secondRow = Arrays.stream(args.get(2).split(" ")).map(Integer::valueOf).collect(toList());
            final Integer ans = IntStream.range(0, firstRow.size())
                    .map(index ->
                            firstRow.subList(0, index + 1).stream().mapToInt(Integer::intValue).sum()
                                    + secondRow.subList(index, secondRow.size()).stream().mapToInt(Integer::intValue).sum())
                    .max()
                    .orElse(-1);
            System.out.println(ans);
        };
    }

}
//  [cpp]
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
inline void Fail(){printf("0");exit(0);}
inline void debug(int x){cerr<<"debug: "<<x<<"\n";}
inline void debug(int n,int x[]){cerr<<"debug "<<"\n";rep(i,n)cerr<<x[i]<<" ";cerr<<"\n";}
inline void debug(string x){cerr<<"debug: "<<x<<"\n";}

const int maxn=105;
int n;
int a[2][maxn];
int dp[2][maxn];

int main(){
	scanf("%d",&n);
	REP(i,2)REP(j,n)scanf("%d",&a[i][j]);
	REP(i,2)REP(j,n)dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
	printf("%d",dp[2][n]);
	return 0;
}

/*
Input:
-----------------
Output:
*/
//  [cpp]
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")
#pragma GCC optimize("unroll-loops")
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
int A[2][105],pre[2][105];
int main()
{
    // std::ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
	int n,i,maxi=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>A[0][i];
		pre[0][i]=pre[0][i-1]+A[0][i];
	}
	for(i=1;i<=n;i++){
		cin>>A[1][i];
		pre[1][i]=pre[1][i-1]+A[1][i];
	}
	for(i=1;i<=n;i++)
		maxi=max(maxi,pre[0][i]+pre[1][n]-pre[1][i-1]);
	cout<<maxi;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

int n,a[2][100];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", a[0] + i);
    for (int i = 0; i < n; i++)
        scanf("%d", a[1] + i);

    for (int i = 1; i < n; i++) {
        a[0][i] += a[0][i-1];
        a[1][n-i-1] += a[1][n-i];
    }
    int m = -1;
    for (int i = 0; i < n; i++)
        m = max(m, a[0][i] + a[1][i]);
    printf("%d\n", m);

    return 0;
}
//  [cpp]
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("NO");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e6+10;
	//------------------FIXED------------------
	int a[N],b[N];
	void main()
	{
		int n=qread();fo(i,1,n) a[i]=a[i-1]+qread();fo(i,1,n) b[i]=b[i-1]+qread();
		int mx=0;fo(i,1,n) chmax(mx,a[i]+b[n]-b[i-1]);write(mx);
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}
//  [cpp]
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <functional>
#include <map>
#include <cmath>
using namespace std;

int H, a[3][100000], dp[3][100000];

int main() {
	cin >> H;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < H; j++) cin >> a[i][j];
	}
	dp[0][0] = a[0][0];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < H; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
		}
	}
	cout << dp[1][H - 1] << endl;
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a[LIMIT2][2];
  char s[LIMIT1];
  ll dp[LIMIT1][2];
  
  scanf("%lld",&n);
  rep(j,2){
    rep(i,n) scanf("%lld",&a[i][j]);
  }
  per(j,2){
    per(i,n){
      if(j==1&&i==n-1){
        dp[i][j] = 0;
      }else if(j==1){
        dp[i][j] = dp[i+1][j];
      }else if(i==n-1){
        dp[i][j] = dp[i][j+1];
      }else{
        dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
      }
      dp[i][j] += a[i][j];
    }
  }
  printf("%lld",dp[0][0]);
  return 0;
}
//  [c]
/*
 * FileName:     C
 * CreatedDate:  2020-04-05 14:08:04 +0900
 * LastModified: 2020-04-05 14:35:31 +0900
 */

#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int A[2][N],dp[2][N];
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            scanf("%d",&A[i][j]);
        }
    }
    dp[0][0]=A[0][0];
    dp[1][0]=dp[0][0]+A[1][0];
    for(int i=1;i<N;i++){
        dp[0][i]=dp[0][i-1]+A[0][i];
//        printf("%d ",dp[0][i]);
    }
//    printf("\n%d \n",dp[1][0]);
    for(int i=1;i<N;i++){
        if(dp[0][i]<dp[1][i-1]){
            dp[1][i]=dp[1][i-1]+A[1][i];
        }
        else{
            dp[1][i]=dp[0][i]+A[1][i];
        }
    }
    printf("%d\n",dp[1][N-1]);
    return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    int n,i,j,sum=0,max=0;

    scanf("%d",&n);
    int ara[2*n],ara2[n];


    for(i=0; i<2*n; i++)
    {
        scanf("%d",&ara[i]);
    }

  /*  for(i=0; i<2*n; i++)
    {
        printf("%d",ara[i]);
    }
*/

for(i=0; i<n; i++)
  {
      sum=0;

      for(j=0; j<2*n;)
      {
          if(j==i)
          {sum+=ara[j];
              j=j+n;}
          else
          {
              sum+=ara[j];
              j++;
          }

      }
      ara2[i]=sum;
  }

  for(i=0; i<n; i++)
  {
      if(ara2[i]>=max)max=ara2[i];
  }

      printf("%d",max);

}
//  [c]
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);

  int a[2][n];
  for(int i = 0;i < 2;i ++){
    for(int j = 0;j < n;j ++){
      scanf("%d",&a[i][j]);
    }
  }

  int ans = 0 , max = 0;
  for(int i = 0;i < n;i ++){
    int t = 0;
    for(int j = 0;j < n;j ++){
      ans += a[t][j];
      if(i == j){
        t ++;
       ans +=  a[t][j];
      }
    }
    if(max < ans){
      max = ans;
    }
    ans = 0;
  }


  printf("%d\n",max);

  return 0;
}
//  [c]
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	int a[2][102];
	for (i = 0; i < 2; i++)
		for (j = 0; j < n; j++)
			scanf("%d", &a[i][j]);
	int ans = 0, x;
	for (i = 0; i < n; i++)
	{
		x = 0;
		for (j = 0; j <= i; j++)
			x += a[0][j];
		for (j = i; j < n; j++)
			x += a[1][j];
		if (ans < x)
			ans = x;
	}
	printf("%d\n", ans);
	return 0;
}
//  [javascript]
function Main(input) {
input = input.split("\n");
    var a1 = input[1].split(' ').map(e => { return parseInt(e) })
    var a2 = input[2].split(' ').map(e => { return parseInt(e) })
    var j = a1.length - 1
    var m = 0, n = a1.length - 2
    var r = 0;
    var temp;

    for (var i = j; i >= m; i--) {
        temp = sum(a1.slice(m, i+1)) + sum(a2.slice(i))
        if (r < temp) r = temp
    }

    function sum(arr) {
        var r = 0
        for (var i = 0; i < arr.length; i++) {
            r += arr[i]
        }
        return r
    }

    console.log(r)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.m(2);
  var d = a[1].reduce((a,b)=>a+b);
  var u = a[0][0];
  var ans = u + d;
  for(var i = 1; i < n; i++){
    u += a[0][i];
    d -= a[1][i-1];
    if(u + d > ans)ans = u + d;
  }
  return ans;
}
//  [go]
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var u []int = NextIntArray()
  var l []int = NextIntArray()
  var m,t,su,sl int
  m,su,sl = 0,0,0
  for i:=0;i<n;i++ { sl += l[i] }
  for i:=0;i<n;i++ {
    su += u[i]
    t = su + sl
    if m < t { m = t }
    sl -= l[i]
  }
  fmt.Println(m)
}
//  [go]
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	a1 := nextIntArray(N)
	a2 := nextIntArray(N)

	res := 0
	for i := 0; i < N; i++ {
		cur := 0
		for j := 0; j <= i; j++ {
			cur += a1[j]
		}
		for j := i; j < N; j++ {
			cur += a2[j]
		}
		res = max(res, cur)
	}
	fmt.Println(res)
}

func dfs(u int, edges [][]Edge, vis []bool, pos []int) bool {
	// fmt.Println(u, edges, vis, pos)
	vis[u] = true

	res := true
	for _, e := range edges[u] {
		if !vis[e.to] {
			pos[e.to] = pos[u] + e.d
			res = res && dfs(e.to, edges, vis, pos)
		} else {
			if pos[u] + e.d != pos[e.to] {
				res = false
			}
		}
	}
	return res
}

type Edge struct {
	to int
	d int
}

// -------- Library --------
func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func abs(x int) int {
	if x > 0 {
		return x
	} else {
		return -x
	}
}

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println("Failed to read int", err)
		os.Exit(1)
	}
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := make([][]int, 2)
	A[0] = sc.NextIntArray()
	A[1] = sc.NextIntArray()

	dp := make([][]int, 2)
	for i := 0; i < 2; i++ {
		dp[i] = make([]int, N)
	}
	dp[0][0] = A[0][0]
	for i := 1; i < N; i++ {
		dp[0][i] = dp[0][i-1] + A[0][i]
	}
	dp[1][0] = dp[0][0] + A[1][0]
	for i := 1; i < N; i++ {
		dp[1][i] = max(dp[0][i], dp[1][i-1]) + A[1][i]
	}

	fmt.Println(dp[1][N-1])
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc = NewScanner(os.Stdin, 1000000)

var A1 []int
var A2 []int
var N int
var max int

func main() {
	max = 0
	N = sc.readInt()
	A1 = []int{}
	A2 = []int{}
	for i := 0; i < N; i++ {
		A1 = append(A1, sc.readInt())
	}
	for i := 0; i < N; i++ {
		A2 = append(A2, sc.readInt())
	}
	for i := 0; i < N; i++ {
		tmp := try(i)
		if max < tmp {
			max = tmp
		}
	}
	fmt.Println(max)
}

func try(n int) int {
	res := 0
	for i := 0; i <= n; i++ {
		res += A1[i]
	}
	for i := n; i < N; i++ {
		res += A2[i]
	}
	return res
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}
//  [go]
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)

	a := make([][]int, 3)
	for i := 0; i <= 2; i++ {
		a[i] = make([]int, n+5)
	}

	for i := 1; i <= 2; i++ {
		for j := 1; j <= n; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	dp := make([][]int, 3)
	for i := 0; i <= 2; i++ {
		dp[i] = make([]int, n+5)
	}

	for i := 1; i <= 2; i++ {
		for j := 1; j <= n; j++ {
			if i == 1 {
				dp[i][j] = dp[i][j-1] + a[i][j]
				continue
			}
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + a[i][j]
		}
	}

	fmt.Println(dp[2][n])
}
//  [go]
package main

import (
	"fmt"
	"io"
	"os"
)

func parse(r io.Reader) [2][]int {
	var N int
	fmt.Fscan(r, &N)
	var a [2][]int

	for i := 0; i < 2; i++ {
		a[i] = make([]int, N)
		for j := 0; j < N; j++ {
			fmt.Fscan(r, &a[i][j])
		}
	}

	return a
}

func calc(a [2][]int) int {
	N := len(a[0])
	max := 0
	for i := 0; i < N; i++ {
		sum := 0
		for j := 0; j < i+1; j++ {
			sum += a[0][j]
		}
		for j := i; j < N; j++ {
			sum += a[1][j]
		}
		if max < sum {
			max = sum
		}
	}
	return max
}

func main() {
	fmt.Println(calc(parse(os.Stdin)))
}
//  [ruby]
N=gets.to_i
a1=gets.split.map(&:to_i)
a2=gets.split.map(&:to_i)

i = 1
s1 = a1[0]
s2 = a1[0]+a2[0]
while i < N
    s1 += a1[i]
    s2 = [s1,s2].max + a2[i]
    i += 1
end

puts s2
//  [ruby]
n = gets.to_i

a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

(1...n).each do |i|
  a[i] = a[i] + a[i - 1]
end

(1...n).reverse_each do |i|
  b[i - 1] = b[i] + b[i - 1]
end

puts a.zip(b).map{|c| c.inject(:+)}.max
//  [ruby]
n=gets.to_i
a=gets.split.map &:to_i
b=(gets.split.map &:to_i).reverse
c=[a[0]];d=[b[0]]
for k in 1...n
c<<c[-1]+a[k]
d<<d[-1]+b[k]
end
m=0
for k in 0...n
s=c[k]+d[n-k-1]
m=s if m<s
end
p m
//  [ruby]
eval"N,*A="+`dd`.split*?,;a,b=[A.pop(N),A].map{|a|[s=0]+a.map{|n|s+=n}};p N.times.map{|i|a[N]-a[i]+b[i+1]}.max
//  [ruby]
n = gets.to_i
a = []
a[0] = gets.split.map(&:to_i)
a[1] = gets.split.map(&:to_i)
for i in 1...n do
  a[0][i] += a[0][i - 1]
end
a[1][0] += a[0][0]
for i in 1...n do
  a[1][i] += [a[0][i], a[1][i - 1]].max
end
puts a[1][n - 1]
//  [ruby]
*a,n=`tac`.split;p (0...n=n.to_i).map{|i|eval a[i,n+1]*?+}.max
//  [rust]
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      a: [[usize; n]; 2]
   }
   let mut u = vec![0; n];
   u[0] = a[0][0];
   for i in 1..n {
      u[i] = u[i - 1] + a[0][i];
   }
   let mut d = vec![0; n];
   d[n - 1] = a[1][n - 1];
   for i in 1..n {
      d[n - i - 1] = d[n - i] + a[1][n - i - 1];
   }
   let mut ans = 0;
   for i in 0..n {
      ans = std::cmp::max(ans, u[i] + d[i]);
   }
   println!("{}", ans);
}
//  [rust]
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read()[0];
    let a: Vec<usize> = read();
    let b: Vec<usize> = read();

    let mut ans = a[0] + b.iter().sum::<usize>();
    let mut candies = ans;
    for i in 1..n {
        candies = candies + a[i] - b[i - 1];
        ans = std::cmp::max(ans, candies);
    }
    println!("{}", ans);
}
//  [rust]
use std::cmp::max;

// ref. https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [[usize;n];2]
    }

    let mut dp: Vec<Vec<usize>> = vec![vec![0;n+1];3];
    for i in 0..2{
        for n_ in 0..n{
            dp[i][n_+1] = max(dp[i][n_], dp[i][n_]+v[i][n_]);
            if i > 0{
                dp[i][n_+1] = max(dp[i][n_+1], dp[0][n_+1]+v[i][n_] )
            }
        };
    };
    println!("{}", dp[1][n]);
}
//  [rust]
use proconio::input;

// ordtools {{{
mod ordtools {
    pub trait Ordtools: PartialOrd + Clone + Sized {
        fn change_min(&mut self, rhs: &Self) {
            if rhs < self {
                *self = rhs.clone();
            }
        }

        fn change_max(&mut self, rhs: &Self) {
            if rhs > self {
                *self = rhs.clone();
            }
        }
    }

    impl<T: PartialOrd + Clone + Sized> Ordtools for T {}
}
// }}}

use ordtools::Ordtools;

fn main() {
    input!(n: usize, a: [u32; n], b: [u32; n]);
    let mut sum = a[0] + b.iter().sum::<u32>();
    let mut ans = sum;
    for i in 0..n - 1 {
        sum += a[i + 1];
        sum -= b[i];
        ans.change_max(&sum);
    }
    println!("{}", ans);
}