akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void question(long long x) {
    cout << "? " << x << endl;
    fflush(stdout);
}

bool response() {
    char c; cin >> c;
    return c == 'Y';
}

void answer(long long x) {
    cout << "! " << x << endl;
}

int main() {
    vector<long long> a(10, 1);
    vector<long long> b(10);
    for (int i = 0; i < 10; i++) {
        if (i) a[i] = a[i-1] * 10;
        b[i] = a[i] * 10 - 1;
    }
    vector<bool> flag(10, true);
    int cnt = 0; int last = 0; int first = 10;
    for (int i = 0; i < 10; i++) {
        question(a[i]);
        flag[i] = flag[i] * response();
        question(b[i]);
        flag[i] = flag[i] * response();
        if (flag[i]) {
            cnt++; last = max(last, i); first = min(first, i);
        }
    }
    if (cnt == 10) {
        answer(1);
        return 0;
    }
    if (cnt > 1) {
        if (flag[0]) {
            if (last == cnt-1) {
                answer(b[cnt-1]);
                return 0;
            }
        } else if (flag[9]) {
            if (first == 10-cnt) {
                answer(a[10-cnt]);
                return 0;
            }
        }
    }
    long long left = a[last] * 10; 
    long long right = left * 10;
    while (right - left > 1) {
        long long mid = (right+left) / 2;
        question(mid);
        if (response()) right = mid;
        else left = mid;
    }
    answer((left+1)/10);
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

// sum, elemc
ll dp[3005][3005], dp2[3005][3005];
const ll mod = 998244353;

ll modpow(ll b, ll p, ll m) {
	ll r = 1;
	for (; p; p >>= 1, b = b * b % m) if (p & 1) r = r * b % m;
	return r;
}

ll modinv(ll x) {
	return modpow(x, mod - 2, mod);
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll inv2 = modinv(2);

	int n, s; read(n, s);
	dp[0][0] = modpow(2, n, mod);
	rep(i, 1, n + 1) {
		int a; read(a);
		for (int j = 0; j <= s; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - a >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j - a] * inv2 % mod) % mod;
		}
	}

	die(dp[n][s]);

}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair



int main () {
  string s;
  cin >> s;
  int n = s.size();
  vl dp(3);
  dp[0] = 1;
  ll ans = 0;
  ll num = 1;
  rep (i, n) {
    if (s[i] == 'A') {
      dp[1] += num;
      dp[1] %= MOD;
    }
    else if(s[i] == 'B') {
      dp[2] += dp[1];
      dp[2] %= MOD;
    }
    else if (s[i] == 'C') {
      ans += dp[2];
      ans %= MOD;
    }
    else {
      ans = (ans * 3 + dp[2]) % MOD;
      dp[2] = (dp[2] * 3 + dp[1] % MOD) % MOD;
      dp[1] = (dp[1] * 3 + num) % MOD;
      num *= 3; num %= MOD;
    }
  }
  cout << ans << endl;
      
}


Measured memory_bytes: 512
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[N-1] == N:
    ans += 1
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    int n , m;
    cin >> n >> m;
    cout << n * m;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int nn = n*2;
  int l[nn];
  int ans=0;
  for(int i=0;i<nn;i++){
    cin >> l[i];
  }
  sort(l,l+nn);
  for(int i=0;i<n;i++){
    ans = ans + l[i*2];
  }
  cout << ans << endl;
}


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

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

using namespace std;
using lint=long long;

class union_find{
	int n;
	vector<int> p;
public:
	union_find(int n):n(n),p(n,-1){}
	int find(int u){
		if(p[u]<0) return u;
		return p[u]=find(p[u]);
	}
	void unite(int u,int v){
		u=find(u); v=find(v);
		if(u!=v){
			if(p[v]<p[u]) swap(u,v);
			p[u]+=p[v]; p[v]=u;
			n--;
		}
	}
	bool is_same(int u,int v){ return find(u)==find(v); }
	int size(){ return n; }
	int size(int u){ return -p[find(u)]; }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int a[100000],b[100000];
	rep(i,m) scanf("%d%d",a+i,b+i), a[i]--, b[i]--;

	lint cnt=n*(n-1LL)/2;
	vector<lint> ans(m);
	union_find U(n);
	for(int i=m-1;i>=0;i--){
		ans[i]=cnt;
		if(!U.is_same(a[i],b[i])){
			cnt-=1LL*U.size(a[i])*U.size(b[i]);
			U.unite(a[i],b[i]);
		}
	}
	rep(i,m) printf("%lld\n",ans[i]);

	return 0;
}


Measured memory_bytes: 3328
import math

A, B, H, M = map(int, input().split())

H_th = 30 * (H + M/60) 
M_th = 6 * M

if(H_th > M_th):
    th = abs(H_th - M_th)
elif(M_th == 0):
    th = abs(360 - H_th)
elif(H_th == 0):
    th = abs(360 - M_th)
else:
    th = abs(M_th - H_th)


print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(th))))






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

int main(){
  int N, K;
  int d;
  int a;
  map<int, int> S;
  int count = 0;

  cin >> N >> K;
  for (int i = 1; i <= K; i++){
    cin >> d;
    for (int j = 1; j <= d; j++){
      cin >> a;
      S[a] += 1;
    }
  }

  for (int i = 1; i <= N; i++){
    if (S[i] == 0){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#define PI 3.141592653589793 

double area(double a,double b,double angle){
	double answer = a*b*sin(angle*PI / 180.0)/2.0;
	return answer;
}

double lenght(double a, double b, double angle){
	double c = pow((pow(a,2.0)+pow(b,2.0)-2.0*a*b*cos(angle*PI/180.0)), 0.5);
	return a + b + c;
}

double hight(double a, double b, double angle){
	return b*sin(angle*PI/180.0);
}

int main(void){
	double a,b,angle;
	scanf("%lf %lf %lf", &a, &b, &angle);

	printf("%.5f\n", area(a,b,angle));
	printf("%.5f\n", lenght(a,b,angle));
	printf("%.5f\n", hight(a,b,angle));


	return 0;
}


Measured memory_bytes: 2080
#include <stdio.h>
#include <math.h>

typedef struct{
	double x;
	double y;
	double z;
}point;
	
int main(void){
	while(1){
		point p, q;
		double a, b, c, d;
		double ccc, theta, dist;
		
		scanf(" %lf %lf %lf %lf", &a, &b, &c, &d);
		if(a==-1 && b==-1) break;
		
		double e, f, g, h;
		e = (90-a) * M_PI / 180.0;
		f = b * M_PI / 180.0;
		g = (90-c) * M_PI / 180.0;
		h = d * M_PI / 180.0;
		
		p.x = sin(e) * cos(f);
		p.y = sin(e) * sin(f);
		p.z = cos(e);
		q.x = sin(g) * cos(h);
		q.y = sin(g) * sin(h);
		q.z = cos(g);
		
		//printf("P(%lf,%lf,%lf) , Q(%lf,%lf,%lf)\n", p.x, p.y, p.z, q.x, q.y, q.z);
		
		ccc = p.x*q.x + p.y*q.y + p.z*q.z;
		theta = acos(ccc);
		dist = theta * 6378.1 + 0.5;
		
		printf("%ld\n", (long)dist);
	}

	return 0;
}

Measured memory_bytes: 680
#include<stdio.h>
int main(void) {
    int i,j;
    int h,w;
    
    while(1) {
        scanf("%d %d", &h, &w);

        if(h == 0 && w == 0) {
            break;
        }
        
        for(i = 0; i < h; i++) {
            for(j = 0; j < w; j++) {
                if( (i+j) % 2 == 0) {
                    printf("#");                    
                } else {
                    printf(".");                                        
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 572
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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



const int N = 200005;
int n, state[N];
vector<int> adj[N], affected;
bool impossible;


void dfs(int v){
    affected.pb(v);
    for(auto vv : adj[v])
        if(state[vv] == -1){
            state[vv] = 1^state[v];
            dfs(vv);
        }
        else if(state[vv] == state[v]){
            impossible = true;
        }
}


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int e;
    cin>>n>>e;
    while(e--){
        int a, b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    memset(state, -1, sizeof(state));
    ll x = 0, y = 0, z = 0;
    for(int i=1;i<=n;i++){

        if(state[i] != -1)  continue;
        if(adj[i].empty()){
            z++;    continue;
        }

        state[i] = 0;
        affected.clear();
        impossible = false;
        dfs(i);

        if(!impossible){
            x++;
            continue;
        }

        while(!affected.empty()){
            state[affected.back()] = -1;
            affected.pop_back();
        }

        state[i] = 1;
        affected.clear();
        impossible = false;
        dfs(i);

        if(impossible){
            y++;
        }
        else{
            x++;
        }
    }

// cout<<x<<" "<<y<<" "<<z<<endl;

    ll ans = x*(2*x+y) + y*(x+y) + z*n + (n-z)*z;;
    cout<<ans;
    return 0;
}








Measured memory_bytes: 13180
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

int n;
char a[105],b[105],c[105];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f; 
}

int main()
{
	scanf("%d%s%s%s",&n,a+1,b+1,c+1);
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		int c1=a[i],c2=b[i],c3=c[i];
		if (c1==c2&&c2==c3) continue;
		else if (c1==c2||c2==c3||c3==c1) ans++;
		else ans+=2;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;

int dp[200001];
int ans[2019];
int dp10[200001];
int modpow(int n, int mod) {
    if (dp10[n] != -1) {
        return dp10[n];
    }
    ll res = 1;
    ll x = 10;
    while (n > 0) {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    dp10[n] = res;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    memset(dp10, -1, sizeof(dp10));
    dp10[0] = 1;
    dp10[1] = 10;
    ll tmp = 0;
    int n = s.size();
    ans[0]++;
    for (int i = n - 1; i >= 0; i--) {
        tmp = (tmp + modpow(n - i - 1, 2019) * (s[i] - '0'));
        while (tmp > 2018)
            tmp -= 2019;
        ans[tmp]++;
    }
    ll res = 0;
    for (int i = 0; i < 2019; i++) {
        res += ans[i] * (ans[i] - 1) / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4576
#include <string.h>
#include <stdlib.h>

#include <cstdio>
#include <string>
#include <iostream>
#include <cstdlib>
#include <tuple>
#include <typeinfo>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main(void)
{
	int x1,x2,y1,y2;
	int xdiff,ydiff,l;
	int x3,x4,y3,y4;
	cin>>x1>>y1>>x2>>y2;

	xdiff=x2-x1;
	if(xdiff<0) xdiff*=(-1);
	ydiff=y2-y1;
	if(ydiff<0) ydiff*=(-1);

	//l=sqrt((xdiff*xdiff)+(ydiff*ydiff));

	if(x2-x1>=0&&y2-y1>=0){
		x3=x2-ydiff;
		y3=y2+xdiff;
		x4=x3-xdiff;
		y4=y3-ydiff;
	}
	else if(x2-x1<=0&&y2-y1>=0){
		x3=x2-ydiff;
		y3=y2-xdiff;
		x4=x3+xdiff;
		y4=y3-ydiff;
	}
	else if(x2-x1<=0&&y2-y1<=0){
		x3=x2+ydiff;
		y3=y2-xdiff;
		x4=x3+xdiff;
		y4=y3+ydiff;
	}
	else if(x2-x1>=0&&y2-y1<=0){
		x3=x2+ydiff;
		y3=y2+xdiff;
		x4=x3-xdiff;
		y4=y3+ydiff;
	}

	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	int i = 0;
  	while(a > 0 && c > 0) {
    	if(i)
          a -= d, i--;
      	else
          c -= b, i++;
    }
  	if(a > 0)
      cout << "Yes\n";
  	else
      cout << "No\n";
}


Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    double n;
    cin>>n;
    double ans=2.0*PI*n;
    cout<<ans<<endl;
}/*
./problem.exe
*/

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

using namespace std;

vector<int> primes;

namespace Sieve {
    vector<bool> ispr;
    vector<int> prs;
    void work(int n) {
        int k = sqrt(n) + 2;
        while (k * k > n) k--;
        vector<bool> f(k + 1, 1);
        f[0] = f[1] = 0;
        ispr.resize(n + 1);
        ispr.shrink_to_fit();
        prs.clear();
        for (int i = 2; i <= k; i++) if (f[i]) {
            for (int j = i * i; j <= k; j += i) {
                f[j] = 0;
            }
            ispr[i] = 1;
            prs.push_back(i);
        }
        vector<int> g(k + 1);
        int c = (int) prs.size();
        for (int i = k + 1; i <= n; i += k) {
            int j = min(i + k - 1, n);
            for (int u = 0; u < c; u++) {
                int p = prs[u];
                for (int q = (i + p - 1) / p * p; q <= j; q += p) {
                    g[q - i] = i;
                }
            }
            for (int u = i; u <= j; u++) if (g[u - i] < i) {
                ispr[u] = 1;
                prs.push_back(u);
            }
        }
    }
}

int main(){
	Sieve::work((int)1e6 + 7);
	int n;
	cin >> n;
	vector<int> a(n);
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	};
	
	int G = a[0];
	for(int i = 1; i < n; i++){
		G = __gcd(G, a[i]);
	};
	
	bool ok = true;
	
	int cnt[(int) 1e6 + 7];
	memset(cnt, 0, sizeof cnt);
	
	for(int i = 0; i < n && ok; i++){
		int nums = a[i];
		for (int d : Sieve::prs) {
			if (d * d > nums)
				break;
			if(nums % d == 0) {
				cnt[d]++;
				if(cnt[d] > 1){
					ok = false;
					break;
				};
			}
			while (nums % d == 0) {
				nums /= d;
			}
		}
		if (nums > 1){
			cnt[nums]++;
			if(cnt[nums] > 1){
				ok = false;
				break;
			};
		}
	};
		
	if(ok){
		cout << "pairwise coprime" << "\n";
		return 0;
	};
	
	if(G == 1){
		cout << "setwise coprime" << "\n";
		return 0;
	};
	
	cout << "not coprime" << "\n";
	
	return 0;
};


Measured memory_bytes: 11624
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

from math import gcd

a, b = map(int,input().split())
g = gcd(a,b)
if g == 1:
    print(1)
else:
    print(len(factorization(g))+1)

Measured memory_bytes: 9468
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,min1=0,min2=0;
    cin>>a>>b>>c>>d;

    if(a>b){
    min1=b;

    }if(a<b){
        min1=a;

    } if(c>d){

        min2=d;


    } if(c<d){
        min2=c;

    } if(a==b){
        min1=a;


    } if(c==d){
        min2=c;

    }

    cout<<min1+min2<<endl;

    return 0;

}











Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cstdlib>
using namespace std;

int arr[32] = { 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 };

int main()
{
	int k;
	cin >> k;
	cout << arr[k - 1];
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <unordered_map>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int v[N];
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    vector<int> e,o;
    for(int i=0;i<N;i++){
        if(i % 2){
            o.push_back(v[i]);
        }
        else{
            e.push_back(v[i]);
        }
    }
    int E1 =0,O1=0,E2=0,O2=0;
    int count_E1 = 0,count_E2 = 0,count_O1 = 0,count_O2 = 0;
    unordered_map<int,int> m1,m2;
    for(int i=0;i<o.size();i++){
        m1[o[i]]++;
        if(count_O1 < m1[o[i]]){
            O1 = o[i];
            count_O1 = m1[o[i]];
        }
        else if(count_O2 < m1[o[i]]){
            O2 = o[i];
            count_O2 = m1[o[i]];
        }
    }
    for(int i=0;i<e.size();i++){
        m2[e[i]]++;
        if(count_E1 < m2[e[i]]){
            E1 = e[i];
            count_E1 = m2[e[i]];
        }
        else if(count_E2 < m2[e[i]]){
            E2 = e[i];
            count_E2 = m2[e[i]];
        }
    }
    int ans;
    if(E1 != O1){
        ans = N - count_O1 - count_E1;
    }
    else{
        ans = min(N - count_O2 - count_E1,N - count_O1 - count_E2);
    }
    cout << ans;
}


Measured memory_bytes: 7484
#include <iostream>
#include <vector> 
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <ctime> 
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std; 
int main(){
    int a;
    cin>>a;
    if(a==25)cout<<"Christmas"<<endl;
    else if(a==24)cout<<"Christmas Eve"<<endl;
    else if(a==23)cout<<"Christmas Eve Eve"<<endl;
    else cout<<"Christmas Eve Eve Eve"<<endl; 
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
//#define _GLIBCXX_DEBUG

int main() {
    ll A;
    double B;
    cin >> A >> B;
    string B_ = to_string(B);
    int B__ = (B_[0]-'0') * 100 + (B_[2]-'0') * 10 + (B_[3]-'0');
    ll ans100 = A * B__;
    ll ans = ans100 / 100;
    cout << ans << endl;
}

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

bool damage_sort(const pair<int, int>& a, const pair<int, int>& b) {
	return a.first == b.first ? a.second < b.second : a.first > b.first; 
}

int main(void) {
	int N, H;
	cin >> N >> H;
	vector <pair <int, int>> damage;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		damage.push_back(make_pair(a, 0));
		damage.push_back(make_pair(b, 1));
	}
	std::sort(damage.begin(), damage.end(), damage_sort);

	int life = H;
	int attacks = 0;
	for (int i = 0; i <= damage.size(); i++) {
		int d = damage.at(i).first;
		int type = damage.at(i).second;
		if (type == 1) {
			life -= d;
			attacks++;
			if (life <= 0) break;
		} else {
			attacks += (life + d - 1) / d;
			break;
		}
	}
	cout << attacks << endl;
	return 0;
}


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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long ll;
int sieve[10000001];
void getsieve(int n){
	for(int i=0;i<=n;i++){
		sieve[i]=i;
	}
	for(ll i=2;i*i<=n;i++){
		if(sieve[i]==i){
			for(ll j=i*i;j<=n;j+=i){
				if(sieve[j]==j){
					sieve[j]=i;
				}
			}
		}
	}
}
ll div(ll n){
	map<int,int> mp;
	while(n>1){
		mp[sieve[n]]++;
		n/=sieve[n];
	}
	ll res=1;
	for(auto it: mp){
		res*=(it.second+1);
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int n;
	cin>>n;
	getsieve(n);
	ll res=0;
	for(int i=1;i<=n;i++){
		res+=div(i)*i;
	}
	cout<<res;
}

Measured memory_bytes: 42728
C = [[] for i in range(3)]
for i in range(3):
  C[i] = [int(x) for x in input().split()]
row = [[c - C[i][0] for c in C[i]] for i in range(3)]
C = list(zip(*C))
col = [[c - C[i][0] for c in C[i]] for i in range(3)]
for i in range(3):
  if row[0][i] != row[1][i] or row[0][i] != row[2][i]:
    print('No')
    break
  if col[0][i] != col[1][i] or col[0][i] != col[2][i]:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
 
int gcd(int a, int b){
	return (b ? gcd(b, a%b) : a);
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 	
 	int a, b; cin >> a >> b;

 	cout << 1LL*a*b/gcd(a,b) << '\n';

 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k,x,y;
  scanf("%d",&n);
  scanf("%d",&k);
  scanf("%d",&x);
  scanf("%d",&y);
  if(n>k) printf("%d\n",(n-k)*y+k*x);
  else printf("%d\n",n*x);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{int n,array[2][1000],max=0,z=0;
cin>>n;
for(int i=0;i<2;i++){
 for(int j=0;j<n;j++){
        cin>>array[i][j];}}

for(int i=0;i<n;i++){z=0;
    for(int j=0;j<=i;j++){z+=array[0][j];}int m=i;
     for(int k=0;k<n-i;k++){
            z+=array[1][m];m++;}
    if(z>=max)max=z;

}
cout<<max;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>a>>b>>c;
    Cout(n-(a+b-c));
    return 0;
}



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

//int x　の先頭の数字aと末尾の数字bをpairにして返す関数
P f(int x){  
    int a=x%10;
    int b=0;
    while(x){
        b=x;
        x/=10;
    }
    return P(a,b);
}

int main(){
    int n;
    cin >> n;
    map<P,int> freq;
    //先頭と末尾が同じ数字の個数を入力
    for(int i=1;i<=n;i++){
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    //相方の数を探し、それを答えに加算
    for(int i=1;i<=n;i++){
        P p = f(i);
        P q(p.second,p.first);
        ans += freq[q];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
 
public class Main {
    public static void main(String[] args) {
        printAnswer();
    }
 
    private static void printAnswer() {
        Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
 
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            List<Integer> trainList = new ArrayList<>();
            String dataset = br.readLine();
 
            while (dataset != null) {
                int integer = Integer.parseInt(dataset);
                if(integer != 0){
                    trainList.add(integer);
                }else{
                    System.out.println(trainList.get(trainList.size()-1));
                    trainList.remove(trainList.size()-1);
                }
                dataset = br.readLine();
            }
        } catch (IOException e) {
            logger.info("Error:  Reading input data is failed.");
        }
    }
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> T gcd(T a, T b)
{
  T tmp;

  while(b){
    tmp = a;
    a = b;
    b = tmp%b;
  }

  return a;
}

template<typename T> inline T lcm(T a, T b){ return a * (b / gcd(a, b)); }


int a, b, c;
int p, q, r, s;

int main()
{
  while((cin >> a >> b >> c) && a){
    int D = b * b - 4 * a * c;
    if(D < 0){
      puts("Impossible");
      continue;
    }
    int d = (int)sqrt((double)D);
    if((double)(d * d) != D){
      puts("Impossible");
      continue;
    }
    int P = 2 * a;
    int Q = -b + d;
    int g = gcd(P, Q);
    p = P / g;  q = -Q / g;
    Q -= 2 * d;
    g = gcd(P, Q);
    r = P / g;  s = -Q / g;
    if(p < 0 && q < 0){ p *= -1;  q *= -1; }
    if(r < 0 && s < 0){ r *= -1;  s *= -1; }
    if(p < r){
      swap(p, r);
      swap(q, s);
    }
    else if(p == r && q < s) swap(q, s);

    cout << p << " " << q << " " << r << " " << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int h[maxn],dp[maxn];
int main()
{
	int n,k;
	while(~scanf("%d%d",&n,&k))
	{
		for(int i=1;i<=n;i++)
		  scanf("%d",&h[i]);
		memset(dp,inf,sizeof(dp));
		dp[0]=0,dp[1]=0,h[0]=h[1];
		for(int i=2;i<=n;i++)
		{
			for(int j=1;j<=k;j++)
			{
				if(i-j>=1)
				{
					dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
				}
				else
				  break;
			}
		}
		cout<<dp[n]<<endl;
	}
}

Measured memory_bytes: 4420
# number of items, number of popular items to select
n, m = list(map(int, input().split()))

item_votes = list(map(int, input().split()))

total_item_votes = sum(item_votes)

item_vote_percentages = [item_votes/total_item_votes for item_votes in item_votes]

required_vote_percentage = 1/(4*m)

can_select = 0
for vote_percentage in item_vote_percentages:
    if vote_percentage >= required_vote_percentage:
        can_select += 1

if can_select >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int fa[500010],siz[500010],fy,n,m,ltk,p[500010],a[500010];
LL ans,f[5010][5010],fac[2000010],inv[2000010],P[2000010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int main(){
	fac[0]=1;
	FOR(i,1,2000000) fac[i]=fac[i-1]*i%MO;
	inv[2000000]=pw(fac[2000000],MO-2);
	FORD(i,1999999,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>n;
	P[0]=1;
	FOR(i,1,n) P[i]=P[i-1]*(n-1)%MO;
	FOR(i,1,n) getint(p[i]);
	FOR(i,1,n) fa[i]=i;
	ltk=n;
	FOR(i,1,n){
		if (p[i]==-1){++fy;continue;}
		int x=i,y=p[i];
		int X=getf(x),Y=getf(y);
		if (X==Y) continue;
		--ltk;
		fa[X]=Y;
	}
	FOR(i,1,n) siz[getf(i)]++;
	FOR(i,1,n) if (p[i]==-1){
		a[++m]=siz[getf(i)];
	}
	f[0][0]=1;
	FOR(i,0,m-1) FOR(j,0,i) if (f[i][j]){
		(f[i+1][j]+=f[i][j])%=MO;
		(f[i+1][j+1]+=f[i][j]*a[i+1])%=MO;
	}
	ans=(n-ltk+fy)*P[fy]%MO;
	FOR(j,2,m) if (f[m][j]){
		(ans-=f[m][j]*fac[j-1]%MO*P[fy-j])%=MO;
	}
	FOR(i,1,m) (ans-=(a[i]-1)*P[fy-1])%=MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 151632
n,c=map(int,input().split())
D=[[0]]
for i in range(c):
    D.append([0] + list(map(int,input().split())) )

color_num=[ [0]*(c+1) for i in range(3)]


for i in range(n):
    tmp=list(map(int,input().split()))
    for j in range(n):
        color_num[(i+j+2)%3][tmp[j]]+=1

ans=[]
for i in range(1,c+1):
    for j in range(1,c+1):
        for k in range(1,c+1):
            if(i!=j and j!=k and k!=i):
                tmp=0
                for m in range(1,c+1):
                    tmp+=color_num[0][m]*D[m][i] + color_num[1][m]*D[m][j] + color_num[2][m]*D[m][k]
                ans.append(tmp)

print(min(ans))

Measured memory_bytes: 4172
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n;
	cin >> n;
	if(n / 10 == 9 || n % 10 == 9) Yes();
	else No();
	return 0;
}

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

int main()
{
	int n,m;
	while(cin >> n >> m){
		if(n==0 && m==0)
			break;
		int place[100] = {0};
		int q;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin >> q;
				place[j] += q;
			}
		}
		bool flag = false;
		for(int i=0;i<m;i++){
			int mplace=0;
			for(int j=0;j<m;j++){
				if(place[mplace]<place[j]){
					mplace = j;
				}
			}
			if(flag)
				cout << " ";
			cout << mplace+1;
			place[mplace] = -1;
			flag = true;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 868
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())
ans = []
vac = []
num = 1
flg = 0
for i in range(H):
    cnt = 0
    res = []
    a = input()
    if '#' in a:
        for b in a[:-1]:
            if b == '#':
                cnt += 1
                if cnt > 1:
                    num += 1
            res.append(num)
        ans.append(res)
        num += 1
    else:
        if i == 0:
            flg = 1
            continue
        else:
            vac.append(i)

if flg:
    ans.insert(0, ans[0])
for k in vac:
    ans.insert(k, ans[k-1])

for a in ans:
    print(*a)


Measured memory_bytes: 47068
#include <string.h>

int main(void){
  int n,x,t[7];

  while(1){
    scanf("%d",&n);
    if(!n) break;

    memset(t,0,sizeof(t));
    while(n--){
      scanf("%d",&x);
      x /= 10;
      if(x<6) t[x]++;
      else t[6]++;
    }
    for(x=0;x<7;x++){
      printf("%d\n",t[x]);
    }
  }

  return 0;
}

Measured memory_bytes: 404
d=gets.to_i
c=gets.split.map(&:to_i)
s=[]
d.times do
  s << gets.split.map(&:to_i)
end
t=[]
d.times do
  t << gets.to_i
end
l=[0]*26
a=0
d.times do |i|
  a+=s[i][t[i]-1]
  26.times do |j|
    if t[i]-1==j
      l[j]=0
    else
      l[j]+=1
      a-=l[j]*c[j]
    end
  end
  puts a
end


Measured memory_bytes: 14260
n = int(input())
dp = [i for i in range(n+1)]

dp[0] = 0
for i in range(n):
    j,l = 1,1
    while i + 6**j <= n:
        dp[i+6**j] = min(dp[i+6**j], dp[i]+1)
        j += 1
    while i + 9**l <= n:
        dp[i+9**l] = min(dp[i+9**l], dp[i]+1)
        l += 1
print(dp[n])

Measured memory_bytes: 7064
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);

    vector <int> arr(N);
    const long long INF = 1000000000LL * 100010;
    vector<vector <long long>> evenBest(N, vector<long long>(2, -INF));

    for (int i = 0; i < N; ++i) {
        scanf("%d", &arr[i]);
    }

    evenBest[N-2][1] = arr[N-2];
    evenBest[N-2][0] = arr[N-1];

    for (int i = N-4; i >= 0; i -= 2) {
        evenBest[i][1] = max(evenBest[i+2][0], evenBest[i+2][1]) + arr[i];
        evenBest[i][0] = evenBest[i+2][0] + arr[i+1];
    }

    if (N%2 == 0) {
        cout << max(evenBest[0][0], evenBest[0][1]) << endl;
    } else {
        long long ans = -INF;
        long long curSum = 0;

        for (int i = 0; i < N; i += 2) {
            // give up i
            if (i+1 < N) {
                long long best = max(evenBest[i+1][0], evenBest[i+1][1]);
                ans = max(ans, curSum + best);
            }

            curSum += arr[i];
        }

        ans = max(ans, curSum-arr[N-1]);
        ans = max(ans, curSum-arr[0]);

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a[10];
    f(3) cin>>a[i];
    sort(a,a+3);
    int ans=0;
    ans+=a[2]-a[1];
    a[0]+=ans;
    if((a[2]-a[0])%2==1){
        ++ans;
    }
    ans+=(a[2]-a[0]+1)>>1;
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split().ToArray();
        int n = int.Parse(input[0]);
        int y = int.Parse(input[1]);

        for (int i = 0; i <= n; i++)
        {
            if (y < i * 10000) continue;
            for (int j = 0; j <= n - i; j++)
            {
                int k = n - i - j;
                int sum = i * 10000 + j * 5000 + k * 1000;
                if (y < sum) break;
                if (y == sum)
                {
                    Console.WriteLine(i + " " + j + " " + k);
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1 -1");
    }
}

Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long S[1 << 18];
int main(void){
  int N;
  cin >> N;
  for(int i = 0; i < (1 << N); i++){
    cin >> S[i];
  }

  sort(S, S + (1 << N));
  reverse(S, S + (1 << N));

  priority_queue <int> pq;
  vector <int> buf;
  long long prev = S[0];
  for(int i = 0; i < N; i++){
    buf.push_back(i);
  }
  for(int i = 1; i < (1 << N); i++){
    if(prev != S[i]){
      for(int j = 0; j < buf.size(); j++){
        pq.push(buf[j]);
      }
      buf.clear();
    }
    if(pq.empty()){
      cout << "No" << endl;
      return 0;
    } else {
      auto left_time = pq.top();
      pq.pop();
      for(int j = 0; j < left_time; j++){
        buf.push_back(j);
      }
    }
    prev = S[i];
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
  int A,B,n;
  cin >> A >> B;
  for(int i = A;i <= B;i =i + 1){
    if(i/1000 == (i%10)*10 + (i%100 - i%10)/10){
      n = n + 1;
    }
  }  
  
  
  cout << n;

}  
     
  
  


Measured memory_bytes: 256
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

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

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, m;
int cnt[N];
set < int > s;

int main(){
  scanf("%d %d", &n, &m);
  s.insert(1);
  for(int i = 1; i <= n; ++i) cnt[i] = 1;
  for(int i = 1; i <= m; ++i){
    int x, y;
    scanf("%d %d", &x, &y);
    cnt[x]--;
    cnt[y]++;
    if(s.count(x)){
      s.insert(y);
    }
    if(!cnt[x]){
      s.erase(x);
    }
  }
  printf("%d\n", sz(s));
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    string T = S;
    reverse(T.begin(), T.end());

    if(S ==T){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	map<ll,int>rel;
	for(int i=0; i<n; i++){
		int num;
		cin>>num;
		rel[num]++;
	}
	for(int i=0; i<m; i++){
		int num1,num2;
		cin>>num1>>num2;
		rel[num2]+=num1;
	}
	vector<pair<int,int> >store;
	for(auto var : rel){
		store.push_back(make_pair(var.first,var.second));
	}
	reverse(store.begin(),store.end());
	ll sum=0;
	int rem=n;
	int i=0;
	while(rem)
	{
		ll var=store[i].first;
		int cnt=store[i].second;
		sum=sum+var*min(cnt,rem);
		rem-=min(cnt,rem);
		i++;
	}
	cout<<sum;
	return 0;
	
}

Measured memory_bytes: 17852
#include<iostream>
#include<math.h>
//#include<algorithm.h>
using namespace std;
int a[100001], h[100001];
int main()
{ int n;
  cin>>n;
  for(int i = 1; i <= n; i++)
  	cin>>h[i];
  a[n] = 0;
  a[n-1] = abs(h[n]-h[n-1]);
  for(int i = n-2; i > 0; i--)
  { a[i] = min((a[i+1] + abs(h[i+1]-h[i])),(a[i+2] + abs(h[i+2]-h[i])));
  }
  cout<<a[1];
  return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
    int  a=0,b=0,c=0,i=0,n=0;//b-max,c=min
    cin >> n;
    cin >> a;
    b=-2147483648;
    //b=a;
    c=a;
    for(i=1;i<n;i++){
        cin >> a;
        if(b<a-c){
            b=a-c;
        }
        if(c>a){
            c=a;
        }

    }
    cout << b;
    cout << endl;
    //cout << b;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    

    class ClassMain {



        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] inputs = line.Split(' ').Select(int.Parse).ToArray();
                if (inputs[0] == 0) { break; }
                a1 = inputs[0]; m1 = inputs[1]; a2 = inputs[2];
                m2 = inputs[3]; a3 = inputs[4]; m3 = inputs[5];
                long loop1 = posiloop(a1, m1);
                long loop2 = posiloop(a2, m2);
                long loop3 = posiloop(a3, m3);
                long lcm12 = loop1 * loop2 / gcd(loop1, loop2);
                long lcm123 = lcm12 * loop3 / gcd(lcm12, loop3);
                Console.WriteLine(lcm123);

            }
        }


        public static int a1 = 0, m1 = 0, a2 = 0, m2 = 0, a3 = 0, m3 = 0;
        
        public static int posiloop(int a, int m){
            int cnt = 0;
            int posi = 1;
            do {
                cnt++;
                posi = (a * posi) % m;
            } while (posi != 1);
            return cnt ;

        }

        public static long gcd(long n1, long n2) {
            if (n1 < n2) { gcd(n2, n1); }
            long r = -1;
            while (true) {
                r = n1 % n2;
                if (r== 0) { return n2; }
                n1 = n2;
                n2 = r;
            }

        } 

    }

    
}

Measured memory_bytes: 5952
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    string s;
    cin >> s;
    s = "ABC" + s;
    cout << s << endl;


    return 0;
}

Measured memory_bytes: 760
#include <iostream>

#define ll long long
using namespace std;

int main(){
    ll a;
    ll b;
    ll k;
    /* 
    long long a;
    long long b;
    long long k;
    */
    cin >> a >> b >> k;
    if(k <= a){
        cout << a - k << " " << b << endl;
    }
    else if(k <= a + b){
        cout << 0 << " " << b - (k - a) << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[0]==s[2]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}   




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

using namespace std;

#define MAX 50010

class Union_Find{
public:
  int par[MAX],rank[MAX],size[MAX],gnum;
  Union_Find(int N){
    gnum = N;
    for(int i = 0 ; i < MAX ; i++){
      par[i] = i;
      rank[i] = 0;
      size[i] = 0;
    }
  }
  int find(int x){
    if(par[x] == x){
      return x;
    }
    return par[x] = find(par[x]);
  }
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y){ return; }
    if(rank[x] < rank[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      size[x] += size[y];
      if(rank[x] == rank[y]){
        rank[x]++;
      }
    }
    gnum--;
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
  int getSize(int x){
    return size[find(x)];
  }
  int groups(){
    return gnum;
  }
};

int N,W,H;
int X[2*MAX],Y[2*MAX],x[MAX],y[MAX];

bool isWall(int x,int y){
  if(x == 1 || y == 1 || x == W || y == H){
    return true;
  }
  return false;
}

int main(){
  cin >> N >> W >> H;
  Union_Find uf(N);
  for(int i = 0 ; i < 2*MAX ; i++){
    X[i] = Y[i] = -1;
  }
  bool wall = false;
  for(int i = 0 ; i < N ; i++){
    cin >> x[i] >> y[i];
    uf.size[i] = 1;
    if(X[x[i]] == -1){
      X[x[i]] = i;
    }else{
      uf.unite(X[x[i]],i);
    }
    if(Y[y[i]] == -1){
      Y[y[i]] = i;
    }else{
      uf.unite(Y[y[i]],i);
    }
    wall |= isWall(x[i],y[i]);
  }
  if(uf.groups() == 1){
    cout << uf.getSize(0)-1 << endl;
  }else{
    int sum = 0;
    set<int> visited;
    for(int i = 0 ; i < N ; i++){
      int f = uf.find(i);
      if(!visited.count(f)){
        visited.insert(f);
        sum += uf.getSize(i)-1;
      }
    }
    cout << sum+(uf.groups()-1)*2+1-wall << endl;
  }
  return 0;
}

Measured memory_bytes: 4100
import sys
from operator import itemgetter
from collections import deque, Counter
from itertools import permutations, combinations
from heapq import heapify, heappop, heappush
from bisect import bisect, bisect_left

def comb(n, r, fact, revfact, mod):
    return (fact[n] * revfact[n - r] * revfact[r]) % mod

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    mod = 7 + 10 ** 9
    fact = [1] * (2 * N)
    revfact = [1] * (2 * N)
    for i in range(1, 2 * N): fact[i] = (fact[i - 1] * i) % mod
    revfact[2 * N - 1] = pow(fact[2 * N - 1], mod - 2, mod)
    for i in reversed(range(1, 2 * N - 1)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod
    ans = 1
    if K < N:
        for i in range(1, min(K + 1, N + 1)): #i個zeroの部屋がある
            z = comb(N, i, fact, revfact, mod) #zeroにする箇所
            add = comb(N - 1, N - i - 1, fact, revfact, mod)
            ans += (z * add) % mod
    else:
        ans = comb(N + N - 1, N, fact, revfact, mod)

    print(ans % mod)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 34924