akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  long long int N;
  cin >> N;
  int ans = 999;
  for(int i = 1; i <= sqrt(N)+1; i++) {
    if(N % i == 0) {
      long long int k = N / i;
      ans = min(ans,(int)max(log10(k)+1,log10(i)+1));
    }
  }
  cout << ans << endl;


}


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

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 ll llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    int H,W,M;
    cin >> H >> W >> M;

    //vector<vector<bool>> b(H, vector<bool>(W));
    vector<int> hb(H);
    vector<int> wb(W);
    //vector<P> b(M);
    set<P> b;


    int hi,wi;
    rep(mi,M){
        cin >> hi >> wi;
        hi--; wi--;
        hb[hi]++; wb[wi]++;
        //b[mi] = P(hi,wi);
        b.emplace(hi,wi);
        //b[hi][wi] = 1;
    }
    
    /*
    rep(hi,H){
        rep(wi,W){
            ans = max(ans, hb[hi]+wb[wi]-b[hi][wi]);
        }
    }
    */
    
    int hmax,wmax;
    hmax = *max_element(hb.begin(),hb.end());
    wmax = *max_element(wb.begin(),wb.end());

    vector<int> hl,wl;
    rep(hi,H) if(hb[hi]==hmax) hl.push_back(hi);
    rep(wi,W) if(wb[wi]==wmax) wl.push_back(wi);

    int ans = hmax + wmax;
    for(int hi : hl) for(int wi : wl){
        if( b.count(P(hi,wi)) )continue;
        cout << ans << endl;
        return 0;
    }
    cout << ans-1 << endl;


    /*
    rep(hi,H){
        if(hb[hi]==hmax){
            rep(wi,W){
                if(wb[wi]==wmax){
                    f = false;
                    rep(mi,M){
                        if(b[mi].first==hi && b[mi].second==wi){
                            f = true;
                            break;
                        }
                    }
                    if(!f){
                        cout << hmax+wmax << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout << hmax+wmax-1 << endl;
    */


    /*
    vector<vector<int>> b(H, vector<int>(W));

    int hi,wi;
    rep(mi,M){
        cin >> hi >> wi;
        hi--; wi--;
        rep(i,H) b[i][wi]++;
        rep(i,W) b[hi][i]++;
        b[hi][wi]--;
    }
    int ans;
    vector<int> bh(H);
    rep(i,H) bh[i] = *max_element(b[i].begin(), b[i].end());

    cout << *max_element(bh.begin(), bh.end()) << endl;
    */


    return 0;
}

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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;


signed main()
{
//	#ifndef ONLINE_JUDGE
//		freopen("./input.txt","r",stdin);
//		freopen("./output.txt","w",stdout);
//	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
    cin>>n;
    int arr[n+1];
    for(int i=1; i<=n; i++){
        cin>>arr[i];
    }
    cin>>m;
    for(int i=1; i<=m; i++){
        int idx; cin>>idx;
        if(arr[idx]+1>2019) continue;
        if( arr[idx]+1==arr[idx+1]) continue;
        arr[idx]++;
    }
    for(int i=1; i<=n; i++){
        cout<< arr[i]; br;
    }
}


Measured memory_bytes: 3216
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int n, q, s, t, x;
    cin >> n >> q;
    vector<vector<int>> arr;
    int ans[q];
    for (int i=0; i<n; i++) {
        cin >> s >> t >> x;
        arr.push_back({s-x, 1, x});
        arr.push_back({t-x, 0, x});
    }
    for (int i=0; i<q; i++) {
        cin >> x;
        arr.push_back({x, 2, i});
    }
    set<int> ms;
    sort(arr.begin(), arr.end());
    for (auto i : arr) {
        if (i[1] == 0) ms.erase(i[2]);
        else if (i[1] == 1) ms.insert(i[2]);
        else {
            if (ms.empty()) ans[i[2]] = -1;
            else ans[i[2]] = *ms.begin();
        }
    }
    for (int i : ans) cout << i << endl;
}

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

#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
const long long INF=1e18;
typedef pair<ll,ll> pll;
#define F first
#define S second



signed main(){
  string a,b;
  cin>>a>>b;
  vector<pll> A(a.size()+2,{INF,INF}),B(b.size()+2,{INF,INF});
  ll mi0=INF;
  ll mi1=INF;
  for(ll i=a.size()-1;i>=0;i--){
    A[i+1]={mi0,mi1};
    if(a[i]=='0'){mi0=i+1;}
    else{mi1=i+1;}
  }
  
  A[0]={mi0,mi1};
  mi0=INF;
  mi1=INF;
  for(ll i=b.size()-1;i>=0;i--){
    B[i+1]={mi0,mi1};
    if(b[i]=='0'){mi0=i+1;}
    else{mi1=i+1;}
  }
  B[0]={mi0,mi1};
  vector<vector<pll>> dp(a.size()+2,vector<pll>(b.size()+2,{INF,-1}));
  for(ll i=a.size()+1;i>=0;i--){
    for(ll t=b.size()+1;t>=0;t--){
      if(A[i].F==INF && B[t].F==INF){dp[i][t]={1,0};}
      else if(A[i].S==INF && B[t].S==INF){dp[i][t]={1,1};}
      else{
	dp[i][t].F=dp[(A[i].F==INF?(ll)a.size()+(ll)1:A[i].F)][(B[t].F==INF?(ll)b.size()+(ll)1:B[t].F)].F+1;
	dp[i][t].S=0;
	if(dp[i][t].F>dp[(A[i].S==INF?(ll)a.size()+1:A[i].S)][(B[t].S==INF?(ll)b.size()+1:B[t].S)].F+1){
	  dp[i][t].F=(dp[A[i].S==INF?(ll)a.size()+1:A[i].S][B[t].S==INF?(ll)b.size()+1:B[t].S].F+1);
	  dp[i][t].S=1;
	}
      }
    }
  }
  
  ll wx=0,wy=0;
  while(wx!=a.size()+1 || wy!=b.size()+1){
    cout<<dp[wx][wy].S;
    if(dp[wx][wy].S==0){
      wx=(A[wx].F==INF?(ll)a.size()+1:A[wx].F);
      wy=(B[wy].F==INF?(ll)b.size()+1:B[wy].F);
    }
    else{
      wx=(A[wx].S==INF?(ll)a.size()+1:A[wx].S);
      wy=(B[wy].S==INF?(ll)b.size()+1:B[wy].S);
    }
  }
  cout<<endl;
  
  
  return 0;
}



Measured memory_bytes: 253336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int H, W;
  cin >> H >> W;
  
  //1行目
  for (int i = 0; i < W+2; i++){
    cout << "#" ;
  }
  cout << endl;
  
  //最後の手前まで
  for (int i = 0; i < H; i++){
    string mozi;
    cin >> mozi;
    cout << "#" << mozi << "#" << endl;
  }
  
  //最後
  for (int i = 0; i < W+2; i++){
    cout << "#" ;
  }
  cout << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#if 1
    #define u8 unsigned char
    #define u16 unsigned short
    #define u32 unsigned int
    #define u64 unsigned long
    #define s8 char
    #define s16 short
    #define s32 int
    #define s64 long
    #define f32 float
    #define f64 double
    #define forin(_x,_y) for(auto& _x: _y)
    #define iter(_i,_c) for(size_t _i=0; _i<_c; ++_i)
    #define rangeloop(_i,_begin,_end) for(size_t _i=_begin; _i<_end; ++_i)
#endif

using namespace std;
#if 1
    int ctoi(char a){return a-'0';}

    template<class T> T max(const vector<T> &x){return *std::max_element(x.begin(), x.end());}
    template<class T> T min(const vector<T> &x){return *std::min_element(x.begin(), x.end());}
    template<class T> size_t argmax(const vector<T> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T> size_t argmin(const vector<T> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T> T sum(const vector<T> &x){ return std::accumulate(x.begin(), x.end());}
    template <class T> void sort(vector<T> &x){sort(x.begin(), x.end());}
    template <class T, class Compare> void sort(vector<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T> void len(const vector<T> &x){return x.size();}
    template<class T> ostream& operator<<(ostream& os, const vector<T> &x){forin(y,x)os<<y<<" "; return os;}

    template<class T, size_t SIZE> T max(const array<T,SIZE> &x){return *std::max_element(x.begin(), x.end());}
    template<class T, size_t SIZE> T min(const array<T,SIZE> &x){return *std::min_element(x.begin(), x.end());}
    template<class T, size_t SIZE> size_t argmax(const array<T,SIZE> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T, size_t SIZE> size_t argmin(const array<T,SIZE> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
    template<class T, size_t SIZE> T sum(const array<T,SIZE> &x){ return std::accumulate(x.begin(), x.end());}
    template<class T, size_t SIZE> void sort(array<T,SIZE> &x){sort(x.begin(), x.end());}
    template<class T, size_t SIZE, class Compare> void sort(array<T,SIZE> &x, Compare comp){sort(x.begin(), x.end(),comp);}
    template<class T, size_t SIZE> ostream& operator<<(ostream& os, const array<T,SIZE> &x){forin(y,x)os<<y<<" "; return os;}
#endif

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

    u32 N;
    cin>>N;

    array<array<u64,10>,10> mat;
    iter(i,10)iter(j,10) mat[i][j]=0;

    rangeloop(i, 1, N+1){
        string s = to_string(i);
        char begin = s[0]-'0';
        char end = s[s.size()-1]-'0';
        mat[begin][end] ++;
    }
    u64 res = 0;
    iter(i,10)iter(j,10){
        res+= mat[i][j]*mat[j][i];
    }
    cout<<res;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>
#include <numeric>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define rng mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count())

#define ri(...) i64 __VA_ARGS__; rx(__VA_ARGS__)
#define rc(...) char __VA_ARGS__; rx(__VA_ARGS__)
#define rs(...) string __VA_ARGS__; rx(__VA_ARGS__)
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << '[' << #__VA_ARGS__ << "]: "; dbg_log(__VA_ARGS__)
#else
#define dbg(...) ;;
#endif

#define fa(i, v) for (auto &i : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(i) ri(_i); fi(i, _i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
#ifdef __SIZEOF_INT128__
typedef __uint128_t u128;
typedef __int128_t i128;
#endif
typedef vector<i64> vi;
typedef vector<vi> vvi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) out << x << ' ';
    return out;
}

template<typename T>
inline void rx(T &x) {
    cin >> x;
}

template<typename T, typename... R>
inline void rx(T &x, R &... l) {
    cin >> x;
    rx(l...);
}

template<typename T>
inline void dbg_log(const T &x) {
    cerr << x << '\n';
}

template<typename T, typename... R>
inline void dbg_log(const T &x, const R &... l) {
    cerr << x << ", ";
    dbg_log(l...);
}

template<typename T>
inline void wl(const T &x) {
    cout << x << '\n';
}

template<typename T, typename... R>
inline void wl(const T &x, const R &... l) {
    cout << x << ' ';
    wl<R...>(l...);
}

int main() {
    fio;

    ri(k);
    i64 n = 7;
    i64 res = -1;
    fi(i, k) {
        n = n % k;
        if (n == 0) {
            res = i + 1;
            break;
        }
        n = 10 * n + 7;
    }
    wl(res);

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

int main(){
    int N;
    int X, Y;
    cin >> N >> X >> Y;
    X--; Y--;
    int ans[N+1];
    rep(i, N+1) {
        ans[i] = 0;
    }
    rep(i, N) {
        REP(j, i+1, N) {
            int d = min(j-i, abs(X-i) + 1 + abs(Y-j));
            ans[d]++;
        }
    }

    rep(i, N-1) {
        cout << ans[i+1] << endl;
    }
}



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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, w;
    cin >> n >> w;
    vector<pair<long long, long long> >item(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> item[i].first >> item[i].second;
    }
    sort(item.begin() + 1, item.begin() + 1 + n);
    long long dp[w + 1];
    for(long long i = 0; i <= w; i++) {
        dp[i] = 0;
    }
    for(long long i = 1; i <= n; i++) {
        for(long long j = w; j >= item[i].first; j--) {
            dp[j] = max(dp[j], item[i].second + dp[j - item[i].first]);
        }
    }
    cout << dp[w] << endl;
    return 0;
}


Measured memory_bytes: 1024
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    
    if(a <= c && c <= b) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}

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

int main(){
    int invx[4]={-1, 1,-1, 1};
    int invy[4]={ 1,-1, 1,-1};
    
    int rep;
    cin >> rep;
    for(int i=0; i<rep; i++){
        int m, n;
        cin >> m >> n;
        int lim = m*m +n*n;
        int count = 0;
        for(int p=0; p*p<lim; p++){
            for(int q=0; p*p+q*q<lim; q++){
                if(p==0 && q==0) continue;
                for(int j=0; j<4; j++){
                    if((p*m+q*n)%(p*p+q*q)==0 && (p*n-q*m)%(p*p+q*q)==0){
                        count++;
                    }
                    p *= invx[j];
                    q *= invy[j];
                }
            }
        }

        if(count == 8){
            cout << "P" << endl;
        }else{
            cout << "C" << endl;
        }
    }
    return 0;
}

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

int main()
{
	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.length()+1, vector<int>(t.length()+1));
	int s_size = s.length();
	int t_size = t.length();
	for(int i = 0; i < t_size; ++i)
		dp[0][i] = 0;
	for(int i = 0; i < s_size; ++i)
		dp[i][0] = 0;
	
	for(int i = 1; i <= s_size; ++i)
	{
		for(int j = 1; j <= t_size; ++j)
		{
			if(s[i-1] == t[j-1])
			{
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else
			{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	std::vector<char> ans;
	int i = s_size;
	int j = t_size;
	while(i > 0 && j > 0)
	{
		if(s[i-1] == t[j-1])
		{
			--i,--j;
			ans.push_back(s[i]);
		}
		else if(dp[i-1][j] > dp[i][j-1])
		{
			--i;
		}
		else
			--j;
	}

	for(int l = ans.size() - 1; l >= 0; --l)
		cout << ans[l];
}

Measured memory_bytes: 38548
#include<bits/stdc++.h>
using namespace std;
int a,b;

int main()
{	cin>>a>>b;
	if(b==1)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int i=1;i<=21;++i)
	{
		if(a>=b)
		{
			cout<<i<<endl;
			break;
		}
		b-=(a-1);
	}
	return 0;
} 

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

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

using namespace std;

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

int main(void){
  int a, b;
  cin >> a >> b;

  cout  << lcm(a, b) << endl;
  return 0;
}

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

int main(){
  string s;
  int check = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'C' && !(check)){
      check = 1;
    }
    else if(s[i] == 'F' && check){
      check = 2;
    }
  }
  
  if(check == 2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
char a[200],b[220],c[200];
int n;
int main()
{
	scanf("%d%s%s%s",&n,a+1,b+1,c+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[i]&&b[i]==c[i]) continue;
		if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i]) ans++;
		else ans+=2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7


def mpow(x, t):
    if t == 0:
        return 1
    a = mpow(x, t >> 1)
    return a * a * (x ** (t & 1)) % MOD


A.sort()
ans = 0
C = 1
for i in range(K, N + 1):
    ans += (A[i - 1] - A[N - i]) * C
    ans %= MOD
    C = C * i * mpow(i - K + 1, MOD - 2)
    C %= MOD
print(ans)


Measured memory_bytes: 14040
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
int h;
int n;
int a[10100];
int b[10100];
int dp[100100];
int main()
{
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=h;i++)
	{
		dp[i]=2000000000;
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=n;j++)
		{
			dp[i]=min(dp[i],dp[max(i-a[j],0)]+b[j]);
		}
	}
	printf("%d\n",dp[h]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long findNumberOfTriangles(long long arr[], long long n)
{
   long count = 0;
    for (long long i= 0; i < n; i++)
    {
        for (long long j = i + 1; j < n; j++)
        {
            for (long long k = j + 1; k < n; k++){
                    if(arr[i]==arr[j]||arr[k]==arr[j]||arr[i]==arr[k])
                    continue;
                    if (
                    arr[i] + arr[j] > arr[k]
                    && arr[i] + arr[k] > arr[j]
                    && arr[k] + arr[j] > arr[i])
                    count++;
            }


        }
    }
    return count;
}

int main()
{
    long long n,arr[104],i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>arr[i];

    cout<< findNumberOfTriangles(arr, n);

    return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    int las = 0;
    int res = 0;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        if (x > las) res += x-las;
        las = x;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
n = gets.chop.to_i
a1 = gets.chop.split.map(&:to_i)
a2 = gets.chop.split.map(&:to_i)

ans = 0

n.times do |i|
  ans = [a1[0,i+1].inject(:+) + a2[i,n-i].inject(:+), ans].max
end

p ans


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  pair<ll, ll> p[4];

  rep(i, 2) { cin >> p[i].first >> p[i].second; }

  p[2].first = p[1].first - (p[1].second - p[0].second);
  p[2].second = p[1].second + (p[1].first - p[0].first);

  p[3].first = p[0].first - (p[1].second - p[0].second);
  p[3].second = p[0].second + (p[1].first - p[0].first);

  cout << p[2].first << " " << p[2].second << " " << p[3].first << " "
       << p[3].second << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int s=0;
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9'){
		s=s*10+c-'0';c=getchar();
	}return s;
}
const int N=1e5+888;
int n,a[N],L,maxx,jl;
int main(){
	n=read();L=read();
	for(int i=1;i<=n;i++){a[i]=read();if(i>1){if(a[i-1]+a[i]>maxx)jl=i-1;maxx=max(maxx,a[i-1]+a[i]);}}
	if(maxx<L){
		puts("Impossible");return 0;
	}
	puts("Possible");
	for(int i=1;i<jl;i++)printf("%d\n",i);
	for(int i=n-1;i>jl;i--)printf("%d\n",i);
	cout<<jl;
	return 0;
}

Measured memory_bytes: 4096
<?php
$num = trim(fgets(STDIN));
$k = intval(fgets(STDIN));

$dp0 = array_fill(0, strlen($num)+1, array_fill(0, $k+1, 0));//not-max
$dp1 = array_fill(0, strlen($num)+1, array_fill(0, $k+1, 0));//max
$dp1[0][0] = 1;// N桁目 - 0以外の数
for($i = 1; $i <= strlen($num); $i++){
    for($j = 0; $j <= $k; $j++){
        $d = $num[$i-1];
        if($d == 0){
            $dp1[$i][$j] += $dp1[$i-1][$j];
        }else{
            $dp1[$i][$j] += $dp1[$i-1][$j-1] ?? 0;
        }
        $dp0[$i][$j] += ($dp0[$i-1][$j - 1]??0) * 9 + $dp0[$i-1][$j] + ($d ? $dp1[$i-1][$j] + ($dp1[$i-1][$j-1]??0) * ($d-1): 0);
    }
}
echo $dp0[strlen($num)][$k] + $dp1[strlen($num)][$k];



Measured memory_bytes: 4604
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn dfs(edges : &Vec<Vec<u32>>, mut visited : &mut Vec<bool>, cur : u32, end : u32) -> bool {
    if cur == end {
        return true;
    }
    if visited[cur as usize] {
        return false;
    }
    visited[cur as usize] = true;
    for next in &edges[cur as usize] {
        let ret = dfs(&edges, &mut visited, *next, end);
        if ret {
            return true;
        }
    }
    return false;
}

fn main() {
    let nm : Vec<usize> = get_vec();
    let n = nm[0];
    let m = nm[1];

    let mut es = Vec::new();
    for _i in 0..m {
        let ab : Vec<u32> = get_vec();
        es.push((ab[0],ab[1]));
    }

    let mut ans = 0;
    for i in 0..m {
        let mut edges : Vec<Vec<u32>> = vec!(Vec::new();n);
        for j in 0..m {
            if i != j {
                edges[(es[j].0-1) as usize].push(es[j].1-1);
                edges[(es[j].1-1) as usize].push(es[j].0-1);
            }
        }
        let mut visited = vec!(false; n);
        if !dfs(&edges, &mut visited, es[i].0-1, es[i].1-1) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i, N)
    cin >> a[i];
  //入力終わり

  //全部のXORを前計算
  int sum = 0;
  rep(i, N)
    sum = sum^a[i];

  //それぞれの値を計算
  rep(i, N){
    int ans = sum^a[i];
    cout << ans << " ";
  }
  cout << endl;
    
  return 0;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
 
int main(void){

     int a[5];
     cin>>a[1]>>a[2]>>a[3];
     sort(a+1,a+4);
     if(a[1]==a[2])
         std::cout<<a[3]<<std::endl;
     else 
         cout<<a[1]<<endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin() , (a).end()
#define rall(a) (a).rbegin() , (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 2e5 + 2 , intf = 2e9;
const ll inf = 2e18 , mod = 1e9 + 7;
const ld eps = 1e-9;


void solve(){
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


//#define DEBUG

signed main(){
	#ifdef DEBUG
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    #endif
 
    for (int t = 1; t--;) solve();
 
    #ifdef DEBUG
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif

	return 0;
}
/*


*/



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

int main(){
	int a,b;
	cin >> a >> b;

		if( a == b ){
		cout << "a == b" << endl;
		}else{
			if( a > b)
			{
			cout << "a > b" << endl;
			}else{
			cout << "a < b" << endl;
			}
		}

}


Measured memory_bytes: 3048
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

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

typedef pair<long double, long double> PLD;

PLD add(PLD p1, PLD p2) {
    PLD ret(p1.first + p2.first, p1.second + p2.second);
    return ret;
}

long double norm(PLD p) {
    return sqrt(p.first * p.first + p.second * p.second);
}

int main() {

    int N;
    cin >> N;

    vector<long double> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

    vector<PLD> xy(N);
    for (int i = 0; i < N; i++) xy[i] = make_pair(x[i], y[i]);

    sort(xy.begin(), xy.end(), [](const auto &p1, const auto &p2) {
        return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first);
    });

    long double ans = 0;

    for (int i = 0; i < N; i++) {
        PLD p(0, 0);
        for (int j = 0; j < N; j++) {
            p = add(p, xy[(i + j) % N]);
            ans = max(ans, norm(p));
        }
    }

    cout << fixed << setprecision(20) << ans << endl;

//    cout << atan2l(1, 1) << endl;
//    cout << atan2l(1, -1) << endl;
//    cout << atan2l(-1, 1) << endl;
//    cout << atan2l(-1, -1) << endl;
//
//    SHOW_MAP(xy);


}






























































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);


int main(){
  often();
  int n;
  cin >> n;
  if(n<10) cout << n << endl;
  else if(n<100) cout << 9 << endl;
  else if(n<1000) cout << n - 99 + 9 << endl;
  else if(n<10000) cout << 909 << endl;
  else if(n<100000) cout << n - 9999 + 909 << endl;
  else cout << 90909 << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}



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

int main()
{
    int A,B,K,c=-1;
    vector<int> v;
    cin >> A >> B >> K;
    if(B-A+1 <= K*2){
        for(int i=A; i<=B; i++){
            cout << i << endl;
        }
    }else{
        for(int i=A; i<=A+K-1; i++){
            v.push_back(i);
        }
        for(int i=B-K+1; i<=B; i++){
            v.push_back(i);
        }
        sort(v.begin(),v.end());
        for(auto i:v){
            if(c != i){
                cout << i << endl;
            }
            c = i;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int S,h,m,s;
	cin >> S;
	m = S / 60;
	s = S % 60;
	h = m / 60;
	m = m % 60;

	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; ++i)
#define per(i, a, n)  for(int i=n-1; i>=a; --i)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 1000000007;
using namespace std;
typedef long long ll;

int main(){
  int N;  cin >> N;
  vector<ll> a(N);
  int n = 0;
  ll Sum = 0;
  ll m = pow(10, 18);
  rep(i, 0, N){
    cin >> a[i];
    Sum += abs(a[i]);
    n += (a[i]<0 ? 1 : 0);
  }

  rep(i, 0, N){
    m = min(m, abs(a[i]));
  }
  if(n&1) cout << Sum - 2*m << endl;
  else  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	vector<int>A(N), B(N);
	int num;
	rep(i, N) {
		cin >> num;
		A[i] = B[i] = num;
	}
	sort(B.begin(), B.end());
	double mid = ((double)B[N / 2 - 1] + (double)B[N / 2]) / 2;
	rep(i, N) {
		if (A[i] <= mid)cout << B[N / 2] << endl;
		else cout << B[N / 2 - 1] << endl;
	}
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,b,c,pos=0;cin>>n>>m;
  vector<ll> a(n,0),v(n,0);
  map<ll,ll> mp;
  rep(i,n) {cin>>a[i];} sort(a.begin(),a.end());
  rep(i,m) {cin>>b>>c;mp[c]+=b;}
  for(auto itr=mp.rbegin();itr!=mp.rend();++itr) {
    b=itr->second;c=itr->first;
    for(ll i=pos;i<min(n,pos+b);++i) v[i]+=c;
    pos+=b;if(pos>=n) break;
  }
  pos=0;
  while(v[pos]>a[pos]) {a[pos]=v[pos];++pos;}
  ll ans=0;rep(i,n) ans+=a[i];
  print(ans);
  return 0;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  int remain;
  remain = A - B;
  
  int move;
  move = min(remain, C);
  
  cout << C - move << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a % 2 == 1 && b % 2 == 1){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
string K;
long long P = 1e9+7;
long long D;

long long dp[100010][110][2];

long long f(int pos, long long sum , bool sw){
    if(pos == (int)K.size()){
        if(sum == 0) return 1;
        else return 0;
    }
    long long &re = dp[pos][sum][sw];
    if(re!=-1) return re;
    re = 0;
    if(sw == 0){
        for(int i = 0 ; i < 10 ; i++){
            re += f(pos+1,(sum%D+i%D)%D,0)  ;
            re %=P;
        }
    }else{
        for( int i = 0; i <= int(K[pos]-'0') ; i++){
            if(i == int(K[pos]-'0')){
                re+=f(pos+1,(sum%D+i)%D,1);
                re %=P;
            } 
            else{
                re += f(pos+1,(sum%D+i)%D,0);
                re %=P;
            } 
        }
    }

    return re;
}
int main(){
    while(cin>>K>>D){
        memset(dp,-1,sizeof dp);
        cout<<(f(0,0,1)-1+P)%P<<"\n";
    }
    return 0;
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    LL ans = 0;

    REP(i, N){
        if(i == 0){
            ans = K;
        }
        else{
            ans = ans * (K - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
constexpr ll INF = 1ll << 60;

vector<vector<pair<ll, ll>>> edges;
vector<bool> update(vector<ll>& gain) {
	const int N = gain.size();
	vector<ll> next(N, -INF);
	rep(from, N)if (gain[from] != -INF)for (auto to : edges[from]) {
		next[to.first] = max(next[to.first], gain[from] + to.second);
	}

	vector<bool> improve(N, false);
	rep(pos, N)if (gain[pos] < next[pos])improve[pos] = true;
	rep(pos, N)gain[pos] = max(gain[pos], next[pos]);
	//gain = next;
	return improve;
}

vector<bool> can_go(const vector<vector<int>> routes, const int start) {
	const int N = routes.size();
	vector<bool> can(N);
	queue<int> q;

	q.push(start);
	can[start] = true;
	while (!q.empty()) {
		int now = q.front(); q.pop();
		for (int next : routes[now]) {
			if (!can[next]) {
				can[next] = true;
				q.push(next);
			}
		}
	}
	return can;
}

vector<bool> find_on_routes(const vector<bool> a, const vector<bool> b) {
	vector<bool> res(a.size());
	rep(i, a.size())res[i] = a[i] && b[i];
	return res;
}

int main()
{
	ll N, M, P;
	cin >> N >> M >> P;

	vector<vector<int>> routes(N), revs(N);
	edges.resize(N);
	rep(i, M) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--; c -= P;
		edges[a].push_back({ b,c });
		routes[a].push_back(b);
		revs[b].push_back(a);
	}

	ll res = -INF;
	vector<ll> gain(N, -INF);
	gain[0] = 0;
	rep(act, N) {
		update(gain);
		res = max(res, gain.back());
	}

	auto on_routes = find_on_routes(can_go(routes, 0), can_go(revs, N - 1));
	rep(act, N) {
		auto improve = update(gain);
		rep(pos, N)if (on_routes[pos] && improve[pos]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << max(res, 0ll) << endl;

	return 0;
}


Measured memory_bytes: 1024
use std::collections::HashSet;
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let ABC:HashSet<i64> = read_line()
                        .split_whitespace()
                        .map(|x|x.parse::<i64>().unwrap())
                        .collect::<HashSet<i64>>();
    if ABC.len() == 2{
        println!("Yes");
    }else{
        println!("No");
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MOD = 1000000007;
const int MAX = 2e5+10;

ll fac[MAX<<2];  // fac[n] = n!
ll finv[MAX<<2]; // (fac[n] * finv[n]) % MOD = 1
ll inv[MAX<<2];  // (n * inv[n]) % MOD = 1

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX<<2) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

ll nHk (int n, int k) {
    return nCk(n-1+k, n-1);
}

ll N, K;

ll sub(int k) { // k回目の移動で初めて発生するパターンの数
    return nCk(N, k) * nCk(N-1, k) % MOD;
}

ll solve() {
    init();
    if (K >= N) return nHk(N, N);
    ll ans = 1;
    FOR (i, 1, K+1) ans = (ans + sub(i)) % MOD;
    return ans;
}

int main() {
    cin >> N >> K;
    cout << solve() << endl;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, D; cin >> a >> b >> c >> D;
    bool ok = false;
    if((abs(a - c) <= D) or
       (abs(a - b) <= D and abs(c - b) <= D)){
        ok = true;
    }

    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
class PriorityQueue
  attr_reader :size

  def initialize(order: :asc)
    @size = 0
    @nodes = []
  end

  def empty?
    @size.zero?
  end

  def push(node)
    index = size

    while index > 0
      parent = (index - 1) / 2

      break if @nodes[parent].last <= node.last

      @nodes[index] = @nodes[parent]
      index = parent
    end

    @nodes[index] = node
    @size += 1
  end

  alias_method :<<, :push

  def pop
    node = @nodes.first
    @nodes[0], @nodes[size - 1] = @nodes[size - 1], nil
    index = 0

    while index * 2 + 1 < @size
      left = 2 * index + 1
      right = left + 1

      target = if @nodes[left] && @nodes[right]
                 (@nodes[left].last <=> @nodes[right].last) < 0 ? left : right
               elsif @nodes[left]
                 left
               elsif @nodes[right]
                 right
               else
                 nil
               end

      break if target.nil?
      break if (@nodes[target].last <=> @nodes[index].last) >= 0

      @nodes[index], @nodes[target] = @nodes[target], @nodes[index]
      index = target
    end

    @size -= 1
    node.first
  end

  def top
    @nodes.first
  end
end

N = gets.to_i
A = gets.split.map(&:to_i)

front = PriorityQueue.new
front_sum = 0

back = PriorityQueue.new(order: :desc)
back_sum = 0

N.times do
  v = A.shift
  front.push([v, v])
  front_sum += v

  w = A.pop
  back.push([w, -w])
  back_sum += w
end

f_sums = [front_sum]
b_sums = [back_sum]

A.each do |a|
  if front.top[0] < a
    front_sum -= front.pop
    front.push([a, a])
    front_sum += a
  end

  f_sums << front_sum
end

A.reverse_each do |a|
  if back.top[0] > a
    back_sum -= back.pop
    back.push([a, -a])
    back_sum += a
  end

  b_sums << back_sum
end

puts f_sums.zip(b_sums.reverse).map { |a, b| a - b }.max



Measured memory_bytes: 45716
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string ans = "";
  string a,b; cin >> a >> b; ll as = a.size(); ll bs = b.size();
  if(as < bs) ans = "LESS";
  else if(as > bs) ans = "GREATER";
  else{
    if(a < b) ans = "LESS";
    else if(a > b) ans = "GREATER";
    else ans = "EQUAL";
  }
  
  cout << ans << endl;
  
  
}

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

using namespace std;

typedef pair<int, int> P;
typedef pair<double, P> PP;

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

vector< vector<edge> > g;
double mincost[1<<8][30];
int n, m, p, a, b;
int t[8];

const double inf = 1 << 25;

double dijkstra()
{
  priority_queue<PP, vector<PP>, greater<PP> > que;
  que.push(PP(0.0, P(a, (1<<n)-1)));
  fill(mincost[0], mincost[1<<8], inf);
  mincost[(1<<n)-1][a] = 0.0;
  while(!que.empty()) {
    PP p = que.top(); que.pop();
    double c = p.first;
    int now = p.second.first, k = p.second.second;
    if(now == b) return c;
    if(k == 0 || mincost[k][now] < c) continue;
    for(int i = 0; i < g[now].size(); i++) {
      edge e = g[now][i];
      for(int j = 0; j < n; j++) {
	if((k>>j) & 1) {
	  if((double)e.cost/t[j] + c < mincost[k&~(1<<j)][e.to]) {
	    mincost[k&~(1<<j)][e.to] = (double)e.cost/t[j] + c;
	    que.push(PP(mincost[k&~(1<<j)][e.to], P(e.to, k&~(1<<j))));
	  }
	}
      }
    }
  }
  return -1;
}

int main()
{
  while(cin >> n >> m >> p >> a >> b, n) {
    --a, --b;
    g.clear(); g.resize(m);
    for(int i = 0; i < n; i++) cin >> t[i];
    for(int i = 0; i < p; i++) {
      int x, y, z;
      cin >> x >> y >> z;
      --x, --y;
      g[x].push_back(edge(y, z));
      g[y].push_back(edge(x, z));
    }
    double ans = dijkstra();
    if(ans == -1) cout << "Impossible" << endl;
    else printf("%.3f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2704
let (n, k, s) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun n k s -> (n, k, s)

let () =
  Array.concat [Array.make k s; Array.make (n - k) (if s = 1000000000 then 1 else s + 1)] 
  |> Array.map string_of_int
  |> Array.to_list
  |> String.concat " "
  |> print_endline

Measured memory_bytes: 11776