akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,M;
string S,T;
void input(){
    fast_io();
    cin >> N >> M;
    cin >> S >> T;
}

ll __gcd(ll x, ll y){
    if(x==0) return y;
    return __gcd(y%x,x);
}
ll lcm(ll x, ll y){return x*y/__gcd(x,y);}

int solve(){
    ll L = lcm(N,M);
    for (int i = 0; i < N; i++)
    {
        int j = i*(L/N)/(L/M);
        if(i*L/N==j*L/M){
            if(S[i]==T[j]) continue;
            else {cout << -1 << endl; return 0;}
        }        
    }
    cout << L << endl;

    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;

struct point
{
	long long int x, y;
	int p, q;
	bool operator <(const point& a)
	{
		if (1LL * q*a.p != 1LL * p*a.q)
		{
			return (1LL * q * a.p) < (1LL * p * a.q);
		}
		if (y != a.y)
		{
			return y < a.y;
		}
		return x < a.x;
	}
};

double distance(const point& a, const point& b)
{
	double dist = sqrt((a.x - b.x)*(a.x-b.x) + (a.y-b.y)*(a.y - b.y));
	return dist;
}

long long int ccw(const point& a, const point& b, const point& c)
{
	return 1LL * (b.x - a.x)*(c.y - a.y) - 1LL * (b.y - a.y)*(c.x - a.x);
}

point t, p[200000];	
int n, x, y;
stack <int> st;
double dist = 0;

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

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> x >> y;
		t.x = x;
		t.y = y;
		t.p = 1;
		t.q = 0;
		p[i] = t;
	}

	sort(p, p + n);

	for (int i = 1; i < n; i++)
	{
		p[i].p = p[i].x - p[0].x;
		p[i].q = p[i].y - p[0].y;
	}

	sort(p + 1, p + n);

	st.push(0);
	st.push(1);
	int next = 2;
	while (next < n)
	{
		while (st.size() >= 2)
		{
			int first = st.top();
			st.pop();
			int second = st.top();

			if (ccw(p[second], p[first], p[next]) > 0)
			{
				st.push(first);
				break;
			}
		}
		st.push(next);
		next++;
	}

	vector <int> v;

	while (!st.empty())
	{
		v.push_back(st.top());
		st.pop();
	}

	long long int res = 0;
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j < v.size(); j++)
		{
			long long int dx = abs(p[v[i]].x - p[v[j]].x);
			long long int dy = abs(p[v[i]].y - p[v[j]].y);
			res = max(res,dx+dy);
		}
	}

	cout << res << '\n';

	return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> num;

    rep(i, n){
        cin >> a[i];
        ++num[a[i]];
    }

    sort(a.begin(), a.end(), greater<int>());

    ll h = 0;
    ll w = 0;
    rep(i, n){
        if(num[a[i]]>1){
            if(h==0) {
                h = a[i];
                num[a[i]] -= 2;
            }
            else if(w==0) w = a[i];
            else if(h && w) break;
        }
    }
    cout << h*w << endl;
}

Measured memory_bytes: 5376
import java.util.*;

class Main {
    public static void main(String[] args) {
        final long MOD = 1_000_000_007L;
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        int B[][] = new int[N][60];
        for (int i=0; i<N; i++) {
            long A =  Long.parseLong(sc.next());
            for (int j=0; j<60; j++) {
                B[i][j] = (int)(A % 2);
                A /= 2;
                if (A==0)
                    break;
            }
        }
        sc.close();

        long sum = 0L;
        for (int j=0; j<60; j++) {
            long cnt = 0;
            for (int i=0; i<N; i++) {
                cnt += B[i][j];
            }
            sum += cnt * (N - cnt) * Math.pow((double)2, (double)j) % MOD;
            sum %= MOD;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 169456
##!/usr/bin/env python3
import sys
# from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int

    # write code
    X = (B // C) - ((A-1) // C)
    Y = (B // D) - ((A - 1) // D)
    Z = (B // (C * D // gcd(C, D))) - ((A - 1) // (C * D // gcd(C, D)))
    print(int(B-A+1-X-Y+Z))



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

int main(){
  int x,y;
  cin >> x >> y;
  int a = (-2*x+y)/2;
  if((-2*x+y)%2==0 && a>=0 && x-a>=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int a,b;
	cin>>a>>b;
	b/=__gcd(a,b);
	int out=1;
	for(int t=2;t*t<=b;t++)if(b%t==0){
		out*=t;
		while(b%t==0)b/=t;
	}
	cout<<out*b<<endl;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#define int long long int
vector<int> vec;
bool function(int n,int j)
{
	if(n<1)
	  return false;
	if(n==1)
	  return true;
	if(n%j==0)
	{
		return function(n/j,j);
	}
	else
	{
		if((n-1)%j==0)
		  return true;
		else
		  return false;
	}
}
int32_t main()
{
    int n,k;
    cin>>n;
    int y=sqrt(n);
    int x=n-1;
    int j;
    set<int> s;
    for(j=1;j*j<=x;j++)
    {
		if(x%j==0)
		{
			int f1=j;
			int f2=x/j;
			if(f1!=1)
			  s.insert(f1);
			if(f2!=1)
			s.insert(f2);
		}
    }
    for(j=2;j<=y;j++)
    {
		bool result=function(n,j);
		if(result)
		  s.insert(j);
	}
	s.insert(n);
	cout<<s.size()<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int dp[100001][3]={};
	int a[100001][3];
	scan(N);
	rep(i,N){
		rep(j,3){
			scan(a[i][j]);
			dp[i+1][j]=max(dp[i][(j+1)%3]+a[i][j],dp[i][(j+2)%3]+a[i][j]);
		}
	}
	prin(max(dp[N][0],max(dp[N][1],dp[N][2])));
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<40;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	 ll z, w;
	ll ans=0;
	cin >>n>>z>>w;
	V a(n+2);
	rep(i, n) { cin >> a[i + 2]; }
	a[0] = z;
	a[1] = w;
	Pi at = mp(0, 1);
	VV dis(n + 2, V(n + 2));
	VV det(n + 2, V(n + 2, 0LL));
	rep(i, n + 2) {
		rep(j, n + 2) { 
			dis[i][j] = abs(a[i] - a[j]);
			if (i == j) {
				dis[i][j] = INFLL;
			}
			if ( j == 0 or i==1 or(i==0 and j!=1)) {
				dis[i][j] = INFLL;
			}
			//clog << dis[i][j]<<" ";
		//	fprintf(stderr, "%15lld ", dis[i][j]);
			if (i == n - 1 or j == n - 1) {
				det[i][j] = dis[i][j];
			}
		}
	//	clog << endl;
	}
	cout<<max(abs(a[1]-a[n+1]),abs(a[n]-a[n+1]));
}
/*
100  1000 10   100  100
---- star ---- ---- ----
---- ---- 0090 0000 0900
---- 0000 ---- 0000 0090
---- 0000 0000 ---- 0000
---- 0900 0090 0000 ----

*/

Measured memory_bytes: 65984
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Array.ST
import Data.Array (elems)
import Data.Maybe (fromJust)
import Debug.Trace

toYesNo :: Bool -> String
toYesNo True = "YES"
toYesNo _ = "NO"


solve :: Int -> Int -> Int -> String
solve a b c = toYesNo ((b - a) == (c - b))


main :: IO ()
main = do
    (a:b:c:_) <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    putStrLn $ solve a b c



Measured memory_bytes: 380
A,B,m=map(int,input().split())
xyc=[]
a=[]
b=[]

s=list(map(int,input().split()))
for i in range(A):
  a.append([s[i],i])
a.sort()
t=list(map(int,input().split()))
for i in range(B):
  b.append([t[i],i])
b.sort()
ans=a[0][0]+b[0][0]

for i in range(m):
  p,q,r=map(int,input().split())
  ans=min(ans,s[p-1]+t[q-1]-r)

print(ans)

Measured memory_bytes: 38268
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;
const int MAXN = 200;
char B[MAXN][MAXN];
int W,H,cnt;

int dx[5] = {1,0,-1,0};
int dy[5] = {0,1,0,-1};

void isStar(int y, int x)
{
	for(int i =0 ; i<5;i++)
		if(B[y+dy[i]][x+dx[i]]=='*')
			{B[y+dy[i]][x+dx[i]]='0';isStar(y+dy[i],x+dx[i]);}
}

void isSharp(int y, int x)
{
	for(int i =0 ; i<5;i++)
		if(B[y+dy[i]][x+dx[i]]=='#')
			{B[y+dy[i]][x+dx[i]]='0';isSharp(y+dy[i],x+dx[i]);}
}

void isAt(int y, int x)
{
	for(int i =0 ; i<5;i++)
		if(B[y+dy[i]][x+dx[i]]=='@')
			{B[y+dy[i]][x+dx[i]]='0';isAt(y+dy[i],x+dx[i]);}
}



void solve()
{

	for(int i = 1; i<=H;i++)
		for(int j = 1; j<=W;j++)
		{
			if(B[i][j] == '*')
			{
				B[i][j] = '0';
				cnt++;
				isStar(i,j);
			}
			else if(B[i][j] == '#')
			{
				B[i][j] = '0';
				cnt++;
				isSharp(i,j);
			}
			else if(B[i][j] == '@')
			{
				B[i][j] = '0';
				cnt++;
				isAt(i,j);
			}
		}
	
	cout << cnt<<endl;
}

int main()
{
	
	
	
	while(cin >>H>> W && W||H)
	{
		memset(B,'0',sizeof(B));
		
		for(int i = 1; i<= H; i++)
		{
			for(int j = 1; j<= W; j++)
				cin >> B[i][j];
		getchar();
		}
		cnt = 0;
		solve();
	}
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll d[1000000];

bool f(int k){
  ll m = 1<<(k+1);
  rep(i,n){
    c[i]=a[i]%m;
    d[i]=b[i]%m;
  }
  sort(d,d+n);
  ll ans = 0;
  m/=2;
  rep(i,n){
    ans += lower_bound(d,d+n,2*m-c[i])-lower_bound(d,d+n,m-c[i]);
    ans += lower_bound(d,d+n,4*m-c[i])-lower_bound(d,d+n,3*m-c[i]);
  }

  return ans%2;
}


int main(){
  cin>>n;

  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }

  ll ans=0;

  rep(i,29){
    if(f(i))
      ans += 1 << i;

  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n,k;
    cin >> n >> k;
    std::string s;
    cin >> s;
    std::vector<int> len;
    char now = s[0];
    int nlen = 1;
    int out = 0;
    for(int i = 1; i < n; i++){
        if(now != s[i]){
            out += nlen - 1;
            len.pb(nlen);
            now = s[i];
            nlen = 1;
        } else {
            nlen++;
        }
    }
    out += nlen - 1;
    len.pb(nlen);
    if( (len.size() - 1) / 2 + (len.size() - 1) % 2<= k){
        cout << n - 1 << endl;
    }/* else if( (len.size() - 1) / 2 + (len.size() - 1) % 2 <= k + 1){
        out += (k - 1) * 2 + 1;
        cout << out << endl;
    }*/ else {
        out += k * 2;
        cout << out << endl;
    }
    return 0;
}

Measured memory_bytes: 1480
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;

ll INF = 1e+18;
int iINF = 1e9;

int 
main()
{
  ll A;
  double B; cin >> A >> B;
  ll B100 = B * 100 + 0.5;
  ll ans = A * B100;
  ans /= 100;
  cout << ans << endl;
}

Measured memory_bytes: 3640
// g++ A.cpp -Wall -Wextra -Woverflow -Wshadow -O2
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pii> edge;

int n;
LL a[200005];
LL get(int x) {
  LL ret = 0;
  for (int i = 0; i < n; i++) {
    ret += abs(a[i] - (LL)(x + i + 1));
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  LL L = -1e10, R = 1e10;
  while (L + 2 < R) {
    LL mid1 = L + (R - L) / 3;
    LL mid2 = R - (R - L) / 3;
    LL val1 = get(mid1), val2 = get(mid2);
    if (val1 > val2) {
      L = mid1 + 1;
    } else if (val1 < val2) {
      R = mid2 - 1;
    } else {
      L = mid1 + 1;
      R = mid2 - 1;
    }
  }
  LL ans = LLONG_MAX;
  for (LL i = L; i <= R; i++) {
    ans = min(ans, get(i));
  }
  cout << ans << endl;
} 

Measured memory_bytes: 5168
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int R, G, B, N;
int cnt = 0;

int main(){
	cin >> R >> G >> B >> N;
	
	REP(i,N/R+1){
		REP(j,(N-(R*i))/G+1){
			if ((N-(R*i)-(G*j))%B == 0)	cnt++;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    double d;
    while (cin >> d) {
        double ret = d;
        for (int i = 2; i <= 10; i++) {
            if (i % 2 == 0) {
                d *= 2.0;
            } else {
                d /= 3.0;
            }

            ret += d;
        }

        printf("%.8lf\n", ret);
    }

    return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int K,N,D=0;
  scanf("%lld%lld",&K,&N);
  
  long long int A[N];
  for (int i = 0 ; i<N; i++){
    scanf("%lld",&A[i]);
    
  }
  long long int d = K- A[N-1]+A[0];
  for (int i=0;i<N-1;i++){
    d=max(d,A[i+1]-A[i]);
  }
  
  

  printf("%lld", K-d);
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define IL inline
#define _ 200005
#define ll long long
#define RG register
using namespace std ;

IL int gi() {
	RG int data = 0 , fu = 1 ; RG char ch = 0 ;
	while(ch != '-' && (ch < '0' || ch > '9')) ch = getchar() ; if(ch == '-') fu = -1 , ch = getchar() ;
	while('0' <= ch && ch <= '9') data = (data << 1) + (data << 3) + (ch ^ 48) , ch = getchar() ; return data * fu ;
}

int n , A , B ; 

void dfs(int b , int x , int fn) {
	if(__builtin_popcount(fn ^ ((1 << n) - 1)) == 1) {cout << x << " " << (b ^ x) << " " ;return ;  }
	for(int i = 0; i < n; i ++)
		if(!(fn & (1 << i)) && (b & (1 << i)))
			for(int j = 0; j < n; j ++)
				if(!(fn & (1 << j)) && i != j) {
					dfs(1 << j , x , fn | (1 << i)) ;
					dfs(b ^ (1 << j) ^ (1 << i) , x ^ (1 << j) ^ (1 << i) , fn | (1 << i)) ; return ; 
				}
	return ; 
}

int main() {
	n = gi() ; A = gi() ; B = gi() ;
	if(__builtin_popcount(A^B)&1) {puts("YES") ;dfs(A ^ B , A , 0) ;puts("") ; }
	else puts("NO") ;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
string S;
int A[26];

signed main(void) {
    cin >> N >> S;
    int ans = 1;
    rep(i, 26) A[i] = 0;
    rep(i, N) {
        A[S[i]-'a']++;
    }
    rep(i, 26) {
        ans = ans * (A[i]+1) % mod;
    }
    cout << ans-1 << endl;
    return 0;
}

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


struct edge{int to,cap,rev;};

const int MAX_SIZE=202;
const int INF=1e9;

int X,Y,E;
vector<edge>G[MAX_SIZE];

void add_edge(int from,int to,int cap){
    G[from].push_back((edge){to,cap,G[to].size()});
    G[to].push_back((edge){from,0,G[from].size()-1});
}

bool used[MAX_SIZE];
int dfs(int p,int t,int f){
    if(p==t)return f;
    used[p]=true;

    for(int i=0;i<G[p].size();i++){
        edge &e=G[p][i];
        if(used[e.to]||e.cap==0)continue;
        int _f=dfs(e.to,t,min(f,e.cap));
        if(_f){
            e.cap-=_f;
            G[e.to][e.rev].cap+=_f;
            return _f;
        }
    }

    return 0;
}

int max_flow(int s,int t){
    int flow=0;
    while(true){
        fill_n(used,MAX_SIZE,false);
        int f=dfs(s,t,INF);
        if(f)flow+=f;
        else return flow;
    }
}
int main(){
    cin>>X>>Y>>E;
    int s=X+Y,t=s+1;

    for(int i=0;i<X;i++)add_edge(s,i,1);
    for(int i=0;i<Y;i++)add_edge(X+i,t,1);

    for(int i=0;i<E;i++){
        int x,y;cin>>x>>y;
        add_edge(x,y+X,1);
    }

    cout<<max_flow(s,t)<<endl;
    return 0;
}

//348504373

Measured memory_bytes: 1536
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
#define debug(x)    cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n,k;
    cin>>n>>k;
    vi a(n);
    f(i,n)cin>>a[i];
    set<int> s;
    int i=0;
    vi p;
    p.pb(1);
    s.insert(1);
    vi cycle;
    vi noncycle;
    int store;
    while(true)
    {
        if(s.find(a[i])!=s.end())
        {
            store=a[i];
            break;
        }
        else
        {
            s.insert(a[i]);
            p.pb(a[i]);
            i=a[i]-1;
        }
    }
    bool flag=true;
    for(int i=0;i<(int)p.size();i++)
    {
        if(p[i]==store)flag=false;
        if(flag)noncycle.pb(p[i]);
        else cycle.pb(p[i]);
    }
    if(k<(int)noncycle.size())
    {
        print(noncycle[k]);
    }
    else
    {
        k-=(int)noncycle.size();
        print(cycle[(k%(int)cycle.size())])
    }
    
    
    
    
    
    
    
    return 0;
}

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

typedef long long int ll;

int main(){
  ll N;
  cin>>N;
  ll sum = 0;
  for(ll i = 1;i < N;i++){
     sum += i;
  }
  ll ans = sum + N % 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r, g, b, n;
    cin >> r >> g >> b >> n;
    ll res = 0;
    vector<ll> poss (n + 1, 0);
    F0R(i, n/r + 1)
    {
        F0R(j, n/g + 1)
        {
            ll sum = i * r + g * j ; 
            if(sum > n) break;
            else poss[sum]++;
        }
    }
    F0R(i, n/b + 1)
    {
        if(i * b <= n)
        res += poss[n - i * b];
    }
    // F0R(i, n + 1) cout << poss[i] << " ";
    // cout << "\n";
    cout << res;
    return 0;
}

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

using namespace std;

int F[1 << 15][15], Mx[15][1 << 15], Sm[1 << 15], B[15][15], Tmp[15], n, m;

vector <int> hsh[1 << 15];

void cmax(int& x, int y) {if(x < y) x = y;}

int main()
{
	scanf("%d%d", &n, &m), memset(B, -1, sizeof B);
	for(int i = 1; i <= m; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c), a--, b--;
		B[a][b] = B[b][a] = c;
	}
	memset(Mx, -1, sizeof Mx), memset(F, 200, sizeof F);
	for(int i = 0; i < (1 << n); i++)
		for(int j = 0; j < n; j++) if(i >> j & 1) hsh[i].push_back(j);
	for(int i = 0; i < (1 << n); i++)
		for(int j = 0; j < n; j++) if(i >> j & 1)
			for(int k = j + 1; k < n; k++) if((i >> k & 1) && B[j][k] != -1) Sm[i] += B[j][k];
	for(int i = 0; i < n; i++)
		for(int j = 1; j < (1 << n); j++)
			for(int k = 0; k < n; k++) if(j >> k & 1) {
				Mx[i][j] = max(B[i][k], Mx[i][j - (1 << k)]);
				break;
			}
	for(int i = 1; i < (1 << n); i += 2) F[i][0] = Sm[i];
	for(int i = 1; i < (1 << n); i += 2) {
		memset(Tmp, 200, sizeof Tmp);
		for(int j = 0; j < n; j++) if(F[i][j] >= 0)
			for(int k = 0; k < n; k++) if(B[j][k] != -1)
				cmax(Tmp[k], F[i][j] + B[j][k]);
		for(int s = (1 << n) - i - 1, j = s; j; j = (j - 1) & s)
			for(int k = 0; k < hsh[j].size(); k++)
				cmax(F[i + j][hsh[j][k]], Tmp[hsh[j][k]] + Sm[j]);
	}
	printf("%d\n", Sm[(1 << n) - 1] - F[(1 << n) - 1][n - 1]);
	return 0;
}

Measured memory_bytes: 6912
#!/usr/bin/env python2
"""
This file is part of https://github.com/cheran-senthil/PyRival
Copyright 2019 Cheran Senthilkumar <hello@cheran.io>

"""
from __future__ import division, print_function

import itertools
import os
import sys
from atexit import register
from io import BytesIO


class dict(dict):
    """ dict() -> new empty dictionary """

    def items(self):
        """ D.items() -> a set-like object providing a view on D's items """
        return dict.iteritems(self)

    def keys(self):
        """ D.keys() -> a set-like object providing a view on D's keys """
        return dict.iterkeys(self)

    def values(self):
        """ D.values() -> an object providing a view on D's values """
        return dict.itervalues(self)


def gcd(x, y):
    """ greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x


range = xrange

filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')


def main():
    a, b = map(int, input().split())

    def solve(m, n):
        if m % 2 == 0:
            res = [n, 1, n ^ 1, 0]
        else:
            res = [m, m ^ n, m - 1, (m - 1) ^ n]
        return res[(n - m) % 4]

    print(solve(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 29164
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int K = sc.nextInt();
			int[] list = new int[N];
			for(int i = 0 ; i < N ; i++){
				list[i] = sc.nextInt();
			}
			Arrays.sort(list);
			int result = 0;
			for(int i = N-1 ; i > N-K-1; i--){
				result += list[i];
			}
			System.out.println(result);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long int
using namespace std;

signed main()
{ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<int> arr(100001,0);
    multiset<int> M;
    int n,sum=0,t;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        arr[t]++;
        sum +=t;
    }
    int q;
    cin>>q;
    int b,c;
    for(int i=0;i<q;i++)
    {
        cin>>b>>c;
        sum -= (arr[b]) * b;
        sum += (arr[b])*c;
        arr[c] +=arr[b];
        arr[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int rc(int lim, int s, int b){
    if(lim){
        return (!s && b) ? 0 : 1;
    }else{
        if(!b) return s;
        return 2-s;
    }
}
int lc(int lim, int s, int b){
    if(!lim){
        return (!s && !b) ? 0 : 1;
    }else{
        if(b) return s;
        return 2-s;
    }
}

int main(){
    int64_t L, R;
    cin >> L >> R;

    static int64_t dp[61][3][3][2];
    dp[60][0][0][0] = 1;
    for(int d=59; d>=0; d--) for(int a=0; a<2; a++) for(int b=0; b<2; b++) for(int c=0; c<2; c++){
        int64_t s = dp[d+1][a][b][c];
        int br = nth_bit(R, d), bl = nth_bit(L, d);
        add(dp[d][rc(br, a, 0)][lc(bl, b, 0)][c], s);
        if(c) add(dp[d][rc(br, a, 1)][lc(bl, b, 0)][1], s);
        add(dp[d][rc(br, a, 1)][lc(bl, b, 1)][1], s);
    }
    int64_t ans = 0;
    for(int a=0; a<2; a++) for(int b=0; b<2; b++) add(ans, dp[0][a][b][1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
long calc(int x, int y, int z)
{
	return x*x + y*y + z*z + x*y + y*z + z*x;
}

long long int a[10001];

int main()
{
	long long int val;
	int x, y, z, n;
  	cin>>n;
  	
  	for(int x = 1; x<=n; x++)
  	{
  		for(int y = 1; y<=n; y++)
  		{
  			for(int z = 1; z<=n; z++)
  			{
  				val = calc(x,y,z);
	  			if(val<10001) a[val]++;
	  			else break;
  			}
  		}		
  	}

  	for(int i = 1; i<=n; i++)
  	{
  		cout<<a[i]<<"\n";
  	}
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 300050; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

struct segTree
{
    vector<ll> a,t;
    ll n;
    segTree(ll sz)
    {
        n = sz;
        a.resize(n, 0);
        t.resize(4*n, 0);
    }
    ll merge(ll left,ll right)
    {
        ll ans = max(left , right);
        return ans;
    }
    void build(ll v,ll tl,ll tr)
    {
        if(tl==tr)
        {
            t[v] = a[tl];
        }
        else
        {
            ll tm = (tl + tr)/2;
            build(2*v,tl,tm);
            build(2*v+1,tm+1,tr);
            t[v] = merge(t[2*v],t[2*v+1]);
        }
    }
    void update(ll v,ll tl,ll tr,ll pos,ll new_val)
    {
        if(tl==tr)  
        {
            t[v] = new_val;
        }
        else
        {
            ll tm = (tl + tr)/2;
            if(pos<=tm)
            {
                update(2*v,tl,tm,pos,new_val);
            }
            else
            {
                update(2*v+1,tm+1,tr,pos,new_val);
            }
            t[v] = merge(t[2*v],t[2*v+1]);
        }
    }
    ll query(ll v,ll tl,ll tr,ll l,ll r)
    {
        if(l>r)   return 0;
        if(l==tl && r==tr)   return t[v];
        ll tm = (tl + tr)/2;
        return merge(query(v*2, tl, tm, l, min(r, tm)),query(v*2+1, tm+1, tr, max(l, tm+1), r));
    }
};


void solve()
{
    ll n,k;
    cin >> n >> k;
    ll a[n];
    segTree s(N);
    ll dp[n];
    for(ll i=0;i<n;i++)
    {
        cin >> a[i];
        ll mini = a[i] - k;
        ll maxi = a[i] + k;
        mini = max(mini,0LL);
        maxi = min(maxi,(ll)N-10);
        ll ans = s.query(1,0,N-1,mini,maxi);
        ans++;
        s.update(1,0,N-1,a[i],ans);
    }
    ll ans = s.query(1,0,N-1,0,N-1);
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 17196
#include <stdio.h>

int main(void){
        int i,j,k;
        int h[10];
        for(i = 0; i < 10; i++){
                scanf("%d", &h[i]);
        }
        for(i = 0; i < 10; i++){
                for(j = 0; j < 10; j++){
                        if(h[i] > h[j]){
                                k = h[i];
                                h[i] = h[j];
                                h[j] = k;
                        }
                }
        }
        for(i= 0; i < 3; i++){
                printf("%d\n", h[i]);
        }
return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python
# coding: utf-8

from collections import Counter

def main():
    inf = float("inf")
    dp = [[-inf for _ in range(2)] for _ in range(42)]
    dp[41][0] = 0

    n, k = list(map(int, input().split()))
    As = list(map(int, input().split()))
    ans = 0
    x = 0
    for i in range(40, -1, -1):
        pow2i = 1 << i
        c = 0
        for a in As:
            if (a >> i) & 1:
                c += 1
        bit = (k >> i) & 1
        dp[i][1] = max(n-c, c) * pow2i + dp[i+1][1]
        if bit == 0:
            dp[i][0] = c * pow2i + dp[i+1][0]
        else:
            dp[i][0] = (n - c) * pow2i + dp[i+1][0]
            dp[i][1] = max(dp[i][1], c * pow2i + dp[i+1][0])
    ans = max(dp[0][0], dp[0][1])
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 15004
#include<bits/stdc++.h>
using namespace std;
long long  k,a,b,ans;
void work(){
	ans=1;
	if(b<=a+2){
		ans=ans+k;return ;
	}
	if(ans<a){
		if(ans+k<=a){
			ans=ans+k;return ;
		}
		k-=(a-ans);ans=a;
	}
	ans+=(k/2)*(b-a);
	if(k%2==1)ans++;
	return ;
}
int main(){
	cin>>k>>a>>b;
	work();
	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
	double L;
	double x, y, z;
	int temp;
	cin >> L;
	//temp = L % 3;
	x = L / 3;
	y = L / 3;
	z = L / 3;
	printf("%lf\n",  x * y * z);
	return 0;
}

Measured memory_bytes: 256
import java.lang.Math.*


fun main(args: Array<String>) {
    val r = readLongList().first()
    println(3 * r * r)
}


fun readList() = readLine()!!.split(' ')
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  cin >> n;

  if(n%1000 != 0) cout << 1000 * (n/1000 + 1) - n << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 3632
using AtCoderBeginnerContest153.Questions;
using AtCoderBeginnerContest153.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest153.Questions
{
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            long h = inputStream.ReadLong();
            long count = 0;
            long monsters = 1;

            while (h > 0)
            {
                count += monsters;
                h >>= 1;
                monsters <<= 1;
            }

            yield return count;
        }
    }
}


namespace AtCoderBeginnerContest153
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest153.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest153.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11220
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

sa1 = [0]*(N+1)
sa2 = [0]*(N+1)

for i in range(N):
    sa1[i+1] = sa1[i] + A1[i]
    sa2[i+1] = sa2[i] + A2[i]

ans = 0
for i in range(1, N+1):
    ans = max(ans, sa1[i] + sa2[N] - sa2[i-1])

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int p=0,f=1; char c=getchar();
	while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ p=(p<<3)+(p<<1)+(c^48); c=getchar();}
	return f*p;
}
int a,b,ans,ansa,ansb;
int main(){
	a=read(); b=read();
	ans=a+b; ansa=a+a-1; ansb=b+b-1;
	ans=max(ans,max(ansa,ansb));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int x,y,ans;
	
	scanf("%d %d",&x,&y);
	if(x%y==0){
		ans=-1;
	}else{
		ans=x;
	}
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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; }

int main() {
  int N; cin >> N;
  vector<int> h(N);
  rep (i, N) cin >> h[i];

  bool flag = true;
  int mi = 1e9 + 1;
  rrep (i, N) {
    
    if (h[i] - 1 > mi){
      flag = false;
      break;
    }
    else if (h[i] > mi && h[i] - 1 <= mi) {
      h[i] --;
    }
    chmin(mi, h[i]);
  }

  if (flag)
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int m[] = {500,100,50,10,5,1};
    while(1){
    int n;
    scanf("%d",&n);
    if(n == 0)
        break;
    n = 1000 - n;
    
    int c = 0;int i = 0;
    while(n > 0){
        if(n < m[i]){
            i++;
        }else{
            n -= m[i];
            c++;
        }
    }
    printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    long long a;
    cin >> a;

    long long result = 1e18;
    for (long long i = 1; i * i <= a; i++) {
        if (a % i == 0) {
            result = min(result, i + a / i - 2);
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main (){

  int N = 0, M = 0;
  scanf("%d %d", &N, &M);

  int H[N], A[M], B[M];
  int i = 0;
  for( i = 0; i < N; i++ ){
    scanf("%d", &H[i]);
  }
  for( i = 0; i < M; i++ ){
    scanf("%d %d", &A[i], &B[i]);
  }

  int check[N];
  for( i = 0; i < N; i++ ){
    check[i] = 1;
  }

  for( i = 0; i < M; i++ ){
    if( H[A[i] - 1] < H[B[i] - 1] ){
      check[A[i] - 1] = 0;
    }
    else if( H[A[i] - 1] > H[B[i] - 1] ){
      check[B[i] - 1] = 0;
    }
    else if( H[A[i] - 1] == H[B[i] - 1] ){
      check[A[i] - 1] = 0;
      check[B[i] - 1] = 0;
    }
  }

  int res = 0;
  for( i = 0; i < N; i++ ){
    res = res + check[i];
  }

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

  return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    C = C - (A - B);
    if(C < 0) cout << 0 << endl;
    else cout << C << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i], a[i]--;

    vector<ll> cnt(n);
    REP(i, n) cnt[a[i]]++;

    ll sum = 0;
    REP(i, n) sum += cnt[i]*(cnt[i]-1)/2;
    REP(i, n) {
        ll tsum = sum;
        tsum -= cnt[a[i]]*(cnt[a[i]]-1)/2;
        tsum += (cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        cout << tsum << "\n";
    }

    return 0;
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
const int maxn=200001;
/*****************************************************************************/

using namespace std;

ll n,i,j;
ll a[maxn],b[maxn];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);ll n;
	cin>>n;
	for (i=0;i<n;i++) cin >>a[i] >>b[i];
	sort(a,a+n);
	sort(b,b+n);
	if (n%2==1) {
		ll x=a[(n+1)/2-1],y=b[(n+1)/2-1];
		cout <<y-x+1 <<endl;
	}
	else {
		ll x=a[n/2-1]+a[n/2],y=b[n/2-1]+b[n/2];
		cout <<y-x+1 <<endl;
	}
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 6764
#include <stdio.h>

int main()
{
  int n;

  scanf("%d", &n);

  int L, R;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &L, &R);
    int x = R - L + 1;
    ans += x;
  }

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


  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int q1, b, c1, c2, q2;
    int cg1, cg2;    
    int i;
    
    while (1){
        scanf("%d", &q1);
        if (q1 == 0){
            break;
        }
        scanf("%d%d%d%d", &b, &c1, &c2, &q2);
        // 予算はb
        // q1以上買う
        // c1をたくさん買う
        // 残りでc2をたくさん買う
        // c1はq2以下しか買えない
        
        
        for (i = q2; i >= 1; i--){
            cg1 = cg2 = 0;
            if (b < i * c1){       // 買えるか？
                continue;
            }
            cg1 = i;
            cg2 = (b - cg1 * c1) / c2;           // 残りでふつうの鶏肉を買う
            if (q1 <= cg1 + cg2){   // 決められた以上買えたか
                break;
            }
        }

        if (q1 <= cg1 + cg2){   // 決められた以上買えたか
            printf("%d %d\n", cg1, cg2);
        }
        else {
            printf("NA\n");
        }
    }
    return (0);
}

Measured memory_bytes: 612