akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);

    string S; cin >>S;
    int N = S.size();
    vector<vector<int>> dp(N, vector<int>(2,0));
    dp[0][0] = 1;
    if (N > 1) dp[1][1] = 1;
    if (N > 2) dp[2][1] = 2;

    rep1(i, S.size()) {
        dp[i][0] = S[i]==S[i-1] ? 0 : dp[i-1][0] + 1;
        chmax(dp[i][0], dp[i-1][1] + 1);
        if (i >= 3) {
            dp[i][1] = S.substr(i-3, 2)==S.substr(i-1,2) ? 0 : dp[i-2][1] + 1;
            chmax(dp[i][1], dp[i-2][0] + 1);
        }
    }

    cout << max(dp.back()[0], dp.back()[1]) << endl;
}


Measured memory_bytes: 11412
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }


const V dx = {1, 0, -1, 0};
const V dy = {0, 1, 0, -1};


int main() {
  int n; cin >> n;
  V p(n*n); cin >> p;

  VV vac(n, V(n));
  VV d(n, V(n));
  rep(i, n) rep(j, n) d[i][j] = min({i, n-i-1, j, n-j-1});

  ll ans = 0;

  for (auto e : p) {
    --e;
    int si = e/n;
    int sj = e%n;
    queue<P> que;
    que.emplace(si, sj);
    ans += d[si][sj];
    vac[si][sj] = 1;

    while (!que.empty()) {
      auto [i, j]  = que.front(); que.pop();
      rep(dir, sz(dx)) {
        int ii = i + dx[dir];
        int jj = j + dy[dir];
        if (ii < 0 || ii >= n || jj < 0 || jj >= n) continue;
        int dd = d[i][j] + 1 - vac[i][j];
        if (chmin(d[ii][jj], dd)) {
          que.emplace(ii, jj);
        }
      }
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 6052
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, r;
    cin >> n >> m >> r;

    int D[n][n];
    REP(i, n){
        REP(j, n){
            if(i == j) D[i][j] = 0;
            else D[i][j] = 1e9;
        }
    }

    vector<int> R(r);
    REP(i, r){
        cin >> R[i];
        R[i]--;
    }
    sort(R.begin(), R.end());

    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        D[a][b] = c;
        D[b][a] = c;
    }

    REP(i, n){
        REP(j, n){
            REP(k, n){
                D[j][k] = min(D[j][k], D[j][i] + D[i][k]);
            }
        }
    }

    int mini = 1e9;
    do{
        int s, cost = 0;
        REP(i, r){
            if(i){
                cost += D[s][R[i]];
                s = R[i];
            }else s = R[i];
        }
        mini = min(mini, cost);
    }while(next_permutation(R.begin(), R.end()));

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, x;
  cin >> a >> b;
  x = (a * b) % 2;

  if (x == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
typedef long long ll;
#define MAX 1000001
using namespace std;
int main(){
  int n, a, b;
  while(cin >> n >> a >> b){
    if(n == 0 && a == 0 && b == 0) break;
    bool dp[MAX];
    memset(dp, false, sizeof(dp));
    dp[0] = true;
    
    for(int i = 0 ; i <= n ; i++){
      if(dp[i]){
	if(i+a <= n) dp[i+a] = true;
	if(i+b <= n) dp[i+b] = true;
      }
    }
    
    int cnt = 0;
    
    for(int i = 0 ; i <= n ; i++) if(!dp[i]) cnt++;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  ll n,d,m,ans=0;
  
  cin >> n;
  
  for (d=1;d*(d+2)<=n;d++){
    if (n%d==0) ans+=n/d-1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,m;
  long double ANS=0.0;
  cin >> N >> K;
  m=N;
  vector<int> Cut(N,1);
  for(int i=0;i<N;i++){
    for(int j=i+1;j<K;j*=2){
      Cut[i]*=2;
    }
  }
  for(int i=0;i<N;i++){
    ANS+=1.0/(m*Cut[i]);
  }
  cout << setprecision(20) << ANS << endl;
}

Measured memory_bytes: 640
using System;


namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //???????????´??°???????????????
            int i = 0;

            while(true)
            {
                string XY = Console.ReadLine();
                string[] xy = (XY.Split(' '));
                int x = int.Parse(xy[0]);
                int y = int.Parse(xy[1]);

                if(x == 0 && y == 0)
                {
                    break;
                }
                if(i >3000)
                {
                    break;
                }
                if (x < y)
                {
                    Console.WriteLine(xy[0] + " " + xy[1]);
                }
                else
                {
                    Console.WriteLine(xy[1] + " " + xy[0]);
                }
            i++;
            }



        }
    }
}

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int count=0;
    bool no=true;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        if(a==b){
            count++;
            if(count==3){
                no=false;
            }
        }
        else{
            count=0;
        }
    }
    if(no){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
void pakuri_sort2(int N, ll A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	int saidai[100000] = {};
	int shurui = 0;
	ll sonota[100001];
	int k = 0;
	rep(i, N) {
		int t, d;
		cin >> t >> d;
		t--;
		if (!saidai[t]) {
			shurui++;
			saidai[t] = d;
		}
		else {
			if (saidai[t] < d) {
				swap(saidai[t], d);
			}
			sonota[k++] = d;
		}
	}

	pakuri_sort(100000, saidai);
	pakuri_sort2(k, sonota);

	for (int i = k - 1; i >= 1; i--) {
		sonota[i - 1] += sonota[i];
	}

	ll kari = 0;
	ll kotae = 0;
	for (int i = 1; i <= min(K, shurui); i++) {
		kari += saidai[100000 - i];
		ll kari2 = kari;
		if (K - i > 0 && 0 <= k - K + i) kari2 += sonota[k - K + i];
		kari2 += 1ll * i * i;
		kotae = max(kotae, kari2);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n=sc.nextInt();
		int x = 0;
		for(int i=1;i<=n;i++) {
			 x = i;
			
			if(x % 3 == 0) {
				System.out.print(" " + i);
			}else if(x % 10 == 3) {
				System.out.print(" " + i);
			}else {
				while(x > 0) {
					x /= 10;
					
					if(x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					
				}
			}
		}
		System.out.println();
	}

}


Measured memory_bytes: 28664
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>


using namespace std;

int main() {
	int n;
	vector<map<char, int>> mp;
	vector<string> s;
	cin >> n;
	s.resize(n);
	mp.resize(n);
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < s[i].size(); j++)
			mp[i][s[i][j]]++;
	for (char i = 'a'; i <= 'z'; i++) {
		int minC = mp[0][i];
		for (int j = 1; j < n; j++) {
			if (mp[j][i] < minC) {
				minC = mp[j][i];
				if (mp[j][i] == 0) {
					break;
				}
			}
		}
		for (int j = 0; j < minC; j++)
			cout << i;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;


int main(){
    string s ;
    cin >> s ;
        cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
int main()
{
	long long int a,b,x,c;
	scanf("%lld%lld%lld",&a,&b,&x);
	c=b/x-a/x;
	if(a%x!=0)
	printf("%lld\n",c);
	else printf("%lld\n",c+1);
	return 0;
	}

Measured memory_bytes: 128
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

solve = 0
for i in range(N):
    calc = 0
    for j in range(M):
        calc += A[i][j] * B[j]
    calc += C
    if calc > 0:
        solve += 1
print(solve)

Measured memory_bytes: 3064
N, X, Y = gets.split.map &:to_i

$ans = [0] * (N+1)
# $ans1 = (N + 10).times.map{[]}

$edges = (N+1).times.map{ [] }
$edges[X] << Y
$edges[Y] << X
(1...N).each{|i|
  $edges[i] << i + 1
  $edges[i + 1] << i
}

def f(start)
  visited = [false] * (N + 1)
  q = [start]
  dist = 0
  visited[start] = true
  while !q.empty?
    dist += 1
    new_q = []
    q.each{|from|
      $edges[from].each{|to|
        next if visited[to]
        visited[to] = true
        $ans[dist] += 1 if start < to
        new_q << to
      }
    }
    q = new_q
  end
end

(1...N).each{|i|
  f(i)
}
(1...N).each{|i|
  p $ans[i]
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
int main()
{
    zzz;
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    for(int i=0;i<n-1;++i)
    {
        if(a[i+1]>a[i]) a[i+1]--;
        else if(a[i+1]==a[i]) continue;
        else
        {
            cout<<"No"; return 0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 2e5+5;
int N,dep[MN],cnt,val,S[3],D[3],ans[MN];
vector<int> G[MN];
void dfs(int s, int r)
{
    if(dep[s]%2) ++cnt;
    for(int e:G[s]){
        if(e==r) continue;
        dep[e] = dep[s]+1;
        dfs(e,s);
    }
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> N;
    int u,v;
    for(int i=1; i<=N; i++){
        ++S[i%3];
    }
    D[0] = 3, D[1] = 1, D[2] = 2;
    for(int i=1; i<N; i++){
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,1);
    val = N-cnt;
    if(cnt<=S[0]){
        for(int i=1; i<=N; i++){
            if(dep[i]%2){
                if(S[0]){
                    S[0]--;
                    ans[i] = D[0];
                    D[0]+=3;
                }
            }
            else{
                if(S[2]){
                    S[2]--;
                    ans[i] = D[2];
                    D[2]+=3;
                }
                else if(S[1]){
                    S[1]--;
                    ans[i] = D[1];
                    D[1]+=3;
                }
                else{
                    S[0]--;
                    ans[i] = D[0];
                    D[0]+=3;
                }
            }
        }
    }
    else if(val<=S[0]){
        for(int i=1; i<=N; i++){
            if(dep[i]%2==0){
                if(S[0]){
                    S[0]--;
                    ans[i] = D[0];
                    D[0]+=3;
                }
            }
            else{
                if(S[2]){
                    S[2]--;
                    ans[i] = D[2];
                    D[2]+=3;
                }
                else if(S[1]){
                    S[1]--;
                    ans[i] = D[1];
                    D[1]+=3;
                }
                else{
                    S[0]--;
                    ans[i] = D[0];
                    D[0]+=3;
                }
            }
        }
    }
    else{
        for(int i=1; i<=N; i++){
            if(dep[i]%2){
                if(S[1]){
                    S[1]--;
                    ans[i] = D[1];
                    D[1]+=3;
                }
                else{
                    S[0]--;
                    ans[i] = D[0];
                    D[0]+=3;
                }
            }
            else{
                if(S[2]){
                    S[2]--;
                    ans[i] = D[2];
                    D[2]+=3;
                }
                else{
                    S[0]--;
                    ans[i] = D[0];
                    D[0]+=3;
                }
            }
        }
    }
    for(int i=1; i<=N; i++) cout << ans[i] << ' ';
}


Measured memory_bytes: 19328
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	x := ""
	for n > 0 {
		a := (n - 1) / 26
		b := (n - 1) % 26
		x = fmt.Sprintf("%c%s", b+'a', x)
		n = a
	}
	con.Println(x)
	return nil
}


Measured memory_bytes: 1848
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+3;
int f[N];
int32_t main()
{
	int n;
	cin>>n;
	int a[n];int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		f[a[i]]++;
		sum+=a[i];
	}
	
	int q;
	cin>>q;
	int u,v,sub,add;
	while(q--)
	{
		cin>>u>>v;
		sub=f[u]*u;
		add=f[u]*v;
		sum+=(add-sub);
		f[v]+=f[u];
		f[u]=0;
		cout<<sum<<'\n';
	}
	
	
}

Measured memory_bytes: 5124
N,M = map(int,input().split())

path = [[] for _ in range(N)]
pin = [0]*N
for _ in range(M):
  ip,op = map(int,input().split())
  pin[op-1]+=1
  path[ip-1].append(op-1)

cur = []
for i in range(N):
  if pin[i]==0:
    cur.append(i)

ans = 0
while cur:
  ans += 1
  nxt = []
  for ip in cur:
    for op in path[ip]:
      pin[op] -= 1
      if pin[op]==0 and not(op in nxt):
        nxt.append(op)
  cur = [x for x in nxt]
print(ans-1)


Measured memory_bytes: 58912
#include<bits/stdc++.h>

using namespace std;

int main()
{
  	int n;
  	cin >> n;
  	vector<int> a(n);
 	for(auto &x: a) cin >> x;
  	sort(a.rbegin(), a.rend());
  	long long sum1 = 0, sum2 = 0;
  	for(int i = 0; i < n; i ++) (i % 2 == 0 ? sum1 : sum2) += a[i];
  	cout << sum1 - sum2 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 505;
int n,m,a,b;
int f(int x, int y){
	x=(x-1)%a+1;y=(y-1)%b+1;
	if(x==1&&y==1)return 1e9-1;
	if(x==a&&y==b)return -1e9;return 0;
}
int main() {
	read(n);read(m);read(a);read(b);
	if(n%a==0&&m%b==0){puts("No");return 0;}
	puts("Yes");rep(i,1,n){rep(j,1,m)printf("%d ",f(i,j));puts("");}
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int mx = v[0];
    int ans = 0;
    for (int i = 1; i < v.size(); i++) {
        if (v[i] < mx)
            ans += abs(mx - v[i]);
        mx = max(mx, v[i]);
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4780
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <stack>
#include <string>

using namespace std;

int main(void){
	string word;
	stack<int> S;

	while(cin >> word){
		if(word == "+"){
			int a, b;
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a + b);
		}else if(word == "-"){
			int a, b;
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b - a);
		}else if(word == "*"){
			int a, b;
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a * b);
		}else{
			S.push(atoi(word.c_str()));
		}
	}
	int ans = S.top();
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1200
def xor_sum(N: int)->int:
    MOD = 10**9 + 7

    digits = len(bin(N)) - 2

    dp = [[0] * 3 for _ in range(digits+1)]
    dp[0][0] = 1

    for i in range(digits):
        if N >> (digits - 1 - i) & 1:
            dp[i+1][0] = dp[i][0]
            dp[i+1][1] = (dp[i][0] + dp[i][1]) % MOD
            dp[i+1][2] = (dp[i][1] * 2 + dp[i][2] * 3) % MOD
        else:
            dp[i+1][0] = (dp[i][0] + dp[i][1]) % MOD
            dp[i+1][1] = dp[i][1]
            dp[i+1][2] = (dp[i][1] + dp[i][2] * 3) % MOD

    return sum(dp[digits]) % MOD


if __name__ == "__main__":
    N = int(input())
    ans = xor_sum(N)
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 1005
#define szz 1005

#define PI 2*acos(0.0)

using namespace std;

int main()
{
    ll n,x;
    set<ll>s;
    s.clear();

    scanf("%lld",&n);

    while(n--)
    {
        scanf("%lld",&x);

        s.insert(x);
    }

    cout<<s.size()<<endl;

    return (0);
}





Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include<algorithm>
#include<map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
#define INF 1001001001
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
        result %= 1000000007;
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}

map<string, int> m; 

set<string> st;
int32_t main() {
 
  	int N;
  	int maxi = 0;
  	cin >> N;
  	for(int i=0; i<N; i++){
  		
  		string s;
		  
		cin >> s;
		
		m[s]++; 
	   	st.insert(s);
	   	maxi = max(maxi,m[s]);
	}
 	
 	
 	for(auto f : st) {
	  
	  if(m[f] == maxi){
	  	cout << f << endl;
	  }
	  
	  
	}    
 	
   
}

Measured memory_bytes: 31096
#include <bits/stdc++.h>
#define REP(a,b,c) for(int a=b; a<(int)c; a++)
#define REPE(a,b,c) for(int a=b; a<=(int)c; a++)
#define REPD(a,b,c) for(int a=b; a>=(int)c; a--)
#define rep(a,b) REP(a,0,b)
#define repd(a,b) REPD(a,b,0)
typedef long long int ll;
using namespace std;
typedef struct{int x; int y;} pos;

int main(){
  while(true){
    int N;
    cin >> N;
    if(N == 0) break;
    vector<int> n(N), d(N);
    rep(i,N-1){
      cin >> n[i+1] >> d[i+1];
    }
    vector<pos> poss(N);
    poss[0] = {0,0};
    int max_x = 0, max_y=0, min_x=0, min_y=0;
    REP(i,1,N){
      int x = poss[n[i]].x, y = poss[n[i]].y;
      switch(d[i]){
      case 0:
        x--;
        break;
      case 1:
        y--;
        break;
      case 2:
        x++;
        break;
      case 3:
        y++;
        break;
      }
      poss[i] = {x,y};
      max_x = max(x,max_x);
      max_y = max(y,max_y);
      min_x = min(x,min_x);
      min_y = min(y,min_y);
    }
    cout <<max_x-min_x+1 << " " << max_y-min_y+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    
    ll N,a[100020],d[100010],len=0;
    cin>>N;
    a[0]=0;a[N+1]=0;
    rep(i,1,N+1)cin>>a[i];
    rep(i,0,N+1){
        if(a[i+1]-a[i]>=0)d[i]=a[i+1]-a[i];
        else d[i]=-(a[i+1]-a[i]);
        len+=d[i];
    }
    ll LEN=len;
    rep(i,1,N+1){
        len=LEN;
        if(a[i-1]>a[i]&&a[i]<a[i+1]){
            len=len-2*(min(a[i-1],a[i+1])-a[i]);
        }
        else if(a[i-1]<a[i]&&a[i]>a[i+1]){
            len=len-2*(a[i]-max(a[i-1],a[i+1]));
        }
        cout<<len<<endl;
        
    }
}






Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(c) printf("%s\n",c?"Yes":"No");
#define pYN(c) printf("%s\n",c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    string s[105]={};
    int n,l; cin>>n>>l;
    rep(i,n)cin>>s[i];
    sort(s,s+n);
    rep(i,n)cout<<s[i];
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>wq,st;
int mic(int g)
{
    if(g<=0)return 0;
    if(st[g]!=-11)return st[g];
    st[g]=mic(g-1)+abs(wq[g]-wq[g-1]);
    if(g>1)st[g]=min(st[g],mic(g-2)+abs(wq[g]-wq[g-2]));
    return st[g];
}
int main()
{
    int g,t;
    scanf("%d",&t);
    wq.resize(t);
    st.assign(t,-11);
    for(g=0;g<t;g++)
        scanf("%d",&wq[g]);
    mic(t-1);
    printf("%d\n",st[t-1]);
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    string s;
    cin >> s;
    vec v(2);
    repall (c, s) {
        if (c == '0')
            v[0]++;
        else
            v[1]++;
    }
    print(min(v[0], v[1]) * 2);

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#include <cassert>
#define INF 10000000000
#define MOD 10000000007
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;

string S;
size_t cur = 0;

//with ()*************************************************************************************

int factor();

bool isdigit(char a){
    if (a == '0' or a == '1' or a == '2' or a == '3' or a == '4' or a == '5' or a == '6' or a == '7' or a == '8' or a == '9') {
        return true;
    }
    return false;
}

//********************************************************************************************

int digit(){
    int n = S[cur] - '0';
    cur++;
    return n;
}

int number(){
    int n = digit();
    while(cur < S.size() and isdigit(S[cur])) n = n*10 + digit();
    return n;
}

int term(){
    //*****************************************************************************************
    int a = factor();
    //*****************************************************************************************
    //int a = number();
    while (cur < S.size() and (S[cur]=='*' or S[cur]=='/')) {
        char op = S[cur++];
        //int b = number();
        //*****************************************************************************************
        int b = factor();
        //*****************************************************************************************
        if(op=='*')a *= b; else a/=b;
    }
    return a;
}

int expression(){
    int a = term();
    while (cur < S.size() and (S[cur] == '+' or S[cur] == '-')) {
        char op = S[cur++];
        int b = term();
        if(op == '+') a += b; else a -= b;
    }
    return a;
}

//with() *************************************************************************************
int factor(){
    if(S[cur] != '(') return number();
    cur++;
    int n = expression();
    assert(S[cur] == ')');
    cur++;
    return n;
}
//********************************************************************************************

int main(){
    int n;
    cin >> n;
    while(n-- > 0){
        cur = 0;
        cin >> S;
        S.resize(S.length()-1);
        cout << expression()<<endl;
    }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll ans = -1;

	For(x,0,n+1){
		double X = x;
		ll t = (X*1.08);
		if(t==n){
			ans = x;
		}
	}
	if(ans==-1){
		cout<<":("<<endl;
	}else{
		cout<<ans<<endl;
	}































	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const int MAX_N = 111, MAX_W = 111111;
int w[MAX_N], v[MAX_N];
int dp[MAX_N][MAX_W];

int main() {
   int N, W;
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i] >> w[i];
   }

   for (int i = 0; i < N; i++) {
      for (int j = 0; j <= MAX_W; j++) {
         if (j >= w[i]) {
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
         } else {
            dp[i+1][j] = dp[i][j];
         }
      }
   }

   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 46508
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

void binary(int j, int ball[10], int box[2][10]);
void pack(int box[2][10]);
int judge(int box[2][10]);

int main()
{
	int i, j, n, ball[10], box[2][10];

	scanf("%d", &n);

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

		for(j=0; j<10; j++)
			scanf("%d", &ball[j]);

		for(j=0; j<1024; j++){
			binary(j, ball, box);
			pack(box);
			if(judge(box) == 0){
				printf("YES\n");
				break;
			}
		}
		if(judge(box) == -1)
			printf("NO\n");
	}
	return 0;

}

void binary(int j, int ball[10], int box[2][10])
{
	int i;
	for(i=0; i<10; i++)
		box[0][i] = 0;
	for(i=0; i<10; i++)
		box[1][i] = 0;
	for(i=0; i<10; i++){
		if(j % 2 == 0)
			box[0][i] = ball[i];
		else
			box[1][i] = ball[i];
		j = j / 2;
	}
	return;
}

void pack(int box[2][10])
{
	int i, j, count = 0;
	for(i=0; i<2; i++){
		for(j=0; j<10; j++){
			if(box[i][j] != 0){
				box[i][count] = box[i][j];
				count++;
			}
		}
		for(j=count; j<10; j++)
			box[i][j] = 0;
		count = 0;
	}
	return;
}

int judge(int box[2][10])
{
	int i, j, c[2];
	for(i=0; i<2; i++){
		for(c[i]=0; c[i]<10; c[i]++){
			if(box[i][c[i]] == 0)
				break;
		}
	}
	for(j=0; j<2; j++){
		for(i=0; i<c[j]-1; i++){
			if(box[j][i] > box[j][i+1]){
				return -1;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+9;
int n,k,ar[maxn];
int main()
{
    scanf("%d%d",&k,&n);
    for(int i=0;i<n;i++) scanf("%d",&ar[i]);
    ar[n]=ar[0]+k;
    int imax=0;
    for(int i=0;i<n;i++)
        imax=max(imax,ar[i+1]-ar[i]);
    cout<<k-imax<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main (){
  int dp1[1000001];
  int dp2[1000001];
  vector<int> shi;
  vector<int> shiki;

  for(int j=0;j<=1000000;j++) dp1[j] = dp2[j] = j;
    
  for(int i=1;i*(i+1)*(i+2)/6<=1000000;i++){
    shi.push_back(i*(i+1)*(i+2)/6);
    if(shi[i-1]%2 == 1) shiki.push_back(shi[i-1]);
  }

  for(int i=0;i<shi.size();i++)
    for(int j=1;j<=1000000;j++)
      if(j>=shi[i]) dp1[j] = min(dp1[j],dp1[j-shi[i]]+1);

  for(int i=0;i<shiki.size();i++)
    for(int j=1;j<=1000000;j++){
      if(j>=shiki[i]) dp2[j] = min(dp2[j],dp2[j-shiki[i]]+1);
    }


  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    cout << dp1[n]<< " "<< dp2[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 9032
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


signed main()
{
	QUICK_CIN;
	debug_input;

	vi a;
	int n;
	int t;
	cin >> n >> t;
	REP(i, n) {
		int c;
		cin >> c;
		a.push_back(c);
	}

	int sum = 0;
	int k = 0;

	REP(i, n) {
		sum += t;
		sum -= max(k - a[i],0LL);
		k = a[i] + t;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    long long half_a = a >> 1, half_b = b >> 1, half_c = c >> 1;
    long long ans = a * b * abs((c - half_c) - half_c);
    ans = min(ans, b * c * abs(half_a - (a - half_a)));
    ans = min(ans, c * a * abs(half_b - (b - half_b)));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long li;

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    li sum = 0;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    li progSum = (n * (li)(n + 1) / 2);
    if (sum % progSum != 0) { cout << "NO\n"; return 0; }
    
    li nProgs = sum / progSum;
    
    for (int i = 0; i < n; i++)
    {
        li delta = a[i] - a[(i + n - 1) % n];
        // if x begin here,
        // (1 - N) * x + (nProgs - x) = nProgs + x * (1 - N - 1)
        
        if (((delta - nProgs) % n + n) % n != 0) { cout << "NO\n"; return 0; }
        
        li nHere = (delta - nProgs) / (-n);
        if (nHere < 0) { cout << "NO\n"; return 0; }
    }
    
    cout << "YES\n";
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)

int n;

int main(void){
	cin >> n;
	vector<vector<int>> a(3, vector<int>(n+1));
	for(int i = 1; i <= 2; i++){
		for(int j = 1; j <= n; j++){
			cin >> a[i][j];
		}
	}
	vector<vector<int>> dp(3, vector<int>(n+1));
	for(int i = 1; i <= 2; i++){
		for(int j = 1; j <= n; j++){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			dp[i][j] += a[i][j];
		}
	}
	cout << dp[2][n] << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,max=32;
  cin >> n;
  
  for (int i = 0 ; i < n ; i++) {
    int d=0;
    int a;
      cin >>a;
    
    for ( int j = 0 ; j <32 ; j++) {
      if ( a%2 == 0 ) {
        d++;
        a/= 2;
      }
    }
    
    if (max > d ){
      max = d;
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int a,b,c; cin >> a >>b >>c;
    if(a<b&&b<c) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>

using namespace std;
 
int main(){
    int n,m;
    vector<int> v;
 
    cin >> n >> m;
    for(int i = 0 ; i < 2*n ; i++){
	v.push_back(i+1);
    } 
 
    int k;
    while(m--){
	cin >> k;
 
	if(k == 0){
	    vector<int> tmp;
	    int t = n;
	    for(int i = 0 ; i < n ; i++){
		tmp.push_back(v[i]);
		tmp.push_back(v[i+t]);
	    }
	    v = tmp;
	}
	else{
	    vector<int> tmp;
	    for(int i = 0 ; i < k ; i++){
		tmp.push_back(v[0]);
		v.erase(v.begin());
	    }
	    for(int i = 0 ; i < (int)tmp.size() ; i++){
		v.push_back(tmp[i]);
	    }
	}
    }
 
    for(int i = 0 ; i < (int)v.size() ; i++){
	cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ld dist(pair<ld, ld> a, pair<ld, ld> b) {
	ld ret = (a.X - b.X) * (a.X - b.X);
	ret += (a.Y - b.Y) * (a.Y - b.Y);
	return ret;
}

ld dist(pair<ld, ld> a, vector<pair<ld, ld>>& v) {
	ld ans = 0;
	for (auto b : v) {
		ans = max(ans, dist(a, b));
	}
	return ans;
}

ll const MAGIC = 322;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	vector<pair<ld, ld>> v(n);
	for (ll i = 0; i < n; i++) {
		cin >> v[i].X >> v[i].Y;
	}

	ld xl = -1005, xr = 1005;
	for (ll i = 0; i < MAGIC; i++) {
		ld xm1 = xl + (xr - xl) / 3, xm2 = xm1 + (xr - xl) / 3;
		ld ans1 = 0, ans2 = 0;
		ld yl = -1005, yr = 1005;
		for (ll j = 0; j < MAGIC; j++) {
			ld ym1 = yl + (yr - yl) / 3, ym2 = ym1 + (yr - yl) / 3;
			ld kek1 = dist({ xm1, ym1 }, v);
			ld kek2 = dist({ xm1, ym2 }, v);
			if (kek1 > kek2) {
				yl = ym1;
			} else {
				yr = ym2;
			}
		}
		ans1 = dist({ xm1, (yl + yr)/2 }, v);
		yl = -1005, yr = 1005;
		for (ll j = 0; j < MAGIC; j++) {
			ld ym1 = yl + (yr - yl) / 3, ym2 = ym1 + (yr - yl) / 3;
			ld kek1 = dist({ xm2, ym1 }, v);
			ld kek2 = dist({ xm2, ym2 }, v);
			if (kek1 > kek2) {
				yl = ym1;
			} else {
				yr = ym2;
			}
		}
		ans2 = dist({ xm2, (yl + yr) / 2 }, v);
		if (ans1 > ans2) {
			xl = xm1;
		} else {
			xr = xm2;
		}
	}
	ld xx = (xl + xr) / 2;
	ld yl = -1005, yr = 1005;
	for (ll i = 0; i < MAGIC; i++) {
		ld ym1 = yl + (yr - yl) / 3, ym2 = ym1 + (yr - yl) / 3;
		ld kek1 = dist({ xx, ym1 }, v);
		ld kek2 = dist({ xx, ym2 }, v);
		if (kek1 > kek2) {
			yl = ym1;
		} else {
			yr = ym2;
		}
	}
	ld yy = (yl + yr) / 2;
	cout << fixed; cout.precision(20);
	cout << sqrtl(dist({ xx, yy }, v)) << endl;

	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

int main()
{
  int x;
  cin >> x;
  if(x==3||x==5||x==7)printf("YES");
  else printf("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

signed main(){
	int A, B;
	scanf("%d%d", &A, &B);
	if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
		printf("Possible\n");
	}
	else{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    string n;
    int k;     cin >> n >> k;
    int l = n.length();
    vector<vector<vector<ll > > > dp(l+1, vector<vector<ll> >(2, vector<ll>(k+1, 0)));
    dp[0][0][0] = 1;

    for (int i = 0; i < l; i++) {
        for (int s = 0; s < 2; s++) {
            for (int j = 0; j <= k; j++) {
                for (int x = 0; x <= (s ? 9 : n[i]-'0'); x++) {
                    if (j != k && x != 0) 
                        dp[i+1][s || x < n[i]-'0'][j+1] += dp[i][s][j];
                    else if (j != k && x == 0)
                        dp[i+1][s || x < n[i]-'0'][j] += dp[i][s][j];
                    else if (x == 0)
                        dp[i+1][s || x < n[i]-'0'][k] += dp[i][s][j];
                }
            }
        }
    }

    cout << dp[l][1][k] + dp[l][0][k] << endl;

    return 0;
}

Measured memory_bytes: 256