akhauriyash/Code-Regression huggingface dataset:
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();

    let mut k = 0;
    while (1 << k) < b {
        k += 1;
    }

    let mut ans = 0i64;
    for i in 0..k + 1 {
        let x = bits(b, i) - bits(a - 1, i);
        if x & 1 == 1 {
            ans |= 1 << i;
        }
    }
    println!("{}", ans);
}

fn bits(x: i64, i: i64) -> i64 {
    let t = 2 * i64::pow(2, i as u32);
    let mut b = (x + 1) / t * t / 2;
    let rem = (x + 1) % t;
    b += std::cmp::max(0, rem - t / 2);
    b
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000123456LL

vector<int> tree[100010];

// have to indicate root node by init(root)
class LCA {
private:
  int n,ln; // number of nodes and log n
public:
  vector<vector<int> > parent;
  vector<int> depth;
  LCA(int _n) : n(_n), depth(_n){
    ln=0;
    while(n>(1<<ln)) ln++;  // calc log n
    parent = vector<vector<int> >(ln, vector<int>(n));
  }
  void dfs(int v, int p, int d){
    parent[0][v]=p;
    depth[v]=d;
    rep(i,tree[v].size()) if(tree[v][i]!=p) dfs(tree[v][i], v, d+1);
  }
  void init(int root){
    dfs(root, -1, 0);
    for(int k=0; k+1<ln; k++){
      for(int v=0; v<n; v++){
        if(parent[k][v] < 0) parent[k+1][v] = -1;
        else parent[k+1][v] = parent[k][parent[k][v]];
      }
    }
  }
  int query(int u, int v){
    if(depth[u] > depth[v]) swap(u,v);
    for(int k=0; k<ln; k++){
      if((depth[v]-depth[u])>>k & 1) v = parent[k][v];
    }  // now, depth[v] == depth[u]
    if(u==v) return u;
    for(int k=ln-1; k>=0; k--){
      if(parent[k][u] != parent[k][v]){
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
}; // END class LCA

template<class T>
void dijkstra(const vector<vector<pair<int,T>>> &vec, vector<T> &d, int from=0){
  using P = pair<T,int>;
  fill(all(d), INF);
  priority_queue<P, vector<P>, greater<P>> pq;
  d[from] = 0;
  pq.push(mp(0,from));
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int v = p.second;
    T dd = p.first;
    if(d[v] < dd) continue;
    for(auto to : vec[v]){
      T nd = dd + to.second;
      int ni = to.first;
      if(d[ni] > nd){
        d[ni] = nd;
        pq.push(mp(nd, ni));
      }
    }
  }
}


int main(){
  int n;
  cin>>n;
  vector<vector<pair<int,long>>> vec(n);
  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    tree[a].pb(b);
    tree[b].pb(a);
    vec[a].pb(mp(b,c));
    vec[b].pb(mp(a,c));
  }

  int q,k;
  cin>>q>>k;
  k--;

  vector<long> d(n);
  dijkstra(vec, d);

  LCA lca(n);
  lca.init(0);

  rep(_,q){
    int x,y;
    cin>>x>>y;
    x--;y--;
    auto dist = [&](int p, int q){
      return d[p]+d[q]-2*d[lca.query(p,q)];
    };
    cout << dist(x,k) + dist(k,y) << endl;
  }

  return 0;
}


Measured memory_bytes: 25464
$\=-1e9;
$N=<>;
@F=map[glob<>],1..$N;
@P=map[glob<>],1..$N;
for$b(1..1023){
	@f=();
	for$i(0..9){
		if($b>>$i&1){
			for(0..$N-1){
				$f[$_]+=$F[$_][$i]
			}
		}
	}
	$x=0;
	$x+=$P[$_][$f[$_]]for 0..$N-1;
	$\+=$-=$x-$\
}
print


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    string s;
    scan(N, s);
    int ans = 0;
    rep(i, N - 2) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ans++;
    }
    print(ans);

    return 0;
}

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

const int mod = 1000000007;
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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int k, n;
    string s;
    cin >> k >> s;
    n = s.size();
    combination c(n+k);
    mint ans = 0;
    for(int i = 0; i <= k; i++){
        mint now = mint(26).pow(k-i);
        now *= mint(25).pow(i);
        now *= c(i+n-1,n-1);
        ans += now;
    }
    cout << ans << endl;
}

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		while (v[i] % 2 == 0) {
			cnt++;
			v[i] /= 2;
		}
	}
	cout << cnt;
}


Measured memory_bytes: 3580
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, U, V, A[1 << 18], B[1 << 18];
int dist1[1 << 18], dist2[1 << 18];
bool used[1 << 18];
vector<int> X[1 << 18];

void dfs1(int pos, int pre, int dep) {
	dist1[pos] = dep;
	for (int i : X[pos]) {
		if (i != pre) dfs1(i, pos, dep + 1);
	}
}

void dfs2(int pos, int pre, int dep) {
	dist2[pos] = dep;
	for (int i : X[pos]) {
		if (i != pre) dfs2(i, pos, dep + 1);
	}
}

void dfs3(int pos, int pre) {
	used[pos] = true;
	for (int i : X[pos]) {
		if (i == pre || dist1[pos] >= dist2[pos]) continue;
		dfs3(i, pos);
	}
}

int main() {
	cin >> N >> U >> V;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	dfs1(U, -1, 0);
	dfs2(V, -1, 0);
	dfs3(U, -1);

	int maxn = 0;
	for (int i = 1; i <= N; i++) {
		if (used[i] == false) continue;
		maxn = max(maxn, dist2[i]);
	}
	cout << maxn - 1 << endl;
	return 0;
}

Measured memory_bytes: 18668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc147/abc147_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  rep(i, 61) {
    ll n0 = 0;
    ll n1 = 0;
    rep(j, N) {
      if (c[j] & (1ll << i)) {
        n1++;
      } else {
        n0++;
      }
    }
    ll base = pow(2, i);
    base %= MOD;
    base = (base * n0) % MOD;
    base = (base * n1) % MOD;
    ans = (ans + base) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll h[100100];
int main(){
	cin>>n;
	REP(i,n){
		cin>>h[i];
	}
	int flag=1;
	h[0]--;
	for(int i=1;i<n;i++){
		if(h[i-1]<h[i]){
			h[i]--;
		}else if(h[i-1]==h[i]){
		}else{
			flag=0;
			break;
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int a,b,c;
int main() {
  cin >> a >> b >> c;
  int ans=c-(a-b);
  if(ans<0) cout << 0 << endl;
  else cout << ans << endl;
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	string s; int K;

	cin >> s >> K;
	int n = s.size();
	REPU(i, 0, n) {
		int x = s[i] - 'a';
		if (x > 0) {
			int need = 26 - x;
			if (need <= K) s[i] = 'a', K -= need;
		}
	}
	K %= 26;

	while (K--) {
		if (s[n - 1] == 'z') s[n - 1] = 'a';
		else s[n - 1]++;
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 592
#include<iostream>
#include<cmath>
using namespace std;
const int N=1e5+5;
int n,ans,d,flag;
int main(){
	cin>>n;
	int x,last;
	last=0,flag=0;
	for(int i=1;i<=n;++i){
		cin>>x;
		if(last){
			if(flag==1||flag==2){
				if(flag==1&&x>=last||flag==2&&x<=last) ;
				else{
					flag=0;
					++ans,d=i-1;
					//printf("%d ",i);
				}
			} 
			else{
				if(x==last) flag=3;
				else if(x>last) flag=1;
				else if(x<last) flag=2;
			}
		}
		last=x;
	}
	if(d!=n) ++ans;
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 

template <class T>
void printArray(vector<T> arr) {for (T a: arr) cout << a << " ";cout << '\n';}
void printVerdict(bool verdict) {cout << (verdict ? "YES": "NO") << '\n';}
void printDecimal(double d) {printf("%.9f\n", d);}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	int p[n], q[n];
	int mult = 1;
	bool p_greater = false;
	for (int i = 2; i<=n; i++) mult *= i;
	for (int i = 0; i<n; i++) cin >> p[i];
	for (int i = 0; i<n; i++) cin >> q[i];
	for (int i = 0; i<n; i++) {
		if (p[i] > q[i]) p_greater = true;
		else if (p[i] < q[i]) break;
	}
	int cnt = 0;
	while (!equal(p, p+n, q)) {
		next_permutation(p, p+n);
		cnt++;
	}
	if (p_greater) cout << mult - cnt << '\n';
	else cout << cnt << '\n';
}



Measured memory_bytes: 3652
def main():
  a, b = map(int, input().split())
  if (a+b)%3 == 0:
    print('Possible')
    return
  if a % 3 == 0:
    print('Possible')
    return
  if b % 3 == 0:
    print('Possible')
    return
  
  print('Impossible')
  
if __name__ == '__main__':
  main()

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

int main()
{
	int n; cin >> n;
	vector<P> a[n];
	int ans;
	bool ok;

	ans = 0;
	rep(i, n)
	{
		int x;
		cin >> x;
		rep(j, x)
		{
			int y, z;
			cin >> y >> z;
			y--;
			P p = make_pair(y, z);
			a[i].push_back(p);
		}
	}
	For(bit, 1, (1 << n))
	{
		set<int> p;
		vector<int> s;
		rep(i, n)
		{
			if (bit & (1LL << i))
			{
				p.insert(i);
				s.push_back(i);
			}
		}
		ok = true;
		rep(k, s.size())
		{
			rep(l, a[s.at(k)].size())
			{
				if(a[s.at(k)].at(l).second == 0)
				{
					if(p.count(a[s.at(k)].at(l).first))
						ok = false;
				}
				else	
				{
					if(!p.count(a[s.at(k)].at(l).first))
						ok = false;
				}
			}
		}
		int sum = p.size();
		if (ok)
			ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
	N, M = map(int,input().split())
	cakes = [0]*N

	for i in range(N):
		x, y, z = map(int,input().split())
		cakes[i] = [ 
		x+y+z
		, x+y-z
		, x-y+z
		, x-y-z
		, -x+y+z
		, -x+y-z
		, -x-y+z
		, -x-y-z
		]

	ans = 0
	for i in range(8):
		this_ans = 0
		cakes.sort(key=lambda x: -x[i])
		for j in range(M):
			this_ans += cakes[j][i]
		ans = max(ans, this_ans)

	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  getline(cin,s);
  int l,count=0;
  l=s.length();
  int max=0;
  for(int i=0;i<l;i++)
  {
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
    {
      count ++;
      if(count>max)
      {
        max=count;
      }
    }
    if(s[i+1]!='A' && s[i+1]!='C' && s[i+1]!='G' && s[i+1]!='T')
      {
      
        count=0;
      }
  }
  cout<<max;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

long long n, m, x;
long long a[50000];



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> x;
    for (int i = 0; i < m; i++) {
        int p;
        cin >> p;
        a[p] = 1;
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < x; i++)
    {
        ans1 += a[i];
    }
    for (int i = x + 1; i <= n; i++)
    {
        ans2 += a[i];
    }
    cout << min(ans1, ans2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mamam=1e5+10;
int n;
int dp[mamam];
int arr[mamam];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define sai(j,n) for(sei j=0;j<sei(n);++j)
#define hsai(j,n) for(sei j=sei(n)-1;j>=0;--j)
#define kan(j,m,n) for(sei j=m;j<sei(n);++j)
#define hkan(j,m,n) for(sei j=sei(n)-1;j>=sei(m);--j)
#define zen(v) (v).begin(),(v).end()
#define yu(v) v.erase(unique(zen(v)), v.end());
#define syutu(v) si(a, (v).size()) {cout << v[a];if(a != v.size()-1)cout << " ";else cout << endl;}
#define mug 10000000111;
#define yo 10000000711;
#define kyo 1e-9;

const int dx[8] = {11,0,-1,-1,-1,0,1};
const int dy[8] = {0,1,1,1,0,-1,-1,-1};

using namespace std;
typedef long long sei;
typedef long double syo;
typedef vector<sei> vs;
typedef vector<syo> vy;
typedef vector<vs> vvs;
typedef vector<vy> vvy;
typedef pair<sei, sei> ks;
sei max(sei a, int b) {return max(a, sei(b));}
sei max(int a, sei b) {return max(sei(a), b);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sei m, nmin, nmax;
    sei ninzu=0;
    while(cin >> m >> nmin >> nmax, m || nmin || nmax){
        vs p(m);
        sei gap=0;
        sai(j,m){
            cin >> p[j];
        }
        sort(p.begin(),p.end());
        kan(j,nmin,nmax+1){
            if((p[m-j] - p[m-j-1])>=gap){
                gap = p[m-j]-p[m-j-1];
                ninzu = j;
            }
        }
        cout << ninzu << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;

int main() {
    int k, n, a[200000] = {}, b[200000] = {},m = 0;
     cin >> k >> n;
     for (int i = 0; i < n;++i) {
         cin >> a[i];
     }
     a[n] = k + a[0];
     for (int i = 0; i < n;++i) {
         b[i]=a[i+1]-a[i];
         if (m < b[i]) m = b[i];
     }
     cout << k - m << endl;  
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  set<int> num;
  int n,x;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x;
    num.insert(x);
  }
  while(num.size()>1){
    for(auto i : num){
      for(auto j : num){
        if(i==j) continue;
        if(j%i==0) num.erase(j);
        else{
          num.insert(j%i);
          num.erase(j);
        }
      }
    }
  }
  for(auto i : num) cout << i << endl;
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
    using namespace std;
    int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int a,b,c,k;    cin >> a >> b >> c >> k;
        int sum = 0;
        if(a > 0 && k > 0){
            if(a >= k){
                sum += k;
                k = 0;
            }
            else if(a < k){
                sum += a;
                k -= a;
            }
        }
        if(b > 0 && k > 0){
            if(b >= k){
                k = 0;
            }
            else if(b < k){
                k -= b;
            }
        }
        if(c > 0 && k > 0){
            if(c >= k){
                sum -= k;
                k = 0;
            }else if(c < k){
                sum -= c;
                k -= c;
            }
        }
        cout << sum;
    	return 0;
}

Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(System.Console.ReadLine());

            string str = Console.ReadLine();
            List<string> strList = new List<string>();
            foreach(char c in str)
            {
                strList.Add(c.ToString());
            }
            
            int count = 1;
         
            string moji = string.Empty;

            for(int i=0; i<num; i++)
            {
                if(i == 0)
                {
                    moji = strList[i];
                }
                else
                {
                    if(moji != strList[i])
                    {
                        moji = strList[i];
                        count++;
                    }
                }
                
            }


            Console.Write(count);

        }
    
    }
}


Measured memory_bytes: 15200
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        998244353
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		pii arr[n+1];
		for(ll int i=1;i<=n;i++) cin>>arr[i].F>>arr[i].S;
		set<pii> s;
		sort(arr+1,arr+1+n);
		for(ll int i=n;i>=1;i--)
		{
			ll int val=1;
			set<pii> t;
			for(auto it:s)
			{
				if(it.F<arr[i].F+arr[i].S) {
					val*=(it.S+1);
					val%=hell;
					t.insert(it);
				}
				else break;
			}
			for(auto it:t) s.erase(it);
			s.insert({arr[i].F,val});
			// cout<<"%%%"<<endl;
			// for(auto it:s) cout<<it.F<<" "<<it.S<<endl;
		}
		ll int ans=1;
		for(auto it:s) ans=(ans*(1+it.S))%hell;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 9600
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  const d = parseInt(input.split(" ")[3], 10);
  if(a+b>c+d){
    console.log("Left");
  }else if(a+b==c+d){
    console.log("Balanced");
  }else{
    console.log("Right");
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(void){
   int n, a[100]={0};
   cin >> n;
   for(int i=0; i <n; i++) {
       cin >> a[i];
   }
   cout << a[n-1];
   for(int i=1; i < n; i++) {
       int j = (n-1)-i;
       cout << " " <<a[j];
   }
   cout << endl;
 }



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
using namespace std;
 
/*
It's been a long day without you, my friend
And I'll tell you all about it when I see you again
We've come a long way from where we began
Oh I'll tell you all about it when I see you again
When I see you again
When I see you again
*/
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;
 
const int mod = 1e9+7;
 
int sod(int n){int sum =0;while(n > 0){sum += n %10;n /= 10;}return sum;}
 
int dig(int n){if(n==0) return 1;int cnt =0;while(n > 0){n /= 10;cnt++;}return cnt;}
 
int divs(int n){int cnt = 0;for(int x=1;x*x<=n;x++){if(n % x == 0){cnt++;if(n/x != x)cnt++;}}return cnt;}
 
int isprime(int n){if(n < 2)return false;for(int x=2;x*x<=n;x++)if(n % x == 0) return false;return true;}
 
int power(int x,unsigned int y,int p=mod) {int res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
 
const int inf = 1e18;

bool pal(string s){int l = 0 , r = s.size()-1;while(l < r){if(s[l++] != s[r--])return false;}return true;}



int32_t main(){
    FAST;

    int a,b;    cin >> a >> b;
    if(a <= 9 and b <=9)
        cout << a*b;    
    else cout << -1;

    return 0;
}
 
 
 
// const int N = 1e6;
// bool prime[N+3];
// void sieve(){
 
//   memset(prime , true , sizeof prime );
 
//   prime[0] = false , prime[1] = false;
//   prime[2] = true;
 
//   for(int x=2;x*x<=N;x++){
//     if(prime[x] == true){
//       for(int i=x*x;i<=N;i+=x)
//         prime[i] = false;
//     }
//   }
 
// } 


// const int N = 1e6+50;
// int spf[N+11];
 
// void SPF(){
 
// 	spf[1] = 1; 
  
//     for (int i = 2; i <= N; i++) 
//     { 
//         if (spf[i] == 0) 
//         { 
//             spf[i] = i; 
  
//             for (int j = 2*i; j <= N; j += i) 
//                 if (spf[j] == 0) 
//                    spf[j] = i; 
//         } 
//     } 
// }
 

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

ll layer[100], patty[100];

ll solve(ll N, ll X);

int main(void){
    ll N, X;
    cin >> N >> X;
    layer[0] = 1ll; patty[0] = 1ll;
    for(int i = 1; i <= N; i++){
        layer[i] = layer[i-1]*2 + 3;
        patty[i] = patty[i-1]*2 + 1;
    }
    
    cout << solve(N, X) << endl;

    return 0;
}

ll solve(ll N, ll X){
    if(N == 0) return 1;
    else if(X == 1) return 0;
    else if(X == layer[N]/2 + 1) return patty[N-1] + 1;
    else if(X <= layer[N]/2) return solve(N-1, X-1);
    else return patty[N-1] + 1 + solve(N-1, X-2-layer[N-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
int main () {
	int n,k;
	scanf("%d%d",&n,&k);
	if(k > (n-1)*(n-2)/2) {
		puts("-1");
		return 0;
	}
	int s = (n-1)*(n-2)/2;
	int cnt = n-1+s-k;
	printf("%d\n",cnt);
	for(int i=2; i<=n; i++) printf("1 %d\n",i),cnt--;
	for(int i=2; i<=n; i++) {
		for(int j=i+1; j<=n; j++) {
			if(!cnt) return 0;
			cnt--;
			printf("%d %d\n",i,j);
		}
	}
	return 0;
}

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

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n, cntm, res;
int a[1005][1005];
bool dd[1005][1005];
int pos[1005];
vector <pii> b[2];

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j < n; j++)
            cin >> a[i][j];
    for (int i = 1; i <= n; i++){
        pos[i] = 1;
        dd[i][a[i][1]]++;
        if (dd[i][a[i][1]] && dd[a[i][1]][i])
            b[0].push_back(pii({i, a[i][1]}));
    }
    int cur = 0;
    while (b[cur].size() != 0){
        res++;
        cntm += b[cur].size();
        //for (int i = 0; i < b[cur].size(); i++) cout << b[cur][i].fr << ' ' << b[cur][i].sc << endl; cout << endl;
        for (int i = 0; i < b[cur].size(); i++){
            int p1 = b[cur][i].fr, p2 = b[cur][i].sc;
            pos[p1]++, pos[p2]++;
            if (pos[p1] < n){
                dd[p1][a[p1][pos[p1]]]++;
                if (dd[p1][a[p1][pos[p1]]] && dd[a[p1][pos[p1]]][p1])
                    b[1 - cur].push_back(pii({p1, a[p1][pos[p1]]}));
            }
            if (pos[p2] < n){
                dd[p2][a[p2][pos[p2]]]++;
                if (dd[p2][a[p2][pos[p2]]] && dd[a[p2][pos[p2]]][p2])
                    b[1 - cur].push_back(pii({p2, a[p2][pos[p2]]}));
            }
        }
        b[cur].clear();
        cur = 1 - cur;
    }
    if (cntm == n * (n - 1) / 2) cout << res;
    else cout << -1;
    return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

// M = 4

// 4, 6
// 2, 10
// 2, 10
// 2, 10
// 2, 4

// 4, 0
// 2, 10
// 2, 10
// 2, 10
// 2, 10

using P = pair<int, int>;
using ll = long long;
const bool DEBUG = false;
int N, M;
ll R = 0;
map<int, vector<int>> mvi;

inline void input() {
  cin >> N >> M;
  int a, b;
  rep(i, N) {
    cin >> a >> b;
    mvi[M-a].emplace_back(b);
  }
}

inline void solve() {
  priority_queue<int> pq;
  for (int i = M; i >= 0; i--) {
    if(mvi[i].size()) {
      for(int x : mvi[i]) {
        if(DEBUG) cout << "push: " << i << ", " << x << endl;
        pq.push(x);
      }
    }
    if(!pq.empty()) {
      if(DEBUG) cout << "pop: " << pq.top() << endl;
      R += pq.top();
      pq.pop();
    }
  }

  cout << R << endl;
}

inline void Main() {
  // code
  input();
  solve();
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>
#include <ctype.h>

using namespace std;

int main(){
    int N,K;
    char S[64]={0};
    scanf("%d %d", &N, &K);
    scanf("%s", S);
    S[K-1] = tolower(S[K-1]);
    printf("%s\r\n", S);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
typedef long long ll;
int n, m, k;

int in[maxn];
int f[maxn], num[maxn];
int findx(int x){
    return f[x] == x ? x : f[x] = findx(f[x]);
}
int ans[maxn];
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for(int i=1;i<=n;i++)f[i] = i, num[i] = 1;
    for(int i=0;i<m;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        in[a]++;
        in[b]++;
        a = findx(a);
        b = findx(b);
        if(a != b){
            f[a] = b;
            num[b] += num[a];
        }
    }
    for(int i=0;i<k;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        int x = findx(a);
        int y = findx(b);
        if(x == y){
            in[a]++;
            in[b]++;
        }
    }
    for(int i=1;i<=n;i++){
        int an = findx(i);
        //cout << i << ' ' << an << ' ' << in[i] << ' ' << num[an] << '\n';
    }
    for(int i=1;i<=n;i++){
        int an = findx(i);
        printf("%d%c", num[an] - in[i] - 1, i == n ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I=(B-1);I>=(A);I--)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,x;
	cin>>n>>x;
	vector<ll> a(n);
	ll mina=INF;
	FOR(i,0,n){
		cin>>a[i];
		mina=min(mina,a[i]);
	}
	ll cost[n][n];
	FOR(i,0,n)cost[i][0]=a[i];
	FOR(i,0,n){
		FOR(m,1,n){
			ll l = i-m;
			if(l<0)l+=n;
			cost[i][m] = min(cost[i][m-1],a[l]);
		}
	}

	vector<P> ac(n);
	FOR(i,0,n){ac[i].se=i;ac[i].fi=a[i];}
	SORT(ac);
	ll ans = mina*n+(n-1)*x;
	FOR(m,0,n){
		ll w=m*x;
		FOR(i,0,n){
			w+=cost[ac[i].se][m];
		}
		ans = min(ans,w);
	}
	pri(ans);
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
//ll p[5001], c[5001], a[5005];
ll a[3005][3005], dp[3005][3005][4],r,c;

ll cc(ll x, ll y, ll ct)
{
	if(x>r || y>c || ct<0) return 0;
	if(dp[x][y][ct]!=-1) return dp[x][y][ct];
	ll ans;
	ans=max(cc(x,y+1,ct),cc(x+1,y,3));
	if(ct>0) ans = max(ans, a[x][y]+max(cc(x+1,y,3),cc(x,y+1,ct-1)));
	return dp[x][y][ct] = ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
//    	ll i,j,m,k,n,x,y,d;
//    	cin>>n>>k;
//    	repi(i,1,n) cin>>p[i];
//    	repi(i,1,n) cin>>c[i];
//    	repi(i,1,n) a[i]=-1*mod;
//    	repi(i,1,n)
//    	{
//    		d=0; j=i; y=0;
//    		while(true)
//    		{
//    			i=p[i];
//    			y++;
//    			d+=c[i];
//    			a[y]=max(a[y],d);
//    			if(j==i) break;
//			}
//		}
//    	d=-1*mod;
//    	repi(i,1,min(n,k))
//    	{
//    		if(a[i]>-1*mod)
//    		{
//    			d=max(d,a[i]);
//				if(k>=i && k%i!=0)d=max(d,(k/i)*a[k%i]);
//			}
//		}
//    	cout<<d;
		ll i,j,k,n,m,d,e,f;
		cin>>r>>c>>k;
		repi(i,0,r){
			repi(j,0,c) {
				a[i][j]=0;
				rep(k,0,4) dp[i][j][k]=-1;
			}
		}
		rep(i,0,k)
		{
			cin>>d>>e>>f;
			a[d][e]=f;
		}
		cout<<cc(1,1,3);
    } 
	return 0;
}













Measured memory_bytes: 356284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class23
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<int> b = Console.ReadLine().Split().Select(int.Parse).ToList();
            List<int> a = new List<int>();
            for(int i = 0; i < N; i++)
            {
                int max = -1;
                for(int j = 0; j < b.Count(); j++)
                {
                    if (j + 1 == b[j])
                        max = j;
                }
                if (max != -1)
                {
                    a.Add(max + 1);
                    b.RemoveAt(max);
                }
                else
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            a.Reverse();
            foreach (int i in a)
                Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13396
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,W = MI()
w1,v = MI()
v0,v1,v2,v3 = [v],[],[],[]  # 重さが w1,w1+1,w1+2,w1+3 である荷物の価値
for i in range(N-1):
    w,v = MI()
    if w == w1:
        v0.append(v)
    elif w == w1+1:
        v1.append(v)
    elif w == w1+2:
        v2.append(v)
    else:
        v3.append(v)

v0.sort(reverse=True)
v1.sort(reverse=True)
v2.sort(reverse=True)
v3.sort(reverse=True)
N0,N1,N2,N3 = len(v0),len(v1),len(v2),len(v3)

from itertools import accumulate
v0_accumulate = [0] + list(accumulate(v0))
v1_accumulate = [0] + list(accumulate(v1))
v2_accumulate = [0] + list(accumulate(v2))
v3_accumulate = [0] + list(accumulate(v3))

ans = 0
for i in range(N0+1):  # 重さが w1 である荷物を i 個選ぶ
    for j in range(N1+1):  # 重さが w1+1 である荷物を j 個選ぶ
        for k in range(N2+1):  # 重さが w1+2 である荷物を k 個選ぶ
            for l in range(N3+1):  # 重さが w1+3 である荷物を l 個選ぶ
                if w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l <= W:
                    ans = max(ans,v0_accumulate[i]+v1_accumulate[j]+v2_accumulate[k]+v3_accumulate[l])
print(ans)


Measured memory_bytes: 70304
o = input()
e = input()
res = ""
if len(o)>len(e):
  for i in range(len(e)):
    res = res + o[i]
    res = res + e[i]
  res = res + o[len(o)-1]
else:
  for i in range(len(e)):
    res= res + o[i]
    res= res + e[i]
print(res)

Measured memory_bytes: 3060
from math import ceil
n,k=map(int,input().split())
b=k
p=0
pp=1
nn=n
while b>0:
    c = max(nn-b+1,0)
    z = c/(n*pp)
    p += z
    pp *= 2
    nn = min(b-1, nn)
    if b == 1:
        b = 0
    else:
        b = ceil(b/2)
print(p)

Measured memory_bytes: 3060
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    let mut c: Vec<Vec<usize>> = vec![vec![0; 10]; 10];
    for i in 0..10 {
        for j in 0..10 {
            c[i][j] = iterator.next().unwrap().parse().unwrap();
        }
    }

    // ワーシャルフロイド法
    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    let mut ans: usize = 0;
    for _ in 0..(h * w) {
        let ai: isize = iterator.next().unwrap().parse().unwrap();
        if ai >= 0 {
            ans += c[ai as usize][1];
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    const int n = s.size();
    if (s[0] == s[n - 1]) {
        if (n & 1)
            cout << "Second" << endl;
        else
            cout << "First" << endl;
    } else {
        if (n & 1)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }

    return 0;
}

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


int main(void) {
	int n;
	int a[200005] = { 0 };

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i+1]);

	if (n % 2) {
		for (int i = n; i > 0; i-=2) {
			printf("%d ", a[i]);
		}
		for (int j = 2; j < n; j += 2) {
			printf("%d ", a[j]);
		}
	}
	else {
		for (int i = n; i > 0; i -=2) {
			printf("%d ", a[i]);
		}
		for (int j = 1; j < n; j += 2) {
			printf("%d ", a[j]);
		}
	}
	return 0;
}


Measured memory_bytes: 2816
def A():
    ab, bc, ca = map(int, input().split())
    print(int(bc * ab / 2))
#A()

def B():
    s = int(input())
    f_data = [s]
    i = 1
    a = [s]
    tmp = [0 for i in range(1000000)]
    def f(n):
        if n % 2 == 0:
            return n // 2
        else:
            return 3 * n + 1

    while True:
        key = f(f_data[-1])
        f_data.append(key)
        if tmp[key] == 1:
            ans = i + 1
            break
        tmp[key] = 1
        i += 1
    print(ans)
#B()

def C():
    N = int(input())
    cnt = 0
    h = list(map(int, input().split()))
    while sum(h) != 0:
        cnt += 1
        for i in range(N):
            if h[i] > 0:
                #print(i)
                for j in range(i, N):
                    #print(i, j)
                    if h[j] == 0:
                        break
                    else:
                        h[j] -= 1
                #print(h, cnt)
                break
    print(cnt)
C()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vi v(n);
    vi r(n);
    FOR(i,0,n){
        cin >> v[i];
        while(v[i]%2 == 0){
            v[i] = v[i]/2;
            r[i]++;
        }
    }
    sort(r.begin(),r.end());
    cout << r[0] << endl;
}

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

int main(){
  int x,y; cin>>x>>y;
  if(x<y){
    if(abs(x)<abs(y)){
      cout<<min(y-x,1+abs(y+x))<<endl;
    }else if(-x==y){
      cout<<1<<endl;
    }else{
      cout<<min(y-x,abs(x)-abs(y)+1)<<endl;
    }
  }else{
    if(abs(x)<abs(y)){
      cout<<min(abs(y)-x+1,2+abs(y)-abs(x))<<endl;
    }else if(abs(x)==abs(y)){
      cout<<1<<endl;
    }else{
      if(y<=0){
        cout<<1+x+y<<endl;
      }else{
        cout<<2+x-y<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], a = tmp[1], b = tmp[2];

        int ans = Math.Min(n*a, b);
        WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

bool cmp( pll a,pll b){
    return a.S < b.S;
}

void  solve(){
    int n,x,y;
    vector<pll> l,r;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        l.push_back({x-y,x+y});
    }
    sort(l.begin(),l.end(),cmp);
    int mx = l[0].S,c=0;
    for(int i=1;i<n;i++){
        if(l[i].F < mx) 
            c++;
        else {
            mx = l[i].S;
        }    
    }
    cout<<n - c;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define N 950527
using namespace std;
typedef unsigned long long ull;
int main(){
  string s,p;
  cin>>s>>p;
  ull a=0,b=0,g=1;
  for(int i=0;i<p.size();i++)b*=N,b+=s[i],g*=N;
  for(int i=0;i<p.size();i++)a*=N,a+=p[i];
  if(b==a)printf("0\n");

  for(int i=p.size();i<(int)s.size();i++){
    b*=N,b+=s[i],b-=s[i-p.size()]*g; 
    if(b==a)printf("%d\n",i-p.size()+1);
  }
  return 0;
}

Measured memory_bytes: 2048