akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int solve()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	forci(0,n)	cin>>a[i];
	int l=1,r=*max_element(a,a+n),ans=0;
	while(l<=r){
		int x=l+(r-l)/2;
		int cnt=0;
		for(int i=0;i<n;i++){
			if(a[i]%x==0)
				cnt+=(a[i]/x-1);
			else
				cnt+=(a[i]/x);
		}
		if(cnt<=k)
			r=x-1,ans=x;
		else
			l=x+1;
	}
	cout<<ans<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 5148
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
#print(X)
ans = 0
for i in range(len(X)):
    for j in range(i+1, len(X)):
        summ = 0
        #print(i, j)
        for d in range(D):
            summ += (X[i][d] - X[j][d])**2
        dist = math.sqrt(summ)
        #print(dist)
        if dist - int(dist) == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<unordered_map>
/*
**
Success doesn't come to you ,
You Go To IT .
**
*/
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define finish(x) return cout << x << endl, 0;
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;


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


enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int main()
{
	Compiler_Beso


		ll a, b, c;
	cin >> a >> b >> c;
	ll ans = 0;
	if (c >= b){
		c -= b;
		ans += b * 2;
		ans += min(a, c)+(c>min(a,c));
	}
	else{
		ans = c+b;
	}
	cout << ans;
		

	return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string S;
  cin >> S;
  if(S.size()%2!=0) S.pop_back();
  int Ans;
  int i = S.size()/2;
  do{
    Ans = 2*i;
    --i;
  }while(S.substr(0,i)!=S.substr(i,i));

  printf("%d\n",Ans-2);
  return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const ll MAX_M=300,MAX_Q=299,INF=3e18+64;
ll Q,X[MAX_M+1];
bool isprime[MAX_M+1];
vector<ll> prime;
void era(){
	memset(isprime,true,sizeof(isprime));
	isprime[0]=isprime[1]=false;
	FOR(i,2,MAX_M+1){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=i*2;j<=MAX_M;j+=i){
				isprime[j]=false;
			}
		}
	}
}
ll len[7];
ll dfs(ll n,ll pro){
	ll ret;
	if(n<7){
		ll a=1;
		ret=-INF;
		REP(i,len[n]){
			ret=max(ret,dfs(n+1,pro*a));
			a*=prime[n];
		}
	}else{
		ret=0;
		FOR(i,2,MAX_M+1){
			if(pro%i==0){
				ret+=X[i];
			}
		}
		FOR(i,7,prime.size()){
			ll sm=0;
			for(ll j=1;j*prime[i]<=MAX_M;j++){
				if(pro%j==0){
					sm+=X[j*prime[i]];
				}
			}
			ret+=max(sm,0ll);
		}
	}
	return ret;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	era();
	cin>>Q;
	REP(i,Q){
		ll m,x;
		cin>>m>>x;
		X[m]=x;
	}
	
	len[0]=9;
	len[1]=6;
	len[2]=4;
	FOR(i,3,7)len[i]=3;
	cout<<dfs(0,1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll X, N, p;
  cin >> X >> N;
  vector<ll> vec;
  vec.reserve(1000);
  for (auto i = 0; i < 1000;i ++) {
    vec.push_back(0);
  }
  for (auto i = 0; i < 100;i ++) {
    cin >> p;
    vec[p] = 1;
  }

  if (vec[X] == 0) {
    cout << X << endl;
    return 0;
  }

  ll ret = 1;
  while(1) {
    if (X - ret < 0) {
      cout << X - ret << endl;
      return 0;
    }
    if (vec[X - ret] == 0) {
      cout << X - ret << endl;
      return 0;
    } 
    if (vec[X + ret] == 0) {
      cout << X + ret << endl;
      return 0;
    }
    ret ++;
  }

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}

int main(){
    vi prime;
    vi isP(300001,1);
    for(int i=2;i<300001;i++){
        if(i%7!=1 && i%7!=6) isP[i]=0;
    }
    for(int i=2;i<ceil(sqrt(300001));i++){
        if(isP[i]){
            for(int j=i*i;j<=300000;j+=i){
                isP[j]=0;
            }
        }
    }
    range(i,2,300001) if(isP[i]) prime.push_back(i);
    int n;
    while(cin>>n,n!=1){
        cout<<n<<":";
        for(auto p : prime){
            if(n%p==0){
                cout<<" "<<p;
                while(n%p)n/=p;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 4280
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto a = lread();
    auto s = sread();
    if (a >= 3200)
        writeln(s);
    else if (a < 3200)
        writeln("red");

}
//https://rclone.org/

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3628
/**
*    author:  y_takano
*    created: 23.06.2020 15:58:39
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

using namespace std;

struct _dice
{
    int dt, ds, de, dw, dn, du;
};

void dice(_dice &dice, char c)
{
    int tmp;

    switch (c)
    {
    case 'E':
        tmp = dice.dt;
        dice.dt = dice.dw;
        dice.dw = dice.du;
        dice.du = dice.de;
        dice.de = tmp;
        break;
    case 'N':
        tmp = dice.dt;
        dice.dt = dice.ds;
        dice.ds = dice.du;
        dice.du = dice.dn;
        dice.dn = tmp;
        break;
    case 'S':
        tmp = dice.dt;
        dice.dt = dice.dn;
        dice.dn = dice.du;
        dice.du = dice.ds;
        dice.ds = tmp;
        break;
    case 'W':
        tmp = dice.dt;
        dice.dt = dice.de;
        dice.de = dice.du;
        dice.du = dice.dw;
        dice.dw = tmp;
        break;
    }
}

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

    _dice sdice1, sdice2;

    string s = "SSSSNESSSESSSWSSSWSSSESSS";
    bool flg = false;

    cin >> sdice1.dt;
    cin >> sdice1.ds;
    cin >> sdice1.de;
    cin >> sdice1.dw;
    cin >> sdice1.dn;
    cin >> sdice1.du;
    cin >> sdice2.dt;
    cin >> sdice2.ds;
    cin >> sdice2.de;
    cin >> sdice2.dw;
    cin >> sdice2.dn;
    cin >> sdice2.du;

    REP(i, s.size())
    {
        dice(sdice1, s[i]);
        if (sdice1.dt == sdice2.dt 
        && sdice1.ds == sdice2.ds
        && sdice1.de == sdice2.de
        && sdice1.dw == sdice2.dw
        && sdice1.dn == sdice2.dn
        && sdice1.du == sdice2.du)
        {
            flg =true;
            break;
        }
    }

    if (flg)
    {
        cout<<"Yes"<<'\n';
    }
    else
    {
        cout<<"No"<<'\n';
    }
    
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string S; cin >> S;
  auto ans = S == "ABC" ? "ARC" : "ABC";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef vector<vector<pair<int, int>>> GRA;

int i,j,N,t,x,y,dt,dx,dy,T,X,Y,D;

int main() {
	cin >> N;

	for (i = 0; i < N; i++)
	{
		cin >> T >> X >> Y;
		dt = T - t;
		dx = X - x;
		dy = Y - y;
		D = ABS(dx)+ABS(dy);
		if ( dt < D ) {
			cout << "No" << endl;
			return 0;
		} else if ( dt == D ) {
			/* nop*/
		} else {
			if ( ( (dt - D) % 2) ) {
				cout << "No" << endl;
				return 0;
			}
		}
		t = T;
		x = X;
		y = Y;
	}
	cout << "Yes" << endl;

	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	for(int i = 0;i<n;i++)
	{
		cin >> a[i];
	}
	for(int i = 0;i<n;i++)
		cin >> b[i];

	int Ans = 0;

	for(int i = 0;i<n;i++)
	{
		int ans = 0;
		for(int j = 0;j<=i;j++)ans+=a[j];
		for(int j = i;j<n;j++)ans+=b[j];
		Ans = max(ans,Ans);
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b;
  c = 0;
  if(a%3==0)c=1;
  if(b%3==0)c=1;
  if((a+b)%3==0)c=1;
  if(c)cout << "Possible";
  else cout << "Impossible";
 
}


Measured memory_bytes: 3568
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	string ans = "";
	int i = 0;
	while(n!=0) {
		if (n % 2) {
			ans = '1'+ans;
			n = -(n - 1) / 2;
		}
		else {
			ans = '0'+ans;
			n = -n / 2;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<chrono>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;

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

	int n,d,x;
	cin>>n>>d>>x;
	int a[1000];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int eaten=n;
	for(int i=0;i<n;i++)
	{
		int t=a[i]+1;
		while(t<=d)
		{
			eaten+=1;
			t+=a[i];
		}
	}
	cout<<eaten+x;
	
	return 0;
}

Measured memory_bytes: 256
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 1000001
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */


void solve(){
	ll n;
	cin >> n;
	vv(double) arr(n);
	inar(arr,n)
	vv(vv(double)) dp(n+1,vv(double)(n+1,0.0));
	fre(i,0,n){
		dp[0][i] = 0;
	}
	dp[0][0] = 1.0;
	fre(i,1,n){
		dp[i][0] = dp[i-1][0] * (1.0 - arr[i-1]);
	}
	fre(i,1,n){
		fre(j,1,i){
			dp[i][j] = arr[i-1]*dp[i-1][j-1] + (1.0 - arr[i-1])*dp[i-1][j];
		}
	}
	double ans = 0;
	fre(i,n/2 + 1, n){
		ans += dp[n][i];
	}
	cout << fixed << setprecision(10) << ans << endl;
	
}
int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
}

Measured memory_bytes: 73728
#include <stdio.h>

int a[100005];
int b[100005];
int sum[100005];

int main() {

	int N, M;

	scanf("%d %d",&N,&M);

	int i;

	for (i = 0; i < M; i++) {
		scanf("%d %d",&a[i],&b[i]);
		sum[a[i]]++;
		sum[b[i]]++;
	}

	for (i = 1; i <= N; i++) {
		if (sum[i] % 2 == 1) { 
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");

	return 0;
}

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

int main() {
	int x[5];
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			cout << i +1 << endl;
		}
	}

	return 0;
}

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

std::vector<ll> v[3];

class cakes{
public:
  int cake[3];
  ll weight;
  cakes();
  cakes(int a, int b, int c);
};

bool operator < (const cakes a, const cakes b)
{
  return a.weight < b.weight;
}

cakes::cakes(){};
cakes::cakes(int a, int b, int c)
{
  cake[0] = a;
  cake[1] = b;
  cake[2] = c;
  weight = v[0][a]+v[1][b]+v[2][c];
}

void input(int x, int i)
{
  for(int j=0; j<x; j++)
  {
    ll tmp;
    cin >> tmp;
    v[i].push_back(tmp);
  }
}

bool check(ll a, ll b, ll c,list<pair<pair<ll,ll>,ll> > list)
{
  pair<pair<ll,ll>,ll> tmp = make_pair(make_pair(a,b),c);
  std::list<pair<pair<ll,ll>,ll> >::iterator itr;
  for(itr=list.begin(); itr!=list.end(); itr++)
  {
    if(tmp==*itr) return false;
  }
  return true;
}

void print(list<pair<pair<ll,ll>,ll> > list)
{
  std::list<pair<pair<ll,ll>,ll> >::iterator itr;
  for(itr=list.begin(); itr!=list.end(); itr++)
  {
    cout << ((*itr).first).first << (*itr).first.second << (*itr).second << " ";
  }
  cout << endl;
}

int main()
{
  int size[3],K;
  cin >> size[0] >> size[1] >> size[2] >> K;
  for(int i=0; i<3; i++)
  {
    input(size[i],i);
    sort(v[i].begin(),v[i].end(),greater<long long>());
  }

  priority_queue<cakes> que;
  list<pair<pair<ll,ll>,ll> > list;

  que.push(cakes(0,0,0));


  for(int i=0; i<K; i++)
  {
    cakes tmp;
    tmp = que.top();
    cout << tmp.weight << endl;
    if(tmp.cake[0]<size[0]-1 && check(tmp.cake[0]+1,tmp.cake[1],tmp.cake[2],list)) {
      que.push(cakes(tmp.cake[0]+1,tmp.cake[1],tmp.cake[2]));
      list.push_front(make_pair(make_pair(tmp.cake[0]+1,tmp.cake[1]),tmp.cake[2]));
    }
    if(tmp.cake[1]<size[1]-1 && check(tmp.cake[0],tmp.cake[1]+1,tmp.cake[2],list)) {
      que.push(cakes(tmp.cake[0],tmp.cake[1]+1,tmp.cake[2]));
      list.push_front(make_pair(make_pair(tmp.cake[0],tmp.cake[1]+1),tmp.cake[2]));
    }
    if(tmp.cake[2]<size[2]-1 && check(tmp.cake[0],tmp.cake[1],tmp.cake[2]+1,list)) {
      que.push(cakes(tmp.cake[0],tmp.cake[1],tmp.cake[2]+1));
      list.push_front(make_pair(make_pair(tmp.cake[0],tmp.cake[1]),tmp.cake[2]+1));
    }
    que.pop();
    /*
    cout <<"L = ";
    print(list);
    */
  }

  return 0;
}


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

namespace TYC
{
	typedef long long ll;
	const int N = 5005;

	int n, k, L[N];
	char S[N << 1], Ans[N], R[N];

	void solve(int p, int len)
	{
		if (p + len - 1 != n)
		{
			p = n - p - len + n + 2;
			len = len * (1 << min(k - 1, 16));
		}
		else
			len = len * (1 << min(k, 16));
		if (len >= n)
		{
			for (int i = 1; i <= n; i++)
				putchar(S[p]);
			exit(0);
		}
		for (int i = 1; i <= len; i++)
			R[i] = S[p];
		for (int i = 1; i <= n - len; i++)
			R[len + i] = S[p - i];
		for (int i = 1; i <= n; i++)
			if (R[i] != Ans[i])
			{
				if (R[i] < Ans[i])
					memcpy(Ans, R, sizeof(char[n + 1]));
				break;
			}
	}

	void work()
	{
		scanf("%d%d%s", &n, &k, S + 1);
		char minc = S[1];
		int maxl = 0;
		for (int i = 1; i <= n; i++)
			minc = min(minc, S[i]);
		for (int i = 1; i <= n; i++)
			if (S[i] == minc)
				maxl = max(maxl, L[i] = S[i] == S[i - 1] ? L[i - 1] + 1 : 1);
		for (int i = 1; i <= n; i++)
			S[i + n] = S[n - i + 1];
		Ans[1] = char('z' + 1);
		for (int i = 1; i <= n; i++)
			if (L[i] == maxl || i == n)
				solve(i - L[i] + 1, L[i]);
		puts(Ans + 1);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

typedef long long ll;
#define MP make_pair

int main(void){

    int n,y,m,d,day=0;

    cin>>n;

    for (int count = 0; count < n; count++) {
        day=0;
        cin>>y>>m>>d;
        for (int yi = 1; yi < y; yi++) {
            day+=(20*5)+(19*5);
            if(yi%3==0){
                day+=5;
            }
        }
        for (int mi = 1; mi < m; mi++) {
            if(mi%2==0&&y%3!=0)day+=19;
            else day+=20;
        }

        day+=d;

        cout<<196470-day+1<<"\n";

    }


    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

bool passNum[666];
bool writed[666];
int dp[666][333][333];

void mod_add(int &a, int b){
	a += b;
	a %= MOD;
}

int main(){
	
	int n;cin >> n;
	int cou = 0;
	vector<int> v(2*n);
	REP(i,2*n){
		cin >> v[i];
		if(v[i] != -1)writed[v[i]] = true;
	}
	
	REP(i,n){
		if(v[2*i] != -1 && v[2*i+1] != -1){
			passNum[v[2*i]] = passNum[v[2*i+1]] = true;
		}
		if(v[2*i] == -1 && v[2*i+1] == -1)cou++;
	}
	
	dp[2*n][0][0] = 1;
	for(int i = 2*n;i > 0;i--){
		REP(j,n+1){
			REP(k,n+1){
				if(passNum[i]){
					mod_add(dp[i-1][j][k],dp[i][j][k]);
					continue;
				}
				if(writed[i]){
					if(j > 0)mod_add(dp[i-1][j-1][k], dp[i][j][k]);
					mod_add(dp[i-1][j][k+1], dp[i][j][k]);
				}
				else{
					if(j > 0)mod_add(dp[i-1][j-1][k], dp[i][j][k]);
					if(k > 0)mod_add(dp[i-1][j][k-1], k * (ll)dp[i][j][k] % MOD);
					mod_add(dp[i-1][j+1][k], dp[i][j][k]);
				}
			}
		}
	}
		
	ll ans = dp[0][0][0];
	REP(i,cou){
		ans *= (i + 1);
		ans %= MOD;
	}
	
	cout << ans << endl;
				
	
	return 0;
}


Measured memory_bytes: 260224
a, b = gets.chomp.split(' ').map(&:to_i)

low_a = (a * 100.0 / 8).ceil
high_a = (a + 1) * 100 / 8
price_a = [*low_a...high_a]

low_b = (b * 100 / 10).ceil
high_b = (b + 1) * 100 / 10
price_b = [*low_b...high_b]

if (ans = (price_a & price_b)).empty?
  print(-1)
else
  print(ans.shift)
end

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

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

long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}

int main() {
  int X; cin >> X;
  cout << lcm(X, 360) / X << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> A(2, vector<int>(N));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int res = 0;
    for (int j = 0; j <= i; ++j) {
      res += A[0][j];
    }
    for (int j = i; j < N; ++j) {
      res += A[1][j];
    }
    ans = max(ans, res);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(-1);
}
int target;
bool f(int v){
    return v < target;
}

int main(){
    ll N,Q;
    cin >> N >> Q;
    vector<int> A(N);
    segtree<int, op, e> seg(N);
    rep(i,N){
        cin >> A[i];
        seg.set(i,A[i]);
    }
    vector<int> a(Q),b(Q),c(Q);
    rep(i,Q){
        cin >> a[i] >> b[i] >> c[i];
    }
    int t,x,v;
    rep(i,Q){
        t = a[i];
        x = b[i];
        v = c[i];
        if(t==1){
            x--;
            seg.set(x,v);
        }else if(t==2){
            x--;
            cout << seg.prod(x,v) << endl;
        }else{
            target = v;
            x--;
            cout << seg.max_right<f>(x) + 1 << endl;
        }
    }
}

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

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define mod 1000000007
#define INF64 1e18

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

void solve(){
  int n,w;cin>>n>>w;
  vi wt(n),v(n);
  for(int i=0;i<n;i++)
  cin>>wt[i]>>v[i];
  vi dp(w+1,0);
  for(int i=0;i<n;i++)
    for(int j=w-wt[i];j>=0;j--)
      dp[j+wt[i]]=max(dp[j+wt[i]],dp[j]+v[i]);
  int ans=0;
  for(int i=0;i<=w;i++)
    ans=max(ans,dp[i]);
  cout<<ans;
}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int T=1;
  //cin>>T;
  for(int TT=1;TT<=T;TT++){
    solve();
  }
}

Measured memory_bytes: 3984
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int D2[100000];
map<P, int> D;
vector<P> G[100000];

signed main() {
  scanf("%d %d", &N, &M);
  rep(i, M) {
    int p, q, c;
    scanf("%d %d %d", &p, &q, &c);
    p--, q--;
    G[p].push_back(P(q, c));
    G[q].push_back(P(p, c));
  }
  priority_queue<P2, vector<P2>, greater<P2> > q;
  rep(i, N) {
    D2[i] = INF;
    for (P &p : G[i]) D[p] = INF;
  }
  D2[0] = 1;
  q.push(P2(1, P(0, -1)));
  while (!q.empty()) {
    int r = q.top()._1,
        s = q.top()._2._1,
        c = q.top()._2._2;
    q.pop();
    if (s == N-1) break;
    if (c == -1) {
      if (D2[s] < r) continue;
    }
    else {
      if (D[P(s, c)] < r) continue;
    }

    if (c == -1) {
      for (P &p : G[s]) {
        if (D2[p._1] > r && D[p] > r) {
          D[p] = r;
          q.push(P2(r, p));
        }
      }
    }
    else {
      if (D2[s] > r+1) {
        D2[s] = r+1;
        q.push(P2(r+1, P(s, -1)));
      }
      for (P &p : G[s]) {
        if (c != p._2) continue;
        if (D2[p._1] > r && D[p] > r) {
          D[p] = r;
          q.push(P2(r, p));
        }
      }
    }
  }
  int m = INF;
  for(auto &p : G[N-1]) m = min(m, D[P(N-1, p.second)]);
  printf("%d\n", (m!=INF?m:-1));
  return 0;
}


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

using namespace std;

#define INF ((1LL<<31)-1)
#define D 2

struct SegTree {
int segSize, realSegSize, nodeSize;
 int sz;
 int *seg;
void init(int n) {
realSegSize = n;

nodeSize = 0;
for (segSize = 1; segSize < n; segSize *= D) nodeSize += segSize;

  sz = nodeSize+n;
  seg = new int[sz];
  for(int i = 0 ; i < sz ; i++) seg[i] = INF;
}

int get(int n) {
if (n < sz) return seg[n];
else return INF;
}
void set(int n, int v) {
if (n < sz) seg[n] = v;
}

void update(int pos, int val) {
int n = nodeSize + pos;
set(n, val);
while (n) {
n = (n-1)/D;

int r = INF;
for (int i = 0; i < D; ++i) {
r = min(r, seg[n*D+i+1]);
}
set(n, r);
}
}
int get(int n, int l, int r, int L, int R) {
// cout << n << " " << l << " " << r << endl;
if (L <= l && r <= R) return get(n);
else if (R <= l || r <= L) return INF;
else {
int ret = INF;
int prev = l;
for (int i = 0; i < D; ++i) {
int next = i == D-1 ? r : prev + (r-l)/D;
ret = min(ret, get(n*D+i+1, prev, next, L, R));
prev = next;
}
return ret;
}
}
int get(int L, int R) {
return get(0, 0, segSize, L, R);
}

~SegTree() {
  		delete seg;
}
};

struct Query {
int y1, x1, y2, x2;
};

int main() {
int H, W, Q;
while ( cin >> H >> W >> Q, H || W || Q ) {
vector< vector<int> > m(H, vector<int>(W, 0));

for (int y = 0; y < H; ++y) {
for (int x = 0; x < W; ++x) {
cin >> m[y][x];
}
}

bool isSegRow = H < W;
vector<SegTree*> seg;

if (isSegRow) {
seg.resize(H);
for (int y = 0; y < H; ++y) {
seg[y] = new SegTree();
    seg[y]->init(W);
}
}
else {
seg.resize(W);
for (int x = 0; x < W; ++x) {
seg[x] = new SegTree();
    seg[x]->init(H);
}
}

for (int y = 0; y < H; ++y) {
for (int x = 0; x < W; ++x) {
if (isSegRow) seg[y]->update(x, m[y][x]);
else seg[x]->update(y, m[y][x]);
}
}

for (int t = 0; t < Q; ++t) {
int y1, x1, y2, x2; cin >> y1 >> x1 >> y2 >> x2;

int ans = INF;
if (isSegRow) {
for (int y = y1; y <= y2; ++y) {
ans = min(ans, seg[y]->get(x1, x2+1));
}
}
else {
for (int x = x1; x <= x2; ++x) {
ans = min(ans, seg[x]->get(y1, y2+1));
}
}
cout << ans << endl;
}
  for(int i = 0 ; i < seg.size() ; i++) delete seg[i];

}
}

Measured memory_bytes: 63736
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

//eÍÍÌë·
//1 * 10^(-5)
#define EPS (1e-8)

int n;
pair<double, double> p[301];

int main() {
	while (1) {
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> p[i].first >> p[i].second;
		}
		int maxPoints = 1;
		//2_ð~üãÉÂ~ðè
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				double d = hypot(p[i].first - p[j].first, p[i].second - p[j].second);
				if (d > 2.0 + EPS) continue;	//£ê·¬
				
				//_(»ê¼êÌÀWÌ½Ï)
				pair<double, double> m((p[i].first + p[j].first) / 2.0, (p[i].second + p[j].second) / 2.0);
				//PÊ@üxNg
				//	@üxNgÌX«Íüªp[i]p[j]Æ|¯Ä-1C·Èí¿
				//		v = (p[j].second - p[i].second, p[j].first - p[i].first)
				//	±êÌ·³Ívx^2 + vy^2 = d^2
				//	æÁÄPÊxNgÉ·éÉÍ
				//		(vx/d)^2 + (vy/d)^2 = 1
				pair<double, double> ve((p[j].second - p[i].second) / d, (p[j].first - p[i].first) / d);
				//_©çSÜÅÌ£
				double l = sqrt(1.0 - d * d / 4.0);
				
				//_2Â©çèÜé~Í2Â
				for (int s = -1; s < 2; s += 2) {//
					pair<double, double> c(m.first + s * l * ve.first, m.second - s * l * ve.second);
					int count = 2;
					for (int k = 0; k < n; k++) {
						if (k==i || k==j) continue;//¯êÌ_ÍÜßÈ¢
						if (hypot(c.first - p[k].first, c.second - p[k].second) < 1.0 + EPS) count++;
					}
					maxPoints = max(maxPoints, count);
				}
			}
		}
		cout << maxPoints << endl;
	}
	return 0;
}

Measured memory_bytes: 980
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define ull unsigned long long
#define MAXN 100010
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define min(a, b) (a) < (b) ? (a) : (b)
#define max(a, b) (a) < (b) ? (b) : (a)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#define allof(x) x.begin(), x.end()
// #define DEBUG 1
// #define NOT_DMOJ 0
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

inline int GCD (int a, int b) { return b == 0 ? a : GCD(b, a % b); }
inline int LCM (int a, int b) { return a * b / GCD(a, b); }
inline ll PowMod (ll a, ll b, ll mod) { ll val = 1; while (b) { if (b & 1) val = (val * a) % mod; a = (a * a) % mod; b >>= 1; } return val; }

int N, ans;
int a[MAXN], pre[MAXN], suf[MAXN];

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("DATA.in", "r", stdin);
	freopen("DATA.out", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for (int i=0; i<N; i++) cin >> a[i];
	for (int i=0; i<N; i++) {
		pre[i + 1] = GCD(pre[i], a[i]);
	}
	for (int i=N - 1; i>=0; i--) {
		suf[i] = GCD(suf[i + 1], a[i]);
	}
	for (int i=0; i<N; i++) {
		ans = max(ans, GCD(pre[i], suf[i + 1]));
		D("%d %d %d\n", i, pre[i], suf[i + 1]);
	}
	cout << ans << "\n";
	return 0;
}

/* 
 Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 * number of test cases (T = 10)
 * resetting containers, variables, etc
 */

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,m,a,b,ans=0;
    cin>>n>>m;
    vector<pair<int,int>> A;
    rep(i,m) cin>>a>>b,A.push_back(make_pair(a,b));
    sort(A.begin(),A.end());
    int l=0,r=0;
    rep(i,m){
        if(r<=A[i].first){
            ans++;
            l=A[i].first,r=A[i].second;
        }
        else l=max(l,A[i].first),r=min(r,A[i].second);
    }
    cout<<ans;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char** argv) 
{
	int n,t,sum = 0;
	cin>>n;
	t = n;
	while(t)
	{
		sum+=t%10,t/=10;
	}
	if(n%sum)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-5-20 21:54:52
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll A[200010];
bool ok[200010];

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for (auto i = 0; i < N; i++)
  {
    if (A[i] > i)
    {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (auto i = 1; i < N; i++)
  {
    if (A[i - 1] + 1 < A[i])
    {
      cout << "-1" << endl;
      return 0;
    }
    ok[i - 1] = (A[i - 1] + 1 != A[i]);
  }
  ok[N - 1] = true;
  ll ans = 0;
  for (auto i = 0; i < N; i++)
  {
    if (ok[i])
    {
      ans += A[i];
    }
  }
  cout << ans << endl;
}

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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	vector<int> w=v;
	sort(w.begin(),w.end());
	if(w[0]){
		cout<<0<<endl;
		return 0;
	}
	reep(i,1,1010){
		bool ok = false;
		int tmp = 0;
		int r = 0;
		int p = 1;
		rep(j,n){
			while(r<n&&tmp<i){
				tmp*=10;
				tmp+=v[r++];
				p*=10;
			}
			if(tmp==i) ok=true;
			p/=10;
			tmp%=p;
		}
		if(!ok){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3176
<?php

    $l = in_int();
    
    $size = $l / 3;
    out($size * $size * $size);
    
    /**
    * お手伝い関数さんたち
    */
    function in() {
        return trim(fgets(STDIN));
    }
    function in_int() {
        return (int)in();
    }
    function in_vals() {
        return explode(' ', in());
    }
    function in_ints() {
        return array_map('intval', in_vals());
    }
    function out($s) {
        echo $s . PHP_EOL;
    }
    function yes() {
        out('Yes');
    }
    function no() {
        out('No');
    }
    function factorial($n) { // 階乗
        if ($n > 0) {
            return $n *= factorial($n - 1);
        }
        return 1;
    }
    function is_palindrome($s) {  // 回文か
        return $s == strrev($s);
    }



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

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

  long A[N];
  pair<int,long> BC[M];
  for(int i=0; i<N; i++){
    cin >>A[i];
  }
  for(int i=0; i<M; i++){
    cin >>BC[i].first >>BC[i].second;
  }
  sort(A, A+N);
  sort(BC, BC+M, [](pair<int,long> p, pair<int,long> q){return p.second > q.second;});

  long ans=0;
  int i=0,j=0;
  while(A[i]<BC[j].second && i<N && j<M){
      A[i]=BC[j].second;
      i++;
      if(BC[j].first > 1) BC[j].first--;
      else j++;
  }

  for(int i=0; i<N; i++){
    ans +=A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 1e7;

int main(){
	string a;
	cin >> a;
	if(a.length() == 2)cout << a << endl;
	else {
		for(int i = a.length() - 1 ; i >= 0 ; i--)cout << a[i];
		cout << endl;
		}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll N;
		cin>>N;
		N++;
		ll ar[N];
		cn(ar,N);
		pair<ll,ll> dp[N]={};
		dp[N-1]={ar[N-1],ar[N-1]};
		if(N-2>60)
		{
			for(ll i=N-2;i>=61;i--)
				dp[i]={(dp[i+1].ff+1)/2+ar[i],dp[i+1].ss+ar[i]};
			for(ll i=60;i>=0;i--)
			{
				ll pmx=power(2,i);
				ll mi=(dp[i+1].ff+1)/2+ar[i];
				ll mx=min(dp[i+1].ss+ar[i],pmx);
				dp[i]={mi,mx};
			}
		}
		else
		{
			for(ll i=N-2;i>=0;i--)
			{
				ll pmx=power(2,i);
				ll mi=(dp[i+1].ff+1)/2+ar[i];
				ll mx=min(dp[i+1].ss+ar[i],pmx);
				dp[i]={mi,mx};
			}
		}
		ll cur[N]={};
		cur[0]=1;
		if(dp[0].ff>1)
		{
			cout<<-1;
			return 0;
		}
		ll ans=1;
		for(ll i=1;i<N;i++)
		{
			if((cur[i-1]-ar[i-1])*2<dp[i].ff)
			{
				cout<<-1<<endl;
				return 0;
			}
			cur[i]=min(dp[i].ss,(cur[i-1]-ar[i-1])*2);
			ans+=cur[i];
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 6784
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mod 1000000007
// -----------------------------------------------------------------
void solve()
{
    int n,i,j,x,m,k,u,y;
    cin>>n>>m>>k;
    int ans=0;
    ans+= n/(m+k) * m;
    ans+= (n%(m+k) >= m)?m:n%(m+k);
    cout<<ans;
}
signed main()
{
    int t=1;
    //  cin>>t;
    string s;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }


signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }

    int X=0;
    for(int i=0;i<N;i++){
        X^=a[i];
    }

    vector<int> b;
    for(int i=0;i<N;i++){
        b.push_back(__builtin_popcount(a[i]^(a[i]-1)));
    }
    sort(b.begin(),b.end(),greater<int>());

/*
    for(int i=0;i<N;i++){
        cout<<b[i]<<' ';
    }
    cout<<endl;
*/
    
    int ans=0;
    for(int i=0;i<N;i++){
        int k=b[i];
        if(X&(1<<(k-1))){
            ans++;
            X^=(1<<k)-1;
        }
    }
    if(X==0){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 2168
#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>;

//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	int n, k;
	cin >> n >> k;
	
	vector<int> l(n), r(n);
	rep(i, k) cin >> l[i] >> r[i];
	
	vector<mint> dp(n + 1);
	vector<mint> dpsum(n + 1);
	dp[1] = 1;
	dpsum[1] = 1;
	for (int i = 2; i <= n; ++i) {
		rep(j, k) {
			// [l[i], r[i]]
			int li = i - r[j];
			int ri = i - l[j];
			if (ri < 0) continue;
			li = max(li, 1); 
			dp[i] += dpsum[ri] - dpsum[li - 1];// dp[li] ~ dp[ri]
		}
		dpsum[i] = dpsum[i - 1] + dp[i];
	}
	
	cout << dp[n] << '\n';
	
	return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	ll k, n, a[200005];
	cin >> k >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	vll v;
	for (int i = 1; i < n; ++i)
	{
		v.pb(a[i] - a[i - 1]);
	}
	v.pb(k - a[n - 1] + a[0]);
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		ans += v[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3956