akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 100003, M = 1024, mod = 998244353;
template<typename T>
void read(T &x){
	int ch = getchar(); x = 0; bool f = false;
	for(;ch < '0' || ch > '9';ch = getchar()) f |= ch == '-';
	for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
void qmo(int &x){x += (x >> 31) & mod;}
int ksm(int a, int b){
	int res = 1;
	for(;b;b >>= 1, a = (LL) a * a % mod) if(b & 1) res = (LL) res * a % mod;
	return res;
}
template<typename T>
inline bool chmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
int n, m, head[N], to[N], nxt[N], cnt, f[3][M], sg[N], pw[N], ans; bool vis[N];
void add(int a, int b){
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
void solve(int t){
	cnt = 0; read(m);
	for(Rint i = 1;i <= n;++ i) head[i] = sg[i] = 0;
	for(Rint i = 1, u, v;i <= m;++ i){
		read(u); read(v); if(u > v) swap(u, v); add(u, v);
	}
	for(Rint i = n;i;-- i){
		for(Rint j = head[i];j;j = nxt[j]) vis[sg[to[j]]] = true;
		for(;vis[sg[i]];++ sg[i]); qmo(f[t][sg[i]] += pw[i] - mod);
		for(Rint j = head[i];j;j = nxt[j]) vis[sg[to[j]]] = false;
	}
}
int main(){
	read(n); pw[0] = 1; pw[1] = 716070898;
	for(Rint i = 2;i <= n;++ i) pw[i] = (LL) pw[i-1] * pw[1] % mod;
	for(Rint t = 0;t < 3;++ t) solve(t);
	for(Rint i = 0;i < M;++ i)
		for(Rint j = 0;j < M;++ j)
			qmo(ans += (LL) f[0][i] * f[1][j] % mod * f[2][i^j] % mod - mod);
	printf("%d\n", ans);
}

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

int main(){
    string s;
    cin >> s;
    rp(i,s.size()/2){
        cout << s.at(2*i);
    }
    if(s.size()%2==1){
        cout << s.at(s.size()-1);
    }
    cout << endl;
}



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

const int MAX = 510000;
const int MOD = 998244353;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll powMod(ll x, ll k) {
  if (k == 0) return 1;
  if (k % 2 == 0)
    return powMod(x * x % MOD, k / 2);
  else
    return x * powMod(x, k - 1) % MOD;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  if (N == 1) {
    cout << M << endl;
    return 0;
  }
  COMinit();
  ll ret = 0;
  for (int i = 0; i <= K; i++) {
    ret =
        (ret + COM(N - 1, i) * M % MOD * powMod(M - 1, N - i - 1) % MOD) % MOD;
  }
  cout << ret << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}

graph g;
vi d;
ll z;
vi v,y,w;
void bfs(ll i){
    queue<ll>q;
    q.push(i);
    v[i]=1;
    y[i]=0;
    while(!q.empty()){
        z=q.front();
        q.pop();
        tr(g[z],h){
            if(!v[*h]){
                v[*h]=1;
                y[*h]=y[z]+1;
                if(!w[*h]) d[y[*h]]++;
                q.push(*h);
            }
        }
    }

}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T=1;
    //cin >> T;
    while(T--){
        ll n,x,y1;
        cin>>n>>x>>y1;
        g.assign(n+1,vi());
        d.assign(n+1,0);
        w.assign(n+1,0);
        y.assign(n+1,0);
        v.assign(n+1,0);
        rep_a(i,1,n){
            g[i].pb(i+1);
            g[i+1].pb(i);
        }
        g[x].pb(y1);
        g[y1].pb(x);
        rep_a(i,1,n+1){
            bfs(i);
            w[i]=1;
            rep(i,n+1) v[i]=0;
        }
        rep_a(i,1,n) cout<<d[i]<<el;

    }

    return 0;
}

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

bool is_prime(int x) {
    if (x == 1) return false;
    for (int i = 2; i*i <= x; i++) {
        if (x%i == 0) return false;
    }
    return true;
}

int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i, n) {
        int a; cin >> a;
        if (is_prime(a)) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n + 10, 0);
    vector<int> a(n + 10);
    for(int i = 1; i <= n; ++i) {
        cin >> h[i];
        a[i] = 1;
        if(h[i] <= h[i - 1]) a[i] += a[i - 1];
    }
    cout << *max_element(a.begin(), a.end()) - 1 << '\n';
}


Measured memory_bytes: 1024
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

int main() {
	int a,b,ans;

	a = b = ans = 0;
	cin >> a;
	ans = (1000 - a % 1000);
	if(ans == 1000)ans = 0; 

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

Measured memory_bytes: 3156
N = [int(i) for i in input().split()]

result = [0 for _ in range(N[0])]
row = []
col = []
for num, info in enumerate(range(N[0]+N[1])):
    if num < N[0]:
        row.append([int(i) for i in input().split()])
    else:
        col.append(int(input()))

for num, r in enumerate(row):
    res = 0
    for i, j in zip(r, col):
        res += i * j
    result[num] = res

for i in result:
    print(str(i))


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
struct SegmentTree {
    int n;
    vector<T> node;
    T calc(T a, T b) {
        return a | b;
    }
    T e = 0;
    SegmentTree(vector<T> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
        for (int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = calc(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    SegmentTree(T sz) {
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
    }
    void update(int x, T val) {
        x = n + x - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    void add(int x, T val) {
        x = n + x - 1;
        node[x] += val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return calc(vl, vr);
    }
    T at(int x) {
        return node[n + x - 1];
    }
};
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> v(n);
    rep(i, n) {
        v[i] = (1 << (s[i] - 'a'));
    }

    SegmentTree<int> segt(v);
    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        if (k == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            segt.update(i, 1 << (c - 'a'));
        }
        if (k == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            cout << __builtin_popcount(segt.query(l, r)) << endl;
        }
    }
}


Measured memory_bytes: 8836
#include<stdio.h>


int main(void){
  int A,B,C;
  scanf("%d %d %d",&A, &B, &C);
  if(A == B && B == C && C == A){
    printf("No");
  }else if(A == B || B == C || C==A){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
  
      
    
  
  


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<numeric>
#include<map>
#include<math.h>

using namespace::std;

int main(void)
{

  char c;

  while(1)
    {
      c = getchar();
      if( c < 'A' || 'Z' < c)
	{
	  break;
	}
      c -= 'A';
      c = (c - 3) + 26;
      c = c % 26;
      cout << char( c + 'A' );
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()

using namespace std;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
// bool sortbysec(const pll &a, const pll &b){return (a.second < b.second);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    	ll k;
    	cin>>k;
    	cout<<arr[k-1];
    }
}

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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
	IOS

	int a,b;
	cin >> a >> b;
	if((max(a,b) - min(a,b)) % 2 == 0){
		cout << (a + b) / 2;
	}else{
		cout << "IMPOSSIBLE";
	}

	return 0;
}

Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

dvd = []
for i in 1..N do
  dvd[i-1] = []
end
for i in 1..(N/2+1) do
  j = 2
  while i * j <= N do
    dvd[i*j-1].push(i)
    j += 1
  end
end

def zero_one(x)
  if x == 0 then
    return 1
  else
    return 0
  end
end
  
a = lines[1]
num_ans = 0
ans = []
for i in 1..N do  #examine the (N-i+1)-th box.
  if a[-i] == 1 then
    ans.push(N-i+1)
    num_ans += 1
    dvd[N-i].each do |j|
      a[j-1] = zero_one(a[j-1])
    end
  end
end
  
puts num_ans
ans.each do |i|
  print i.to_s + " "
end

Measured memory_bytes: 56656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
    ll n,a,top,end;
    cin >> n;
    vector<ll> b(n);
    if(n%2==0){
        top=n/2;
        end=n/2+1;
        for(int i=0;i<n;i++){
               cin >> a;
               if(i%2==0){
                      b[top-1]=a;
                      top--;
               }
               else{
                   b[end-1]=a;
                   end++;
               }
        }
    }
    else{
        top=n/2;
        end=(n+1)/2;
        for(int i=0;i<n;i++){
            cin >> a;
            if(i%2==0){
                b[end-1]=a;
                end++;
            }
            else{
                b[top-1]=a;
                top--;
            }
        }
    }
    for(int i=n-1;i>=0;i--){
        cout << b[i] << ' ';
    }
	return 0;
}

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

int main() {
    int h,w;
    cin >> h>>w;
    vector<vector<char>> vec(h+2,vector<char>(w+2,'#'));
    
  	for(int i=1 ;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>vec.at(i).at(j);
        
        }
     	cout<<" \n";
    }
    
    for(int i=0 ;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            cout<<vec.at(i).at(j);
        
        }
     	cout<<" \n";
    }
    
    return 0;
}


Measured memory_bytes: 3648
#include <cstdlib>
#include <iostream>

int main(void) {
  int A, B, C;
  std::cin >> A >> B >> C;
  if(A + B >= C) {
    std::cout << "Yes" << std::endl; 
  }
  else {
    std::cout << "No" << std::endl;
  }
}

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

using namespace std;
using ll = long long;

const int MAX_N = 1e6;
ll a[MAX_N];
int n;


int main(){
	cin >> n;

	ll count = 0;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if (i > 0){
			if (a[i-1] > a[i]){
				count += a[i-1] - a[i];
				a[i] = a[i-1];
			}
		}
	}
	cout << count;

	return 0;
}


Measured memory_bytes: 5148
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long llong;
static const int max_n = 100010;
using namespace std;

vector<int> numbers(max_n);


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i=0;i<size;i++){
                makeSet(i);
            }
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y] ++;
                }
            }
        }

        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};



int main(){
    int N, M, p, a;
    scanf("%d %d", &N, &M);
    DisjointSet DS(N);
    for(int i=0;i<N;i++){
        scanf("%d ", &p);
        numbers[i] = p-1;
    }

    for(int i=0;i<M;i++){
        scanf("%d %d", &p, &a);
        DS.unite(p-1, a-1);
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        ans += (int)DS.same(i, numbers[i]);
    }

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

}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
#include<utility>

using namespace std;

int main(void){
    long long N,M,C,T;
    cin>>N>>M;
    T=0;
    C=0;
    
    if(N==1){
        int K;
        cin>>K;
        
        cout<<K*M<<endl;
        return 0;
    }
    pair<long long,long long> P[N];
    
    long long A,B;
    for(int i=0;i<N;i++){
        cin>>A>>B;
        P[i]=make_pair(A,B);
        
    }
    sort(P,P+N);
    
    for(int i=0;i<N;i++){
        if((M-C)>P[i].second){
            C=C+P[i].second;
            T=T+P[i].first*P[i].second;
        }else{
            
            T=T+P[i].first*(M-C);
            cout<<T<<endl;
            return 0;

        }

    }
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int linearSearch(int,int);

int S[10000];

int main()
{
    int n,q,i,count=0,flag;
    int T[10000];

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

    scanf("%d",&q);
    for(i=0;i<q;i++)
    {
        scanf("%d",&T[i]);
        flag=linearSearch(n,T[i]);
        if(flag==0)count++;
    }
    printf("%d\n",count);
    return 0;
}

int linearSearch(int n,int key)
{
    int i=0;
    S[n]=key;
    while(S[i]!=key)i++;
    if(i!=n)return 0;
    return 1;
}


Measured memory_bytes: 2108
# ABC142D - Disjoint Set of Common Divisors
def gcd(x: int, y: int) -> int:
    while y:
        x, y = y, x % y
    return x


def prime_factors(x: int) -> list:
    if x % 2:
        max_prime, factors = 0, []
    else:
        max_prime, factors = 2, [2]
        while x % 2 == 0:
            x //= 2
    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            factors.append(i)
            while x % i == 0:
                x //= i
    if x > 2:  # when x is prime greater than 2
        factors.append(x)
    return factors


def main():
    # compute the number of prime factors of gcd(A, B)
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(prime_factors(g)) + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while(x <= y){
    ans++;
    x *= 2;
  }
  print(ans);
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, d;
  long long int cnt = 0;
  cin >> n;
  multiset <long long int> l, r;
  set <long long int> s;
  for (long long int i = 0; i < n; ++i){
	cin >> d;
	l.insert(i + d);
	r.insert(i - d);
	s.insert(i + d);	
  }
  for (auto it = s.begin(); it != s.end(); ++it){
	cnt += l.count(*it) * r.count(*it);	
  } 
  cout << cnt << "\n";
return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

struct Solver {
  vector<int> v;
  set<int> s;
  int n, k;
  bool used[10];

  Solver(int n, int k) : n(n), k(k) { fill(used, used + 10, false); }
  void read(){ inpt(v, n); }
  void solve(int ki=0, int a=0){
    if (ki == k){
      s.insert(a);
      return;
    }
    for (int i = 0; i < n; i++){
      if (used[i]) continue;
      int ai = a;
      for (int x = 1; x <= v[i]; x *= 10) ai *= 10;
      ai += v[i];
      used[i] = true;
      solve(ki + 1, ai);
      used[i] = false;
    }
  }
};

int main()
{
  int n, k;
  while (cin >> n >> k, n){
    Solver s(n, k);
    s.read();
    s.solve();
    cout << s.s.size() << endl;
  }
  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

Measured memory_bytes: 1312
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int d[];
        d=new int[6];
        for(int i=0;i<6;i++){
            d[i]=sc.nextInt();
        }
        Dice D1=new Dice(d[0],d[1],d[2],d[3],d[4],d[5]);
        for(int i=0;i<6;i++){
            d[i]=sc.nextInt();
        }
        Dice D2=new Dice(d[0],d[1],d[2],d[3],d[4],d[5]);
        if(D2.d2==D1.d1 || D2.d5==D1.d1 || D2.d6==D1.d1){
            while(D2.d1!=D1.d1) D2.roll('N');
        }
        else if(D2.d3==D1.d1) D2.roll('W');
        else if(D2.d4==D1.d1) D2.roll('E');
        if(D2.d2!=D1.d2){
            while(D2.d2!=D1.d2) D2.slide();
        }
        if(D1.d3==D2.d3) System.out.println("Yes");
        else System.out.println("No");
    }
}

class Dice{
    int d1,d2,d3,d4,d5,d6,db;
    Dice(int a,int b,int c,int d,int e,int f){
        this.d1=a;
        this.d2=b;
        this.d3=c;
        this.d4=d;
        this.d5=e;
        this.d6=f;
    }
    void roll(char c){
        switch (c){
            case 'N':
                db=d1;
                d1=d2;
                d2=d6;
                d6=d5;
                d5=db;
                break;
            case 'S':
                db=d1;
                d1=d5;
                d5=d6;
                d6=d2;
                d2=db;
                break;
            case 'E':
                db=d1;
                d1=d4;
                d4=d6;
                d6=d3;
                d3=db;
                break;
            case 'W':
                db=d1;
                d1=d3;
                d3=d6;
                d6=d4;
                d4=db;
                break;
        }
    }
    void slide(){
        db=d2;
        d2=d3;
        d3=d5;
        d5=d4;
        d4=db;
    }
}


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

int main(){
  int  a[4] = {};
  int  b[4] = {};
  int  c[4] = {};
  
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	cin >> a[j];
    }
      for(int k=0;k<3;k++){
	cin >> b[k];
      }
      for(int l=0;l<3;l++){
        c[l] =  b[l] - a[l];
      }
      for(int m=2;m>-1;m--){
	if(c[m]<0){c[m] += 60;
	  c[m-1] -= 1;}
      }
      
      cout << c[0] <<" " << c[1] << " " << c[2] << endl;}
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int res = 0;
    int a[200005];
    for (int i = 0; i<n; ++i){
        cin >> a[i];
        res^=a[i];
    }
    for (int i = 0; i<n; ++i){
        cout << (res^a[i]) << " ";
    }
}

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

const int N = 5500;
const int MOD = 1e9 + 7;

vector<int> con[N];
int a[N], vis[N], pw[N];

int dfs(int u) {
	int sz = 1;
	vis[u] = 1;
	for (int v : con[u]) if (!vis[v]) sz += dfs(v);
	return sz;
}

int dp[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, k = 0; cin >> n;
	
	pw[0] = 1;
	for (int i = 1; i <= n; i++) pw[i] = (long long)pw[i - 1] * (n - 1) % MOD; 
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] != -1) con[i].push_back(a[i]), con[a[i]].push_back(i);
		else k++;
	}
	vector<int> V;
	V.push_back(0);
	for (int i = 1; i <= n; i++) if (!vis[i] && a[i] == -1) {
		V.push_back(dfs(i));
	}
	int Vn = V.size() - 1;
	int ans = (long long)n * pw[k] % MOD;
	int xxx = 0;
	for (int i = 1; i <= n; i++) if (!vis[i]) {
		xxx++;
		dfs(i);
	}
	ans -= (long long)xxx * pw[k] % MOD;
	if (ans < 0) ans += MOD;
	dp[0] = 1;
	for (int i = 1; i <= Vn; i++) {
		for (int j = Vn; j >= 1; j--) {
			dp[j] += (long long)dp[j - 1] * max(j - 1, 1) % MOD * V[i] % MOD;
			if (dp[j] >= MOD) dp[j] -= MOD;
		}
	}
	
	for (int i = 1; i <= Vn; i++) {
		int xx = dp[i] - (i == 1) * Vn;
		if (xx < 0) xx += MOD;
		ans -= (long long)xx * pw[Vn - i] % MOD;
		if (ans < 0) ans += MOD;
	}
	
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 4048
#include<stdio.h>
#include<string.h>

int saikoro1(int a[7],char b[101]) {
	unsigned int x,i;
	for (i = 0; i < strlen(b); i++) {
		if (b[i] == 'N') {
			x = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = x;
		}else if (b[i] == 'E') {
			x = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = x;
		}
		else if (b[i] == 'S') {
			x = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = x;
		}
		else if (b[i] == 'W') {
			x = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = x;
		}
	}
	return a[0];
}

int saikoro2(int a[7],int b,int c){
	int i=0, j=0,k=0;
	
	while (a[0] != b || a[1] != c) {
		for (i = 0; i < 4; i++) {
			saikoro1(a, "N");
			if (a[0] == b && a[1] == c) break;
			for (j = 0; j < 4; j++) {
				saikoro1(a, "E");
				if (a[0] == b && a[1] == c) break;
				for (k = 0; k < 4; k++) {
					saikoro1(a, "N");
					if (a[0] == b && a[1] == c) break;
				}
				if (a[0] == b && a[1] == c) break;
			}
			if (a[0] == b && a[1] == c) break;
		}

	}

	return a[2];
}

int saikoro3(int a[7], int b[7]) {
	if (a[2] == b[2] && a[3] == b[3] && a[4] == b[4] && a[5] == b[5]) {
		printf("Yes\n");
	}
	else printf("No\n");

	return 0;
}

struct dice {
	int men[7];
};

int main() {
	int i;
	struct dice d1,d2;

	for (i = 0; i < 6; i++) {
		scanf("%d",&d1.men[i]);
	}
	for (i = 0; i < 6; i++) {
		scanf("%d", &d2.men[i]);
	}
	saikoro2(d1.men, d2.men[0], d2.men[1]);
	saikoro3(d1.men, d2.men);

	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
const int MAX_N = 100;
string S[MAX_N];
int P[MAX_N];

struct Review {
  int id;
  string city;
  int score;
};

bool comp(const Review& lhs, const Review& rhs) {
  if(lhs.city == rhs.city) {
    return lhs.score > rhs.score;
  } else {
    return lhs.city < rhs.city;
  }
}

int main(){
  cin >> N;
  REP(i, N) {
    cin >> S[i] >> P[i];
  }

  vector<Review> vec;
  REP(i, N) vec.pb(Review{i+1, S[i], P[i]});
  std::sort(ALL(vec), comp);

  REP(i, N) {
    cout << vec[i].id << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

    public static void main(String[] args) 
    {
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        
        int[] a= new int[n];
        
        for(int i=0;i<n;i++)
        {
            int x;
            x=sc.nextInt();
            a[i]=x;
        }
        
        int flag=1;
        
        for(int i=0;i<n;i++)
        {
            if(a[i]%2==0 )
            {
                if(a[i]%3==0 || a[i]%5==0)
                {
                    flag=1;

                }
                
                else
                {
                    flag=0;
                    break;
                }
            }
        }
        
        if(flag==0)
        {
            System.out.println("DENIED");
        }
        
        else{
            System.out.println("APPROVED");
        }
    
    }
    
    
    
}



Measured memory_bytes: 22996
import java.io.*;
import java.util.*;
public class Main {
	static final int N=100005;
	static int map[][]=new int[105][105];
	public static void main(String[] args){
		InputReader in = new InputReader(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    int h=in.nextInt(),w=in.nextInt();
	    int n=in.nextInt();int x=0,y=0;
	    for(int i=1;i<=n;i++){
	    	int tmp=in.nextInt();
	        while(tmp>0) {
	        	if(x%2==0) {
	        		map[x][y++]=i;
	        		tmp--;if(y==w) {
	        			y=w-1;x++;
	        		}
	        	}else {
	        		map[x][y--]=i;
	        		tmp--;if(y==-1) {
	        			y=0;x++;
	        		}
	        	}
	        }
	    }
	    for(int i=0;i<h;i++) {
	    	for(int j=0;j<w;j++) {
	    		if(j!=0) out.print(" ");
	    		out.print(map[i][j]);
	    	}
	    	out.println();
	    }
	    out.flush();
	}
	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	int kotae = 0;
	int s = 0;
	int t = 0;
	char mae = 'S';
	rep(i, S.size()) {
		if (S[i] == 'S') {
			if (mae != S[i]) {
				if (t > s) {
					kotae += t - s;
					s = 0;
					t = 0;
				}
				else {
					s -= t;
					t = 0;
				}
			}
			s++;
		}
		else t++;
		mae = S[i];
	}
	if (t > s) {
		kotae += t - s;
	}
	else {
		kotae += s - t;
	}
	co(kotae);

	Would you please return 0;
}

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

using pp = pair<int, int>;
int N, M; 
vector<pp> A;
vector<vector<int>> G;
vector<int> C, cnt, visited;
map<pp, int> edge;

int dfs(int v, int p) {
    visited[v] = 1;
    int tmp = C[v];
    for(int to : G[v]) {
        if(visited[to]) continue;
        tmp += dfs(to, v);
    }
    if(tmp & 1) {
        if(p == -1) return -1;
        else {
            cnt[edge[pp(min(v, p), max(v, p))]] = (cnt[edge[pp(min(v, p), max(v, p))]] + 1) & 1;
        }
    }
    //cout << p << ' ' << v << ' ' << tmp << endl;
    return tmp;
}

int main() {
    cin >> N >> M;
    A.resize(N);
    for(int i=0; i<N; ++i) cin >> A[i].first >> A[i].second;
    sort(begin(A), end(A));

    G.resize(N + 1);
    for(int i=0; i<M; ++i) {
        int l,r; cin >> l >> r; ++r;
        int li = lower_bound(begin(A), end(A), pp(l, 0)) - begin(A);
        int ri = lower_bound(begin(A), end(A), pp(r, 0)) - begin(A);
        if(li == ri) continue;
        edge[pp(li, ri)] = i;
        G[li].push_back(ri);
        G[ri].push_back(li);
    }

    C.resize(N + 1);
    C[0] = A[0].second;
    for(int i=1; i<N; ++i) C[i] = (A[i].second - A[i - 1].second + 2) % 2;
    C[N] = A[N - 1].second;

    cnt.resize(M, 0); visited.resize(N + 1, 0);
    for(int i=0; i<=N; ++i) {
        if(!visited[i] && dfs(i, -1) == -1) {
            cout << -1 << endl;
            return 0;
        }
    }

    int k = count(begin(cnt), end(cnt), 1);
    cout << k << endl;
    for(int i=0; i<M; ++i) {
        if(cnt[i]) {
            cout << i + 1;
            if(--k) cout << ' ';
        }
    }
    cout << endl;
}

Measured memory_bytes: 30848
#include<stdio.h>
int main()
{
    int a,b,d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    
    d = a / b;
    r = a % b;
    f = 1.000000000 * a / b;
    
    printf("%d %d %f\n",d ,r, f);
    
    return 0;
}


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

namespace Program
{
    public class ABC096D
    {
        static public void Main(string[] args)
        {
            Console.WriteLine(string.Join(" ", Prime(1327).Where(e => e % 10 == 7).Take(NextInt)));
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static string NextString => Console_.NextString();

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
    }
}


Measured memory_bytes: 11476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[][][] house = new int[3][10][4];
        String count = br.readLine();
        for(int i = 0 ; i < Integer.parseInt(count) ; i++){
            String info = br.readLine();
            String[] ia = info.split(" ");
            house[Integer.parseInt(ia[1])-1][Integer.parseInt(ia[2])-1][Integer.parseInt(ia[0])-1] += Integer.parseInt(ia[3]);
                                                                      
        }
        for(int i = 0 ; i < house[2][0].length ; i++){
            for(int j = 0 ; j < house.length ; j++){
                for(int k = 0 ; k < house[j].length ; k++){
                    System.out.print(" " + house[j][k][i]);
                }
                System.out.println();
            }
            if(i != house[0][0].length-1) System.out.println("####################");
        }
    }
 
}

Measured memory_bytes: 24604
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int nam = sc.nextInt();
		int har = nam/2;
		String stc = sc.next();
		
		    String ans = "No";
	    	String front = stc.substring(0, har);
	    	String back  = stc.substring(har, nam);
	    	if (front.equals(back)){
		         ans = "Yes";
	    	}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

int main(){
   string s;
   cin>>s;
   int i;
   for(i=0;i<(int)s.size();i++){
      s[i] = s[i]-3;
      if(s[i] < 'A'){
         s[i] ='Z'-('A'-s[i])+1;
      }
   }
   cout<<s<<endl;
   return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int H,W;
vector<vector<char>> mp(60, vector<char>(60));
vector<vector<int>> d(60, vector<int>(60, INF));

void dijkstra(){
    priority_queue<pair<int, Pint>, vector<pair<int, Pint>>, greater<pair<int, Pint>>> pque;
    pque.push({0, {0, 0}});
    d[0][0] = 0;
    while(!pque.empty()){
        int c = pque.top().first;
        int vy = pque.top().second.first;
        int vx = pque.top().second.second;
        pque.pop();
        if(d[vy][vx] < c) continue;
        for(int i = 0; i < 4; i++){
            int nvy = vy + dy[i];
            int nvx = vx + dx[i];
            if(nvy < 0 || H <= nvy)continue;
            if(nvx < 0 || W <= nvx)continue;
            if(mp[nvy][nvx] == '#')continue;
            if(d[nvy][nvx] > c + 1){
                d[nvy][nvx] = c + 1;
                pque.push({c+1, {nvy, nvx}});
            }
        }
    }
}

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cin >> H >> W;
    int cnt = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> mp[i][j];
            if(mp[i][j] == '.')cnt++;
        }
    }
    
    dijkstra();
    if(d[H-1][W-1] == INF){
        cout << -1 << endl;
    }else{
        cout << cnt - d[H-1][W-1] - 1 << endl;
    }
}


Measured memory_bytes: 256
// abc141_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    REP(i, S.size()){
        if ( (i % 2 == 0 && S[i] == 'L') || (i % 2 == 1 && S[i] == 'R')){
            print("No");
            return 0;
        }
    }

    print("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
//#define spec
using namespace std;

inline ll in() {ll n = 0; char ch = getchar(); bool x = 0;
	while (!isdigit(ch)) x |= (ch == '-'), ch = getchar(); while (isdigit(ch))
	n = (n << 3) + (n << 1) + (ch ^ 48), ch = getchar(); return x ? -n : n;
} inline string instr() {string ret = ""; char ch = getchar();
	while (ch == ' ' || ch == '\n') ch = getchar(); while (ch != ' ' && ch != '\n')
	ret += ch, ch = getchar(); return ret;
}

#ifdef spec
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif

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

	string s = instr();
	ll n = in(), len = s.length();
	if (len == 1)
	{
		printf("%lld\n", n / 2);
		return 0;
	}
	ll t = 1, x = 0;
	for (int i = 1; i < len; i++)
	{
		if (s[i] == s[i - 1]) t++;
		else x += (t / 2), t = 1; 
	}
	if (t == len)
	{
		printf("%lld\n", len * n / 2);
		return 0;
	}
	x += (t / 2);
	x *= n;
	int l = 0, r = 0;
	for (int i = 0; i < len; i++)
		if (s[i] == s[len - 1]) l++;
		else break; 
	for (int i = len - 1; i >= 0; i--)
		if (s[i] == s[0]) r++;
		else break; 
	if (l % 2 && r % 2) x += n - 1;
	printf("%lld\n", x);

  return 0;
}



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

int main(){
    long N,nE=0,nW=0;
    string S;

    cin >> N;
    cin >> S;
    for(long i = 0;i<N;i++){
        if(S[i] == 'E'){
            nE++;
        }
        else{
            nW++;
        }
    }

    long Enow = nE;
    long Wnow = 0;
    long ans = 300002;
    for(long i = 0;i<N;i++){
        if(S[i]=='E'){
            Enow--;
            ans = min(ans,Enow+Wnow);
        }
        else{
            ans = min(ans,Enow+Wnow);
            Wnow++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i=0; i<s.length()-1;){
        if(s[i]=='O'){
            if(s[i+1]=='X') {
                ans++;
                i++;
            }
            i++;
            continue;
        }
        if(s[i]=='X'){
            if(s[i+1]=='O') {
                ans++;
                i++;
            }
            i++;
            continue;
        }

    }
    pr(ans);
    return 0;
}


Measured memory_bytes: 3328
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                ans +=1
print(ans)

Measured memory_bytes: 39536
#include <iostream>

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  for (int i=9; i>0; i--) {
    if (n%i == 0 && n/i >= 1 && n/i <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2 == 0){
    cout << (a+b)/2 << endl;
  }
  else
  {
    cout <<  (a+b)/2 + 1 << endl;
  }
  
  
}


Measured memory_bytes: 256