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


long long A[11];
map<pair<long long,long long>, long long> mp;

int main(){
	long long h,w,n,a,b;
	cin >> h >> w >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		for(int x=0;x<3;x++){
			for(int y=0;y<3;y++){
				if(a-x>=1&&b-y>=1 && a-x+2<=h&&b-y+2<=w){
					mp[make_pair(a-x,b-y)]++;
				}
			}
		}
	}
	for(auto x:mp){
		A[x.second]++;
	}
	
	A[0]=(h-2)*(w-2)-mp.size();
	for(int i=0;i<10;i++){
		cout << A[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> hasSnack(N, false);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int index;
            cin >> index;
            hasSnack[index - 1] = true;
        }
    }
    int count = 0;
    rep(i, N) {
        if (!hasSnack[i]) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
/***
 ** " In order to be irreplaceable, one must always be different "
 **     -- Coco Chanel
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: Replacing Integer
  *  Date:   05.04.2020
  *  Time:   03:03:40
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif


typedef unsigned int ui;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(),s.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define test int T = 1;if(testcases)cin >> T;for(int tc = 1 ; tc <= T ; tc++)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

ll seed;mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a)
{in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a)
{for(auto &x : a)in>>x;return in;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}

int main(int argc, char **argv)
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","a",stderr);
    #endif
    
    fast;
    ll n, k;
    test
    {
    	cin >> n >> k;
        n %= k;

        ll mini = n;
        for(int i = 0 ; i < 100000 ; i++)
        {
        	n = abs(n - k);
        	mini = min(mini, n);
        }

        cout << mini << endl;
        fundri;
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int sLength = s.size();
	if(sLength < 7){
		cout << "NO\n";
		return 0;
	}

	for(int i = 0; i <= 7; i++){
		string substring;
		for(int j = 0; j < i; j++)
			substring += s[j];
		for(int j = sLength - 7 + i; j < sLength; j++)
			substring += s[j];
		if(substring == "keyence"){
			cout << "YES\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


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

using namespace std;
int main(){
	
	vector <int> v(5,0);
	for(int i=0;i<3;i++){
		int a,b;
		cin>>a>>b;
		v[a]++;
		v[b]++;
		
	}
	for(int i=1;i<=4;i++){
		if(v[i]==3){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

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

int main(){
    //N個の要素数の配列をソートして小さい順にK個足す

    int num, kosu;
    vector <int> price;
    cin >> num >> kosu;

    //cout << num << "  " << kosu << "\n";
    int tmp;
    for(int i =0; i < num; i++)
    {
        cin >> tmp;
        price.push_back(tmp);
    }

    sort(price.begin(), price.end());

    int sum_price =0;

    for(int j =0; j< kosu; j++)
    {
        sum_price += price[j];
    }

  	cout << sum_price;
  
    return 0;
}



Measured memory_bytes: 3632
#!/usr/bin/env ruby
x, n = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_i)

return puts x if p.empty?

diff = 0

while true
  if !p.include?(x - diff)
    puts x - diff
    break
  elsif !p.include?(x + diff)
    puts x + diff
    break
  end
  diff += 1
end


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

class Cube {
   public:
    int f[6];  //サイコロ
    Cube() {}  //コンストラクタ
    void roll_z() { roll(1, 2, 4, 3); }
    void roll_y() { roll(0, 2, 5, 3); }  // to W
    void roll_x() { roll(0, 1, 5, 4); }  // to N
    void roll(int i, int j, int k, int l) {
        int t = f[i];
        f[i]  = f[j];
        f[j]  = f[k];
        f[k]  = f[l];
        f[l]  = t;
    }
    void move(char ch) {
        if (ch == 'E')
            for (int i = 0; i < 3; i++) roll_y();  // Wを３回
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S')
            for (int i = 0; i < 3; i++) roll_x();  // Nを３回
    }
};

int getRight(Cube c1, int top, int front) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (c1.f[0] == top && c1.f[1] == front) return c1.f[2];
            c1.roll_z();
        }
        if (i % 2 == 0)
            c1.roll_y();
        else
            c1.roll_x();
    }
    return -1;
}

int judgeSame(Cube c1, Cube c2) {
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 4; j++) {
            if (c1.f[0] == c2.f[0] && c1.f[1] == c2.f[1] &&
                c1.f[2] == c2.f[2] && c1.f[3] == c2.f[3] &&
                c1.f[4] == c2.f[4] && c1.f[5] == c2.f[5]) {
                return 1;
            }
            c1.roll_z();
        }
        if (i % 2 == 0)
            c1.roll_y();
        else
            c1.roll_x();
    }
    return -1;
}
int main() {
    Cube c1, c2;  // サイコロ
    int  ans;

    // 入力
    for (int i = 0; i < 6; i++) cin >> c1.f[i];  // サイコロ 1
    for (int j = 0; j < 6; j++) cin >> c2.f[j];

    ans = judgeSame(c1, c2);
    if (ans == 1) {
        cout << "Yes" << endl;

    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3104
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    println(ifelse(length(collect(Set(split(readline()))))==4,"Four","Three"))
end
main()

Measured memory_bytes: 129244
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 998244353
#define lim 5000
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll fact[lim], ifact[lim], pow2[lim];

ll powmod(ll b, ll e)
{
	ll ret = 1; b = b%mod; e %= (mod-1);
	while(e)
	{
		if(e&1) ret = (ret*b)%mod;
		b = (b*b)%mod;
		e >>= 1;
	}
	return ret;
}

ll inv(ll n){ return powmod(n, mod-2); }

/* factorials, inverses */
ll pre()
{
	int i,j;
	pow2[0] = fact[0] = 1;
	for(i=1; i<lim; i++) fact[i] = (fact[i-1]*i)%mod;
	ifact[lim-1] = inv(fact[lim-1]);
	for(i=lim-2; i>=0; i--) ifact[i] = (ifact[i+1]*(i+1))%mod;
	for(i=1; i<lim; i++) pow2[i] = (pow2[i-1]*2)%mod;
}

ll nCr(int n, int r)
{
	return n<r?0:(((fact[n]*ifact[r])%mod)*ifact[n-r])%mod;
}

int main()
{
	pre();
	nfs_mw;
	int i,j,k,n,np; ll ans = 0;
	cin>>k>>n;
	for(i=2; i<=2*k; i++){
		ll ans = 0;
		np = (min(i-1,k) - max(i-k,1) + 2)/2;
		for(j=0; j<=min(np,n); j++)
			ans = (ans + (((pow2[j]*nCr(np,j))%mod)*nCr(n+k-2*np-1,n-j))%mod)%mod;
		cout<<ans<<" ";
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll n,m;
  cin>>n>>m;
  vec(l,m);
  vec(r,m);
  ll mal=LLONG_MIN;
  ll mir=LLONG_MAX;
  rep(i,m){
    cin>>l[i]>>r[i];
    mal=max(l[i],mal);
    mir=min(r[i],mir);
  }
  op(mir-mal+1>0?mir-mal+1:0)
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
typedef unsigned long long int ull;
//--main function
int main(){
	ull a[87];
	int n;
	cin>>n;
	a[0]=2;a[1]=1;
	REP(i,2,n){
		a[i]=a[i-1]+a[i-2];
	}
	cout<<a[n];
	
	return 0;

//   TimeTaken();
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int red = 0, ans = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'R')
			red++;

	for (int i = 0; i < red; i++)
		if (s[i] == 'W')
			ans++;

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

//!

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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  map<ll, ll> m;
  REP(i, s.size())
    m[s[i]-'a'] += 1;

  ll x = 0;
  ll y = INF;
  REP(i, 3){
    x = max(x, m[i]);
    y = min(y, m[i]);
  }

  if(x-y<=1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}


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

struct card { char suit, value; };


// 配列の出力
void trace(struct card A[], int n) {
  for (int i=0; i<n; i++) {
    if (i != n-1) {
      cout << A[i].suit << A[i].value << " ";  
    } else {
      cout << A[i].suit << A[i].value  << endl;
    }
  }
}

// バブルソート
void bubbleSort(struct card A[], int n) {
  bool flag = 1;
  for (int i=0; flag; i++) {
    flag = 0;
    for (int j=n-1; j>=i+1; j--) {
      if (A[j].value < A[j-1].value) {
        swap(A[j], A[j-1]);
        flag = 1;
      }
    }
  }
}

int selectionSort(struct card A[], int n) {
  int minj;
  for (int i=0; i<n-1; i++) {
    minj = i;
    for (int j=i+1; j<n; j++) {
      if (A[minj].value > A[j].value) {
        minj = j;
      }
    }
    if (i != minj) {
      swap(A[i], A[minj]);
    } 
  }
}

bool isStable(struct card c1[], struct card c2[], int n) {
  rep(i, n){
    if (c1[i].suit != c2[i].suit) return false;
  }
  return true;
}

int main() {
  card c1[100], c2[100];
  int n;
  char ch;
  
  cin >> n;
  rep(i, n) cin >> c1[i].suit >> c1[i].value;
  rep(i, n) c2[i] = c1[i];

  bubbleSort(c1, n);
  selectionSort(c2, n);

  trace(c1, n);
  cout << "Stable" << endl;

  trace(c2, n);
  if (isStable(c1, c2, n)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int n;
  cin >> n;

  while(n!=0){
    int s[86401]={};
    for(int i=0;i<n;i++){
      string u,t;
      cin >> u >> t;
      s[stoi(u.substr(0,2))*3600+stoi(u.substr(3,2))*60+stoi(u.substr(6,2))]++;
      s[stoi(t.substr(0,2))*3600+stoi(t.substr(3,2))*60+stoi(t.substr(6,2))]--;
    }

    int m=0;
    for(int i=0;i<86400;i++){
      s[i+1]+=s[i];
      m=max(m,s[i]);
    }

    cout << m << endl;

    cin >> n;
  }

}


Measured memory_bytes: 3428
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int n = scanner.nextInt();

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += scanner.nextInt();
            if(sum >=h){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 47416
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  ULL N;
  cin >> N;

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  vector<ULL> culmSum(N+1, 0);
  culmSum[0] = 0;
  for (int i = 1; i < (N+1); i++)
  {
    culmSum[i] = i + culmSum[i-1];
  }

  int upper;
  for (int i = 1; i < (N+1); i++)
  {
    if(culmSum[i] > N) {
      upper = i;
      break;
    }
  }

  for (int i = 1; i <= upper; i++) {
    if(culmSum[upper] - i == N) {
      continue;
    }
    cout << i << endl;
  }
  

  return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=300010;



signed main(){
    ll h,w;cin>>h>>w;
    ll ch,dh,cw,dw;cin>>ch>>dh>>cw>>dw;
    ch--;
    dh--;
    cw--;
    dw--;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    deque<pll>q;
    vector<vector<ll> >d(h,vector<ll>(w,inf));
    vector<vector<vector<ll> > >used(h,vector<vector<ll> >(w,vector<ll>(2)));
    q.push_front(mp(ch,dh));
    d[ch][dh]=0;
    used[ch][dh][0]=1;
    while(!q.empty()){
        pll k=q.front();
        ll x=k.fi;
        ll y=k.se;
        q.pop_front();
        rep(i,5){
            rep(j,5){
                ll nx=x-2+i;
                ll ny=y-2+j;
                if(nx<0||nx>=h||ny<0||ny>=w)continue;
                if(s[nx][ny]=='#')continue;
                if(nx==x&&ny==y)continue;
                if(abs(nx-x)+abs(ny-y)==1){
                    if(!used[nx][ny][0]){
                        q.push_front(mp(nx,ny));
                        used[nx][ny][0]=1;
                    }
                    d[nx][ny]=min(d[x][y],d[nx][ny]);
                }else{
                    if(!used[nx][ny][1]&&!used[nx][ny][0]){
                        q.push_back(mp(nx,ny));
                        used[nx][ny][1]=1;
                    }
                    d[nx][ny]=min(d[nx][ny],d[x][y]+1);
                }
            }
        }
    }
    if(d[cw][dw]!=inf)cout<<d[cw][dw]<<endl;
    else cout<<-1<<endl;
}

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

int main() {
	int n;
	cin >> n;
	string strn = to_string(n);
	int sn = 0;
	for (int i = 0; i < strn.size(); i++) {
		sn += strn[i] - '0';
	}
	if (n % sn == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val num = readLine()!!.toInt()
    val prime = mutableMapOf<Int,Int>()
    for(i in (2..num)) {
        val ret = primeDivide(i)
        for(j in ret.keys) {
            if(prime.containsKey(j)) {
                prime[j] = prime[j]!! + ret[j]!!
            } else {
                prime[j] = ret[j]!!
            }
        }
    }
    var ans = 1L
    for(i in prime.values) {
        ans *= (i+1)
        ans %= 1000000000 + 7
    }
    println(ans)

}

fun primeDivide(num:Int):Map<Int, Int> {
    var current = num
    val divide = mutableMapOf<Int,Int>()
    var div = 2
    while (current > 1) {
        if(current % div == 0) {
            divide[div] = 0
            while (current%div == 0) {
                divide[div] = divide[div]!! + 1
                current /= div
            }
        }
        div++
    }
    return divide
}


Measured memory_bytes: 33988
gets
p = gets.chomp.split(" ").map(&:to_i)
count  = 0

i = 0
while(i < p.size)
    if p[i] == i + 1 then
        if i < p.size - 1 && p[i+1] == i+2 then
            i += 2
        else
            i += 1
        end
        count += 1
    else
        i += 1
    end

end

puts count


Measured memory_bytes: 8708
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int n, m, l;
  cin >> n >> m >> l;
  long a[n][m], b[m][l], c[n][l];
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++)
      cin >> a[i][j];
  for(int i = 0; i < m; i++)
    for(int j = 0; j < l; j++)
      cin >> b[i][j];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l; j++) {
      c[i][j] = 0;
      for(int k = 0; k < m; k++)
        c[i][j] += a[i][k] * b[k][j];
    }
  }
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l - 1; j++) {
      cout << c[i][j] << " ";
    }
    cout << c[i][l - 1] << endl;
  }

  return 0;
}



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

int main () {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  vector<int> y(M);
  for (int i = 0; i < M; i++) {
    cin >> y.at(i);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (x.at(N-1) < y.at(0) && X < y.at(0) && x.at(N-1) < Y) cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

void initialize();
void printBoard();
void recursive(int);

int row[N], col[N], dpos[2*N-1], dneg[2*N-1];

bool X[N][N];

void initialize(){

  int i=0;

  for(i=0; i<N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i=0; i<2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard(){

  int i=0, j=0;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(X[i][j]!=0){
        if(row[i] != j){
          return ;
        }
      }
    }
  }

for(i=0; i<N; i++){
      for(j=0; j<N; j++){
        printf("%s",(row[i] == j) ? "Q" : ".");
      }
      printf("\n");
    }
  }

void recursive(int i){

  int j=0;

  if(i == N){
    printBoard();
    return;
  }

  for(j=0; j<N; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]\
){
      continue;
    }
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main(){

  int i=0, j=0;

  initialize();

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      X[i][j] = false;
    }
  }

  int k;

  scanf("%d",&k);

  for(i=0; i<k; i++){
    int r, c;
    scanf("%d%d",&r,&c);
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<int> w(n);
    vector<int> s(n);
    REP(i,n) {
        cin >> w[i];
        if(i==0) s[i] = w[i];
        else s[i] += w[i]+s[i-1];
    }
    int ans = MOD;
    REP(i,n) {
        ans = min(abs(s[n-1] - s[i]*2), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <type_traits>
#include <algorithm>
#include <string>
#include <vector>
#include <assert.h>

template<typename RET = uint64_t, typename Integral>
RET combination(Integral all, Integral get)
{
	assert(all >= get);
	get = std::min(all - get, get);
#if 0
	constexpr int32_t ALL_MAX = 10'000;
	static std::vector<RET> DP_comb[ALL_MAX+1];
	if (!DP_comb[all].empty())
	{
		return DP_comb[all][get];
	}

	if (DP_comb[0].empty())
	{
		DP_comb[0].resize(1);
		DP_comb[0][0] = (RET)1;
		DP_comb[1].resize(1);
		DP_comb[1][0] = (RET)1;
	}
	for (int32_t i = 2; i <= all; i++)
	{
		if (DP_comb[i].empty())
		{
			int32_t size = i/2 + 1;
			DP_comb[i].resize(size);
			DP_comb[i][0] = (RET)1;
			for (int32_t j = 1; j < size-1; j++)
			{
				DP_comb[i][j] = DP_comb[i - 1][j - 1] + DP_comb[i - 1][j];
			}
			DP_comb[i][size-1] = DP_comb[i - 1][size - 2] + DP_comb[i - 1][(i&1)?(size-1):(size - 2)];
		}
	}
	return DP_comb[all][get];
#else
	RET ret = (RET)1;
	for (Integral i = 1; i <= get; ++i)
	{
		ret *= all+1-i;
		ret /= i;
	}
	return ret;
#endif
}
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>


#define in std::cin
#define out std::cout

int32_t N;
int32_t MIN, MAX;
int64_t A[100];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	in >> MIN >> MAX;
	for (size_t i = 0; i < N; i++)
	{
		in >> A[i];
	}
	std::sort(A, A + N, std::greater<>{});

	uint64_t sum = 0;
	for (size_t i = 0; i < MIN; ++i)
	{
		sum += A[i];
	}
	out << std::fixed << std::setprecision(10) << (double)(sum) / MIN << endl;

	auto range = std::equal_range(A, A + N, A[MIN - 1], std::greater<>{});
	auto range_lrngth = range.second - range.first;
	if (range_lrngth == 1)
	{
		out << 1 << endl; return 0;
	}
	auto not_free = range.first - A;
	uint64_t count = 0;
	if (not_free == 0)
	{
		for (int i = MIN; i <= std::min<int>(MAX, range_lrngth); ++i)
		{
			auto free = (MIN - not_free) + (i - MIN);
			//count += fact_v[range_lrngth] / fact_v[free] / fact_v[range_lrngth - free];
			count += combination(range_lrngth, free);
		}
	}
	else
	{
		auto free = (MIN - not_free) + (MIN - MIN);
		//count += fact_v[range_lrngth] / fact_v[free] / fact_v[range_lrngth - free];
		count += combination(range_lrngth, free);
	}
	out << count << endl;

	return 0;
}
#endif

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll num = 1e18;
    ll ans = 1;
    int n; cin >> n;
    vc<ll> nu(n);
    rep(i,n){
        cin >> nu[i];
        if(nu[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n){
        ll x = nu[i];
        ll a = num / ans;
        if(a < x){
            cout << -1 << endl;
            return 0;
        }
        ans *= x;
    }
    cout << ans << endl;
    return 0;
}


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

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

  int64_t sum = 0;
  for (int64_t i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int A, B, ans;
	
	cin >> A >> B;
	ans = max(A + B, A - B);
	cout << max(ans, A * B);
	
	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=(x);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    vll v(n),c(n);
    rep(i,n)cin >> v[i];
    rep(i,n)cin >> c[i];

    ll sum=0;
    rep(i,n){
        if(v[i] - c[i] > 0)sum += v[i]-c[i];
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

n,m,x = inp
d = []
n.times do
  d << inp
end
ans = 1e20
(0...(2**12)).each do |bit|
  cost = 0
  now = na(m)
  d.size.times do |i|
    if(bit[i] == 1)
      (1..m).each do |j|
        now[j-1] += d[i][j]
      end
      cost += d[i][0]
    end
  end
  f = true
  (m).times do |j|
    f &= (now[j] >= x)
  end
  if f
    ans = [ans,cost].min
  end
end
puts (ans > 1e19)? -1 : ans


Measured memory_bytes: 14372
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5);
ll n, m;
 
void solve(){
    ll n, w;
    cin >> n >> w;
    ll weights[n], values[n];
    ll s = 0;
    for(int i=0; i<n; i++) {
        cin >> weights[i] >> values[i];
        s += values[i];
    }
    // ll dp[mxn] = {};
    vector<ll>dp(s+1, INF);
    dp[0] = 0;
    /// dp[i] = min weight for exactly i value
    for(int i=0; i<n; i++) {
        for(int v=s; v>=0; v--) {
            if(v+values[i] <= s)
            dp[v+values[i]] = min(dp[v+values[i]], dp[v] + weights[i]);
        }
    }
    ll ans=0;
    for(int i=s; i>=0; i--) {
        if(dp[i] <= w) {
            ans = i;
            break;
        }
    }
    cout << ans;
}
 
int main(){
    fast;
    //  tt
        solve();
}

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

char x[10][10];
char y[10][10];

void TheRotate90() {
	for (int j = 0; j < 8; j++) {
		for (int k = 0; k < 8; k++) {
			y[k][7 - j] = x[j][k];
		}
	}
}

int main() {
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 1; i < 4; i++) {
		cout << i * 90 << endl;
		TheRotate90();
		for (int j = 0; j < 8; j++) {
			for (int k = 0; k < 8; k++) {
				x[j][k] = y[j][k];
				cout << x[j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {
    int N;
    string S;
    cin >>N>>S;
    string flg="Yes";
    if(N%2!=0)flg="No";
    else{
        for(int i=0;i<N/2;++i){
            if(S[i]!=S[N/2+i]){
                flg="No";
                break;
            }
        }
    }
    cout<<flg<<endl;

return 0;
}

Measured memory_bytes: 256
"""
N <= 100
h <= 100
ということで,実装さえすれば通りそう
山の絵を書いて考える
"""

N = int(input())
H = [-1] + list(map(int, input().split()))

ans = 0
for _ in range(max(H)):
    count = 0
    for j in range(N):
        if H[j] <= 0 and H[j+1] > 0:
            count += 1
    ans += count
    H = [i-1 for i in H]
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s;
    int y,m,d;
    while(1){
        cin>>s;
        if(s=="#")break;
        cin>>y>>m>>d;
        if(y>31||(y==31&&m>=5)){
            cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
        }
        else{
            cout<<s<<" "<<y<<" "<<m<<" "<<d<<endl;
        }
    }

    
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[1005],n,k;
int main(){
    scanf("%d %d",&n,&k); 
    for(int i = 1;i <= n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	int ans =0;
	for(int i = n; i >= n-k+1;--i) ans+=a[i];
	cout<<ans; 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	ll A, B;
	cin >> A >> B;
	if (A == B) {
		cout << 1 << endl;
		return 0;
	}
	int t = 0;
	for (t = 59; t >= 0; t--) {
		if ((A&(1LL << t)) == (B&(1LL << t))) {
			A &= ~(1LL << t);
			B &= ~(1LL << t);
		}
		else break;
	}
	ll ans = (1LL << t) - A;
	int r = -1;
	for (int i = t - 1; i >= 0; i--) {
		if (B&(1LL << i)) {
			r = i;
			break;
		}
	}
	ll l1 = (1LL << t) + A, r1 = (1LL << (t + 1));
	ll l2 = (1LL << t), r2 = (1LL << t) + (1LL << (r + 1));
	if (r2 < l1) {
		ans += r1 - l1;
		ans += r2 - l2;
	}
	else {
		ans += r1 - l2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<int,int> P;

int dist(P x, P y){
    return abs(x.first-y.first)+abs(x.second-y.second);
}

int main(){
    int H, W, D; cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    vector<P> coord(H*W);
    rep(i,H) rep(j,W){
        cin >> A[i][j]; A[i][j]--;
        coord[A[i][j]] = make_pair(i,j);
    }

    vector<int> sum_d(H*W, 0);

    for(int i = D; i<H*W; i++){
        int d = dist(coord[i], coord[i-D]);
        sum_d[i] = sum_d[i-D] + d;
    }

    int Q; cin >> Q;
    rep(query, Q){
        int L, R; cin >> L >> R; L--; R--;
        cout << sum_d[R] - sum_d[L] << endl;
    }    
}

Measured memory_bytes: 2560
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(string s, long long k){
    int n = s.size();
    int p = 1;
    int q = 1;
    for(int i = 0; i < k; ++i)
        p *= n;
    for(int i = 0; i < k; ++i)
        q *= 9;

    string t;
    for(int i = 0; i < n; ++i)
        t += '0';

    i64 ans = 0;
    for(int mask = 0; mask < p; ++mask){
        vector<int> pos;
        int j = mask;
        for(int i = 0; i < k; ++i){
            int x = j % n;
            pos.emplace_back(x);
            j /= n;
        }
        bool fl = true;
        for(int i = 0; i < pos.size() - 1; ++i)
            fl &= pos[i] > pos[i + 1];
        if(!fl)
            continue;

        auto f = [&](int val){
            for(int i = 0; i < k; ++i){
                int vv = val % 9;
                t[pos[i]] = vv + '1';
                val /= 9;
            }
            bool fl = (s >= t);
            for(int i = 0; i < k; ++i)
                t[pos[i]] = '0';
            return fl;
        };

        int ok = -1, ng = q;
        while(ng - ok > 1){
            int mid = (ok + ng) / 2;
            (f(mid) ? ok : ng) = mid;
        }
        ans += ok + 1;
    }
    cout << ans << endl;
}


signed main(){
    string s;
    cin >> s;
    long long K;
    scanf("%lld",&K);
    solve(s, K);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007


map<char, int> m;


int main()
{
	FAST;
	ll n;
	cin >> n;
	ll a[n+5];
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	} ll ans = 0;
	for(ll i = 1; i  + 1 < n ; i ++){
		ll x = min(a[i-1], min(a[i], a[i+1]));
		ll y = max(a[i-1], max(a[i], a[i+1]));
		ll z = a[i] + a[i-1] + a[i+1] - x - y;
		if(a[i] == z){
			ans ++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        if (n==1) {
            cout << 0 << endl; break;
        }
        map<ll,ll> factors;
        ll d = 2;
        while (d*d <= n) {
            if (n % d == 0) {
                while (n % d == 0) {
                    factors[d]++;
                    n /= d;
                }
            } else {
              ++d;
            }
        }
        if (n > 1) {
            factors[n]++;
        }

        ll ret = 0;
        for(auto p : factors)  {
            int m = p.second;
            int summ = 0;
            int count = 0;
            while (summ <= m) {
                count++;
                summ += count;
            }
            ret += count-1;
        }
        cout << ret << endl;

        
    }
    return 0;
}


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

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  map<int,vector<int>> m;
  for(int i=1;i<=k;++i){
    int d;
    cin >> d;
    for(int j=0,x;j<d;++j){
      cin >> x;
      m[x].push_back(i);
    }
  }
  int ans=0;
  for(int i=1;i<=n;++i){
    if(m[i].size() == 0) ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  vector<int> d(n);
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  
  int idx = d.size() / 2;
  cout << d[idx] - d[idx-1] << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    cout << pow(N,3) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
int main()
{
	int a,b,c,d; 
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int i,j,k;
	if(b<=c||a>=d)
	{
		printf("0\n");
	}
	else
	{
		if(d>=b)
		{
			if(a<=c)
			printf("%d\n",b-c);
			else
			printf("%d\n",b-a);
			
		}
		else
		{
			if(a<=c) 
			printf("%d\n",d-c);
			else
			printf("%d\n",d-a);
		 } 
	}
	return 0;
 } 

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int N, K, P;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &K, &P);
		if (K > P) {
			if (K%P != 0)printf("%d\n", K%P);
			else printf("%d\n", K/(K / P));
		}
		else {
			printf("%d\n", K);
		}
	}
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string S;
    cin >> S;
    vector<int> q;
    int ans = 0;
    q.push_back(0);
    while (q.size() && !ans) {
        int i = q.back();
        if(i == S.length()) ans = 1;
        q.pop_back();
        if(S.substr(i, 5) == "dream") {
            q.push_back(i + 5);
        }
        if(S.substr(i, 5) == "erase") {
            q.push_back(i + 5);
        }
        if(S.substr(i, 6) == "eraser") {
            q.push_back(i + 6);
        }
        if(S.substr(i, 7) == "dreamer") {
            q.push_back(i + 7);
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

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

typedef long long int ll;


double PI = 3.14159265358979;

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  vector<ll> A(N);
  vector<ll> B(N+1,0);
  for(ll i = 0;i < N;i++){
    cin >> A[i];
    B[i+1] = B[i] + A[i];
  }
  sort(B.begin(),B.end());
  ll memo = 1;
  for(ll i = 0;i < N;i++){
    if(B[i] == B[i+1]){
      memo++;
    }else{
      ans += (memo * (memo - 1)) / 2;
      memo = 1;
    }
    if(i == N - 1 && memo != 1){
      ans += (memo * (memo - 1)) / 2;
    }
  }
  cout << ans << endl;
}





Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  int s[14] = {0,14,2,3,4,5,6,7,8,9,10,11,12,13};
  if(s[a] == s[b]) {
    cout << "Draw" << endl;
  } else if (s[a] > s[b]) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }

  return 0;
}


Measured memory_bytes: 256