akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
 /////////////////////////////////////////////////////
int main(){
	long long a,b;
	scanf("%lld %lld",&a,&b);
	long long x;
	scanf("%lld",&x);
	
	long long p,q;
	if (a==0){
		q = 0;
	}else{
		q = 1 + ((a-1)/x);
	}
	
	p = 1 + (b/x);
	
	printf("%lld",(p-q));
}



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


def main():
    H, W, D = map(int, input().split())
    A = []
    d = [0]*(H*W)
    for h in range(H):
        a = list(map(int, input().split()))
        A.append(a)
        for i, x in enumerate(a):
            d[x-1] = h*W + i
    mp = [0]*(H*W)
    for i in range(H*W):
        if i >= D:
            mp[i] = mp[i-D] + abs(d[i]//W - d[i-D]//W) + abs(d[i]%W - d[i-D]%W)
    Q = int(input())
    for q in range(Q):
        ans = 0
        l, r = map(int, input().split())
        print(mp[r-1] - mp[l-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 14904
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, t; cin >> n >> t;
  vi arr(n);
  rep(i,n) cin >> arr[i];
  int ans = 0;
  int stop = 0;
  rep(i,n) {
    ans += t - max(0, stop-arr[i]);
    stop = arr[i] + t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

int main(void){
	int n;
	cin>>n;
	ll ans = 0;
	ans += min(9, n);
	if(n < 100){
		cout<<ans<<endl;
		return 0;
	}
	ans += min(999, n) - 99;
	if(n < 10000){
		cout<<ans<<endl;
		return 0;
	}
	ans += min(99999, n) - 9999;
	cout<<ans<<endl;
	return 0;
}


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

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

int n, a[114514], ans = 1;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int b = 1;
	REP(i, n) {
		if (!b&&a[i - 1] > a[i]) {
			ans++;
			i++;
			b = 1;
		}
		if (b == 2 && a[i - 1] < a[i]) {
			ans++;
			i++;
			b = 1;
		}
		if (a[i - 1] < a[i])b = 0;
		if (a[i - 1] > a[i])b = 2;
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 1024
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String abc = "abcdefghijklmnopqrstuvwxyz";
		Map<String, Integer> map = new LinkedHashMap<String, Integer>();
		int i;
		for (i = 0; i < abc.length(); i++) {
			map.put(abc.substring(i, i + 1), 0);
		}
		while (in.hasNext()) {
			String input = in.next();
			for (i = 0; i < input.length(); i++) {
				String c = input.substring(i, i + 1).toLowerCase();
				if (map.containsKey(c)) {
					map.put(c, map.get(c) + 1);
				}
			}
		}
		for (Map.Entry<String, Integer> e : map.entrySet()) {
			System.out.println(e.getKey() + " : " + e.getValue());
		}
	}
}

Measured memory_bytes: 20336
from scipy.sparse.csgraph import floyd_warshall 

n,m = map(int, input().split())
s = [[float('inf')]*n for i in range(n)]
d = [list(map(int, input().split())) for i in range(m)]
ans = 0

for a,b,c in d:
    s[a-1][b-1] = c
    s[b-1][a-1] = c

cost = floyd_warshall(s)

for a,b,c in d:
    #print(cost[a-1][b-1], c)
    if cost[a-1][b-1] != c:
        ans += 1
        
print(ans)

Measured memory_bytes: 26896
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     string s;
     ld r;
     cin>>r;
     cout<<fixed<<setprecision(16)<<2*PI*r;
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3852
#include<iostream>
#include<vector>
#define rep(i, s, n) for (int i=(s);i<(n);i++)
using namespace std;

int main() {
  int n; cin>>n;
  vector<int> c1(n),c2(n);
  vector<char> a1(n),a2(n);
  rep(i, 0, n) {
    cin>>a1[i]>>c1[i];
    a2[i]=a1[i];
    c2[i]=c1[i];
  }
  
  //bubbleSort
  bool frag=true;
  for (int i=0;frag;i++) {
    frag=false;
    for (int j=n-1; j>i; j--) {
      if (c1[j]<c1[j-1]) {
        swap(a1[j], a1[j-1]);
        swap(c1[j], c1[j-1]);
        frag=true;
      }
    }
  }

  //selectionSort
  rep(i, 0, n) {
    int minj=i;
    rep(j, i, n) {
      if (c2[j]<c2[minj]) minj=j;
    }
    swap(a2[i], a2[minj]);
    swap(c2[i], c2[minj]);
  }
  
  bool ans=true;
  rep(i, 0, n) {
    if (a1[i]!=a2[i]) ans=false;
  }
  
  rep(i, 0, n-1) cout<<a1[i]<<c1[i]<<" ";
  cout<<a1[n-1]<<c1[n-1]<<endl;
  cout<<"Stable"<<endl;
  
  rep(i, 0, n-1) cout<<a2[i]<<c2[i]<<" ";
  cout<<a2[n-1]<<c2[n-1]<<endl;
  if (ans) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
  
  return 0;
}


Measured memory_bytes: 3092
# すめけくんは
# 現在のレートが 1200未満ならば AtCoder Beginner Contest (ABC) に、
# そうでなければ AtCoder Regular Contest (ARC) に参加することにしました。
# すめけくんの現在のレート xが与えられます。
# すめけくんが参加するコンテストが ABC ならば ABC と、そうでなければ ARC と出力してください。

# 制約
# 1 ≦ x ≦ 3,000
# x は整数

# 標準入力から x を取得する
x = int(input())

# レートを判定して結果を出力する
result = "ret"

if x < 1200:
    result = "ABC"
else:
    result = "ARC"

print(result)


Measured memory_bytes: 9060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] N = cin.ArrayInt(3,0);
        if(N[0]<N[1]&&N[1]<N[2])Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 17940
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  dll xx = ((dll)(n)/(dll)(1.08));
  // cout << xx << endl;
  ll cn1 = (ll)((ceil)(xx)* (dll)(1.08));
  ll cn2 = (ll)((floor)(xx)* (dll)(1.08));
  // cout << cn1 << " " << cn2 << endl;
  if(cn1 != n and cn2 != n) {
    cout << ":(";
  } else if(cn1 == n){ 
    cout << (ceil)(xx) << endl;
  } else cout << (floor)(xx) << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s;
int c[10][10];

void solve(int num){
	if (num == 1)return;

	for (int i = 0; i < num - 1; i++){
		c[10 - num + 1][i] = (c[10 - num][i] + c[10 - num][i + 1]) % 10;
	}

	solve(num - 1);
}

int main(){
	while (cin >> s){
		REP(i, 10)c[0][i] = s[i] - '0';
		solve(10);
		cout << c[9][0] << endl;
	}
}

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

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

    int d[13];
    fill(d, d + 13, 0);
    d[0] = 1;
    for (int i = 0; i < N; ++i) {
        int D;
        cin >> D;
        ++d[D];
    }

    if (d[0] > 1 || d[12] > 1) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 1; i < 12; ++i) {
        if (d[i] > 2) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 0;
    for (int b = 0; b < (1 << 13); ++b) {
        set<int> t;
        for (int i = 0; i < 13; ++i) {
            if (d[i] == 0) continue;
            if (d[i] == 2) {
                t.insert(12 - i);
                t.insert(12 + i);
                continue;
            }
            if ((b >> i) & 1) {
                t.insert(12 + i);
            } else {
                t.insert(12 - i);
            }
        }

        int s = 30;
        int pre = *t.rbegin();
        for (int now : t) {
            s = min(s, (now - pre + 24) % 24);
            pre = now;
        }

        ans = max(ans, s);
    }

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


Measured memory_bytes: 256
/**
 * バブルソート
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()

    Main.display()
}

class Main {

    companion object {

        // 連結リスト
        private lateinit var list: MutableList<Int>
        private var size: Int = 0

        // 交換した回数
        private var swapSize: Int = 0

        fun init() {

            size = readLine()!!.toInt()

            val inputs = readLine()!!.split(" ")

            list = inputs.map {
                it.toInt()
            }.toMutableList()
        }

        fun execute() {
            for (count in 0..size) {

                for (index in size - 1 downTo (1 + count)) {

                    // swap
                    if (list[index - 1] > list[index]) {
                        val temp = list[index]
                        list[index] = list[index - 1]
                        list[index - 1] = temp
                        swapSize++
                    }
                }
            }
        }

        fun display() {
            println(list.joinToString(" "))
            println(swapSize)
        }
    }
}




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

bool solve(vector<int> v, bool turn, int k, vector<int> &dp) {
	if(dp[k]!=-1) {
		return dp[k];
	}
	for(int i=0;i<v.size();i++) {
		if(k>=v[i]) {
			if(!solve(v,!turn,k-v[i], dp)) {
				dp[k] = true;
				return dp[k];
			}
		}
	}
	dp[k]=false;
	return dp[k];
}

int main() {
	int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++) {
    	cin>>v[i];
    }
    vector<int> dp(k+1, -1);
    bool answer = solve(v,true,k, dp);
    if(answer) {
    	cout<<"First"<<endl;
    } else {
    	cout<<"Second"<<endl;
    }
    
	return 0;
}


Measured memory_bytes: 53760
#include <bits/stdc++.h>
using namespace std ;
int l,ll,temp;
int main(){
	string s;
	cin>>s;
	l=s.length();
	ll=l-1;
	for(int i=0;i<=l/2-1;i++){
		if(s[i]!=s[ll]){
			temp++;
		}
		ll--;
	}
	
	cout<<temp<<"\n";
}

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

typedef long long ll;

struct node {int parent, mark;};
node N[100001];

int find(int v) {
	while(!N[v].mark) {
		v = N[v].parent;
	}
	return v;
}

int main() {
	int n, q; ll ans;
	char ope; int v;
	while(1) {
		cin >> n >> q;
		if(!n&&!q) break;
		N[1].parent = 0; N[1].mark = 1;
		for(int i=2; i<=n; ++i) {
			cin >> N[i].parent;
			N[i].mark = 0;
		}
		ans = 0;
		for(int i=0; i<q; ++i) {
			cin >> ope >> v;
			if(ope=='M') N[v].mark = 1;
			if(ope=='Q') ans += find(v);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1932
def add_sub_mul(A, B):
    add = A + B
    sub = A - B
    mul = A * B
    return max(add, sub, mul)

def main():
    A, B = [int(i) for i in input().split()]
    print(add_sub_mul(A, B))

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
# ABC 47, B - sunuke coloring easy 2
w, h, n = [int(el) for el in input().split(' ')]
field = [[int(el) for el in input().split(' ')] for i in range(n)]

left = 0
right = w
top = h
bottom = 0

for i in range(n):
    if field[i][2] == 1:
        left = max(left, field[i][0])
    if field[i][2] == 2:
        right = min(right, field[i][0])
    if field[i][2]  == 3:
        bottom = max(bottom, field[i][1])
    if field[i][2] == 4:
        top = min(top, field[i][1])
print(max(top - bottom, 0) * max(right - left, 0))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    int a_index = 0;
    int z_index = 0;
    bool flg = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' && flg) {
            a_index = i;
            flg = false;
        }
        else if (s[i] == 'Z') {
            z_index = i;
        }
    }
    cout << z_index - a_index + 1 << endl;
}


Measured memory_bytes: 640
H, W, K = map(int,input().split())
colors = []
for i in range(H):
    colors+=input().split()

ans=0
for maskH in range(1 << H):
    for maskW in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((maskH >> i) & 1)==0 and ((maskW >> j) & 1)==0 and colors[i][j]=="#":
                    black+=1
        if black==K: ans+=1
print(ans)

Measured memory_bytes: 9104
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
int n;cin>>n;
  string s="No";
  for(int i=1;i<10;i++)
  {
    for(int j=0;j<10;j++)
    {
      int ans=i*j;
      if(ans==n)
        s="Yes";
    }
  }
  cout<<s;
}
      

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    string s, t, tmp;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    cin >> tmp;

    if (tmp == s) cout << a - 1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()(string&s, string&t) {
		int l=s.length();
		int ret=0;
		for(int i=0;i<l;i++)
		{
			if(s[i]!=t[i]) ret++;
		}
		return ret;
	}
};

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

	for(;;)
	{
		string s, t;
		cin >> s >> t;
		if(cin.fail()) break;
		if(s.length()!=t.length()) break;
		cout << solve()(s, t) << "\n";
	}
	return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout << (a*b%2 ? "Odd" : "Even") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		
		//long startTime = System.currentTimeMillis();
		
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		String str=sc.next();
		char[] c=str.toCharArray();
		//char[] c=new char[n+1];
		
		
		/*for(int i=0;i<tmparray.length;i++){
			c[i]=tmparray[n-i];
		}*/
		
		
		int c1=0;
		
		StringBuilder ans=new StringBuilder();
		
		
		//Case unsolvable
		for(char ch:c){
			if(ch=='1'){
				c1++;
				if(c1>=m){
					System.out.println("-1");
					System.exit(0);
					
				}
			}else{
				c1=0;
			}
		}

		
		
		//case solvable
		
		
		int index=0;
		for(int i=m;i>0;i--){
			if((index+i)==c.length-1){
				ans.insert(0," ");
				ans.insert(0,i);
				break;
			}else if((index+i)>=c.length){
				continue;
			}
			if(c[n-index-i]=='1'){
				continue;
			}else{
				if(ans==null)ans.append(i);
				else{
					ans.insert(0," ");
					ans.insert(0,i);
				}
				index=index+i;
				i=m+1;
			}
		}
		
		System.out.println(ans);
		//long endTime = System.currentTimeMillis();
		//System.out.println("処理時間：" + (endTime - startTime) + " ms");
		}
		
	
}



Measured memory_bytes: 28964
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

vector<int> G[1002];

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll I,O,L,J,hoge;
  cin>>I>>O>>hoge>>J>>L>>hoge>>hoge;
  ll ans = 0;
  if(I >= 3){
    ans += I / 2 * 2;
    I %= 2;
    if(I == 0){
      ans -= 2;
      I = 2;
    }
  }
  ans += O;
  if(L >= 3){
    ans += L / 2 * 2;
    L %= 2;
    if(L == 0){
      ans -= 2;
      L = 2;
    }
  }

  if(J >= 3){
    ans += J / 2 * 2;
    J %= 2;
    if(J == 0){
      ans -= 2;
      J = 2;
    }
  }

  if(L > 0 && J > 0 && I > 0){
    ans += max(3ll, L/2*2 + I/2*2 + J/2*2);
  }else{
    ans += L/2*2 + I/2*2 + J/2*2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    Map<Integer, List<Integer>> map = new HashMap<>();
    for (int i = 0; i < N; i++) {
      int days = sc.nextInt();
      List<Integer> r =  map.get(days);
      if (r == null) {
        r = new ArrayList<>();
        map.put(days, r);
      }
      r.add(sc.nextInt());
    }
    
    int ans = 0;
    PriorityQueue<Integer> pq = new PriorityQueue(Collections.reverseOrder());
    for (int i = 1; i <= M; i++) {
      List<Integer> list = map.get(i);
      if (list != null) {
        for (int v : list) {
          pq.offer(v);
        }
      }
      Integer v = pq.poll();
      if (v != null) {
        ans += v;
      }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 102776
/**
 *  author: mahfuzz
 *  created: 03.05.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << #x << ':' << x << "\n"
#define pii pair<int, int>
typedef long long ll;

bool cmp(pii a, pii b){
    if(a.second > b.second)
        return true;
    
    return false;
}

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n; cin >> n;
    vector<pii> vec;
    
    for(int i = 1; i <= n; i++){
        int x = i, cnt = 0;
        while(x % 2 == 0){
            x /= 2;
            ++cnt;
        }
        vec.push_back({i, cnt});
    }
    
    sort(all(vec), cmp);
    
    cout << vec[0].first << "\n";
        
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    while (true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H == 0 && W == 0){
        break;
      }
      for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if((i + j)%2 == 0){
            System.out.print("#");
          }else if((i + j) %2== 1){
            System.out.print(".");
          }
        }
        System.out.print("\n");
      }
System.out.print("\n");

    }
  }
}


Measured memory_bytes: 35516
#include <bits/stdc++.h>
using namespace std;
long long int dp[101][101][301];
int main(void)
{
	long long int i,j,k,n,w,w0,w1[101],w2[101],v[101],max1,x;
	cin >> n >> w;
	for(i=0;i<n;i++)cin >> w1[i] >> v[i];
	w0=w1[0];
	for(i=0;i<n;i++)w2[i]=w1[i]-w0;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n*3;k++){
				dp[i][j][k]=-1;
			}
		}
	}
	dp[0][0][0]=0;
	for(i=0;i<n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n*3;k++){
				if(dp[i][j][k]!=-1){
					dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
					if(j<n){
						dp[i+1][j+1][k+w2[i]]=max(dp[i+1][j+1][k+w2[i]],dp[i][j][k]+v[i]);
					}
				}
			}
		}
	}
	max1=-1;
	for(j=0;j<=n;j++){
		for(k=0;k<=n*3;k++){
				x=w0*j+k;
				if(w>=x){
					max1=max(max1,dp[n][j][k]);
				}
		}
	}
	
	cout << max1 << endl;
	return 0;
}
				

Measured memory_bytes: 24192
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,m;
int a[1010],S=0;

void solve(){
    cin >> n >> m;
    rep(i,n){
        cin >> a[i];
        S+=a[i];
    }
    int num=0;
    rep(i,n){
        if(a[i]*4*m>=S){
            num+=1;
        }
    }
    if(num>=m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int v[100000][3];

 
int main()
{     int n;
      cin>>n;
      
      for (int i=0;i<n;i++)
      { int  x,y,z;
        cin>>x;
        v[i][0]=x;
        cin>>y;
        v[i][1]=y;
        cin>>z;
        v[i][2]=z;

      }
      int dp[n][3];
      dp[0][0]=v[0][0];
      dp[0][1]=v[0][1];
      dp[0][2]=v[0][2];

      for(int i=1;i<n;i++)
      {
         dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
         dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
         dp[i][2]=v[i][2]+max(dp[i-1][1],dp[i-1][0]);


      }
      int ans = max(dp[n-1][0],max(dp[n-1][2],dp[n-1][1]));
      cout<<ans;
    
      return 0;
}

Measured memory_bytes: 5932
import sys

read = sys.stdin.buffer.read
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    M = 60

    ans = 0
    p = 1
    for _ in range(M):
        n = 0
        for i in range(N):
            A[i], d = A[i] // 2, A[i] % 2
            n += d
        ans = (ans + n * (N - n) * p) % MOD
        p = p * 2 % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 125868
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    if (A + B > C * 2) {
        int cnt = min(X, Y);
        X -= cnt; Y -= cnt;
        ans += cnt * C * 2;
        if (X > 0) {
            if (A > C * 2) {
                ans += C * 2 * X;
            }
            else {
                ans += A * X;
            }
        }
        if (Y > 0) {
            if (B > C * 2) {
                ans += C * 2 * Y;
            }
            else {
                ans += B * Y;
            }
        }
    }
    else {
        ans += A * X + B * Y;
    }

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Map;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String s;
        Map<String, Integer> map = new TreeMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            s = br.readLine();
            if (map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            } else {
                map.put(s, 1);
            }
            max = Math.max(max, map.get(s));
        }

        br.close();

        for (var entry : map.entrySet()) {
            if (entry.getValue() == max) {
                bw.write(entry.getKey() + "\n");
            }
        }

        bw.flush();

    }
}

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

using namespace std;
using ll = long long;

int main() {
    string s = "";
    cin >> s;
    if(s == "RRS" || s == "SRR"){
        cout << 2 << endl;
    }else if(s == "RRR"){
        cout << 3 << endl;
    }else if(s == "SSS"){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }

    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

int main(void) {
	int N, alice, bob, buf;
	bool isAliceTurn = true;
	std::cin >> N;
	int *a = new int[N];
	// cin to a_i
	for(int i = 0; i < N; ++i) {
		std::cin >> a[i];
	}
	// sort
	for(int i = 0; i < N; ++i) {
		for(int j = 1; j < N - i; ++j) {
			if(a[j-1] < a[j]) {
				buf = a[j];
				a[j] = a[j-1];
				a[j-1] = buf;
			}
		}
	}
	// game
	alice = bob = 0;
	for(int i = 0; i < N; ++i) {
		if(isAliceTurn) {
			alice += a[i];
			isAliceTurn = false;
		} else {
			bob += a[i];
			isAliceTurn = true;
		}
	}
	// cout
	std::cout << (alice - bob) << std::endl;
	delete [] a;
	return 0;
}

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

typedef struct item{
  int n;
  string S;
  int P;
} item;

int main(){
  int N;
  cin >> N;
  vector<item> items(0);
  for(int i=1;i<=N;i++){
    item I;
    I.n = i;
    cin >> I.S >> I.P;
    items.push_back(I);
  }
  for(int i=N-1;i>=0;i--){
    for(int j=0;j<i;j++){
      if(items[j].S>items[j+1].S){
        item temp=items[j];
        items[j] = items[j+1];
        items[j+1] = temp;
      }else if(items[j].S==items[j+1].S){
        if(items[j].P<items[j+1].P){
          item temp=items[j];
          items[j] = items[j+1];
          items[j+1] = temp;
        }
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << items[i].n << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        const int LI = 3501;
        for(var n=1;n<LI;n++)
            for(var w = n; w < LI; w++)
            {
                var h = (double)num * n * w / (4 * n * w - num * w - num * n);
                if ((long)h == h&&h>0)
                {
                    WriteLine($"{h} {w} {n}");
                    return;
                }
            }
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>


int dp[200000][130];

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

  string s;
  cin>>s;

  dp[0][0]=1;
  rep(i,s.size()){
    int c;
    if(s[i]=='?') c=10;
    else c=s[i]-'0';

    rep(j,10){
     if(c!=10&&c!=j) continue; 
     rep(k,13){
       dp[i+1][(k*10+j)%13]+=dp[i][k];
       dp[i+1][(k*10+j)%13]%=M;
     }
    }
  }

  cout<<dp[s.size()][5]<<endl;

}


Measured memory_bytes: 102864
// template version 1.2
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

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

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,T;cin>>n>>T;
  int c,t;

  int res = INF;
  rep(i, n){
    cin>>c>>t;
    if (t<=T) chmin(res, c);
  }

  if (res==INF){
    cout << "TLE" << endl;
  }
  else{
    cout << res << endl;
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

using namespace std;

void solve()
{
	int N, W;
	cin >> N >> W;

	vector<long>dp(W+1), ws(N), vs(N);

	for (int i = 0; i < N; i++)
	{
		cin >> ws[i] >> vs[i];
	}

	for (int i = 0; i < N; i++)
	{
		for (int w = W; w >= 0; w--)
		{
			if (w + ws[i] > W) continue;
			dp[w + ws[i]] = max(dp[w + ws[i]], dp[w] + vs[i]);
		}
	}

	cout << *max_element(dp.begin(), dp.end()) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}


/*int cnt[1005];
map<pair<ll,ll>,ll> dp[106];
int lg(ll t){
	for(int i=0;i<60;i++)
		if((1ll<<i)==t) return i;
}
ll get(int dig,ll l,ll r){
	if(l==-1){if(!r) return 1ll<<dig+1;}
	else if(r==-1){if(l==(1ll<<dig+1)-1) return 1ll<<dig+1;}
	else if(l+1>=r) return 1ll<<dig+1;
	if(dig==0){
		if(l==-1) return 1;
		if(r==-1) return 1;
	}
	if(dp[dig].count(mp(l,r))) return dp[dig][mp(l,r)];
	ll &ans=dp[dig][mp(l,r)];ans=0;
	if(l==-1){
		if(r&(1ll<<dig)) ans=get(dig-1,-1,r^(1ll<<dig));
		else ans=(1ll<<dig)+get(dig-1,-1,r);
	}
	else if(r==-1){
		if(!(l&(1ll<<dig))) ans=get(dig-1,l,-1); 
		else ans=(1ll<<dig+1);
	}
	else{
		if(l&(1ll<<dig)) ans=(1ll<<dig)+(1ll<<dig-__builtin_popcount(r));
		else if(!(r&(1ll<<dig))) ans=(1ll<<dig)+get(dig-1,l,r);
		else ans=get(dig-1,l,-1)+get(dig-1,l,r^(1ll<<dig));
	}
	printf("%d %lld %lld %lld\n",dig,l,r,ans);
	return ans;
}*/
int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
	time_tester(0);
#endif
	ll l,r;cin>>l>>r;
	if(l==r){puts("1");return 0;}
	int st=59;
	while((l&(1ll<<st))==(r&(1ll<<st))) l-=l&(1ll<<st),r-=r&(1ll<<st),st--;
	ll ans=(1ll<<st)-l;
	r^=(1ll<<st);
		ll t=1;
		while(t<=r) t<<=1;
		ans+=min((1ll<<st),t+(1ll<<st)-l);
	cout<<ans<<endl;
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

vector<ll>v;
int main()
{
   ll t;
   sl(t);

   while(t>0)
   {
       if(t%26) v.pb(t%26), t=t/26;
       else v.pb(26), t= (t/26)-1;
   }
   for(int i=v.sz-1; i>=0; i--)
   cout<<(char)(v[i]-1+'a');
}


Measured memory_bytes: 3780
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String X = sc.next();
		String Y = sc.next();
		
		if (X.compareTo(Y) == 0) {
			System.out.println("=");
		} else if (X.compareTo(Y) <= -1) {
			System.out.println("<");
		} else {
			System.out.println(">");
		}
	}
}

Measured memory_bytes: 21844
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = pow(Ki, N, MOD) - getLarge(i) % MOD
        memo[i] = c
        ans += i * c
        ans %= MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69392
from bisect import bisect_left
import numpy as np

n = int(input())
a = map(int, input().split())

border = np.arange(399, 3200, 400)
cnt = [0] * (len(border) + 1)
for i in a:
    cnt[bisect_left(border, i)] += 1

k = np.count_nonzero(cnt[:-1])
print(k, k + cnt[-1]) if k != 0 else print(1, cnt[-1])


Measured memory_bytes: 12216
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int main(){
	int c[5][5];
	REP(i,0,3) REP(j,0,3) cin >> c[i][j];
	
	REP(i,0,101){
		REP(j,0,101){
			REP(k,0,101){
				int a[] = {i, j, k};
				int b[] = {c[0][0] - i, c[1][1] - j, c[2][2] - k};
				int pos[5][5];
				
				REP(i,0,3) REP(j,0,3) pos[i][j] = a[i] + b[j];
				
				bool f = true;
				REP(i,0,3) REP(j,0,3) if(c[i][j] != pos[i][j]) f = false;
				
				if(f){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	
	cout << "No" << endl;
	return 0;
}


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

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

using namespace std;
const int INF = 1e+8;
int dist[300][300];

int main() {
  while(1){
    int n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    --s;
    if(!n)break;
    REP(i,300)REP(j,300)dist[i][j] = INF;
    REP(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      --a;--b;
      dist[a][b] = c;
      dist[b][a] = c;
    }
    REP(k,n)REP(i,n)REP(j,n)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    vector<tuple<int,int>> siro;
    siro.emplace_back(s,0);
    REP(i,l){
      int j,e;
      cin>>j>>e;
      --j;
      siro.emplace_back(j,e);
    }
    ++l;
    vector<vector<int>> dp(1<<l,vector<int>(l,INF));
    dp[1][0] = 0;
    int num = 0;
    REP(i,1<<l){
      REP(j,l){
        if(dp[i][j] < INF && ((i>>j)&1) == 1) {
          if (dp[i][j] + dist[get<0>(siro[j])][get<0>(siro[0])] <= t) {
            int cnt = 0;
            REP(k,l) if (((i>>k)&1)==1) ++cnt;
            num = max(num, cnt-1);
          }
          REP(k,l){
            if (((i>>k)&1)==0) {
              int sj,se,tj,te;
              tie(sj,se) = siro[j];
              tie(tj,te) = siro[k];
              dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j] + dist[sj][tj] + te);
            }
          }
        }
      }
    }
    cout<<num<<endl;
  }
  return 0;
}

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

int main(){

    int i, A, N, D, X, tmp_day, count = 0;

    cin >> N;
    cin >> D >> X;
    for(i = 0; i < N; i++){
        cin >> A;
        tmp_day = 1;
        while(true){
            tmp_day += A;
            count++;
            if(tmp_day > D) break;
        }
    }

    cout << count + X << endl;

    return 0;
}

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

using Graph = vector<vector<int> >;
Graph G;

void dfs(int v, vector<bool> &seen, int &res) {
    bool end = true;
    for (int i = 0; i < seen.size(); ++i) 
    if (seen[i] == false && i != v) end = false;
    if (end) {
        ++res;
        return;
    }

    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(nv, seen, res);
    }
    seen[v] = false;
}

int main() {
    int N, M; cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> seen(N, false);
    int res = 0;
    dfs(0, seen, res);
    cout << res << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
sum_A = sum(A)
for a in A:
    if a >= sum_A / (4 * M):
        cnt += 1

if cnt >= M:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 3064
def main():
    N = int(input())
    B = list(map(int, input().split()))
    B.insert(0, B[0])
    B.append(B[-1])
    ret = 0
    for b, b1 in zip(B, B[1:]):
        ret += min(b, b1)
    print(ret)


main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 205;
const int MOD = 1e9 + 7;

int n,m,k,ans = 1,len,top,tot;
int fac[MAXN],ifac[MAXN],head[MAXN],dfn[MAXN],low[MAXN],st[MAXN];
set<int> s;

struct Edge{
	int to,next;
} e[MAXN << 1];

void add(int u,int v){
	e[++len].to = v;
	e[len].next = head[u];
	head[u] = len;
}

int power(int x,int y){
	int res = 1;
	while(y){
		if(y & 1)
			res = 1ll * res * x % MOD;
		x = 1ll * x * x % MOD;
		y >>= 1;
	}
	return res;
}

void Init(int n){
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= n;i++)
		fac[i] = 1ll * fac[i - 1] * i % MOD;
	ifac[n] = power(fac[n],MOD - 2);
	for(int i = n - 1;i >= 1;i--)
		ifac[i] = 1ll * ifac[i + 1] * (i + 1) % MOD;
}

int C(int n,int m){
	if(n < m || n < 0 || m < 0)
		return 0;
	return 1ll * fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int Polya(int n){
	int res = 0;
	for(int i = 1;i <= n;i++)
		res = (res + power(k,__gcd(n,i))) % MOD;
	return 1ll * res * power(n,MOD - 2) % MOD;
}

int Perm(int n){
	return C(n + k - 1,k - 1);
}

void tarjan(int u,int fa){
	dfn[u] = low[u] = ++tot;
	st[++top] = u;
	for(int i = head[u];i != -1;i = e[i].next){
		int v = e[i].to;
		if(!dfn[v]){
			tarjan(v,u);
			low[u] = min(low[u],low[v]);
			if(low[v] >= dfn[u]){
				s.clear();
				int tmp,point = 0,edge = 0;
				do{
					tmp = st[top];
					s.insert(tmp);
					point++;
					top--;
				}while(tmp != v);
				s.insert(u);
				point++;
				for(int x : s){
					for(int j = head[x];j != -1;j = e[j].next){
						int y = e[j].to;
						if(s.count(y))
							edge++;
					}
				}
				edge >>= 1;
				if(edge < point)
					ans = 1ll * ans * k % MOD;
				if(edge == point)
					ans = 1ll * ans * Polya(point) % MOD;
				if(edge > point)
					ans = 1ll * ans * Perm(edge) % MOD;
			}
		}else
			low[u] = min(low[u],dfn[v]);
	}
	if(!fa)
		top--;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	memset(head,-1,sizeof(head));
	scanf("%d%d%d",&n,&m,&k);
	Init(m + k + 5);
	for(int i = 1;i <= m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i = 1;i <= n;i++){
		if(!dfn[i])
			tarjan(i,0);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 3832