akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
A = list(map(int, input().split()))
table = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse=True)
inf = (-1) * 10**5
#dp[i] := ちょうどi本のマッチを使って作る整数の、最大桁数
dp = [inf for i in range(N+1)]
dp[0] = 0
for i in range(N+1):
    for j in range(len(A)):
        if i + table[A[j]] > N:
            continue
        if dp[i + table[A[j]]] < dp[i] + 1:
            dp[i + table[A[j]]] = dp[i] + 1
#こうすることで、答えの桁数が分る.
#あとは実現する経路復元のようなものを行う
ans = ""
cur_cost = N
#各桁について一つずつ答えを決めていく
for _ in range(dp[N]):
    #大きい数字から最上位に決めていきたいので、大きい数字から考える
    for j in range(len(A)):
        if cur_cost - table[A[j]] < 0:
            continue
        if dp[cur_cost - table[A[j]]] == dp[cur_cost] - 1:
            ans += str(A[j])
            cur_cost -= table[A[j]]
            break
print(ans)



Measured memory_bytes: 42608
#include <bits/stdc++.h>
using namespace std;
const int max_n = 100000+5;
int n, W,L,P,k,m;
static long  dp[101][max_n];
long  x[max_n],y[max_n],p[max_n],X[max_n],T[max_n],ppar[max_n],rrank[max_n];
void init(int n){
    for(int i=0 ; i<n ; i++){
        ppar[i] = i;
        rrank[i] = 0;
    }
}
int find(int x){
    if(ppar[x] == x){
        return x;
    }else{
        return ppar[x] = find(ppar[x]);
    }
}
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;

    if(rrank[x] < rrank[y]){
        ppar[x] = y;
    }else{
        ppar[y] = x;
        if(rrank[x] == rrank[y])  rrank[x]++;
    }
}
bool same(int x, int y){
    return find(x) == find(y);
}
void solve(){
}

int main(){
    int count = 0;
    cin >> n >> m;
    init(n);
    for(int i=0 ; i<n ; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i=0 ; i<m ; i++){
        cin >> x[i] >> y[i];
        unite(--x[i], --y[i]);
    }
    for(int i=0 ; i<n ; i++){
        if(same(p[i], i)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
#define LM 55555
using namespace::std;


long long A,B,C,H,W,X,Y,N, M,num,x[1000],y[1000],z[1000],ans,dp[8][1000][1000],xyz[8][1000],gomi[1000];
string s[1000], t;
int a[3] = {0,-1,1};
int b[3] = {0,-1,1};
int c[3]=  {0,-1,1};
vector<vector<vector<vector<int>>>> v;




int main() {
	cin >>N>>M;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> z[i];
		num = 0;
		for (int j = 1; j <= 2; j++) {
			for (int k = 1; k <= 2; k++) {
				for (int l = 1; l <= 2; l++) {
					xyz[num][i] = x[i] * a[j] + y[i] * b[k] + z[i] * c[l];
					num++;
				}
			}
		}
	}
	for (int k = 0; k < 8; k++) {
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			if (xyz[k][i] < xyz[k][j]) {
				H = xyz[k][i];
				xyz[k][i] = xyz[k][j];
				xyz[k][j] = H;
				}
			}
		}
	}
	ans = -1;
	for (int i = 0; i < 8; i++) {
		A = 0;
		for (int j = 0; j < M; j++) {
			A += xyz[i][j];
		}
		if (ans < A) {
			ans = A;
		}
	}
	cout << ans << endl;
	return 0;

}




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

using namespace std;

int main() {
	long long int n;

	cin >> n;

	vector <char> letter(1, 'z');

	for (char c = 'a'; c <= 'y'; c++) {
		letter.push_back(c);
	}
	vector <char> ans;

	while (n > 0) {
		char c;

		c = letter[n % 26];
		ans.push_back(c);
		n = (n-1) / 26;
	}

	reverse(ans.begin(), ans.end());

	for (char c: ans) {
		cout << c;
	}

	cout << "\n";

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

void doProblemE(){
    int N, mod;
    cin >> N;
    mod = 1000;
    if(1000 - (N % mod) == 1000){
        cout << 0 << endl;
    }else{
        cout << 1000 - (N % mod) << endl;
    }
}

int main(int argc, const char * argv[]) {
    // insert code here...
    doProblemE();
    return 0;
}

Measured memory_bytes: 3188
ds = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
wd = [:Sunday, :Monday, :Tuesday, :Wednesday, :Thursday, :Friday, :Saturday]

while s = gets
  m, d = s.split.map(&:to_i)
  break if m == 0
  1.upto(m - 1).each { |i| d += ds[i - 1] }
  puts wd[(d - 4) % 7]
end

Measured memory_bytes: 5204
n, m = map(int, input().split())
k = []
for i in range(n):
    a = list(map(int, input().split()))
    k.append(a)

ans = [0]*m
for i in range(n):
    for j in range(1,k[i][0]+1):
        ans[k[i][j]-1] += 1

print(ans.count(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using lli=long long int;
using ld=long double;

lli N;
lli memo[1001][20001];

struct element
{
	lli w;
	lli s;
	lli v;
	lli w_plus_s;
};

element arr[1001];

bool compare(element i,element j)
{
	return(i.w_plus_s > j.w_plus_s);
}



lli max_value(lli index,lli wt)
{
	if(wt>10000)
		return 0;
	if(index==-1)
		return 0;
	if(memo[index][wt]!=-1)return memo[index][wt];
	if(wt>arr[index].s)
		return ( memo[index][wt] = max_value(index-1,wt) );
	return( memo[index][wt] =   max( max_value(index-1,wt) , max_value(index-1,wt+arr[index].w)+arr[index].v )   );
}


int main()
{
	lli i,j;
	for(i=0;i<=1000;i++)
		for(j=0;j<=10000;j++)
			memo[i][j]=-1;


	cin>>N;

	for(i=0;i<N;i++)
	{
		cin>>arr[i].w>>arr[i].s>>arr[i].v;
		arr[i].w_plus_s=arr[i].w + arr[i].s;
	}
	sort(arr,arr+N,compare);


	lli ans=max_value(N-1,0);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 155516
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;



long n = 0;

char s[1000003];

long int ans = 0;

int main(){



  scanf("%s",s);

  n = strlen(s);


  for(long i = 0;i < n;i++){


    if(s[i] != 'J'){
      continue;
    }else{
      long int nau = i + 1;
      long lenj = 1,leno = 0,leni=0;

      while(1){
	if(s[nau] == 'J'){
	  lenj++;
	  nau++;
	}else{
	  break;
	}
      }

      if(lenj < ans){
	i = nau ;
	continue;
      }

      while(1){
	if(s[nau] == 'O'){
	  leno++;
	  nau++;
	}else{
	  break;
	}
      }
      if(leno > lenj || leno < ans){
	i = nau-1;
	continue;
      }

      while(1){
	if(s[nau] == 'I'){
	  leni++;
	  nau++;
	}else{
	  break;
	}
      }

      if(leni < leno || leni < ans){
	i = nau - 1;
	continue;
      }

      ans = max(min(min(lenj,leno),leni),ans);

      i = nau - 1;
    }
  }

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

  return 0;

}


Measured memory_bytes: 1944
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort(reverse=True)
xmax = max(x[0], X)
y.sort()
ymin = min(y[0], Y)

if ymin - xmax > 0:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int N; cin >> N;
    int c = 0;
    bool ok = false;
    REP(i, N) {
        int d1, d2; cin >> d1 >> d2;
        if (d1 == d2) {
            ++c;
            if (c == 3) ok = true;
        } else {
            c = 0;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3616
A,B,K = map(int,input().split())

ls_1 = [i for i in range(A,min(A+K,B+1))]
ls_2 = [j for j in range(max(A,B-K+1),B+1) if j not in ls_1]
ls = ls_1 + ls_2

for ans in ls:
  print(ans)

Measured memory_bytes: 9076
#include<stdio.h>

int main(){

  int n,S[10000],q,T[500],i,j,count=0,same;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){
      if(S[i]==T[j]){
	count++;
	break;
      }
      // if(S[i]==T[j]==same) count--;
    }
  }

 
  
  printf("%d\n",count);
}



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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	while(true){
		int m, nmin, nmax; cin >> m >> nmin >> nmax;
		if(m == 0)break;
		vector<int> p(m);
		for(auto &&e : p)cin >> e;
		sort(ALL(p), greater<int>());
		int acc = 0, ans;
		for(int i = nmin; i <= nmax; i++){
			if(p[i-1] - p[i] >= acc){
				ans = i;
				acc = p[i-1]-p[i];
			}
		}
		cout << ans << endl;

	}

	return 0;
}




Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main()
{
    int sum=0,n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>m;
        sum+=m;
    }
    sum-=n;
    cout<<sum<<endl;
    return 0;
}


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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  long long count=0;
  for(int i=0;i<N-1;i++){
    int B=A.at(i)+A.at(i+1);
    if(B<=X){
      continue;
    }
    int C=B-X;
    count+=C;
    if(A.at(i+1)>=C){
      A.at(i+1)-=C;
      C=0;
    }
    else{
      A.at(i+1)=0;
    } 
  }
  cout << count << endl;
} 

Measured memory_bytes: 3776
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "AC":"WA"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>s) {
		ll c=0;
		REP(i, s.size()) if(IN(s[i], 'a', 'z'+1)) c++;
		ll C=0;
		RANGE(i, 2, s.size()-1) if(s[i]=='C')C++;
		ll ans=s[0]=='A'&&C==1&&c==s.size()-2;
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    char s;
    cin>>s;

    if(s >='A' && s<='Z'){
        cout<<"A\n";
        return;
    }

    else if(s >='a' && s<='z'){
        cout<<"a\n";
    } 
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
int average(int a, int b){
    return round((float)(a + b) / 2);
}
int main(){
    int a, b;
    double avg;
    scanf("%d %d", &a, &b);

    printf("%d\n", average(a, b));

    return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
sa = set()
sb = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print('POSSIBLE' if len(sa&sb) != 0 else 'IMPOSSIBLE')

Measured memory_bytes: 57944
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int c;
char s[110];
int main()
{
    scanf("%s",s);
    int ls=strlen(s);
    for(int i=0;i<ls;i++)
        if(s[i]=='C')
            c=1;
        else if(s[i]=='F'&&c==1)
        {
            printf("Yes");
            return 0;
        }
    printf("No");
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N, K;
	cin >> N >> K;
	if ((N-1)*(N-2)/2<K) {
		ce(-1)
	}
	else {
		int M = N - 1+ (N - 1)*(N - 2) / 2 - K;
		ce(M);
		fx(N-1) {
			doublece(1,x+2)
		}
		int w = 2, z = 3;
		fx((N - 1)*(N - 2) / 2 - K) {
			doublece(w, z);
			z++;
			if (z > N) {
				w++;
				z = w + 1;
			}
		}
	}

	
    return 0;
}



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

lli n, m;

int main(void){
	cin >> n >> m;
	lli d = min(n, m/2);
	cout << d+(m-2*d)/4 << endl;
	return 0;
}


Measured memory_bytes: 3548
//SHIVANSH BHAT
//IIT ROORKEE

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

//NUMBER THEORY
//(a-b)%c=((a%c)-((b%c))+c)%c;
//to find gcd use function __gcd(x,y);

//Seive of erathonesis(finding prime numbers till n)
/*
 *
 *
************************************************************************
       vector<bool> isPrime(n+1,true);
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
*************************************************************************

*/
//Prime Factorisation of numbers of large orders like 1e9,1e12 in O(sqrt(N))
/*
 *
 **********************************************************************
 vector<ll> res;
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
 ***********************************************************************

 */
//Prime Factors of numbers of order 1e5,1e6 in O(logn) using seive
/*
 *
 ***********************************************************************
 //max_value is upper limit of elements we have to factorise
 vector<ll> minPrime(max_value + 1,0);
for (int i = 2; i * i <= max_value; ++i) {
    if (minPrime[i] == 0) {         //If i is prime
        for (int j = i * i; j <= max_value; j += i) {
            if (minPrime[j] == 0) {
                minPrime[j] = i;
            }
        }
    }
}
for (int i = 2; i <= max_value; ++i) {
    if (minPrime[i] == 0) {
        minPrime[i] = i;
    }
}
//factorising array of elements in log(n)
 for(int i=0;i<n;i++){
     vector<ll> res;
    while (a[i] != 1) {
        res.push_back(minPrime[a[i]]);
        a[i] /= minPrime[a[i]];
    }
 }
 ****************************************************************

 */
ll add_self(ll a,ll b){
    a+=b;
    if(a>=mod1)
        a-=mod1;
    return a;
}
ll sub_self(ll a,ll b){
    a-=b;
    if(a<0)
        a+=mod1;
    return a;
}

//to get sum of b consecutive non negative integers starting from a
ull sumcons(ull a,ull b){
    if(a==0){
        return (b*(b-1))/2;
    }
    else{
        ull zzz=(b*(b+1))/2;
        zzz+=((a-1)*b);
        return zzz;
    }
}
ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x;
    cin>>x;
    if(x==0){
        cout<<"1"<<"\n";
    }
    else{
        cout<<"0"<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */
    private static void getAns(MyScanner sc){
        double w = sc.nd(), h = sc.nd(), x = sc.nd(), y = sc.nd();

        out.print(w * h / 2 + " ");
        out.print(w / 2 == x && h / 2 == y? 1: 0);
    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

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

int main(){
	int K;
	int buff;
	cin >> K;

	if(K%2 == 0){
		buff = K/2;
		cout << buff * buff;
	}else{
		buff = (K+1)/2;
		cout << buff * (buff-1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;

int n, m;
int main() {
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c, d, e, f, x, y;
  while(scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF){
    x = (c * e - f * b) * 100000 / (a * e - d * b) + 5;
    y = (c * d - f * a) * 100000 / (b * d - e * a) + 5;
    printf("%.3lf %.3lf\n", x * 0.00001, y * 0.00001);
  }
  return 0;
}

Measured memory_bytes: 1068
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,T;
int A[100010];

signed main(){
	cin>>N>>T;
	REP(i,N){
		cin>>A[i];
	}
	int Min=INF;
	int dim=0;
	int ans=1;
	REP(i,N){
		if(dim<A[i]-Min){
			dim=A[i]-Min;
			ans=1;
		}
		else if(dim==A[i]-Min){
			ans++;
		}
		Min=min(Min,A[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int MAXN = 1 << 19;
int N = 400000;
int seg[2 * MAXN]; // root is seg[1]

void update(int p, int val)
{
    p += N;
    for (seg[p] = max(seg[p], val); p > 0; p >>= 1)
        seg[p >> 1] = max(seg[p], seg[p ^ 1]);
}

int query(int l, int r)
{
    int res = 0;
    for (l += N, r += N; l <= r; l >>= 1, r >>= 1)
    {
        if (l & 1)
            res = max(res, seg[l++]);
        if (!(r & 1))
            res = max(res, seg[r--]);
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        update(x, 1 + query(max(0, x - k), min(300000, x + k)));
    }
    cout << query(0, 300000);
}


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

int INF = 1001001001;

int main(){
	int n, k;
  	cin >> n >> k;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  
  	vector<int> dp(n, INF);
  	dp[0] = 0;

  	for(int i = 0; i < n; i++){
      	for(int j = 1; j <= k; j++){
          	if(i + j + 1 > n) break;
          	
        	dp[i + j] = min(dp[i + j], dp[i] + abs(a[i + j] - a[i]));
        }
    }
  
  	cout << dp[n - 1] << endl;
}	

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<iomanip>
using namespace std;

int main(){
	
	int a,b,d,r;
	double f;
	cin >> a >> b;
	
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	
	//printf("%d %d %lf\n",d,r,f);
	
	cout << d << " "<< r << " ";
	cout << fixed;
	cout << setprecision(9) << f << endl;
	return 0;
	
}
 	
	
	




Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long

int main() {
  int a;
  cin >>a;
  
  cout << 1110-a;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if((C+B-1) / B <= (A+D-1) / D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define itmin(x,y) (x) = min((x),(y));
#define itmax(x,y) (x) = max((x),(y));
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

string s,t;
vector<vector<pair<int,ii>>> v;
string ans = "";

void rec(pair<int,ii> a){
    if(a.S.F==-1) return;
    if(v[a.S.F][a.S.S].F == a.F-1) ans = s[a.S.F] + ans;
    rec(v[a.S.F][a.S.S]);
}

int main(){
    cin>>s>>t;
    int n = s.size(), m = t.size();
    v = vector<vector<pair<int,ii>>>(n+2,vector<pair<int,ii>>(m+2,{0,{-1,-1}}));
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i<n && j<m && s[i]==t[j]){
                if(v[i][j].F+1 > v[i+1][j+1].F) v[i+1][j+1] = {v[i][j].F+1,{i,j}};
            }
            
            if(v[i][j].F > v[i+1][j].F) v[i+1][j] = {v[i][j].F,{i,j}};
            if(v[i][j].F > v[i][j+1].F) v[i][j+1] = {v[i][j].F,{i,j}};
        }
    }
    rec(v[n][m]);
    cout<<ans;
}

Measured memory_bytes: 106240
#include<stdio.h>
#include<stdlib.h>
#define N 100000
 
int A[N];
int Partition(int A[],int p,int r);
int main(){
   
  int i,j,n,x;
   
  scanf("%d",&n);
  /*
    A = malloc(sizeof(int)*n+1);
    B = malloc(sizeof(int)*n+1);
  */
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
   
  x=Partition(A,0,n-1);
  for(i=0;i<x;i++){
    printf("%d ",A[i]);   
  }
  printf("[%d] ",A[x]);
  for(i=x+1;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1)
      printf(" ");    
  }
  printf("\n");
  return 0;
}
 
int Partition(int A[],int p,int r){
  int x,i,j,n;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(x>=A[j]){
      i=i+1;
      n=A[j];
      A[j]=A[i];
      A[i]=n;
    }
  }
  n=A[r];
  A[r]=A[i+1];
  A[i+1]=n;
  return i+1;
}

Measured memory_bytes: 992
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  int tmp;

  cin >> N >> M;

  vector<int> K(N);
  vector<int> A(M+1, 0);
  for(int i = 0; i < N; i++){
    cin >> K[i];
    for(int j = 0; j < K[i]; j++){
      cin >> tmp;
      A[tmp]++;
    }
  }

  for(int i = 0; i <= M; i++){
    //cout << "cnt = " << A[i] << " at num = " << i <<endl;
    if(A[i] == N){
      ans++;
      //cout << "ans++" << endl;
    }
  }
  cout << ans << endl;

}


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

//C++14 (GCC 5.4.1)

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

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

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

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

#define PI 3.14159265358979
int main() {
    double a,b,x;
    scanf("%lf%lf%lf",&a,&b,&x);
    double S=x/a,m,r;
    if(a*b/2<S){
        m=(a*b-S)*2/a;
        //printf("  %.6f %.6f\n",m,a);
        r=atan2(m,a);
    }else{
        m=S*2/b;
        //printf("  %.6f %.6f\n",b,m);
        r=atan2(b,m);
    }
    double deg=r*180.0/PI;
    
    printf("%.20f\n",deg);
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

// Extended Print Func
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& input){
    os << "[ ";
    REP(i, input.size()){
        os << input[i];
        if (i < input.size()-1) { os << " "; }
    }
    os << " ]";
    return os;
}
void print() { std::cout << "\n"; }
template<class T, class... A> void print(const T& first, const A&... rest) { std::cout << first << " "; print(rest...); }
template<class... A> void print(const A&... rest) { print(rest...); }



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

  ll N;
  cin >> N;
  double denom = 0;
  REP(i,N){
      double ai;
      cin >> ai;
      denom += 1/ai;
  }
  
  cout << fixed << setprecision(10) << 1.0/denom << "\n";
  return 0;
}


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

int count(long long N) {
  int count = 0;
  while(N>0) {
    N = N/10;
    count++;
  }
  return count;
}

int main() {
  long long N;
  cin >> N;
  
  int ans = count(N);
  
  for (long long A = 1; A*A <= N; A++) {
    if (N%A == 0) {
      long long B = N/A;
      if (ans > max(count(A), count(B))) {
        ans = max(count(A), count(B));
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define P 5

int main(void)
{
        int card[P] = {0, 0, 0, 0, 0};
        int i = 0;
        int j = 0;
        int k = 0;
        int m = 0;
        int count = 0;
        int t = 0;
        int c[P] = {0, 0, 0, 0, 0};

        while( scanf("%d,%d,%d,%d,%d",&card[0],&card[1],&card[2],&card[3],&card[4]) != EOF )
        {
                for(i = 0; i < P ; i++)
                {
                        for(j = 0; j < P ; j++)
                        {
                                if(card[i] > card[j])
                                {
                                        m = card[i];
                                        card[i] = card[j];
                                        card[j] = m;
                                }
                        }
                }
                for(i = 0; i < P ; i++)
                {
                        for(j = i + 1; j < P ; j++)
                        {
                                if(card[i] == card[j])
                                {
                                        count++;
                                }
                        }
                }

                if(count == 0)
                {
                        for(k = 0 ;k < P; k++)
                        {
                                c[k] = card[k] + k;
                        }
                        for(k = 1 ;k < P; k++)
                        {
                                if(c[0] == c[k])
                                {
                                        t++;
                                }
                        }
                        if((t == 4) || (card[0] == 13 && card[1] == 12 && card[2] == 11 && card[3] == 10 && card[4] == 1))
                        {
                                printf("straight\n");
                        }
                        else
                        {
                                printf("null\n");
                        }
                }
                else if(count == 1)
                {
                        printf("one pair\n");
                }
                else if(count == 2)
                {
                        printf("two pair\n");
                }
                else if(count == 3)
                {
                        printf("three card\n");
                }
                else if(count == 4)
                {
                        printf("full house\n");
                }
                else if(count == 6)
                {
                        printf("four card\n");
                }
                t = 0;
                m = 0;
                count = 0;
                for(i = 0; i < P; i++)
                {
                           c[i] = 0;
                        card[i] = 0;
                }
                i = 0;
                j = 0;
                k = 0;
        }
        return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> il;
map<il,ll> mapa;
ll inf = 0x3f3f3f3f3f3f3f3f;
int n;
ll W;

ll vet[101][2];

ll solve(int id, ll w){
	if(w < 0)
		return -inf;
	if(id == n)
		return 0;
	if(mapa[{id,w}])
		return mapa[{id,w}];
	ll ans = max(vet[id][0] + solve(id+1,w-vet[id][1]), solve(id+1,w));
	mapa[{id,w}] = ans;
	return ans;
}

int main(){
	cin >> n >> W;
	int id = 0;
	for(int i = 0;i<n;i++){
		cin >> vet[id][1] >> vet[id][0];
		if(vet[id][1] <=W)
			id++;
	}
	n = id;
	cout<<solve(0,W);	

}

Measured memory_bytes: 6272
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

ab = sorted(AB, key=lambda x: x[1])
task = 0
result = 'Yes'

for i in range(N):
    task += ab[i][0]
    if task > ab[i][1]:  # comparison with limit.
        result = 'No'

print(result)

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

int main() {

string S, T, U;
int A, B;
cin >> S >> T;
cin >> A >> B;
cin >> U;
if(S==U){
    cout << A-1 << " " << B << endl;
}
else{
    cout << A << " " << B-1 << endl;
}

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <cstring>
#include <list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
static const double EPS = 1e-5;
static const int INFTY = (1<<21);
static const ll LLINFTY = (1LL<<53);
#define REP(i,m,n) for(i=m;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define out(a,b) (a<0||a>=b)
struct node{
  int tx,ty;
  int kx,ky;
  int c;
  int mini;
  node(){}
  node(int a,int b,int c_,int d,int e):tx(a),ty(b),kx(c_),ky(d),c(e),
  mini((abs(a-c_)+abs(b-d))*2){}
  bool operator>(const node& e)const{
    //return c+mini>e.c+e.mini;
    return c>e.c;
  }
};
bool used[50][50][50][50];
int dx[]={0,1,0,-1};
int dy[]={0,-1,0,1};
int main(void)
{
  int w,h,i,j,ii,jj;
  int tx,ty,kx,ky;
  int g[50][50];
  node p;
  for(;;){
    scanf("%d%d",&w,&h); if(!w)break;
    scanf("%d%d%d%d",&tx,&ty,&kx,&ky); tx--; ty--; kx--; ky--;
    rep(i,h)rep(j,w){
      scanf("%d",g[i]+j);
      rep(ii,h)rep(jj,w)used[i][j][ii][jj]=false;
    }
    //priority_queue<node,vector<node>,greater<node> >q;
    queue<node>q;
    q.push( node(tx,ty,kx,ky,0) );
    used[ty][tx][ky][kx]=true;
    while( !q.empty() ){
      //p=q.top();
      p=q.front();
      q.pop();
      if(p.tx==p.kx && p.ty==p.ky){
        printf("%d\n",p.c);
        goto END;
      }
      rep(i,4){
        tx=p.tx+dx[i]; ty=p.ty+dx[3-i];
        kx=p.kx+dy[i]; ky=p.ky+dy[3-i];
        if(out(tx,w)||out(ty,h)||g[ty][tx])tx=p.tx,ty=p.ty;
        if(out(kx,w)||out(ky,h)||g[ky][kx])kx=p.kx,ky=p.ky;
        if(!used[ty][tx][ky][kx]){
          used[ty][tx][ky][kx]=true;
          q.push(node(tx,ty,kx,ky,p.c+1));
        }
      }
    }
    puts("NA");
  END:;
  }
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {

            // 文字列の入力
            int a = int.Parse(Console.ReadLine());



            int result = a + a*a + a*a*a;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27384
#include<stdio.h>

int main(void){
	int n,i, j;
	int a[200000];
	int ri,rj ,max, min;
	scanf("%d", &n);
	
	for(i = 0;i<n;i++){
		scanf("%d", &a[i]);
	}

	max = a[1]-a[0];
	min = a[0];
	for(j =1;j<n;j++){
		if(max < (a[j] -min)){
			max = a[j]-min;}
		if(min > a[j]){
			min = a[j];}
	}
	
	printf("%d\n", max);
	return 0;
}



Measured memory_bytes: 2556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int64_t h, w;
  cin >> h >> w;
  vector<vector<int64_t>> A(h, vector<int64_t>(2, 0));
  int64_t big = pow(10, 9);

  rep(i, h)
  {
    cin >> A[i][0] >> A[i][1];
  }
  rep(i, h)
  {
    A[i][0]--;
    A[i][1]--;
  }

  set<pair<int64_t, int64_t>> S;
  rep(i, w)
  {
    S.insert(make_pair(i, i));
  }
  S.insert(make_pair(-big, -big));
  S.insert(make_pair(big, big));

  multiset<int64_t> M;
  rep(i, w)
  {
    M.insert(0);
  }


  rep(i, h)
  {
    int64_t max_begin_p = -1;
    for (auto itr = S.lower_bound(make_pair(A[i][0]-1, -1)); itr != S.end();)
    {
      pair<int64_t, int64_t> pp = *itr;
      int64_t end_p = pp.first;
      int64_t begin_p = pp.second;
      if (A[i][0] <= end_p && end_p <= A[i][1]+1)
      {
        M.erase(M.find(end_p - begin_p));
        max_begin_p = max(max_begin_p, begin_p);
        itr = S.erase(itr);
      }
      else if (end_p > A[i][1]+1)
      {
        break;
      }
      else
      {
        itr++;
      }
    }
    if (max_begin_p != -1)
    {
      // cout << "S insert" << endl;
      
      // cout << "M insert" << endl;
      if (A[i][1]+1 != w)
      {
        M.insert(A[i][1]+1 - max_begin_p);
        S.insert(make_pair(A[i][1]+1, max_begin_p));
      }
      else
      {
        M.insert(big);
        // S.insert(make_pair(big, max_begin_p));
      }
    }
    // cout << "makeans" << endl;

    // cout << "S ";
    // for (auto itr = M.begin(); itr != M.end(); ++itr)
    // {
    //   cout << *itr << " ";
    // }
    // cout << endl;
    // cout << "M ";
    // for (auto itr = S.begin(); itr != S.end(); itr++)
    // {
    //   pair<int64_t, int64_t> pp = *itr;
    //   cout << pp.first << "," << pp.second << " ";
    // }
    // cout << endl;


    int64_t ans = *begin(M) + i + 1;
    if (ans > pow(10, 7)) {
      ans = -1;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 42308
solve :: Int -> Int -> Int
solve k s =
 length $ 
    [()|
       x <- [0..k]
     , y <- [0..k]
     , let z = s - x - y
     , z >= 0 && z <= k
     , x+y+z == s]

main = do
  [k, s] <- map read . words <$> getLine :: IO [Int]
  print $ solve k s

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
#define Test int T;cin>>T;while(T--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) (int)s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define mem(a,n) memset((a),n,sizeof (a))
#define ii pair<int,int>
const double eps=1e-9;
const int mod=1e9+7;
const int N=5001;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
ll gcd(ll x,ll y){return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y){return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main(){
    fast();
    int n;
    cin>>n;
    while(n--){
        cout<<"ACL";
    }
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
vector<int> p[100010];
queue<int> q;
int vis1[100010],vis2[100010],n;
void dfs()
{
    int i,j,x,y;
    q.push(1);
    q.push(0);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        y=q.front();
        q.pop();
        for(i=0;i<p[x].size();i++)
        {
            j=p[x][i];
            if(vis1[j]==0)
            {
                vis1[j]=y+1;
                q.push(j);
                q.push(y+1);
            }
        }
    }
}
void bfs()
{
    int i,j,x,y;
    while(!q.empty())
        q.pop();
    q.push(n);
    q.push(0);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        y=q.front();
        q.pop();
        for(i=0;i<p[x].size();i++)
        {
            j=p[x][i];
            if(vis2[j]==0)
            {
                vis2[j]=y+1;
                q.push(j);
                q.push(y+1);
            }
        }
    }
}
int main()
{
    int i,j,k,x,y;
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        p[x].push_back(y);
        p[y].push_back(x);
    }
    memset(vis1,0,sizeof(vis1));
    vis1[1]=-1;
    dfs();
    memset(vis2,0,sizeof(vis2));
    vis2[n]=-1;
    bfs();
    vis2[n]=-1;
    y=0;
    for(i=1;i<=n;i++)
        if(vis2[i]<vis1[i])
            y++;
        x=n-y;
        if(x>y)
            printf("Fennec\n");
        else
            printf("Snuke\n");
        return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int main(){
      int a,b,c,d,e;
      while(cin>>a&&a){
            cin>>b>>c>>d>>e;
            int cnt1=min(e,b/c);
            int sum=b-cnt1*c;
            int cnt2=sum/d;
            sum-=cnt2*d;
            if(cnt1==0){
                  cout<<"NA"<<endl;
            }else if(cnt1+cnt2>=a){
                  cout<<cnt1<<" "<<cnt2<<endl;
            }else{
                  if(d>=c)cout<<"NA"<<endl;
                  else{
                        while(cnt2+cnt1<a&&cnt1>1){
                              sum+=c;cnt1--;
                              while(sum>=d){
                                    sum-=d;
                                    cnt2++;
                              }
                        }
                        if(cnt2+cnt1>=a&&cnt1>0)cout<<cnt1<<" "<<cnt2<<endl;
                        else cout<<"NA"<<endl;
                  }
            }
      }
}

Measured memory_bytes: 1164
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const e = parseInt(args[4][0], 10)
	const k = parseInt(args[5][0], 10)
	if (e - a <= k) console.log('Yay!')
	else console.log(':(')
}

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


Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

const int inf = 1e8;
const int sz = 1005;
string s, t;
int ans = 0;

int main() {

    while (cin >> s >> t) {

        ans = 0;
        
        for (int i = 0; i < s.size(); i++) {
            ans += (s[i] == t[i]);
        }

        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int main(){
  int a, b;
  string s;
  char c;
  cin >> a >> b;
  if(a <= b) cout << "unsafe" <<endl;
  else cout << "safe" <<endl;
}

Measured memory_bytes: 3624