akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rn0(const i64 e) noexcept { return ran(e); }
constexpr ran rn0(const i64 b, const i64 e) noexcept { return ran(b, e); }
constexpr ran rn1(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rn1(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

i64 pow_(i64 x, i64 p) {
  i64 ans = 1;
  while(p) {
    if(p & 1) ans *= x;
    x = x * x;
    p >>= 1;
  }
  return ans;
}

i64 calc(i64 x) {
  i64 ans = 0;
  while(x) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}

int main() {
  i64 a, n, m;
  cin >> a >> n >> m;
  i64 ans = 0;
  for(i64 z = 1;pow_(z, n) <= m;z++) {
    i64 x = pow_(z, n);
    i64 y = z - a;
    if(calc(x) == y) {
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

const ll mod = 998244353;

vector<ll> one(1000000);
vector<ll> ten(1000000);


struct S{
  ll a;
  int len;
};

struct F{
  int f;
};

S op(S l,S r){
  return S{(l.a*ten[r.len]+r.a)%mod , l.len+r.len};
}

S e(){
  return S{0,0};
};

S mapping(F f, S s){
  if(f.f==0) return s;
  return S{one[s.len]*f.f%mod, s.len};
}

F composition(F l,F r){
  return l.f?l:r;
}

F id(){
  return F{0};
}


int main(){
  int N, Q; cin >> N >> Q;
  ten[0]=1;
  one[0]=0;
  for(int i=1;i<1000000;i++){
    ten[i] = ten[i-1]*10%mod;
    one[i] = (one[i-1]*10+1)%mod;
  }
  S s = {1,1};
  vector<S> v(N,s);
  atcoder::lazy_segtree<S,op,e,F,mapping,composition,id> seg(v);
  rep(i,Q){
    int L,R,D; cin >> L >> R >> D;
    seg.apply(L-1,R,F{D});
    cout << seg.all_prod().a << endl;
  }
  return 0;
}


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

int main(){
  int64_t H,W;
  cin >> H >> W;
  if((H==1)||(W==1)){
    cout << 1 << endl;
    return 0;
  }
  cout << ((H*W)+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int n,m,a[110];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	  scanf("%d",&a[i]);
	if(m==1 && n>1)
	  {
	   printf("%d\n2\n%d 1\n",n,n-1);
	   return 0;
	  }
	for(i=1;i<=m;i++)
	  if(a[i]&1)
	    {
   	     swap(a[1],a[i]);
	     break;
		}
	for(i=2;i<=m;i++)
	  if(a[i]&1)
	    {
	     swap(a[m],a[i]);
	     break;
		}
	for(i=2;i<m;i++)
	  if(a[i]&1)
	    break;
	if(i<m)
	  printf("Impossible\n");
	else
	  {
	   for(i=1;i<=m;i++)
	     printf("%d ",a[i]);
	   printf("\n");
	   a[1]++;
	   a[m]--;
	   if(!a[m])
	     m--;
	   printf("%d\n",m);
	   for(i=1;i<=m;i++)
	     printf("%d ",a[i]);
	   printf("\n");
	  }
	return 0;
}


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

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

using namespace std;

signed main(){
    int n; cin >> n;
    string str; cin >> str;
    vector<bool> w(n,true);
    int l=0, r=0;
    for(int i = 0; i < n; i++){
        if(str[i] == 'E'){
            w[i] = false;
            r++;
        }
    }
    if(!w[0]){r--;}
    int ans = r;
    for(int i = 1; i < n; i++){
        if(!w[i]){
            r--;
        }
        if(w[i-1]){
            l++;
        }
        ans = min(ans, r+l);
    }

    cout << ans << endl;

    return 0;
}



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

ll	F(const vector<ll> &B, int K) {
	ll S0=0; // Total
	for (auto BB: B)
		S0+=BB;
	if (S0<0)
		S0=0;
	vector<ll> BBB;
	BBB.push_back(0);
	for (auto BB: B)
		BBB.push_back(BB);
	for (auto BB: B)
		BBB.push_back(BB);
	for (auto i=1; i<(int)BBB.size(); i++)
		BBB.at(i) +=BBB.at(i-1);
	ll S1=-1000000000000000000;
	int KK=min(K, (int)B.size());
	Rep1(i, KK) {
		ll S2=((K-i)/B.size())*S0;
		for (auto j=0; j+i<(int)BBB.size(); j++)
			S1=max(S1, BBB.at(j+i)-BBB.at(j)+S2);
	}
	return S1;
}

int	main() {
	int N, K;
	cin >>N >>K;
	vector<int> P(N+1, 0);
	vector<ll> C(N+1, 0);
	Rep1(i, N)
		cin >>P.at(i);
	Rep1(i, N)
		cin >>C.at(i);
	vector<bool> Done(N+1, false);
	ll S=-1000000000000000000;
	Rep1(i, N) {
		if (Done.at(i))
			continue;
		vector<ll> B;
		int I=i;
		while (!Done.at(I)) {
			B.push_back(C.at(I));
			Done.at(I)=true;
			I=P.at(I);
		}
		ll S0=F(B, K);
		S=max(S, S0);
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 3788
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=500010;
const int K=25;
int dp[N][26];
int fa[N][21];
int a[N];char s[N];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,j,x,n,last,l,r,Q;
	scanf("%s",s+1);n=strlen(s+1);
	rep(i,1,n)	a[i]=s[i]-'a';
	rep(i,1,n+1)	rep(j,0,K)	dp[i][j]=-1;
	rep(i,1,n+1)	fa[i][0]=n+2;
	fa[n+2][0]=n+2;
	for(i=n;i;i--){
		dp[i][a[i]]=i;last=i+1;
		rep(j,a[i]+1,K){
			if(last==n+1)	dp[i][j]=-1;
			else{
				if(dp[last][j-1]!=-1){dp[i][j]=dp[last][j-1];last=dp[i][j]+1;}
				else last=n+1;
			}
		}
		if(dp[i][K]!=-1&&dp[dp[i][K]+1][K]!=-1){
			x=dp[dp[i][K]+1][K]+1;
			rep(j,0,K)	if(dp[i][j]==-1)	dp[i][j]=dp[x][j];
			fa[i][0]=x;
		}
	}
	rep(j,1,20)	rep(i,1,n+2)	fa[i][j]=fa[fa[i][j-1]][j-1];
	scanf("%d",&Q);
	while(Q--){
		scanf("%d%d",&l,&r);r++;
		for(i=20;i>=0;i--)	if(fa[l][i]<=r)	l=fa[l][i];
		if(l==r)	printf("Yes\n");
		else printf("No\n");
	}
}
		
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 94848
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 1;

void input(){
    string s, t;
    cin >> s >> t;
    int a, b;cin >> a >> b;
    string u; cin >>u;
    if(s == u)a--;
    if(t == u)b--;
    cout << a << " "<< b << endl;
}
int main(){
    input();
    return 0;
}

Measured memory_bytes: 256
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
const int maxn = 18;
const int p = 1e9+7;
int n, m;
int lo[maxn];
ll dp[1 << maxn];
ll fa[1 << maxn], inv[1 << maxn], fainv[1 << maxn];
inline void init(){
	inv[1] = fa[1] = fainv[1] = fa[0] = inv[0] = fainv[0] = 1;
	for(int i = 2;i < (1 << maxn);++i){
		fa[i] = fa[i-1] * i % p;
		inv[i] = (p-p/i) * inv[p % i] % p;
		fainv[i] = inv[i] * fainv[i-1] % p;
	}
}
ll per(int a, int b){
	return (a < b ? 0 : fa[a] * fainv[a - b]) % p;
}
int count_bit(int v){
	int res = 0;
	for(;v;v -= (v & -v))++res;
	return res;
}
void out(int s){
	for(int i = n-1;i >= 0;--i)cout << !!(s & (1 << i));
	cout << '\n';
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	init();
	cin >> n >> m;
	read(m, lo+1);
	sort(lo+1, lo+1+m, greater<int>());
	dp[0] = 1;
#define lowbit(i) ((i) & (-i))
	for(int i = 1;i <= m;++i){
		for(int s = 1<<n;s > 0;--s){
			for(int j = s;j > 0;j -= lowbit(j)){
				dp[s] = (dp[s] + (dp[s ^ lowbit(j)] * per((1<<n)-lo[i]-s+lowbit(j), lowbit(j)-1) % p * lowbit(j) % p)) % p;				
			}
		}
	}
	// for(int i = 1;i < (1<<n);++i)cout << dp[i] << '\n';
	ll res = 0;
	for(int s = 1;s < (1 << n);++s){
		dp[s] = dp[s] * fa[(1<<n)-1-s];
		if(count_bit(s)&1)res = (res + p - dp[s]) % p;
		else res = (res + dp[s]) % p;
	}
	res = (fa[(1<<n)-1] + p + res) % p * (1 << n) % p;
	cout << res << '\n';
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	map<int, int> a;
	int n;
	cin >> n;
	int t;
	int ans = 0;
	rep(i, n) {
		cin >> t;
		a[t - 1]++;
		a[t]++;
		a[t + 1]++;
		int b = max(a[t - 1], a[t]);
		b = max(b, a[t + 1]);
		ans = max(ans, b);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4736
def ans(N, Y):
    for m in range(N + 1):
        for g in range(N + 1 - m):
            s = N - m - g
            sum = m * 10000 + g * 5000 + s * 1000
            if sum == Y:
                return m, g, s
    return -1, -1, -1

def read():
    N, Y = [int(a) for a in input().split(' ')]
    return N, Y

def write(a):
    print(a[0], a[1], a[2])

if __name__ == '__main__':
    N, Y = read()
    write(ans(N, Y))


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

int main(){
    int H,N;cin>>H>>N;
    int P=0;
    int A=0;
    for(int i=0;i<N;i++){
        cin>>A;
        P+=A;
    }
    if(H>P){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
from functools import lru_cache
N=int(input())

@lru_cache(maxsize=32)
def generate_lucas(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return generate_lucas(n-2)+generate_lucas(n-1)

print(generate_lucas(N))

Measured memory_bytes: 3572
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,m;
    cin>>n>>m;
    VL p(m);
    VS s(m);
    REP(i,m){
        cin>>p[i]>>s[i];
    }
    LL ac = 0;
    LL wa = 0;

    VVL q(n);
    REP(i,m){
        LL x = s[i] == "AC" ? 1 : 0;
        q[p[i]-1].PB(x);
    }

    REP(i,n){
        if(q[i].size() == 0){
            continue;
        }
        LL cnt = 0;
        REP(j,q[i].size()){
            if(q[i][j] == 1)break;
            else cnt++;
        }
        if(cnt != q[i].size()){
            ac++;
            wa += cnt;
        }
    }

    cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 12032
n = gets.to_i
tasks = []
n.times do
  a, b = gets.split.map(&:to_i)
  tasks << [b,a]
end
now = 0
tasks.sort.each do |t|
  now += t[1]
  if now > t[0]
    puts 'No'
    exit
  end
end
puts 'Yes'


Measured memory_bytes: 31688
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(n)]
B = []

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1
    
for i in range(8):
    temp = sorted([f(i//4) * A[j][0] + f(i//2) * A[j][1] + f(i) * A[j][2] for j in range(n)], reverse=True)
    B.append(sum(temp[:m]))
    
print(max(B))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>
 
#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
using ll = long long;
using pii = std::pair<int,int>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;
 
const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 10241024;
const ll INFL = (1ll << 62) - 1;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//
 
template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}
 
//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}
 
inline void IN(void){
  return;
}
 
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}
 
inline void OUT(void){
  cout << "\n";
  return;
}
 
template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
//_____________________　following sorce code_________________________//
int n,m;
ll k;
//vvll dp(400, vll(400));
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vvi v;
vll u;
 
bool check(ll x){
  ll tot = 0;
  rep(i,n){
    if(u[i] < 0){
      int l = -1, r = n;
      while(l+1<r){
        ll c = (l+r)/2;
        if(u[i]*u[c] < x)r = c;
        else l = c;
      }
      tot += n - r;
    }
    else {
      int l = -1, r = n;
      while(l+1<r){
		ll c = (l+r)/2;
        if(u[i]*u[c] < x)l = c;
        else r = c;
      }
      tot += r;
    }
    if(u[i]*u[i] < x)tot--;
  }
  tot /= 2;
  return tot < k;
}
 
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n,k);
  u = vll(n);
  rep(i,n)IN(u[i]);
  sort(All(u));
  ll l = -(1e18 + 10), r = 1e18 + 10;
  while(l+1<r){
    ll c = (l+r)/2;
    if(check(c))l = c;
    else r = c;
  }
  OUT(l);
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 2304
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main(){
    int n,color[8] = {},ano = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        if(a < 400)color[0] = 1;
        else if(a < 800)color[1] = 1;
        else if(a < 1200)color[2] = 1;
        else if(a < 1600)color[3] = 1;
        else if(a < 2000)color[4] = 1;
        else if(a < 2400)color[5] = 1;
        else if(a < 2800)color[6] = 1;
        else if(a < 3200)color[7] = 1;
        else ano++;
    }
    
    int a = color[0]+color[1]+color[2]+color[3]+color[4]+color[5]+color[6]+color[7];
    if(a > 0)cout << a << ' ';
    else cout << 1 << ' ';
    
    cout << a+ano <<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007LL
#define INF 5000000000000000000
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H*W - H*w - W*h + h*w << endl;	

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int n;
    scanf("%lld",&n);
   long long int a[n];
   for(int i=0;i<n;i++)
   {
       scanf("%lld",&a[i]);
   }
    long long int ans=0;
    
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            long long int diff = a[i-1]-a[i];
            ans+=diff;
            a[i]+=diff;
        }
    }
    printf("%lld",ans);

    return 0;
}

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

int main() {
   int r;cin >> r;
   cout << (2 * r) * pi << endl;
   return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}

int main(){
    string s;
    cin >> s;
    if(s=="0")
    {
        cout << "Yes" << endl;
        return 0;
    }

    ll n_sum = 0;
    rep(i, s.size()) {
        n_sum += ctoi(s[i]);
    }
    if(n_sum%9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3752
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int N = 1 << 20, oo = 1e18 + 100, mod = 1e9 + 9;
const double eps = 1e-9, PI = 2 * acos(0.0);
vi vertices[N];
vi visit(N, 0);
int n, m, k;
int cnt = 0;

typedef int ftype;
typedef complex<ftype> point;
#define x real
#define y imag

ftype dot(point a, point b) 
{
	return (conj(a) * b).x();
}

ftype f(point a, ftype x) {
	return dot(a, { x, 1 });
}

vector<point> t(N << 1, { 0, oo });

void add_line(point nw, int v = 1, int l = 0, int r = N-1)
{
	int md = (r + l) >> 1;

	bool left = f(nw, l) < f(t[v], l);
	bool mid = f(nw, md) < f(t[v], md);

	if (mid)
	{
		swap(t[v], nw);
	}

	if (l == r)
		return;

	if (left != mid)
	{
		add_line(nw, v << 1, l, md);
	}
	else
	{
		add_line(nw, v << 1 | 1, md+1, r);
	}

	return;
}

int get(int x, int v = 1, int l = 0, int r = N-1)
{
	int ret = f(t[v], x);

	if (l == r)
		return ret;

	int md = (r + l) >> 1;

	if (x <= md)
	{
		return min(ret, get(x, v << 1, l, md));
	}
	else
	{
		return min(ret, get(x, v << 1 | 1, md+1, r));
	}
}

int dp[N];

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/
	
	cin >> n >> m;

	vi h(n);

	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	dp[0] = 0;
	add_line({ -2 * h[0], h[0] * h[0] + dp[0] });

	for (int i = 1; i < n; i++)
	{
		dp[i] = get(h[i]) + h[i]*h[i] + m;
		add_line({ -2 * h[i], h[i] * h[i] + dp[i] });
	}

	cout << dp[n - 1];
}

Measured memory_bytes: 69504
S = str(input())

if S == 'SUN':
    print(7)
elif S =='MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

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

using namespace std;
using ll = long long;


int main(){
  ll L, R;
  cin >> L >> R;
  
  vector<ll> x;
  
  if(R-L>2500){
    cout << 0 << endl;
  }else{
    ll res = 2018;
    for(ll i=L; i<R; i++){
      for(ll j=i+1; j<=R; j++){
        res = min(res, (i*j)%2019);
      
      }
    }
    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3644
n,m = map(int, input().split())

l = []
for i in range(n): #Kを除く好きな食べ物を取得
    a = [int(_) for _ in input().split()]
    l.append(a[1:a[0]+1])

y = [] #全部好きな人を要素’1’として格納
for j in range(1,m+1):
    x = 0
    for k in range(n):
        if j in l[k]:
            x += 1
    if x == n:
        y.append(1)
        
print(len(y))


Measured memory_bytes: 3060
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     int i, j;
     cin >> n >> m >> k;
     if (n + m + k >= 22)
          cout << "bust";
     else
          cout << "win";

}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),v(100001);
    ll ans=0;
    rep(i,n){
        cin >> a[i];
        v[a[i]]++;
        ans+=a[i];
    }
    ll q;
    cin >>q;
    rep(i,q){
        ll b,c;
        cin >> b >> c;
        ll num=v[b];
        ans+=(c-b)*num;
        v[b]=0;
        v[c]+=num;
        cout << ans << endl;
    }
} 


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

int main(int argc, char const *argv[]) {
  int a,b;
  cin>>a>>b;
  int s[a];
  for(int i=0;i<a;i++){
    cin>>s[i];
  }
  int sum=0;
  sort(s,s+a,greater<int>());
  for(int i=0;i<b;i++){
    sum+=s[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
int n,m;
char str[40] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
scanf("%d", &n);    
m = str[n-1];    
    
printf("%d", m);    
    

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, M, K, A[222222], B[222222];

long long acc1[222222], acc2[222222];


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N >> M >> K;

  acc1[0] = acc2[0] = 0;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    acc1[i + 1] = A[i] + acc1[i];
  }
  
  for (int i = 0; i < M; i ++) {
    std::cin >> B[i];

    acc2[i + 1] = B[i] + acc2[i];
  }

  int cp = 0;

  for (int i = 0; i <= N; i ++) {
    long long S = acc1[i];
    long long T = std::max(K - S, 0LL);

    int k = std::upper_bound(acc2, acc2 + M + 1, T) - acc2 - 1;

    long long U = S + acc2[k];

    int c = i + k;

    if (U <= K)
      cp = std::max(c, cp);
  }

  std::cout << cp << std::endl;

  return 0;
}


Measured memory_bytes: 8332
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  int k = 0;
  for (ll i = 1; i <= n; i++){
    if (i*(i - 1)/2 == n){
      k = i;
    }
  }
  if (n == 1){
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;
  }
  else if (k == 0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
    cout << k << endl;
    vector<vector<ll>> store(k, vector<ll>(0));
    for (int i = 0; i < k; i++){
      for (int j = i + 1; j < k; j++){
        store[i].emplace_back(i*(2*k-i-1)/2 + j - i);
        store[j].emplace_back(i*(2*k-i-1)/2 + j - i);
      }
    }
    for (int i = 0; i < k; i++){
      cout << k - 1;
      for (int j = 0; j < k - 1; j++){
        cout << " " << store[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 114514
int n,m;
set<int> G[MAX];
int c[MAX],d[MAX],e[MAX];
typedef pair<int,int> P;
signed main(){
  fill_n(c,MAX,0);
  fill_n(d,MAX,0);
  fill_n(e,MAX,-1);
  cin>>n;
  for(int i=0;i<n;i++) cin>>c[i];
  cin>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].insert(b);
    G[b].insert(a);
  }
  priority_queue<P,vector<P>,greater<P> > q;
  for(int i=0;i<n;i++) q.push(P(c[i],i));
  while(!q.empty()){
    int x=q.top().first;
    //cout<<x<<endl;
    set<int> v;
    while(!q.empty()&&q.top().first==x){
      v.insert(q.top().second);
      q.pop();
    }
    priority_queue<P> q2;
    while(1){
      bool f=0;
      for(int w:v){
	int t=d[w];
	for(int u:G[w]) t=max(t,d[u]);
	if(e[w]<=t) q2.push(P(t,w));
      }
      while(!q2.empty()){
	P p=q2.top();q2.pop();
	int t=p.first,w=p.second;
	t=max(t,d[w]);
	for(int u:G[w]) t=max(t,d[u]);
	if(e[w]>t) continue;
	e[w]=t+1;
	f=1;
	for(int u:G[w])
	  d[u]=max(d[u],t);
      }
      if(!f) break;
    }
    for(int w:v)
      for(int u:G[w]){
	if(c[u]==c[w]&&e[u]>0){
	  if(e[u]!=e[w]) cout<<u<<" "<<w<<":"<<e[u]<<" "<<e[w]<<endl;
	  assert(e[u]==e[w]);
	}
      }
    for(int w:v)
      for(int u:G[w])
	d[u]=max(d[u],e[w]);
  }
  int ans=0;
  //for(int i=0;i<n;i++) assert(e[i]);
  //for(int i=0;i<n;i++) cout<<i<<":"<<e[i]<<endl;
  for(int i=0;i<n;i++) ans+=e[i];
  cout<<ans<<endl;
  return 0;
}

      /*
      for(int u:G[w]){
	if(c[u]==c[w]&&e[u]>0){
	  if(e[u]!=e[w]) cout<<u<<" "<<w<<":"<<e[u]<<" "<<e[w]<<" "<<b<<endl;
	  assert(e[u]==e[w]);
	}
      }
      */

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if (n%2!=0){
    cout<<"No";
  }
  else{
    string temp = s.substr(0,n/2);
    if (s==temp+temp){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
  }
}

Measured memory_bytes: 3584
H, W, K=map(int, input().split())
s=[]
gyob=[0]*H
retub=[0]*W
for _ in range(H):
  c=input()
  gyob[_]=list(c).count("#")
  for j in range(W):
    if c[j]=="#":
      retub[j]+=1
  s.append(c)
bs=sum(gyob)

gyo=[]
for i in range(1, 2**H):
  l=[]
  for j in range(H):
    if (i>>j)&1:
      l.append(j)
  gyo.append(l)
retu=[]
for i in range(1, 2**W):
  l=[]
  for j in range(W):
    if (i>>j)&1:
      l.append(j)
  retu.append(l)
ans=0
for g in gyo:
  blc=0
  for i in g:
    blc+=gyob[i]
  if bs-blc==K:
    ans+=1
  elif bs-blc<K:
    continue
  for r in retu:
    tmp=0
    for j in r:
      tmp+=retub[j]
      for i in g:
        if s[i][j]=="#":
            tmp-=1
    if bs-(blc+tmp)==K:
      ans+=1
for r in retu:
  blc=0
  for j in r:
    blc+=retub[j]
  if bs-blc==K:
    ans+=1

if bs==K:
  ans+=1
print(ans)  
    

Measured memory_bytes: 9228
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(n)]



cd_cands = {}
for c, d in cd:
    cands = []
    for a, b in ab:
        if a < c and b < d:
            cands.append((a, b))
    cd_cands[(c, d)] = cands

cd = sorted(cd, key = lambda x: x[0])
ab_set = set(ab)
ans = 0
for c, d in cd:
    cands = cd_cands[(c, d)]
    if len(cands) == 0:
        continue
    cands = sorted(cands, key = lambda x: x[1], reverse = True)
    for cand in cands:
        if cand in ab_set:
            ans += 1
            ab_set.remove(cand)
            break
print(ans)

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
long long f[N];
ll arr[N];
int n , k , x;


long long power(long long a , long long b){
    long long x = 1 , y = a;
    while(b > 0){
        if(b & 1){
            x = (x * y);
            if(x > MOD)
                x %= MOD;
        }

        y = y*y;
        if(y > MOD)
            y %= MOD;

        b >>= 1;
    }
    return x;
}


long long nCr(long long n , long long r){
    if(r > n)return 0;
    return (f[n] * power(f[r] * f[n-r] %MOD , MOD - 2))% MOD;
}




int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    f[0] = 1;
    for(int i = 1 ; i < N ;i++)
        f[i] = (f[i-1] * i) % MOD;



    cin >> n >> k;

    loop(i,n){
        cin >> x;
        arr[i] = x;
    }

    sort(arr,arr+n);
    ll ans = 0;
    loop(i,n){
        ans -= nCr(n-i-1,k-1) * arr[i] % MOD;
        ans += MOD;
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }

    rloop(i,n-1){
        ans += nCr(i,k-1) * arr[i] % MOD;
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }

    ans %= MOD;
    ans += MOD;
    ans %= MOD;

    cout << ans << endl;

    return 0;
}


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

int main() {
  string S; cin >> S;
  rep(i, 1, S.size()) if(S[i-1] == S[i]) {
    cout << i << " " << i + 1 << endl;
    return 0;
  }
  rep(i, 2, S.size()) if(S[i-2] == S[i]) {
    cout << i - 1 << " " << i + 1 << endl;
    return 0;
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
vector <char> v;
vector<string>ansl;
string s;
string ans = "YES";
int main(){
  int N;
  int cnt = 0;

  cin >>N;
  for(int i= 0;i<N;i++){
    cin >>s;
    if(s == "A")cnt++;
    else cnt--;
    if(cnt < 0){
      ans = "NO";
    }
  }
  if(cnt != 0)ans = "NO";
  cout <<ans<<endl;

  return 0;
}



Measured memory_bytes: 3224
import java.util.*;

public class Main {

    static long ans;
    static boolean[] used;
    static int k;
    static int mod = 1_000_000_007;
    static int[][] g;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        k = sc.nextInt();
        g = buildGraph(sc, n, n-1);
        used = new boolean[n];
        ans = 1L;
        dfs(0, 0, 0);
        System.out.println(ans);
        sc.close();

    }

    public static void dfs(int v, int depth, int sib){
        if(!used[v]){
            if(k - sib - Math.min(depth, 2) == 0){
                ans = 0;
                return;
            }
            used[v] = true;
            ans = ans * (k - sib - Math.min(depth, 2)) % mod;
            int cnt = 0;
            for(int next: g[v]){
                if(used[next]) continue;
                dfs(next, depth+1, cnt++);
            }
        }
    }

    public static int[][] buildGraph(Scanner sc, int n, int m) {
        int[][] graph = new int[n][];
        int[][] edges = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            edges[i][0] = a;
            edges[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }

}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

ll  n,a,b;
int main(){
	cin >> n >> a >> b;
	ll ans = 0;
	ans += n / (a + b) * a;
	ll rest = n % (a + b);
	if(rest > a)ans += a;
	else ans += rest;
	cout << ans << endl;
}

Measured memory_bytes: 256
//tenka1_c.cpp
//Sat Dec 22 18:48:49 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll h,n,w;
	for (h=1;h<=3500;h++){
		for (n=1;n<=3500;n++){
			w = N*h*n;
			if (4*h*n-N*n-N*h == 0){
				continue;
			}
			if(w%(4*h*n-N*n-N*h)==0 && w/(4*h*n-N*n-N*h) > 0){
				cout << h << " " << n << " " << w/(4*h*n-N*n-N*h) << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-13;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[7100];
int A[3100];
int B[3100];
int lv[3100];
int use[3100];
int v[6100];
string dp[3100];
int n;
string pa(int a,int b){
	for(int i=0;i<6100;i++){
		v[i]=0;
	}
	for(int i=a;i<b;i++){
		v[A[i]]=v[B[i]]=1;
	}
	string ret="";
	for(int i=0;i<6100;i++){
		if(v[i])ret+=in[i];
	}
	return ret;
}
string calc(int a){
	if(dp[a]!="wolf")return dp[a];
	if(a==n)return dp[a]="";
	string ret=calc(a+1);
	if(A[a]<B[a]){
		int to=a;
		string tmp="ab";
		while(to<n&&A[to]<B[a]){
			to++;
		}
		tmp+=calc(to);
		if(ret<tmp)ret=tmp;
		return dp[a]=ret;
	}
	int at=a+1;
	int ar=A[a];
	while(at<n&&B[at]<ar){
		ar=A[at];
		at++;
	}
	string tmp=pa(a,at)+calc(at);
	if(ret<tmp)ret=tmp;
	return dp[a]=ret;

}
int main(){
	int a;scanf("%d",&a);
	n=a;
	scanf("%s",in);
	int as=0;
	int bs=0;
	for(int i=0;i<a*2;i++){
		if(in[i]=='a')A[as++]=i;
		if(in[i]=='b')B[bs++]=i;
	}
	for(int i=0;i<=a;i++){
		dp[i]="wolf";
	}
	string ret=calc(0);
	printf("%s\n",ret.c_str());
}

Measured memory_bytes: 15104
#include <stdio.h>
#include <math.h>
typedef long long ll;
#define WA 1000000007

int main()
{
    ll h;
    scanf("%lld",&h);
    ll add=0;
    while(h>0){
        h/=2;
        add++;
    }
    ll ans=1;
    ll snd=0;
    for(int i=0;i<add-1;i++){
        ans*=2;
        snd+=ans;
    }
    printf("%lld",snd+1);
}



Measured memory_bytes: 128