akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(){
    int N;
    cin >> N; // numbar of human
    int D, X; // D: days , X:number of chocolate
    cin >> D >> X;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        int j = 0;
        int day = 1;
        while (day <= D){
            day = 0;
            X++;
            j++;
            day += j * A.at(i) + 1;
        }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = il()
    sm = sum(A)
    A.sort(reverse=True)

    if A[M-1] >= sm / (4*M):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector< pair<int, int> > v1(n), v2(n);
  set< pair<int, int> > st;
  vector<bool> used(n, false);

  for(int i=0;i<n;i++) {
    int ai, bi;
    cin >> ai >> bi;
    v1[i] = make_pair(ai, bi);
  }

  for(int i=0;i<n;i++) {
    int ci, di;
    cin >> ci >> di;
    v2[i] = make_pair(ci, di);
  }

  sort(v2.begin(), v2.end());



  int ans = 0;

  for(int i=0;i<v2.size();i++) {
    int y = -1;
    int idx = -1;
    for(int j=0;j<v1.size();j++) {
      if(!used[j] && v2[i].first > v1[j].first && v2[i].second > v1[j].second && y < v1[j].second) {
        y = v1[j].second;
        idx = j;
      }
    }
    if(y >= 0) {
      used[idx] = true;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() {
	int x,y;
	int ans = 0;
	
	cin >> x >> y;
	
	if(x < y){
		ans += y--;
	}
	else{
		ans += x--;
	}
	
	if(x < y){
		ans += y;
	}
	else{
		ans += x;
	}
	
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
const chunks = [];
process.stdin.on("data", (chunk) => {
  chunks.push(chunk);
});
process.stdin.on("end", () => {
  const lines = Buffer.concat(chunks)
    .toString("utf8")
    .trim()
    .split("\n")
    .map((line) => line.split(" ").map((s) => parseInt(s, 10)));
  const [N] = lines[0];
  const A = lines[1];
  console.log(solve(N, A));
});

// Ai is not divisible by any other numbers in A.
// O(N^2) is not acceptable.
// If A has 1, the answer is 0?
// If there are equal nubmers, they can't be i.
// Ai is not divisible by Aj when:
// - Ai is smaller than Aj
//
// Enumerate divisors and check if each of them is in A.

class Counter extends Map {
  increment(key) {
    if (this.has(key)) {
      this.set(key, this.get(key) + 1);
    } else {
      this.set(key, 1);
    }
  }
}

function solve(N, A) {
  const counter = new Counter();
  for (const a of A) {
    counter.increment(a);
  }

  if (counter.has(1)) {
    return counter.get(1) === 1 ? 1 : 0;
  }

  let result = 0;
  for (const [key, count] of counter.entries()) {
    if (count > 1) continue;
    if (check(key)) result++;
  }
  return result;

  function check(key) {
    const sqrt = Math.floor(Math.sqrt(key));
    for (let i = 2; i <= sqrt; i++) {
      if (key % i === 0) {
        if (counter.has(i)) return false;
        if (counter.has(key / i)) return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 74384
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    ll n,a,b;
    cin>>n>>a>>b;
    ll x[n];
    rep(i,0,n)
        cin>>x[i];
    ll dp[n];
    dp[0] = 0;
    for(int i = 1;i<n;i++){
        ll w = a*(x[i] - x[i-1]);
        ll t = b;
        dp[i] = dp[i-1] + min(w,t);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s,t;
    in(s,t);
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(i+t.length()<s.length()&&s.substr(i,t.length())==t){
            ans=1;
            break;
        }
        if(i+t.length()>=s.length()&&s.substr(i,s.length()-i)+s.substr(0,t.length()-s.length()+i)==t){
            ans=1;
            break;
        }
    }
    yn(ans);
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
 
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9;

int n, m;

int main() {
	scanf("%d %d", &n, &m);
	ll ans = 1e10;
	for (int i = 1; i < n; i++) {
		ll mx = 0, mn = 1e10;
		mx = max(mx, (ll)i * m);
		mn = min(mn, (ll)i * m);
		if (n - i == 1) continue;
		mx = max(mx, (ll)(n - i) / 2 * m);
		mx = max(mx, (ll)(n - i - (n - i) / 2) * m);
		mn = min(mn, (ll)(n - i) / 2 * m);
		mn = min(mn, (ll)(n - i - (n - i) / 2) * m);
		ans = min(ans, mx - mn);
	}
	for (int i = 1; i < n; i++) {
		ll mx = 0, mn = 1e10;
		mx = max(mx, (ll)i * m);
		mn = min(mn, (ll)i * m);
		//if (n - i == 1) continue;
		mx = max(mx, (ll)(n - i) * (m / 2));
		mx = max(mx, (ll)(n - i) * (m - m / 2));
		mn = min(mn, (ll)(n - i) * (m / 2));
		mn = min(mn, (ll)(n - i) * (m - m / 2));
		ans = min(ans, mx - mn);
	}
	swap(n, m);
	for (int i = 1; i < n; i++) {
		ll mx = 0, mn = 1e10;
		mx = max(mx, (ll)i * m);
		mn = min(mn, (ll)i * m);
		if (n - i == 1) continue;
		mx = max(mx, (ll)(n - i) / 2 * m);
		mx = max(mx, (ll)(n - i - (n - i) / 2) * m);
		mn = min(mn, (ll)(n - i) / 2 * m);
		mn = min(mn, (ll)(n - i - (n - i) / 2) * m);
		ans = min(ans, mx - mn);
	}
	for (int i = 1; i < n; i++) {
		ll mx = 0, mn = 1e10;
		mx = max(mx, (ll)i * m);
		mn = min(mn, (ll)i * m);
		//if (n - i == 1) continue;
		mx = max(mx, (ll)(n - i) * (m / 2));
		mx = max(mx, (ll)(n - i) * (m - m / 2));
		mn = min(mn, (ll)(n - i) * (m / 2));
		mn = min(mn, (ll)(n - i) * (m - m / 2));
		ans = min(ans, mx - mn);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>
#include <chrono>

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	string S;
	cin >> S;
	REP(i,S.size()){
		if (S[i] == 'A') S[i] = 'T';
		else if (S[i] == 'T') S[i] = 'A';
		else if (S[i] == 'C') S[i] = 'G';
		else if (S[i] == 'G') S[i] = 'C';
	}
	cout << S << endl;



	return 0;
}


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

int main() {
	
	int h, w;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10)), a(h, vector<int>(w));
	rep(i, 10) rep(j, 10){
		cin >> c[i][j];
	}
	rep(i, h) rep(j, w){
		cin >> a[i][j];
	}
	// warshal-floyd
	for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
	int ans = 0;
	rep(i, h) rep(j, w){
		if(a[i][j] == -1) continue;
		ans += c[a[i][j]][1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=len(s);
    ll r=0,l=0;
    vector<ll> ans(n,0);
    vector<ll> c1,c2;
    rep(i,n){
      if(i+1<=n-1 && s[i]=='R' && s[i+1]=='L'){
        c1.push_back(i);
      }
    }
    for(int i=n-1;i>=0;i--){
      if(i-1>=0 && s[i]=='L' && s[i-1]=='R'){
        c2.push_back(-i);
      }
    }
    //cout_vec(c2);
    rep(i,n){
      if(s[i]=='R'){
        ll ind=*lower_bound(begin(c1),end(c1),i);
        //cout<<i<<' '<<ind<<endl;
        if((ind-i)%2==0) ans[ind]++;
        else ans[ind+1]++;
      }
    }
    for(int i=n-1;i>=0;i--){
      if(s[i]=='L'){
        ll ind=*lower_bound(begin(c2),end(c2),-i);
        //cout<<-i<<' '<<ind<<endl;
        if((ind-i)%2==0) ans[-ind]++;
        else ans[-ind-1]++;
      }
    }
    cout_vec(ans);
}

Measured memory_bytes: 2248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 2e5+2;
int N, in[MAXN];
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N;
	for(int i = 2, x;i<=N;i++){cin >> x; in[x]++;}
	for(int i = 1;i<=N;i++){cout << in[i] << '\n';}
	return 0;
}

Measured memory_bytes: 4388
T_list = input()
T = list(T_list)
nT = [0]*len(T)
if T[len(T)-1] == '?':
    T[len(T)-1] = 'D'
for i in range(len(T)):
    if T[i] != '?':
        nT[i] = T[i]
    else:
        if 0<i and i<len(T)-1:
            if T[i-1] == 'P':
                nT[i] = 'D'
                T[i] = 'D'
            elif T[i+1] == 'D':
                nT[i] = 'P'
                T[i] = 'P'
            elif T[i+1] == '?':
                nT[i] = 'P'
                T[i] = 'P'
            else:
                nT[i] = 'D'
                T[i] = 'D'
        else:
            if i<len(T)-1:
                if T[i+1] == 'D':
                    nT[i] = 'P'
                    T[i] = 'P'
                elif T[i+1] == '?':
                    nT[i] = 'P'
                    T[i] = 'P'
                else:
                    nT[i] = 'D'
                    T[i] = 'D'
nT=''.join(nT)              
print(nT)       

Measured memory_bytes: 12520
n,x = map(int,input().split())
a = list(map(int,input().split()))

ans = sum(a)

for i in range(n-1):
    s = a[i]
    t = a[i+1]
    if s + t > x:
        a[i+1] = max(x - s, 0)
        t = a[i+1]
    if s + t > x:
        a[i] = max(x - t, 0)

ans -= sum(a)

print(ans)


Measured memory_bytes: 14068
using System;
using System.Collections.Generic;
using System.Text;
class Program{
	static int s;
	static string q;
	static Dictionary<string,int> hs=new Dictionary<string,int>();
	static StringBuilder u;
	static long ans=0;
	static void Main(){
		s=int.Parse(Console.ReadLine());
		q=Console.ReadLine();
		u=new StringBuilder(q.Substring(0,s));
		fu1(0,0,"");
		q=q.Substring(s);
		u=new StringBuilder(q);
		fu2(s-1,0,"");
		Console.WriteLine(ans);
	}
	static void fu2(int n,int k,string t){
		if(n>-1){
			fu2(n-1,k,t);
			u.Remove(n,1);
			u.Insert(n,"_");
			fu2(n-1,k+1,t+q[n]);
			u.Remove(n,1);
			u.Insert(n,q[n]);
		}
		else{
			string key=u.ToString();
			key=key.Replace("_","");
			key=k+" "+t+key;
			if(hs.ContainsKey(key)){ans+=hs[key];}
		}
	}
	static void fu1(int n,int k,string t){
		if(n<s){
			fu1(n+1,k,t);
			u.Remove(n,1);
			u.Insert(n,"_");
			fu1(n+1,k+1,t+q[n]);
			u.Remove(n,1);
			u.Insert(n,q[n]);
		}
		else{
			string key=u.ToString();
			key=key.Replace("_","");
			char[] a=key.ToCharArray();
			Array.Reverse(a);
			key=new string(a);
			key=k+" "+t+key;
			if(hs.ContainsKey(key)){hs[key]++;}
			else{hs.Add(key,1);}
		}
	}
}

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

int main() {
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    int sum = X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 1; j <= D; j += A[i]) {
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n, b, f, r, v;
  int R[4][3][10];

  for(int i=0; i < 4; i++) {
    for(int j=0; j < 3; j++) {
      for(int k=0; k < 10; k++) {
        R[i][j][k] = 0;
      }
    }
  }

  cin >> n;
  while(n > 0) {
    cin >> b >> f >> r >> v;
    if(R[b-1][f-1][r-1] + v >= 0 && R[b-1][f-1][r-1] + v < 10) {
      R[b-1][f-1][r-1] += v;
    } else if(R[b-1][f-1][r-1] + v >= 10 || R[b-1][f-1][r-1] + v < 0) {
      continue;
    }
    n--;
  }

  for(int i=0; i < 4; i++) {
    for(int j=0; j < 3; j++) {
      for(int k=0; k < 10; k++) {
        cout << " " << R[i][j][k];
      }
      cout << endl;
    }
    if(i < 3) {
      cout << "####################" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>
int main(void){
  int n,i,j;
  int a[100];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=n-1;i>=1;i--)
    printf("%d ",a[i]);
  printf("%d\n",a[0]);

  return 0;
}

Measured memory_bytes: 1024
N = int(input())
XY = sorted([tuple(map(int, input().split())) for _ in range(N)])
PQ = []
for i in range(N):
    for j in range(i+1, N):
        PQ.append((XY[j][0]-XY[i][0], XY[j][1]-XY[i][1]))

ans = N
for p, q in PQ:
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            if XY[j][0] - p == XY[i][0] and XY[j][1] - q == XY[i][1]:
                cnt += 1
    ans = min(ans, N-cnt)
print(ans)

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M (int)3e5+1

using namespace std;

int cnt[M];

int main()
{
	int n;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		int tmp;
		cin >> tmp;
		cnt[tmp - 1] ++;
	}

	vector<int> c, p;

	for (int i = 0; i < n; i++)
		if (cnt[i] != 0)
			c.push_back(cnt[i]);

	sort(c.begin(), c.end());

	p.push_back(c.front());

	for (int i = 1; i < c.size(); i++)										//前缀和
		p.push_back(p.back() + c[i]);

	for (int k = 1; k <= n; k++)
	{
		int l = 0, r = n / k, mid;
		while (l != r)
		{
			mid = (l + r) / 2 + 1;
			int id = lower_bound(c.begin(), c.end(), mid) - c.begin();		//二分查找第一个>=m的pos
			int t = c.size() - id;
			if (id != 0)
				t += p[id - 1] / mid;
			if (t >= k)
				l = mid;
			else
				r = mid - 1;
		}
		cout << l << endl;
	}

	return 0;
}

Measured memory_bytes: 5616
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
string s;
int k;
int main(){
    cin>>k>>s;
    if(s.size()<=k)cout<<s<<'\n';
    else{
        s.resize(k);
        cout<<s<<"..."<<'\n';
    }
    return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    string S;
    cin >>S;

    int N=S.size();    
    //-----------------------------------
    bool is=true;
    rep(i,N){
        if((i%2==0 && S[i]=='L')||(i%2==1 && S[i]=='R'))is=false;
        
    }

    cout << ((is) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string t;
    cin >> t;

    for (auto c : t) {
        if (c == '?') cout << 'D';
        else cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
ll N,P;
vector<int> A(55);
ll dp[55][2];
int main() {
	cin>>N>>P;
	dp[0][0] = 1;
	rep(i,N)cin>>A[i];
	rep(i,N){
		//選ばない場合
		dp[i+1][0] += dp[i][0];
		dp[i+1][1] += dp[i][1];
		//偶数を選ぶ場合
		if(A[i]%2 == 0){
			dp[i+1][0] += dp[i][0];
			dp[i+1][1] += dp[i][1];
		}
		//奇数を選ぶ場合
		else{
			dp[i+1][0] += dp[i][1];
			dp[i+1][1] += dp[i][0];
		}
	}
	ll ans = dp[N][P];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

// 最大公約数を求める 条件(a > b)
ll eculidean(ll a, ll b) {
  ll c = a % b;
  if (c == 0) {
    return b;
  }
  return eculidean(b, c);
}

int main() {
  int N;
  cin >> N;
  int V[N];
  int C[N];
  int X = 0, Y = 0;
  REP(i, N) { cin >> V[i]; }
  REP(i, N) { cin >> C[i]; }

  REP(i, N) {
    if (V[i] > C[i]) {
      X += V[i];
      Y += C[i];
    }
  }

  cout << X - Y << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            String s=sc.nextLine();
            if(s.equals(".")) break;
            int ok=1;
            LinkedList<Character> st=new LinkedList<Character>();
            for(int i=0;i<s.length();i++){
                if(s.charAt(i)=='('||s.charAt(i)=='['){
                    st.addFirst(s.charAt(i));
                }
                else if(s.charAt(i)==')'||s.charAt(i)==']'){
                    
                    if(st.isEmpty()){
                        ok=0;
                        break;
                    }
                    char a=s.charAt(i);
                    char c=st.getFirst();
                    st.removeFirst();
                    if(a==')'){
                        if(c!='('){
                            ok=0;
                            break;
                        }
                    }else{
                        if(c!='['){
                            ok=0;
                            break;
                        }
                    }
                }
            }
            if(!st.isEmpty()) ok=0;
            String ans;
            if(ok==1) ans="yes";
            else ans="no";
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 46840
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  string s;
  cin >> s;
  int w;
  cin >> w;
  int l = s.length();
  for (int i = 0; i < l; i += w) {
    printf("%c", s[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 888
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	x,y=MI()
	ans="No"
	if 4*x-y>=0 and -2*x+y>=0 and (4*x-y)%2==0 and (-2*x+y)%2==0:
		ans="Yes"
	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 61964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> ans(n);
	rrep(i, n) {
		ans[i] = a[i] - a[i - 1];
	}
	ans[0] = (k - a[n - 1]) + a[0];
	//rep(i, n) dunk(ans[i]);
	int j_ans = 0;
	rep(i, n) j_ans = max(j_ans, ans[i]);
	dunk(k - j_ans);
	return 0;
}

Measured memory_bytes: 1792
using System;

namespace ABC170B
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var x = int.Parse(str[0]);
            var y = int.Parse(str[1]);

            var flag = false;
            if (y % 2 == 0)
            {
                for (var i = 0; i <= x; i++)
                {
                    var kame = i * 2;
                    var tsuru = (x - i) * 4;

                    if (y == tsuru + kame)
                    {
                        flag = true;
                        Console.WriteLine("Yes");
                        break;
                    }
                }
            }
            if (!flag)
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}


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

#define pb push_back
#define fi first
#define se second


using namespace std;

vector<int> v;

int main()
{
	
	int a,b;

	cin>>a>>b;

	v.pb(a);
	v.pb(b);


	sort(v.begin(), v.end());
	
	if(v[0]==2)
		cout<<1<<endl;
	else if(v[1] == 2)
		cout<<3<<endl;
	else
		cout<<2<<endl;


	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

const double EPS = 1e-13;
double dist(double x1, double y1, double z1, double x2, double y2, double z2)
{
	return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1));
}
int main(void)
{
	int N, Q;
	cin >> N >> Q;
	double x[50], y[50], z[50], r[50];
	LL l[50];
	for (int i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
	}
	for (int j = 0; j < Q; ++j)
	{
		double sx, sy, sz, dx, dy, dz;
		cin >> sx >> sy >> sz >> dx >> dy >> dz;
		double vx = dx - sx, vy = dy - sy, vz = dz - sz;
		LL cost = 0;
		for (int i = 0; i < N; ++i)
		{
			double dn = 0, up = 1;
			while (up - dn >= EPS)
			{
				double m1 = (up + dn + dn) / 3;
				double m2 = (up + up + dn) / 3;
				double px1 = sx + vx * m1;
				double py1 = sy + vy * m1;
				double pz1 = sz + vz * m1;
				double px2 = sx + vx * m2;
				double py2 = sy + vy * m2;
				double pz2 = sz + vz * m2;
				if (dist(px1, py1, pz1, x[i], y[i], z[i]) <= dist(px2, py2, pz2, x[i], y[i], z[i]))
				{
					up = m2;
				}
				else
				{
					dn = m1;
				}
			}
			double px = sx + vx * dn;
			double py = sy + vy * dn;
			double pz = sz + vz * dn;
			if (dist(px, py, pz, x[i], y[i], z[i]) <= r[i] + EPS)
			{
				cost += l[i];
			}
		}
		cout << cost << endl;
	}
	return 0;
}

Measured memory_bytes: 3232
S = input()

N = len(S)
S_rev = ''.join(list(reversed(S)))

S_cond1 = S[0:int((N-1)/2)]
S_cond1_rev = ''.join(list(reversed(S_cond1)))

S_cond2 = S[int((N+3)/2)-1:]
S_cond2_rev = ''.join(list(reversed(S_cond2)))

if(S == S_rev and S_cond1 == S_cond1_rev and S_cond2 == S_cond2_rev):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
  var k, x int
  fmt.Scan(&k, &x)

  for i := x-k+1; i < x+k; i++ {
    fmt.Print(i)
    if (i == x+k-1) {
      fmt.Print("\n")
    } else {
      fmt.Print(" ")
    }
  }
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> input = new List<string>();
            input.AddRange(Console.ReadLine().Split(' '));
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = 1;

            if(B==1)
            {
                Console.WriteLine(0);
            }
            else
            {

            B -= A;

            while(B>0)
            {
                B -= (A-1);
                C++;
            }
            Console.WriteLine(C);
            }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n);i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
struct Sieve
{
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1)
  {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; i++)
    {
      if (f[i])
        continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i)
      {
        if (!f[j])
          f[j] = i;
      }
    }
  }
  bool isPrime(int x)
  {
    return f[x] == x;
  }
  vector<int> factorList(int x)
  {
    vector<int> res;
    while (x != 1)
    {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<pair<int, int>> factor(int x)
  {
    vector<int> fl = factorList(x);
    if (fl.size() == 0)
      return {};
    vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
    for (int p : fl)
    {
      if (res.back().first == p)
      {
        res.back().second++;
      }
      else
      {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
int main()
{
  Sieve sieve(1e6);
  int q;
  cin >> q;
  vector<int> l(q);
  vector<int> r(q);
  for(int i = 0;i<q;i++){
    cin >> l[i] >> r[i];
  }

  vector<int> memo(100005);
  for (int i = 1; i <= 100000; i++)
  {
    if(sieve.isPrime(i) && sieve.isPrime((i+1)/2) && i%2==1){
      memo[i] = memo[i - 1] + 1;
    }else{
      memo[i] = memo[i - 1];
    }
  }
  rep(i,q){
    cout << memo[r[i]] - memo[l[i]-1] << endl;
  }
}

Measured memory_bytes: 6136
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    for(int i = 0; ; i++){
        if(i % 2 == 0){
            C -= B;
            if(C <= 0){
                cout << "Yes" << endl;
                break;
            }
        }else{
            A -= D;
            if(A <= 0){
                cout << "No" << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define sqr(x) ((x) * (x))

int main()
{
  int d;
  while(scanf("%d",&d)!=EOF){
   unsigned long s=0;
           if(600%d!=0) break;
           int i;
           for(i=d; i<600; i+=d){
                s += sqr(i)*d;
           }
printf("%lu\n",s);
}
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int h, w; cin >> h >> w;
  char field[h][w+1];
  rep(i, h) cin >> field[i];

  int dh[4] = {-1, 0, 1, 0};
  int dw[4] = {0, -1, 0, 1};

  bool flag = true;
  rep(i, h) rep(j, w) {
    if(field[i][j] == '#') {
      bool can = false;
      rep(k, 4) {
        int nh = i+dh[k];
        int nw = j+dw[k];

        if(0<=nh && 0<=nw && nh<h && nw<w && field[nh][nw] == '#') can = true;
      }
      if(!can) flag = false;
    }
  }

  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll d, t, s; cin >> d >> t >> s;
  if(d <= t * s) fin("Yes");
  fin("No");
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF (1e9)
#define PI (acos(-1))

int TypeCount(string s) {
	string save = "";
	for (int i = 0; i < s.size(); i++) {
		if (save.find(s[i]) == string::npos) save += s[i];
	}
	return save.size();
}

int main() {
	int n, type;
	cin >> n;
	string ans;
	vector<vector<string>> table(n, vector<string>(0));

	table[0].push_back("a");
	if(n == 1) cout << "a" << endl;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < table[i-1].size(); j++) {
			type = TypeCount(table[i-1][j]);
			for (int k = 0; k < type+1; k++) {
				ans = table[i-1][j];
				ans.push_back('a' + k);
				table[i].push_back(ans);
				if(i == n-1) cout << ans << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 8268
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	if (((b - a) + 1) / 2  < k) {
		REP(i, ((b - a) + 1)) {
			cout << a + i << endl;
		}
	}
	else {


		REP(i, k) {
			cout << a + i << endl;
		}
		REP(i, k) {
			cout << b - k + 1 + i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[][] A = new int[2][N+1];
		int[] t0 = new int[N+1];
		int[] t1 = new int[N+1];
		int[] ans = new int[N+1];
		int total0 = 0,total1 = 0;
		for( int i=1; i<=N; i++ ){
			A[0][i] = sc.nextInt();
			total0 += A[0][i];
			t0[i] = total0;
		}
		for( int i=1; i<=N; i++ ){
			A[1][i] = sc.nextInt();
		}
		for( int i=N; i>=1; i-- ){
			total1 += A[1][i];
			t1[i] = total1;
		}
		for( int i=1; i<=N; i++ ){
			ans[i] = t0[i] + t1[i];
		}
		Arrays.sort(ans);
		System.out.println(ans[N]);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
using namespace std;

double StandardDeviation(vector<int> s){
	int n = s.size();
	double S = 0;
	double D = 0;
	for(int i = 0; i < n; i++) S += s[i];
	double m = S / n;
	for(int i = 0; i < n; i++) D += (s[i] - m) * (s[i] - m);
	double d = sqrt( D / n );
	return d;
}

vector<int> Enter(int n){
	vector<int> s;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		s.push_back(a);
	}
	return s;
}

int main(){
	vector<double> alpha;
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		vector<int> s;
		s = Enter(n);
		double d = StandardDeviation(s);
		alpha.push_back(d);
	}
	for(int i = 0; i < alpha.size(); i++){
		cout << fixed << setprecision(8) << alpha[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  int a = 0, b = 0, counter = 0;
  iota(all(r), 1);
  do {
    if(r==p)
      a = counter;
    if(r==q)
      b = counter;
    counter++;
  } while (next_permutation(all(r)));
  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int N;
    cin>>N;
    int x=1e6;
    char a[x];
    rep(i,2*N){
        cin>>a[i];
        
    }
    if (a[0]=='W' or a[2*N]=='W'){
        cout<<0<<endl;
        return 0;
    }
    bool lor=true;
    int left=1;
    ll ans=1;
    ll mod=1e9+7;
    for (int i=1;i<2*N;i++){
        if (a[i]==a[i-1]){
            lor=!lor;
        }
        if (lor==true){
            left++;
        }else {
            ans*=left;
            ans%=mod;
            left--;
        }
        if (left<0){
            cout<<0<<endl;
            return 0;
        }
    }
    if (left!=0){
        cout<<0<<endl;
        return 0;
    }
    
    for (int i=1;i<=N;i++){
        ans*=i;
        ans%=mod;
    }
    cout<<ans%mod<<endl;
    
    
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(string.Join("", Enumerable.Repeat(Console.ReadLine(), 2)).Contains(Console.ReadLine()) ? "Yes" : "No");
        }

        /*private static bool IsInput(out int[] arr)
        {
            var s = Console.ReadLine();
            if (s == "0 0") { arr = null; return false; }

            arr = s.Split(' ').Select(int.Parse).ToArray();
            return true;
        }
        // */
    }
}


Measured memory_bytes: 18136
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N], T[N];
  for(int i = 0; i < N; ++i){
    cin >> T[i];
  }
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  if(N == 1){
    if(A[0] == T[0]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
  }
  int H[N][2];
  for(int i = 0; i < N; ++i){
    H[i][1] = min(T[i],A[i]);
    H[i][0] = 1;
  }
  H[0][0] = T[0];
  H[N-1][0] = A[N-1];
  long long int ans = 1LL, mod = 1000000007LL;
  for(int i = 1; i < N-1; ++i){
    bool f = false;
    if(T[i-1] != T[i]){
      H[i][0] = T[i];
      f = true;
    }
    if(A[i] != A[i+1]){
      if(f && H[i][0] != A[i]){
	cout << 0 << endl;
	return 0;
      }
      H[i][0] = A[i];
    }
  }
  
  for(int i = 0; i < N; ++i){
    ans *= max(0LL,(long long int)(H[i][1]-H[i][0]+1));
    ans %= mod;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
v[][4]={{0,4,2,5},{0,5,2,4},{0,3,2,1},{0,1,2,3},{4,3,5,1},{1,5,3,4}};main(n,c,i,j,t,s){while(scanf("%d",&n)&&n){int d[]={1,3,6,4,2,5};for(s=1;n--&&scanf(" %s",&c);){c&=255;i=c-'N'?c-'S'?c-'E'?c-'W'?c-'L'?5:4:3:2:1:0;t=d[v[i][0]];for(j=0;j<3;++j)d[v[i][j]]=d[v[i][j+1]];d[v[i][3]]=t;s+=*d;}printf("%d\n",s);}}

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

int main(){
    int n;
    cin>>n;
    int L[52];
    for(int i=0; i<52; i++){
        L[i]=i;
    }
    for(int i=0; i<n; i++){
        char a;
        int b;
        cin>>a>>b;
        if(a=='S')L[b-1]=-1;
        if(a=='H')L[b+12]=-1;
        if(a=='C')L[b+25]=-1;
        if(a=='D')L[b+38]=-1;
    }
    for(int i=0; i<52; i++){
        if(L[i]!=-1){
            int c=(L[i]+1)%13;
            if((L[i]+1)%13==0)c=13;
            if(L[i]/13==0)cout<<"S"<<" "<<c<<endl;
            if(L[i]/13==1)cout<<"H"<<" "<<c<<endl;
            if(L[i]/13==2)cout<<"C"<<" "<<c<<endl;
            if(L[i]/13==3)cout<<"D"<<" "<<c<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
import numpy as np

H, W = map(int, input().split())
mat = np.array([[0 if v == "#" else 1 for v in input()] for _ in range(H)])

l, r = np.zeros((H, W)), np.zeros((H, W))
for w in range(W):
    l[:, w] = (l[:, w-1] + 1) * mat[:, w]
    r[:, -w-1] = (r[:, -w] + 1) * mat[:, -w-1]

u, d = np.zeros((H, W)), np.zeros((H, W))
for h in range(H):
    u[h, :] = (u[h - 1, :] + 1) * mat[h, :]
    d[-h - 1, :] = (d[-h, :] + 1) * mat[-h - 1, :]

print(int(np.max(u+d+l+r-3)))

Measured memory_bytes: 253856
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dob double
int main(){
	int a,b;
	cin>>a>>b;
	if (a + b == 3){
		cout<<3;
	}
	else if (a + b == 4){
		cout<<2;
	}
	else{
		cout<<1;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
 
int main()
{
  int i,j,e,m;
  double k;
 
  while(1){
    scanf("%d",&e);
    if(e==0)break;
    m=1000000;
    for(i=0;i<101;i++){
      for(j=0;j<1001;j++){
    k=e-(i*i*i+j*j);
          if(i+j+k<m && k>=0){
        m=i+j+k;
      }
    }
      }
     
    printf("%d\n",m);
  }
  return 0;
}


Measured memory_bytes: 2048