akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll int,ll int>
#define PI 2*acos(0)
#define INF 1e18
#define mx 200005
using namespace std;
//const ll int p=1000000007;
//vector<ll > prime;
//bool mark[mx];
ll int mod(ll int a,ll int b)
{
    ll int m=a%b;
    if(m<0) m=(b<0)?(m-b):(m+b);
    return m;
}
ll maxpow(ll n)
{
    return (n & (~(n-1)));
}
bool isPrime(ll n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
/*void init()
{
    mark[1]=1;
    int i,j,limit=sqrt(mx*1.0)+2;
    prime.push_back(2);
    for(i=4;i<mx;i+=2) mark[i]=1;
    mark[2]=0;
    for(i=3;i<mx;i+=2){
        if(!mark[i]){
            prime.push_back(i);
            if(i<=limit){
                for(j=i*i;j<mx;j+=2*i){
                    mark[j]=1;
                }
            }
        }
    }
}
/*
ll maxdiv(ll n)
{
    ll i,ans=1;
    for(i=0;i<prime.size();i++){
        if(n%prime[i]==0){
            ans=n/prime[i];break;
            //return ans;
        }
    }
    return ans;
}*/
ll lcm(ll a,ll b)
{
    ll ans=a*b;
    return (ans/__gcd(a,b));
}
ll abso(ll a)
{
    if(a>=0) return a;
    return -a;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll H,W,i,j,k;
    ll sx,sy,dx,dy;
    cin>>H>>W;
    cin>>sx>>sy;
    cin>>dx>>dy;
    string grid[H];
    for(i=0;i<H;i++) cin>>grid[i];
    sx--;sy--;
    dx--;dy--;
    bool ok=false;
    deque< pii > q;
    ll dist[H][W];
    for(i=0;i<H;i++){
        for(j=0;j<W;j++) dist[i][j]=INF;
    }
    q.push_back({sx,sy});
    dist[sx][sy]=0;
    while(!q.empty()){
        pii curr=q.front();
        ll row=curr.first;
        ll col=curr.second;
        q.pop_front();
        if(row==dx && col==dy){
            ok=true;
            break;
        }
        for(ll x=-2;x<=2;x++){
            for(ll y=-2;y<=2;y++){
                ll nrow=row+x;
                ll ncol=col+y;
                if(nrow==row && ncol == col ) continue;
                if(nrow<0 || ncol<0 || nrow>=H || ncol>= W) continue;
                if(grid[nrow][ncol]=='#') continue;
                ll w=1;
                if((abso(nrow-row)==1 && abso(ncol-col)==0) || (abso(nrow-row)==0 && abso(ncol-col)==1)) w=0;
                if(dist[nrow][ncol]> dist[row][col]+w ){
                    dist[nrow][ncol]=dist[row][col]+w;
                    if(w==1) q.push_back(pii(nrow,ncol));
                    else q.push_front(pii(nrow,ncol));
                }
            }
        }
    }
    if(!ok) dist[dx][dy]=-1;
    cout<<dist[dx][dy];
    return 0;
}
//1028C


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(void)
{
        int n;
        int m;
        bool to[200010] = {false};
        bool from[200010] = {false};
        int a;
        int b;
        cin >> n >> m;
        REP(i,m){
                cin >> a >> b;
                if(a == 1) to[b] = true;
                if(b == n) from[a] = true;
        }

        for(int i = 1; i <= n; i++){
                if(to[i] && from[i]){
                        cout << "POSSIBLE" << endl;
                        return 0;
                }
        }

        cout << "IMPOSSIBLE" << endl;

        return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#include<bits/stdc++.h> 
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
int main() {
	fast;
	read(a)
	read(b)
	a=a-1;
	b=b-1;cout<<(ceil(float(b)/a))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30

using namespace std;
typedef long long ll;

int w,h,x,y;
int sx,sy,gx,gy;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int ans = 0;
bool f[25][25];

bool can(int y,int x) {
    if(0 <= y && y < h && 0 <= x && x < w) return true;
    return false;
}

void dfs(int y, int x, int cnt) {
	if(cnt >= 10) return;

	rep(i, 4) {
		int ny = y;
		int nx = x;
		bool flag = false;

		while(can(ny + dy[i], nx + dx[i]) && f[ny + dy[i]][nx + dx[i]]) {
			ny += dy[i];
			nx += dx[i];

			if(ny == gy && nx == gx) {
				flag = true;
				break;
			}
		}

		if(flag) {
			ans = min(ans, cnt + 1);
			return;
		}

		if(ny == y && nx == x) continue;
		if(!can(ny + dy[i], nx + dx[i])) continue;


		f[ny + dy[i]][nx + dx[i]] = true;
		dfs(ny, nx, cnt + 1);
		f[ny + dy[i]][nx + dx[i]] = false;
	}
}

int main() {

    while(cin >> w >> h) {
        if(w == 0 && h == 0) break;

		memset(f, 0, sizeof(f));
		ans = INF;

        rep(i, h) {
            rep(j, w) {
                int x;
                cin >> x;

				if(x == 0)  f[i][j] = true;
                if(x == 2) {
                    sy = i;
                    sx = j;
					f[i][j] = true;
                }
                if(x == 3) {
                    gy = i;
                    gx = j;
					f[i][j] = true;
                }
            }
        }

		dfs(sy, sx, 0);

		if(ans == INF) cout << -1 << endl;
		else cout << ans << endl;
    }
    return 0;
}

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

int main(){
	char o[51],e[51];
  	cin>>o>>e;
  	for(int i=1;i<(strlen(o)+strlen(e));i++)
      	if(i&1)
          cout<<o[i/2];
  		else cout<<e[i/2-1];
  	
  	if(strlen(e)==strlen(o)) cout<<e[strlen(e)-1];
  	else cout<<o[strlen(o)-1];
    cout<<'\n';
}

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

void printVec(vector<int> vec) {
  for (size_t i = 0; i < vec.size(); i++) {
    if (i == vec.size() - 1) {
      cout << vec[i] << endl;
    } else {
      cout << vec[i] << " ";
    }
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (size_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  printVec(A);

  for (size_t i = 1; i < N; i++) {
    for (size_t j = i; 0 < j; j--) {
      if (A[j - 1] > A[j]) {
        auto tmp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = tmp;
      } else {
        break;
      }
    }
    printVec(A);
  }
}


Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define MAXN 1000010
#define inf 1e18

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
	while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
	return f ? -s : s;
}

int x;

signed main() {
    x = read();
    for (rr int i = -1000; i <= 1000;i++)
        for (rr int j = -1000; j <= 1000; j++)
            if (i * i * i * i * i - j * j * j * j * j == x) {
                cout << i << " " << j << "\n";
                return 0;
            }
}
// int n, ans;

// int a[MAXN];

// signed main() {
//     n = read();
//     for (rr int i = 1; i <= n; i++) {
//         a[i] = read();
//         for (rr int j = 1; j < i; j++)
//             if ((i - j) == (a[i] + a[j]))
//                 ans++;
//     }
//     cout << ans;
// }

Measured memory_bytes: 3564
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#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 pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int _;

int main() {
	INIT
	int n;
	cin >> n;
	VI A(n);
	unordered_map<int, ll> B;
	vector<bool> C(n + 1);
	ll sum = 0;
	rep (i, 0, n) {
		cin >> A[i];
		B[A[i]]++;
		if (B[A[i]] >= 2) {
			C[A[i]] = true;
		}
	}
	rep (i, 1, n + 1) {
		if (C[i]) {
			sum += 1ll * (B[i] * (B[i] - 1)) / 2;
		}
	}
	rep (i, 1, n + 1) {
		int t = A[i - 1];
		
		if (!C[t]) {
			cout << sum << '\n';
		} else {
			ll d = B[t] - 1;
			ll ans = sum - d;
			cout << ans << '\n';
		}
	}
	
	

	return 0;
}
/*
rep (i, 0, n) {
		if (i) cout << ' ';
		cout << A[i];
	}
*/

Measured memory_bytes: 8392
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		List<Restaurant> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			String city = sc.next();
			int score = Integer.parseInt(sc.next());
			list.add(new Restaurant(city, score, i + 1));
		}
		Collections.sort(list);
		list.stream().forEach(System.out::println);
	}
}

class Restaurant implements Comparable<Restaurant> {
	String city;
	int score;
	int index;

	public Restaurant(String city, int score, int index) {
		this.city = city;
		this.score = score;
		this.index = index;
	}

	@Override
	public String toString() {
		return Integer.toString(index);
	}

	@Override
	public int compareTo(Restaurant o) {

		int i = this.city.compareTo(o.city);
		if (i == 0)
			i = o.score - this.score;
		return i;
	}

}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 1000005;

/* ...o(^-^)o... */

int dp[MAX][72];

int main(){
    int n; lint k; cin>>n>>k; 
    vector<int> a(n);
    rep(i, n){
        cin>>a[i]; a[i]--;
    }
    
    vector<int> p; int m = 0;
    while(k){
        if(k%2) p.push_back(m);
        k /= 2;
        m++;
    }

    rep(j, m+1) rep(i, n){
        if(j==0) dp[i][j] = a[i];
        else dp[i][j] = dp[dp[i][j-1]][j-1];
    }

    int v = 0;
    rep(i, p.size()) v = dp[v][p[i]];
    out(v+1);
}

Measured memory_bytes: 60256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main = do
    (n:x:_)<-map read.words<$>getLine::IO[Int]
    xs<-sort.(x:).unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
    print $ gcds $ dff [] xs
--
dff ac [_] = ac
dff ac (x:y:r) = dff ((y-x):ac) (y:r)
--
gcds [x] = x
gcds (a:ys) = gcd a $ gcds ys

Measured memory_bytes: 22908
#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>;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int ans = 0;
  rep(i,n){
  	if(a[i]%2 == 0){
      if((a[i]%3)*(a[i]%5) != 0){
  		++ans;
  	  }
    }  
  }
   if(ans){
   	cout << "DENIED" << endl;
   }else{
   	cout << "APPROVED" << endl;
   }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int groups[100002];

int main(void) {
	int n, k;
	scanf("%d%d ", &n, &k);

	int gind = groups[0] = 0;
	for (int i = 0; i < n; i++) {
		int c = getchar() == '1';
		if (c == gind%2) groups[gind]++;
		else groups[++gind] = 1;
	}
	if (gind%2) groups[++gind] = 0;

	int max = 0;
	for (int i = 0; i <= gind; i++) {
		if (max < groups[i]) max = groups[i];
	}

	int sum = 0;
	for (int i = 0; i <= gind; i++) {
		if (i > 2*k) sum -= groups[i-2*k-1];
		sum += groups[i];
		if (i%2 != gind%2 && max < sum) max = sum;
	}
	sum = 0;
	for (int i = 0; i <= gind; i++) {
		if (i > 2*k) sum -= groups[gind-(i-2*k-1)];
		sum += groups[gind-i];
		if (i%2 != gind%2 && max < sum) max = sum;
	}

	printf("%d\n", max);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(unsigned long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX = 510000;


int main() {
  int n, m;
  cin >> n >> m;
  
  if(n==m)cout <<"Yes"<< endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y,n1,n2,n3;
    cin>>x>>y>>n1>>n2>>n3;
    int a[n1],b[n2],c[n3];
    vector<pair<int,int>>v;
    for(int i=0;i<n1;i++){
        cin>>a[i];
        v.push_back({a[i],2});
    }
    for(int i=0;i<n2;i++){
        cin>>b[i];
        v.push_back({b[i],3});
    }
    for(int i=0;i<n3;i++){
        cin>>c[i];
        v.push_back({c[i],1});
    }
    sort(v.rbegin(),v.rend());
    int cnt = 0;
    int l,r;
    int ans = 0;
    l = r = 0;
    for(int i=0;i<v.size();i++){
        if(v[i].second == 1){
            if(l == x and r == y){
                continue;
            }
            cnt++;
            
        }
        if(v[i].second == 2){
            if(l == x){
                continue;
            }
            l++;
        }
        if(v[i].second == 3){
            if(r == y){
                continue;
            }
            r++;
        }
        // cerr<<v[i].first<<endl;
        ans += v[i].first;
        if(cnt + l + r == x + y){
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
    
}



Measured memory_bytes: 12780
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

struct UnionFind {  // UnionFind uni(N);
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化、頂点数N
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry] += siz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main() {
    LL N,M;cin >> N >> M;
    vector<LL> A(M);
    vector<LL> B(M);
    rep(i,M){
        int a,b;cin >> a >> b;
        a--;b--;
        A[i] = a;
        B[i] = b;
    }

    UnionFind uni(N);
    rep(i,M){
        uni.unite(A[i],B[i]);
    }

    int ans = 0;
    rep(i,N){
        ans = max(ans,uni.size(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 13852
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int m = Integer.parseInt(sc.next());
            int f = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());

            if (m == -1 && f == -1 && r == -1) break;

            if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65 && m + f < 80) {
                System.out.println("B");
            } else if (m + f >= 50 && m + f < 65) {
                System.out.println("C");
            } else if (m + f >= 30 && m + f < 50) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else if (m + f < 30) {
                System.out.println("F");
            }
        }
    }
}

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

using namespace std;

char a[10];
int ff;

int main(void)
{
	scanf("%s", a);
	
	if(a[0] == a[1] && a[1] == a[2])
		ff = 1;
	
	if(ff == 1)
		printf("No");
	else
		printf("Yes");
	
	return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n;
int aa[1234][1234];
int co[1234];
string ans;

main(){
	cin>>n;
	rep(i,n){
		string t;
		cin>>t;
		rep(j,t.size()){
			aa[i][t[j]]++;
		}
	}
	rep(i,n){
		for(int j='a';j<='z';j++){
			cerr<<aa[i][j];
		}
		cerr<<endl;
	}
	for(int i='a';i<='z';i++){
		int res=INT_MAX;
		rep(j,n){
			cerr<<aa[j][i];
			chmin(res,aa[j][i]);
		}
		cerr<<endl;
		co[i]=res;
	}
	for(int i='a';i<='z';i++){
		rep(j,co[i]){
			ans+=(char)i;
		}
	}
	dans;
}

Measured memory_bytes: 512
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
 
        int pura=0;
        for(int i=0; i<4; i++){               
            if(ss[i]=='+'){
             pura++;
}
}
             System.out.print(pura-(4-pura)); 	        
 	    }
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a+b == c) || (b+c == a) || (c+a == b)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
ll A, B, C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
bool check(int num) {
	int c = 0;
	int t[5];
	while (num > 0)
	{
		t[c++] = num % 10;
		num /= 10;
	}
	for (size_t i = 0; i < (c / 2); i++)
	{
		if (t[i] != t[c - 1 - i]) {
			return false;
		}
	}
	return true;
}
void PalindromicNumbers() {
	cin >> A >> B;
	int count = 0;
	for (size_t i = A; i <= B; i++)
	{
		if (check(i)) count++;
	}

	cout << count << endl;
}
int main() {
	PalindromicNumbers();
	return 0;
}

Measured memory_bytes: 256
<?php
	for($i = 0; $i < 1000000; $i++) {
		$isPrime[$i] = true;
	}
	$isPrime[0] = $isPrime[1] = false;

	for($i = 2; $i < 1000000; $i++) {
		if(!$isPrime[$i]) continue;
		for($j = 2 * $i; $j < 1000000; $j += $i) {
			$isPrime[$j] = false;
		}
	}

	$num[0] = 0;
	for($i = 1; $i < 1000000; $i++) {
		$num[$i] = $num[$i - 1];
		if($isPrime[$i]) $num[$i]++;
	}

	while(fscanf(STDIN, "%d", $n)) {
		print $num[$n] . "\n";
	}
?>

Measured memory_bytes: 245476
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

# [0] is Dummy
V_even = Counter(V[::2]+[0])
V_odd = Counter(V[1::2]+[0])

ans = 0

if len(set(V)) == 1:
  ans = n//2
elif V_odd.most_common()[0][0]==V_even.most_common()[0][0]:
  ans += min((n//2)-V_odd.most_common(2)[1][1]+(n//2)-V_even.most_common(2)[0][1],
             (n//2)-V_odd.most_common(2)[0][1]+(n//2)-V_even.most_common(2)[1][1])
else:
  ans += (n//2)-V_odd.most_common()[0][1]+(n//2)-V_even.most_common()[0][1]

print(ans)

Measured memory_bytes: 22364
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>

bool sort_pair( std::pair< int, int > origin, std::pair< int, int > another )
{
    return origin.first < another.first;
}

int main()
{
    int a;
    int64_t c = 0;
    std::cin>> a;
    /*
    std::vector< int > b(a);

    for( int i = 0; i < a; i++ )
    {
        b[i] = i + 1;
    }
    */

    for( int i = 1; i < a; i++ )
    {
        c += i;
        //std::cout<< c <<"\n";
    }

    std::cout<< c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	string s;
	cin >> s;
	char a = 'A', z = 'Z';
	int fst = 0, lst = 0;
	for(int i = 0; i < s.size(); i++)
		if(s[i] == a) {
			fst = i;
			break;
		}
	for(int i = s.size() - 1; i > 0; i--)
		if(s[i] == z) {
			lst = i;
			break;
		}
	cout << lst - fst + 1 << endl;
  	return 0;
}



Measured memory_bytes: 3700
import sys
def reviewRe():
    #print ' '.join(map(str,map(str,residence[i][j])))
    for area in range(4):
        for floor in range(3):
            sys.stdout.write(' ')
            print ' '.join(map(str,residence[area][floor][:]))
        if area <= 2:
            print "####################"

def move_in():
    n=input()
    for i in range(n):
        b,f,r,v = map(int,raw_input().split())
        adding(b,f,r,v)

def adding(b,f,r,v):
    residence[b-1][f-1][r-1] += v


if __name__ == '__main__':
    residence = [[[0 for room in range(10)] for floor in range(3)] for area in range(4)]
    move_in()
    reviewRe()

Measured memory_bytes: 6392
MOD = 10 ** 9 + 7

# MODを法とした階乗、組み合わせ
class ModCombination
  attr_reader :fac, :inv, :finv, :mod
 
  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]
 
    (2..n).each do |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
    end
  end
 
  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0
 
    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end
  
  def repeated_combination(n, k)
    combination(n + k - 1, k)
  end
end

# MODを法としたxのy乗を求める（繰り返し二乗法）
def modPow(x,y)
  ans = 1
  while y > 0
    ans = ans * x % MOD if y & 1 == 1
    y /= 2
    x = x * x % MOD
  end
  return ans
end

MC = ModCombination.new(300000)

# MODを法としたnCk、kが小さいとき
def nCk(n,k)
  ans = n
  2.upto(k) do |i|
    ans = ans * (n - i + 1) % MOD
    ans = ans * MC.inv[i] % MOD
  end
  ans
end

n,a,b = gets.split.map &:to_i
x = modPow(2,n)
y = MOD - nCk(n,a)
z = MOD - nCk(n,b)
puts (x + y + z - 1) % MOD


Measured memory_bytes: 9112
#include <stdio.h>

int par(int *,int,int);
int A[2000000];

int main()
{
  int i,n,a;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  a=par(A,0,n-1);

  printf("%d",A[0]);
  for(i=1;i<a;i++){
    printf(" %d",A[i]);
  }
  printf(" [%d]",A[a]);
  for(i=a+1;i<n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
  
}

int par(int *A,int p,int r){
  int x,i,j,a;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  a=A[i+1];
  A[i+1]=A[r];
  A[r]=a;
  return i+1;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
string ans;

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double A,B,H,M;
	cin >> A >> B >> H >> M;
	double pi = 3.14159265359;
	double D = (double)cos(pi * M / 30.0 - pi * H / 6.0- M*pi/360.0);

	
	double C = double(A*A+ B *B - 2*A*B * D);
	printf("%.10f\n", sqrt(C));
	
	return 0;
}

Measured memory_bytes: 7376
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_map>
using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
count = 0
ans = 0

for i in range(n):
    d1,d2 = list(map(int,input().split()))
    if d1 == d2:
        count += 1
    else:
        count = 0
    if ans < count:
        ans = count

if ans >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62364
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n,a[N];
ll ans,b[N];

int main(){
	n=read()+1;
	For(i,1,n) a[i]=read();
	Dow(i,n,1) b[i]=b[i+1]+a[i];
	ll now=1;
	For(i,1,n){
		if (a[i]>now) return puts("-1"),0;
		ans+=now,now-=a[i],now=max(min(now*2,b[i+1]),now);
	}
	if (now) return puts("-1"),0;
	printf("%lld\n",ans);
}

Measured memory_bytes: 4880
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

const double pi = acos(-1.0);

#define filename ""

int n;
int m;

int main () {
//  freopen (filename".in", "r", stdin);
//  freopen (filename".out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    vvi v(n, vi());
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y; x--; y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    vi q, ans(n, -1);
    ans[0] = 1;
    q.pb(0);
    int cnt = 0;
    for (int l = 0; l < sz(q); l++) {
        int x = q[l];
        for (auto y : v[x]) {
            if (ans[y] == -1) {
                ans[y] = x;
                cnt++;
                q.pb(y);
            }
        }
    }
    if (cnt + 1 == n) {
        cout << "Yes" << endl;
        for (int i = 1; i < n; i++) cout << ans[i] + 1 << "\n";
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 10596
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


int main()
{
	int n;
	cin >> n;
	vector<int> x, y;
	for(int i = 0; i < n; i++){
		if(i % 6 == 1){
			for(int j = 0; j < n; j += 2){
				x.push_back(i);
				y.push_back(j);
			}
		} else if(i % 6 == 4){
			for(int j = 1; j < n; j += 2){
				x.push_back(i);
				y.push_back(j);
			}
		} else if(i % 6 == 3 || i % 6 == 5){
			x.push_back(i);
			y.push_back(0);
		}
	}
	if((n - 1) % 6 == 0){
		for(int j = 1; j < n; j += 2){
			x.push_back(n - 1);
			y.push_back(j);
		}
	} else if((n - 1) % 6 == 3){
		for(int j = 2; j < n; j += 2){
			x.push_back(n - 1);
			y.push_back(j);
		}
	}
	cout << x.size() << endl;
	for(int i = 0; i < x.size(); i++){
		cout << x[i] << " " << y[i] << endl;
	}
	return 0;
}

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

int main(){
int N,Q;
string S;
  cin >>N>>Q;
  cin >>S;

  int Num=0;

  vector<int> num(N);
  num.at(0)=0;
  
  for(int i=1;i<N;i++){
    if(S.at(i)=='C'){
      if(S.at(i-1)=='A'){Num++;}
    }
    num.at(i)=Num;
  
  }
  int r,l;
  for(int i=0;i<Q;i++){cin >>l>>r;
                      
           cout <<num.at(r-1)-num.at(l-1)<<endl;          
                      }
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  while (true) {
    string n = to_string(N);
    if (n[0] == n[1] && n[0] == n[2]) {
      cout << n << endl;
      return 0;
    }

    N++;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}

		int ans = 0;
		int active = 0;
		for (int i = 0; i < N; i++) {
			if (active >= h[i]) {
				active = h[i];
			} else {
				ans += h[i] - active;
				active = h[i];
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
s = input()
n = len(s)
mod = 998244353

R = [0] * n
B = [0] * n
for i in range(n):
    if s[i] == '0':
        R[i] = 2
    elif s[i] == '1':
        R[i] = 1
        B[i] = 1
    else:
        B[i] = 2

for i in range(n-1):
    R[i+1] += R[i]
    B[i+1] += B[i]


dp = [[0] * (2*n+10) for _ in range(2*n+10)]

if R[0] > 0:
    dp[0][1] = 1
if B[0] > 0:
    dp[0][0] = 1

for i in range(n-1):
    for r in range(2*n+1):
        if R[i+1] >= r+1:
            dp[i+1][r+1] += dp[i][r]
            dp[i+1][r+1] %= mod
        if i+2-r < 0:
            break
        if B[i+1] >= i+2-r:
            dp[i+1][r] += dp[i][r]
            dp[i+1][r] %= mod

for i in range(n-1, 2*n-1):
    for r in range(2*n+1):
        if R[n-1] >= r+1:
            dp[i + 1][r + 1] += dp[i][r]
            dp[i + 1][r + 1] %= mod
        if i+2-r < 0:
            break
        if B[n-1] >= i+2-r:
            dp[i+1][r] += dp[i][r]
            dp[i+1][r] %= mod

ans = 0
for r in range(2*n+1):
    ans += dp[2*n-1][r]
    ans %= mod

print(ans)

Measured memory_bytes: 167260
import math

while True:
    b = int(input())
    if b == 0:
        break
    k_max = int(((-1 + math.sqrt(1 + 8 * b)) / 2))
    for k in range(k_max, 0, -1):
        if 2 * b % k == 0 and (2 * b / k + 1 - k) % 2 == 0:
            n = int((2 * b / k + 1 - k) / 2)
            print("{} {}".format(n, k))
            break


Measured memory_bytes: 5664
// Author:- Yatin Patel
// Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN                                                                 \
  ifstream fin;                                                                \
  fin.open("input.txt");
#define FILEOUT                                                                \
  ofstream fout;                                                               \
  fout.open("output.txt");

using namespace std;

#define error(args...)                                                         \
  {                                                                            \
    string _s = #args;                                                         \
    replace(_s.begin(), _s.end(), ',', ' ');                                   \
    stringstream _ss(_s);                                                      \
    istream_iterator<string> _it(_ss);                                         \
    err(_it, args);                                                            \
  }
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

#define FAST                                                                   \
  ios::sync_with_stdio(false);                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x, d) cout << fixed << setprecision(d) << x
#define minQueue priority_queue<ll, vector<ll>, greater<ll>>
#define maxQueue priority_queue<ll, vector<ll>, less<ll>>

#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define RFOR(i, a, b) for (ll i = a; i > b; i--)
#define FILL(a, b) memset((a), (b), sizeof((a)))

#define MOD 1000000007
#define INF INT_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}

//#define fin cin
//#define fout cout

int main() {

  FAST;
  ll n, W;
  cin >> n >> W;

  vector<ll> v(n);
  vector<ll> w(n);
  for (ll i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  ll dp[100006];
  for (ll j = 100005; j >= 0; j--) {
    dp[j] = INF;
  }
  dp[0] = 0;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 100005; j >= 0; j--) {
      if (j + v[i - 1] <= 100005)
        dp[j + v[i - 1]] = min(dp[j + v[i - 1]], dp[j] + w[i - 1]);
    }
  }
  for (ll j = 100005; j >= 0; j--) {
     //cout<<dp[j]<<" ";
    if (dp[j] <= W) {
      cout << j;
      return 0;
    }
  }
  cout << 0;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#define int long long

const int MOD = (int)1e9 + 7;
char str[100010];
int ans = 1, len;

int qpow(int x, int k) {
    int ret = 1;
    while(k) {
        if(k & 1) ret *= x, ret %= MOD;
        x *= x, k >>= 1, x %= MOD;
    }
    return ret % MOD;
}

signed main() {
    scanf("%s", str + 1);
    len = strlen(str + 1);
    for(int i = len; i; --i)
        if(str[i] == '1')
            ans <<= 1, ans += qpow(3, len - i), ans %= MOD;
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
  int m = X.size(), n = Y.size();
  vector<vector<int>> C(N + 1, vector<int>(N + 1, 0));
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 1; i < m; i++)
    C[i][0] = 0;
  for (int j = 1; j < n; j++)
    C[0][j] = 0;

  int maxl = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        C[i][j] = C[i - 1][j - 1] + 1;
      } else {
        C[i][j] = max(C[i - 1][j], C[i][j - 1]);
      }
      maxl = max(maxl, C[i][j]);
    }
  }
  return maxl;
}

int main(void) {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string x, y; cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
}



Measured memory_bytes: 6856
using System;
public class Solution{
public static void Main(){
  		string line = Console.ReadLine();
  		string[] input = line.Split(' ');
  		int A = Convert.ToInt32(input[0]);
  		int B = Convert.ToInt32(input[1]);
  		int T = Convert.ToInt32(input[2]);
  		
  		Console.WriteLine((T/A) * B);
}
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    int n;
    int path[101][101] = {0};
    bool noway[101][101] = {0};

    cin >> a >> b >> n;

    while (a != 0) {
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        noway[y-1][x-1] = true;
    }

    for (int i = 0; i < b; i++) {
        path[i][0] = 1;
    }
    for (int i = 0; i < a; i++) {
        path[0][i] = 1;
    }

    for (int i = 0; i < b; i++) {
        for (int j = 0; j < a; j++) {
            if (noway[i][j]) {
                if (j == 0) {
                    for (int k = i; k < b; k++) {
                        path[k][0] = 0;
                    }
                }
                if (i == 0) {
                    for (int k = j; k < a; k++) {
                        path[0][k] = 0;
                    }
                }
                else {
                    path[i][j] = 0;
                }
            }
            else if (i != 0 && j != 0) {
                path[i][j] = path[i-1][j] + path[i][j-1];
            }
        }
    }
    cout << path[b-1][a-1] << endl;
    cin >> a >> b >> n;

    for (int i = 0; i < 101; i++) {
        for (int j = 0; j < 101; j++) {
            path[i][j] = 0;
            noway[i][j] = 0;
        }
    }
    }
}



Measured memory_bytes: 3108
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long x = sc.nextLong();
		
		// 計算
	    long result = dfs(n, x);

		// 出力
		System.out.println(result);
        
	}
	
	public static long pow(long a,long n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a);
	        }
	        a=(a*a);
	        n>>=1;
	    }
	    return res;
	}
	
	public static long len(int n) {
	    return pow(2, n+2) - 3;
	}
	
	public static long p(int n) {
	    return pow(2, n+1) - 1;
	}
	
	public static long dfs(int n, long x) {
	    if(x == 0) return 0;
	    if(n == 0) return 1;
	    long len = len(n-1);
	    if(x <= 1 + len){
	        return dfs(n-1, x-1);
	    }else{
	        return p(n-1) + 1 + dfs(n-1, x-2-len);
	    }
	}
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] box = new int[100];
            int N = int.Parse(Console.ReadLine());
            ;
            for (int c = 2; c <= N; c++)
            {
                if (isPrime(c))
                {
                    box[c]++;
                    continue;
                }
                else
                {
                    int bigone = c;
                    while (isPrime(bigone) == false)
                    {

                        int div = candivideby(bigone);
                        box[div]++;
                        bigone = bigone / div;
                    }
                    box[bigone]++;
                }

            }
            ;
            int output = 0;
            //75候補
            List<int> upto74 = new List<int>();
            List<int> upto24 = new List<int>();
            List<int> upto14 = new List<int>();
            List<int> upto4 = new List<int>();
            List<int> upto2 = new List<int>();

            for (int i = 0; i < 51; i++)
            {
                if (box[i] >= 74) upto74.Add(i);
                if (box[i] >= 24) upto24.Add(i);
                if (box[i] >= 14) upto14.Add(i);
                if (box[i] >= 4) upto4.Add(i);
                if (box[i] >= 2) upto2.Add(i);
            }
            ;
            output = upto74.Count;
            for (int i = 0; i < upto24.Count; i++)
            {
                int choice = upto24[i];
                for (int j = 0; j < upto2.Count; j++)
                {
                    if (choice != upto2[j]) output++;
                }
            }

            for (int i = 0; i < upto14.Count; i++)
            {
                int choice = upto14[i];
                for (int j = 0; j < upto4.Count; j++)
                {
                    if (choice != upto4[j]) output++;
                }
            }

            for (int i = 0; i < upto2.Count; i++)
            {
                int choice = upto2[i];
                int combination = upto4.Count;
                if (upto4.Contains(choice))
                {
                    combination--;
                }
                output += (combination) * (combination - 1) / 2;
            }

            ;
            Console.WriteLine(output);
        }
        static int candivideby(int n)
        {
            int[] primes = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
            for (int i = 0; i < primes.Length; i++)
            {
                if (n % primes[i] == 0) return primes[i];
            }
            return 1;
        }

        static bool isPrime(int n)
        {
            int[] primes = new int[] {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
            if (primes.Contains(n)) return true;
            else return false;

        }

    }
}


Measured memory_bytes: 13152
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,Q=MAP()
S=input()

sm=[0]*(N+1)
for i in range(1, N):
    if S[i-1]=='A' and S[i]=='C':
        sm[i+1]=sm[i]+1
    else:
        sm[i+1]=sm[i]

for i in range(Q):
    l,r=MAP()
    print(sm[r]-sm[l])


Measured memory_bytes: 6356
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    var sum = 0
    for (i in 0..n-1) {
        val h = scanner.nextInt()
        if (h >= k) sum+=1
    }
    println(sum)
}


Measured memory_bytes: 52428
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}
ll pow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll n;
ll dp[1234567];
ll sum[1234567];

int main(){
  cin>>n;
  
  dp[n]=n;
  sum[n]=n;
  for(ll i=n-1;i>=1;i--){
    dp[i]=sum[i]=0;
    
    dp[i]=add(dp[i], mul(n-1,n-1) );

    //    cout<<' '<<i<<' '<<dp[i]<<' ';
    //    cout<<sum[i+1];
    //    cout<<endl;
    dp[i]=add(dp[i],sum[i+1]);
    
    ll cnt=n-i;
    dp[i]=add(dp[i],n-cnt);
    if(cnt>=2) dp[i]=add(dp[i],1);
    
    if(i+2<=n){
      dp[i]=add(dp[i], mod - dp[i+2]);
    }
    
    sum[i]=add(sum[i+1],dp[i]);

    
  }
  cout<<dp[1]<<endl;
  return 0;
}


Measured memory_bytes: 18688
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int T,D,L;

int main() {
    cin>>T>>D>>L;
	while(T!=0){
		long long int res=0,inp,water=0;
		for(int i=1;i<=T;i++){
			
			if(water>0){res++;water--;}
			cin>>inp;
			if(inp>=L){water=D;}
		}	
		cout<<res<<endl;
		cin>>T>>D>>L;
	}
} 



Measured memory_bytes: 3104
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

const double PI = 3.1415926535;

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

	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double H_angle = 360.0 / 12.0 * H + 0.5 * M;
	double M_angle = 360.0 / 60.0 * M;
	double diffAngle = abs(H_angle - M_angle);
	diffAngle = min(diffAngle, 360.0 - diffAngle);

	double left = (A * A) + (B * B);
	double right = 2 * A * B * cos(diffAngle * PI / 180.0);

	double square_a = left - right;

	cout.setf(ios::fixed);
	cout.precision(11);
	cout << sqrt(square_a);

	return 0;
}

Measured memory_bytes: 4204