akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, tmpa;
    int acnt[100010];
    cin >> n;

    reps(i, 1, 100009){
        acnt[i] = 0;
    }

    rep(i, n){
        cin >> tmpa;
        acnt[tmpa]++;
    }

    ll eaten = 0;
    ll cnt = 0;
    reps(i, 1, 100009){
        if(acnt[i] == 0) continue;
        if(acnt[i]%2 == 0) eaten++;
        cnt++;
    }

    //cout << cnt << " " << eaten << endl;

    cout << cnt-(eaten%2) << endl;

    return 0;
}


Measured memory_bytes: 640
m, k = map(int, input().split())
if 2**m <= k:
    print(-1)
    exit()
elif m == 0 and k == 0:
    print("0 0")
    exit()
elif m == 1 and k == 1:
    print(-1)
    exit()
elif m == 1 and k == 0:
    print("1 1 0 0")
    exit()
l = [i for i in range(2**m) if i != k]
rev_l = sorted(l, reverse=True)
ans = l + [k] + rev_l + [k]
print(" ".join(map(str, ans)))

Measured memory_bytes: 29456
#include <cstdio>
#include <cstdint>
#include <string>
#include <vector>

constexpr intmax_t mod=1e9+7;

int main() {
  size_t N;
  char buf[64];
  scanf("%zu %s", &N, buf);
  std::string S[2]={buf};
  scanf("%s", buf);
  S[1] = buf;

  std::vector<int> a;
  for (size_t i=0; i<N; ++i) {
    if (S[0][i] == S[1][i]) {
      a.emplace_back(3);
    } else {
      a.emplace_back(6);
      ++i;
    }
  }

  intmax_t res=a[0];
  for (size_t i=1; i<a.size(); ++i) {
    if (a[i-1] == 6 && a[i] == 6) {
      res = res*3 % mod;
    } else if (a[i-1] == 3) {
      res = res*2 % mod;
    }
  }

  printf("%jd\n", res);
}


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

const int INF = 1e9;

int c[10][1005];

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = INF;
    rep(div,1<<(h-1)){
        int g = 0;
        vector<int> id(h);
        rep(i,h){
            id[i] = g;
            if(div>>i&1) g++;
        }
        g++;
        rep(i,g)rep(j,w) c[i][j] = 0;
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');

        int num = g-1;
        vector<int> now(g);
        auto add = [&](int j){
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if(now[i] > k) return false;
            return true;
        };
        rep(j,w){
            if(!add(j)){
                num++;
                now = vector<int>(g);
                if(!add(j)){
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	cout<<n/3<<endl;
	return 0;
}


Measured memory_bytes: 764
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


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

const int N=200005;


void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;int ans=0;
    a=min(a,k);
    ans+=a;
    k-=a;
    b=min(b,k);
    k-=b;
    ans-=min(c,k);
    cout<<ans<<endl;
}

int32_t main()
{
    IOS;
   
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
N = int(input())


def digits(n):
    return len(list(str(n)))


digit_list = []
for a in range(1, int(N**(1/2))+1):
    b = N // a if N % a == 0 else 0
    if b != 0:
        digit_list += [max(digits(a), digits(b))]

print(min(digit_list))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A){
  map<ll,ll> cnt;
  REP(N){
    if(cnt.count(A[i])){
      ++cnt[A[i]];
    }else{
      cnt[A[i]]=1;
    }
  }
  ll sum=0;
  for (auto &&i : cnt)
  {
    ll tmp=i.second;
    sum+=tmp*(tmp-1)/2;
  }
  REP(N){
    ll ans=sum;
    ll tmp=cnt[A[i]];
    ans-=tmp*(tmp-1)/2;
    ans+=(tmp-1)*(tmp-2)/2;
    cout<<ans<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11008
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(){int X=IN(),a=360;while(a%X){a+=360;}printf("%d\n",a/X);}

Measured memory_bytes: 1536
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N, M, K, ans,mi;
string s;



int main() {
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;

			return 0;
		}
	}
		cout <<"Good" << endl;
	
	return 0;

}

Measured memory_bytes: 764
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
struct process{
	char name[11];
	int time;
	process(char* n, int t){strcpy(name, n); time = t;}
};

int main(){
	char nm[11];
	int i, n, t, q, t_elapsed = 0;
	int *tp;
	queue<process> prcs;
	
	cin >> n >> q;
	for(i=0;i<n;i++){
		cin >> nm >> t;
		prcs.push(process(nm, t));
	}
	while(!prcs.empty()){
		tp = &(prcs.front().time);
		if(*tp <= q){
			t_elapsed += *tp;
			cout << prcs.front().name << " " << t_elapsed << endl;
			prcs.pop();
		}else{
			t_elapsed += q;
			*tp -= q;
			prcs.push(prcs.front());
			prcs.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1940
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
const long long md=1e9+7;
string k;
long long n,dp[10101][2][111];
int main()
{
	cin>>k>>n;
	dp[0][0][0]=1;
	for(int i=0;i<k.size();i++)
	{
		for(int j=0;j<2;j++)
		{
			int lm;
			if(j==1)
			{
				lm=9;
			}
			else
			{
				lm=k[i]-'0';
			}
			for(int kk=0;kk<n;kk++)
			{
				for(int l=0;l<=lm;l++)
				{
					if(j || l<lm)
					{
						dp[i+1][1][(kk+l)%n]+=dp[i][j][kk];
						dp[i+1][1][(kk+l)%n]%=md;
					}
					else
					{
						dp[i+1][0][(kk+l)%n]+=dp[i][j][kk];
						dp[i+1][0][(kk+l)%n]%=md;
					}
				}
			}
		}
	}
	cout<<(dp[k.size()][0][0]+dp[k.size()][1][0]-1+md)%md<<endl;
	return 0;
}

Measured memory_bytes: 17664
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}

function Main(input){
    let temp = input.trim().split('\n');
    let n = parseInt(temp[0]);
    let w = mapint(temp[1]);

    let s1 = w[0];
    let s2 = 0;
    for(let i=1;i<n;i++){
        s2+=w[i];
    }
    let sa = Math.abs(s1-s2);
    let sa2;
    for(let i=1;i<n;i++){
        s1+=w[i];
        s2-=w[i];

        sa = Math.min(sa,Math.abs(s1-s2));
    }
    console.log(sa);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

int a[2005];

bool palin(string x)
{
  auto  rx = x;
  reverse(all(rx));
  return x == rx;
}

int main()
{
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  auto f = s.substr(0, (s.size() - 1) / 2);
  auto se = s.substr((s.size() + 3) / 2 - 1, (s.size() - (s.size() + 3) / 2) + 1);
  // cout << f << ' ' << se << endl;
  cout << (palin(f) && palin(se) && palin(s) ? "Yes" : "No") << endl;

  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<vector<ll>>ans(10,vector<ll>(10,0));
  for(int i=0;i<=N;i++){
    int n=i;
    int f=n%10;
    while(n/10!=0)n/=10;
    int s=n%10;
    ans[f][s]++;
  }
  ll sum=0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      sum+=ans[i][j]*ans[j][i];
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)
// Multiplies str1 and str2, and prints result.

// int main() {
//   int n, k;
//   cin >> n >> k;
//   vector<int> a(n + 1);

//   for (int i = 1; i <= n; ++i) {
//     int ai;
//     cin >> ai;
//     a[i] = ai;
//   }

//   // vector<long long> grades;
//   vector<string> grades;
//   // long long s = 1;
//   string s;
//   s = "1";
//   for (int i = 1; i < k; ++i) {
//     // s *= (long long)a[i];
//     s = multiply(s, to_string(a[i]));
//   }
//   for (int i = k; i <= n; ++i) {
//     // s *= a[i];
//     s = multiply(s, to_string(a[i]));
//     grades.push_back(s);
//     // s /= a[i - k + 1];
//     s = dvd(s, a[i - k + 1]);
//   }

//   // for (int ss : grades) {
//   //   cout << ss << " ";
//   // }
//   // cout << endl;

//   for (int i = 1; i < (int)grades.size(); ++i) {
//     // if (grades[i] > grades[i - 1]) {
//     if (is_greater(grades[i], grades[i - 1])) {
//       cout << "Yes" << endl;
//     } else
//       cout << "No" << endl;
//   }
//   return 0;
// }

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<double> loga(n + 1);
  for (int i = 1; i <= n; ++i) {
    int ai;
    cin >> ai;
    a[i] = ai;
    loga[i] = log(double(ai));
  }

  vector<long long> grades;
  vector<double> loggrades;
  long long s = 1;
  double logs = 0;
  for (int i = 1; i < k; ++i) {
    s *= (long long)a[i];
    logs += loga[i];
  }
  for (int i = k; i <= n; ++i) {
    s *= a[i];
    logs += loga[i];
    grades.push_back(s);
    loggrades.push_back(logs);
    s /= a[i - k + 1];
    logs -= loga[i - k + 1];
  }

  // for (int i = k + 1; i <= n; ++i) {
  //   int aa = a[i];
  //   int bb = a[i - k + 1];
  //   if (aa > bb) {
  //     cout << "Yes" << endl;
  //   } else {
  //     cout << "No" << endl;
  //   }
  // }

  // for (int ss : grades) {
  //   cout << ss << " ";
  // }
  // cout << endl;

  for (int i = 1; i < (int)grades.size(); ++i) {
    // if (grades[i] > grades[i - 1]) {
    if (loggrades[i] > loggrades[i - 1]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 9316
#!/usr/bin/env php
<?php
if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {
  $a = '';
  $b = '';
  $c = '';

  while ($line = fgets(STDIN)) {
    $tokens = explode(' ', $line);
    $a = $tokens[0];
    $b = $tokens[1];
    $c = $tokens[2];
  }

  $a_len = strlen($a);
  $b_len = strlen($b);
  $c_len = strlen($c);
  if (substr($a, $a_len - 1, $a_len) !== substr($b, 0, 1)) {
  	echo 'NO';
  	return;
  }
  if (substr($b, $b_len - 1, $b_len) !== substr($c, 0, 1)) {
  	echo 'NO';
  	return;
  }
  echo 'YES';
}
?>

Measured memory_bytes: 4604
package main

import "fmt"

func gcd(x, y int64) int64 {
	for y != 0 {
		r := x % y
		x = y
		y = r
	}
	return x
}

func lcm(x, y int64) int64 {
	return x / gcd(x, y) * y
}

func main() {
	for {
		var a, b int64

		fmt.Scanf("%d %d", &a, &b)

		if a == 0 && b == 0 {
			break
		}

		fmt.Printf("%d %d\n", gcd(a, b), lcm(a, b))
	}
}



Measured memory_bytes: 1100
#include <assert.h>
#include <stdio.h>

#define MED(x,y,z) (x < y ? (y < z ? y : z < x ? x : z) : (x < z ? x : y < z ? z : y))

void sort(int arr[], int desc, int left, int right) {
  if (left >= right) return;
  int i = left, j = right;
  int tmp, pivot = MED(arr[i], arr[i + (j - i) / 2], arr[j]), order = desc ? -1 : 1;
  while (1) {
    while (arr[i] * order < pivot * order) i++;
    while (arr[j] * order > pivot * order) j--;
    if (i >= j) break;
    tmp = arr[i];
    arr[i] = arr[j];
    arr[j] = tmp;
    i++;
    j--;
  }
  sort(arr, desc, left, i - 1);
  sort(arr, desc, j + 1, right);
}

int main() {
  int n, m, a[100], r = 1, sum = 0, min;
  assert(scanf("%d %d", &n, &m) == 2);
  for (int i = 0; i < n; i++) {
    assert(scanf("%d", &a[i]) == 1);
    sum += a[i];
  }
  min = (sum + 4 * m - 1) / (4 * m);
  sort(a, 1, 0, n - 1);
  for (int i = 0; i < m; i++) {
    if (a[i] < min) {
      r = 0;
      break;
    }
  }
  puts(r ? "Yes" : "No");
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

typedef struct Node{
    char word[13];
    struct Node *left;
    struct Node *right;
}node;
node *tree;
char keyWord[13];
void insert(node **ref){
    node *newnode;
    node *temp = *ref;
    if(temp == NULL){
        newnode = malloc(sizeof(node));
        strcpy(newnode->word, keyWord);
        newnode->left = NULL;
        newnode->right = NULL;
        (*ref) = newnode;
        return;
    }else{
        if(strcmp(keyWord, temp->word)>0){
            insert(&temp->right);
        }else{
            insert(&temp->left);
        }
    }
}
int find(node **ref){
    node *temp = *ref;
    int i = 0;
    if(temp == NULL) return 0;
    int r = strcmp(temp->word, keyWord);
    if( r == 0) return 1;
    else if(r>0){
        i = find(&temp->left);
    }else{
        i = find(&temp->right);
    }
    return i;
}
int main () {
    long long int n;
    char cmd[7];
    int f;

    scanf("%lld", &n);
    while(n--){
        scanf("%s %s", &cmd, &keyWord);
        if(strcmp(cmd, "insert") == 0){
            insert(&tree);
        }else if(strcmp(cmd, "find") == 0){
            f = find(&tree);
            printf("%s\n", f == 1? "yes":"no");
        }
    }
    return 0;
}



Measured memory_bytes: 28396
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

// r[x][i] := x を p-1 または p+1 で割ったあまり
int r[200100][2];
int sum[2];

int main(){
	int n; cin >> n;
	vector<int> x(n, 0);
	int pc = 0;
	for( int i = 0; i < n; ++i ){
		char c; cin >> c;
		x[n-1-i] = c-'0';
		if( x[n-i-1] == 1 ) ++pc;
	}
	int cur = 1;
	for( int i = 0; i < n; ++i ){
		if( pc == 1 ) break;
		r[i][0] = cur % (pc-1);
		cur *= 2;
		cur %= (pc-1);
		if( x[i] == 1 ){
			sum[0] += r[i][0];
			sum[0] %= (pc-1);
		}
	}
	cur = 1;
	for( int i = 0; i < n; ++i ){
		r[i][1] = cur % (pc+1);
		cur *= 2;
		cur %= (pc+1);
		if( x[i] == 1 ){
			sum[1] += r[i][1];
			sum[1] %= (pc+1);
		}
	}
	/*
	for( int i = 0; i < n; ++i ){
		cout << r[i][1] << ' ';
	} cout << endl;
	*/
	for( int i = n-1; i >= 0; --i ){
		int s;
		if( x[i] == 1 ){
			if( pc == 1 ){
				cout << 0 << endl;
				continue;
			}
			s = ( sum[0] - r[i][0] + (pc-1) ) % (pc-1);
		} else {
			s = ( sum[1] + r[i][1] ) % (pc+1);
		}
		int cnt = 1;
		while( s > 0 ){
			s %= __builtin_popcount(s);
			++cnt;
		}
		cout << cnt << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

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

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, L; cin >> n >> L;
    int s = n * (1+L-1 + L+n-1) / 2;
    if (-L+1 <= n && -L+1 >= 1) cout << s << endl;
    else if (L>0) cout << s - L << endl;
    else cout << s - (L-1+n) << endl;
    return 0;
}



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


    class Pairs
    {
      
        static long N;
        static long K;
        static long[] A;
        
        static void Main(string[] args)
        {
            var HN = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var H = HN[0];
            var N = HN[1];
          
            var A = new long[N+1];
            var B = new long[N+1];
            for(int i = 0;i < N;i++){
              var CD = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
              A[i+1] = CD[0];
              B[i+1] = CD[1];
            }
            var Amax = A.Max();
            var dp = new long[N+1,H+Amax];
            //Console.WriteLine(String.Join(" ",A));
            for(int i = 0;i < N+1;i++){
              for(int j = 0;j < H+Amax;j++){
                dp[i,j] = 10000000000;
              }
            }
           
            for(int i = 0;i < N+1;i++){
              dp[i,0] = 0;
            }
          
            for(int i = 0;i < N;i++){
              for(int j = 0;j < H+Amax;j++){
                if(j-A[i+1] >= 0){
                  dp[i+1,j] = Math.Min(dp[i,j],dp[i+1,j-A[i+1]]+B[i+1]);
                }else{
                  dp[i+1,j] = dp[i,j];
                }
              }
            }
            long ans = long.MaxValue;
            for(long i = H;i < H+Amax;i++){
              ans = Math.Min(ans,dp[N,i]);
            }
            Console.WriteLine(ans);
        }
    }


Measured memory_bytes: 98656
#include<stdio.h>
int main(void)
{
    int s,m,h;
	scanf("%d",&s);
	h=s/3600;
	s=s%3600;
	m=s/60;
	s=s%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int N;

int main() {
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    
    vector<int> cost(N);
    cost[0] = 0; cost[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]),
                      cost[i - 2] + abs(h[i] - h[i - 2]));
    }
    
    cout << cost[N - 1] << endl;
}

Measured memory_bytes: 1024
from collections import deque

H, W = map(int, input().split())
X = [[[0, 1][a=="#"] for a in input()] for i in range(H)]

ch = [[0] * W for _ in range(H)]
move = [[-1,0], [1,0], [0,-1], [0,1]]
ans = 0
for i in range(H):
    for j in range(W):
        if ch[i][j]:
            continue
            
        q = deque([[i,j]])
        a = [0, 0]
        while q:
            t = q.popleft()
            x = t[0]
            y = t[1]
            ch[x][y] = 1
            a[(x+y)%2] += 1
            for m in move:
                nx = x + m[0]
                ny = y + m[1]
                if nx >= 0 and nx < H and ny >= 0 and ny < W and X[x][y] != X[nx][ny]:
                    if ch[nx][ny] == 0:
                        q.append([nx,ny])
                        ch[nx][ny] = 1
        ans += a[0] * a[1]

print(ans)

Measured memory_bytes: 5996
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
m = max(times.items(), key = lambda x:x[1])[1]
a = []
for t in times.items():
	if(t[1]==m):
		a.append(t[0])
 
a.sort()
for t in a:
	print(t)

Measured memory_bytes: 32096
S = input()
X,Y = map(int,input().split())

# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key,g in itertools.groupby(S):
  sumS.append([key,len(list(g))])
  
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
  startx = sumS[0][1]
  sumS.popleft()

xdir = True # X軸方向を向いている
dpXcur = set()
dpXcur.add(startx)
dpYcur = set()
dpYcur.add(0) # Y軸は必ず0から始まる
dpXnex = set()
dpYnex = set()
while sumS:
  mark, steps = sumS.popleft()
  if mark == "F":
    if xdir: # X軸方向を向いている場合
      for x in dpXcur:
        dpXnex.add(x + steps)
        dpXnex.add(x - steps)
      dpXcur = dpXnex
      dpXnex = set()
    else:
      for y in dpYcur:
        dpYnex.add(y + steps)
        dpYnex.add(y - steps)
      dpYcur = dpYnex
      dpYnex = set()
  elif mark == "T":
    if steps % 2 == 1:
      # 奇数回の場合はX/Y軸の切り替え (偶数回の場合は何も起こらない)
      xdir ^= True
      
if X in dpXcur and Y in dpYcur:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 10536
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll N_MAX = 100000;
const ll M_MAX = 100000;
const ll C_I_MAX = 1000000000;

ll N, M;

priority_queue<ll, vector<ll>, greater<ll> > que;
ll ans=0;
vector<ll> v;
void input() {
	scanf("%lld%lld", &N, &M);

	rep(i, N) {
		ll a;
		cin >>a;
		que.push(a);
		ans+=a;
	}
	vector<pair<ll,ll>> pa(M);
	rep(i,M){
		cin >>pa[i].first>>pa[i].second;
	}
	sort(all(pa), [](const pair<ll,ll> &x, const pair<ll,ll> &y) {
		return x.second > y.second;
	});

	v.assign(N,0);
	ll k=0;
	rep(i,M){
		rep(j,pa[i].first){
			v[k]=pa[i].second;
			//v.push_back(pa[i].second);
			k++;
			if(k==N)break;

		}
		if(k==N)break;
	}
	//sort(all(v),greater<ll>());


	ll i=0;
	while(1){
		ll qq=que.top();
		ll vv=v[i];
		if(qq<vv){
			que.pop();
			que.push(vv);
			ans+=vv-qq;
			i++;
			if(i==N)break;
		}else{
			break;
		}	
	}



	/*
	while(!que.empty()){
		ll t=que.top();que.pop();
		ans+=t;
	}
	*/
	printf("%lld\n", ans);
}

signed main() {
	input();
	//solve();
	return 0;
}


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

using namespace std;
const int Inf = 1e9 + 5;

int main()
{
    int n;
    cin >> n;
    multiset<int> st;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (st.lower_bound(a[i]) != st.begin()) {
            st.erase(--st.lower_bound(a[i]));
            st.insert(a[i]);
        } else {
            ans++;
            st.insert(a[i]);
        }
    }
    cout << ans;
    return 0;
}


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

using namespace std;


using i64 = long long;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i){
        --a[i];
        a[i] %= k;
    }
    vector<int> r(n + 1, 0);
    for(int i = 0; i < n; ++i)
        r[i + 1] = (r[i] + a[i]) % k;
    map<int,int>v ;
    i64 ans = 0;
    for(int i = 0; i <= n; ++i){
        ans += v[r[i]];
        v[r[i]]++;
        if(i - k + 1 >= 0)
            v[r[i - k + 1]]--;
    }
    cout << ans << endl;
}


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


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,k,sum=0,inf=1e9+6;
  cin>>n>>k;
  ll v[n],w[n];
  for(ll i=0; i<n; i++){
    cin>>w[i]>>v[i];
    sum=sum+v[i];
  }
  ll dp[n+1][sum+1];
  for(ll i=0; i<=sum; i++){
     dp[0][i]=inf;
  }
  dp[0][0]=0;
  for(ll i=1; i<=n; i++){
    for(ll j=0; j<=sum; j++){
        if(j==0){dp[i][j]=0;}
        else if(j>=v[i-1]){
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
        }
        else{dp[i][j]=dp[i-1][j];}
    }

  }
  int ans=0;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=sum; j++){
        //  cout<<dp[i][j]<<" ";
        if(dp[i][j]<=k){ans=max(ans,j);}
    }
   // cout<<endl;
  }
  cout<<ans;

  return 0;
}

Measured memory_bytes: 82448
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    int z=1;
    a--,b--,c--,d--;
    for(int i=a;i<c;i++) if(s[i]=='#'&&s[i+1]=='#') z=0;
    for(int i=b;i<d;i++) if(s[i]=='#'&&s[i+1]=='#') z=0;
    if(d<c){
        int x=0;
        for(int i=b;i<=d;i++) if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') x=1;
        if(x==0) z=0;
    }
    if(z) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    ans=0
    for i in range(1,n+1):
        cnt=0
        while i<=k-1:
            i*=2
            cnt+=1
        ans+=0.5**cnt
    print(ans/n)
resolve()

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007
const int INF = 1000000000;
const int NIL = -1;

ll s;

main(){
    scanf("%lld", &s);
    ll a = (ll)ceil(sqrt(s)),b,c,d;
    d=a;
    while(a*d - s >= INF)d--;
    b = 1;
    c = a*d - s;
    printf("0 0 %lld %lld %lld %lld\n", a, b, c, d);
    return 0;
}

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

using namespace std;

int main() {
	int n; long long k;
	scanf("%d %lld", &n,&k);
	vector<int> adj(n);

	for(int i=0; i<n; i++) {
		int x; scanf("%d", &x);
		adj[i] = x-1;
	}

	long long last_time_visited[n];
	memset(last_time_visited, -1, sizeof(last_time_visited));

	last_time_visited[0] = 0;

	long long time = 0; int node = 0;
	bool insideCycle = false;

	while(k--) {
		time++;
		node = adj[node];
		if(!insideCycle && last_time_visited[node] != -1) {
			insideCycle = true;
			k %= time - last_time_visited[node];
			//printf("k: %d\n", k);
		}
		last_time_visited[node] = time;
	}

	printf("%d\n", node+1);

	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int A,B,C,X,Y;cin>>A>>B>>C>>X>>Y;
  int ans = A*X+B*Y;
  if (X>Y) {
    ans = min(ans, C*2*X);
    ans = min(ans, C*2*Y+A*(X-Y));
  } else {
    ans = min(ans, C*2*Y);
    ans = min(ans, C*2*X+B*(Y-X));
  }
  OUT(ans);

  return 0;
}

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

int main() {
  int a;
  cin >> a;
  int b;
  cin >> b;
  int count = a;
  int i;

  for(i = 1; count < b; i++){
    count = count - 1 + a;
  }
  if(b == 1 ){
    i = 0;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

// youtube editorial

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> ans;
  rep(i, n) {
    for (int j = sz(a) - 1; j >= 0; --j) {
      if (a[j] == j + 1) {
        ans.eb(j + 1);
        a.erase(a.begin() + j);
        break;
      }
      if (j == 0) {
        cout << -1 << endl;
        return;
      }
    }
  }
  reverse(all(ans));
  rep(i, n) cout << ans[i] << endl;
}


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


const int maxn = 1e6+5;
int w[maxn];
int main(){
    int k, n; cin >> k >> n;
    for(int i = 1; i <= n; i++) {
        cin >> w[i];
    }
    sort(w+1, w+n+1);
    int maxx = 0;
    for(int i = 2; i <= n; i++) {
        maxx = max(maxx, w[i]-w[i-1]);
    }
    w[1] += k;
    maxx = max(maxx, w[1]-w[n]);
    cout << k - maxx << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)cout << 0 << endl;
	else cout << min({ a*b,b*c,c*a }) << endl;
	endre;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	vector<string>s(n),ch;
	rep(i,n)cin>>s[i];
	rep(i,n){
	    if(s[i]=="AB"){
	        if(a>b||(a==b&&i==n-1)){
	            a--;b++;
	            ch.push_back("B");
	        }
	        else if(a<b){
	            a++;b--;
	            ch.push_back("A");
	        }
	        else if(i!=n-1){
	            if(s[i+1]=="AC"){
	                a++;b--;
	                ch.push_back("A");
	            }
	            else{
	                a--;b++;
	                ch.push_back("B");
	            }
	        }
	    }
	    if(s[i]=="AC"){
	        if(a>c||(a==c&&i==n-1)){
	            a--;c++;
	            ch.push_back("C");
	        }
	        else if(a<c){
	            a++;c--;
	            ch.push_back("A");
	        }
	        else if(i!=n-1){
	            if(s[i+1]=="AB"){
	                a++;c--;
	                ch.push_back("A");
	            }
	            else{
	                a--;c++;
	                ch.push_back("C");
	            }
	        }
	    }
	    if(s[i]=="BC"){
	        if(c>b||(c==b&&i==n-1)){
	            c--;b++;
	            ch.push_back("B");
	        }
	        else if(c<b){
	            c++;b--;
	            ch.push_back("C");
	        }
	        else if(i!=n-1){
	            if(s[i+1]=="AC"){
	                c++;b--;
	                ch.push_back("C");
	            }
	            else{
	                c--;b++;
	                ch.push_back("B");
	            }
	        }
	    }
	    //check negative
	    if(a<0||b<0||c<0){
	        cout<<"No";
	        return 0;
	    }
	}
	//if you reach here
	cout<<"Yes"<<endl;
	rep(i,n)cout<<ch[i]<<endl;
	return 0;
}


Measured memory_bytes: 10588
import math

# xのn乗
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

# nCkの導出
def comb(n,k):
    nCk = 1
    # X
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= mod

    # Y
    for i in range(1,k+1):
        nCk *= pow(i,mod-2,mod)
        nCk %= mod
    return nCk

n, a, b = map(int, input().split())
mod = 10**9+7

# ans = pow_k(2,n) - c(n,a) - c(n,b) - 1

ans = pow(2,n,mod) - 1 - comb(n,a) - comb(n,b)

print(ans%mod)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string.h>
#include <sstream>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(ll i = 0;i < n;i++)
#define rep1(i,n) for(ll i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<ll>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

ll gcd(ll a, ll b) {
	if(a*b == 0) return max(a, b);
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	if (a%b == 0)return b;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int main(){

	ll n,m;
	cin >> n >> m;

	vector<ll> a(n);

	for(ll i = 0;i < n;i++) {
		cin >> a[i];
		a[i] /= 2;
	}

	ll odd,even;
	ll even_count = 0;

	while(true){
		
		odd = 0;even = 0;

		for(ll i = 0;i < n;i++){
			if(a[i]%2 == 0) even++;
			else odd++;
		}

		if(even*odd != 0){
			cout << 0 << endl;
			return 0;
		}
		if(even == 0){
			break;
		}
		even_count++;

		for(ll i = 0;i < n;i++) a[i] /= 2;

	}

	ll lcm_all = lcm(pow(2,even_count),a[0]);

	for(ll i = 1;i < n;i++){
		lcm_all = lcm(lcm_all,a[i]);
		if(lcm_all > m) {
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (m/lcm_all + 1)/2 << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

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

  int num[110] = { 0 };
  for (int i = 0; i < n; i++) {
    num[d[i]]++;
  }

  int res = 0;
  for (int i = 1; i <= 100; i++) {
    if (num[i]) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>
using namespace std;

#define abs(x) ((x)>=0?(x):-(x))
#define LL long long
#define u32 unsigned int
#define u64 unsigned long long
#define clr(x,y) memset(x,y,sizeof(x))
#define PI acos(-1.0)
#define sqr(x) ((x)*(x))
#define maxn 10000
struct node
{
  int x,y;
  int len ;
  string name;
};
node a[maxn];

int main()
{
  int n ,q ;
  
  for(int i=0;i<100000;i++)
  for(int j=0;j<100000;j++)
  for(int k=0;k<100000;k++)
  for(int l=0;l<100000;l++)
  {
      int b = 12%10;
  }
  
  while(scanf("%d%d",&n,&q)!=EOF && !(n == 0 && q == 0 ))
  {
      
    for(int i = 1; i <= n ; i ++ )
    {
      cin >> a[i].name;
      scanf("%d%d",&a[i].len ,&a[i].y);
      a[i].x = a[i].y - a[i].len + 1 ;
    }
    int x ;
    while(q --  )
    {
      scanf("%d",&x);
      int pos ;
      pos = -1 ;
      int wh;
      for(int i = 1; i <= n ; i ++ )
      {
        if(a[i].x <= x && a[i].y >= x )
        {
          pos = i ;
          wh = x - a[i].x + 1 ;
        }
      }
      if(pos == -1)
      {
        printf("Unknown\n");
      }
      else
      {
        printf("%s %d\n",a[pos].name.c_str(),wh);
      }
    }
  }
	return 0;
}

Measured memory_bytes: 1544
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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; }

const int mxN = 1e5 + 6;
const int mxC = 32;
int s[mxN], t[mxN], c[mxN];
vector<int> sum(mxN * mxC + 5);
vector<int> cnt(mxN * mxC + 5, 0);

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

	int n, C;
	cin >> n >> C;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> c[i];
	}
	for (int i = 1; i <= C; i++) {
		for (int j = 0; j < (int)sum.size(); j++) {
			sum[j] = 0;
		}
		for (int j = 0; j < n; j++) {
			if (c[j] == i) {
				sum[s[j] * 2 - 1]++, sum[t[j] * 2]--;
			}
		}
		for (int j = 0; j < (int)sum.size() - 1; j++) {
			sum[j + 1] = sum[j + 1] + sum[j];
		}
		for (int j = 0; j < (int)sum.size(); j++) {
			if (sum[j] > 0) cnt[j]++;
		}
	}

	int mx = 0;
	for (int i = 0; i < (int)cnt.size(); i++) {
		chmax(mx, cnt[i]);
	}
	cout << mx << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int k,n;
    cin >> n >> k;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(all(l),greater<>());
    ll sum=0;
    rep(i,k) sum+=l[i];

    cout << sum << endl;

    
    return 0;
}

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

int main(){
	int N,Y;
	cin >> N >> Y;
	int x=0,y=0,z=0;

	for(x=0;x<N+1;x++){
		for(y=0;y<N+1;y++){
			z = N - x - y;
			if(z >= 0 && Y == (10000*x + 5000*y + 1000*z)){
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define m 1000000007
#define MAXN 1000001
#define satya ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cil(a,b) (((a-1)/b)+1)
//#define init int t;cin>>t;while(t--)
#define in(a) ll a;scanf("%lld",&a)
#define ine(a,b) ll a,b;scanf("%lld lld",&a,&b)



ll spf[MAXN]; 

void sieve1() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 

		spf[i] = i; 

	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		if (spf[i] == i) 
		{ 
			for (int j=i*i; j<MAXN; j+=i) 

				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

ll  getFactorization(int x) 
{ 
	vector<int> ret; 
	long long int p=0;
	while (x != 1) 
	{ 
		ret.push_back(spf[x]); 
		x = x / spf[x]; 
	} 
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size()-1;i++) 
	{
	    if(ret[i]!=ret[i+1])
	    p=p+ret[i];
	}
	p=p+ret[ret.size()-1];
	return p;
} 

ll d[1000055],u=0;
void Sieve(int n) 
{ 
	bool prime[n+1]; 
//	ll u=0;
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		if (prime[p] == true) 
		{ 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	for (int p=2; p<=n; p++) 
	if (prime[p]) 
	{
	    d[u]=p;
	    u++;
	}
} 

ll minverse(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return minverse((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*minverse((x*x)%M,(n-1)/2,M))%M;

}
ll prime(ll n){
    ll i;
    if(n==1||n==0)
    return 0;
    for(i=2;i<sqrt(n);i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main() {
       satya;
     //sieve1(); 
     //Sieve(100);
    	   ll n;
    	   cin>>n;
    	   ll p=(3*n*n);
    	   cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 256