codeparrot/codecomplex huggingface dataset:
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class ProblemB {
    
    public static void main(String[] args) throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String[] line = s.readLine().split(" ");
        long n = Long.valueOf(line[0]);
        long y = Long.valueOf(line[1]);
        long x = Long.valueOf(line[2]);
        long c = Long.valueOf(line[3]);
        
        long min = 0;
        long max = n*2L+20;
        for (int cnt = 0 ; cnt < 300 ; cnt++) {
            long med = (min+max) / 2L;
            long ct = isok(med, n, x, y, c); 
            if (ct >= c) {
                max = med;
            } else {
                min = med+1;
            }
        }
        
        long lst = max;
        for (long d = -2 ; d <= 2 ; d++) {
            if (max+d >= 0 && isok(max+d, n, x, y, c) >= c) {
                lst = Math.min(lst, max+d);
            }
        }
        
        out.println(lst);
        out.flush();
    }
    

    private static long isok(long time, long n, long x, long y, long c) {
        long total = time * 2 * (time + 1) + 1;
        long top = y - time;
        if (top <= 0) {
            long dy = Math.abs(top)+1;
            total -= dy*dy;
            long over = dy - x;
            if (over >= 1) {
                total += (1L + over) * over / 2; 
            }
            over = dy - ((n + 1) - x);
            if (over >= 1) {
                total += (1L + over) * over / 2; 
            }
        }
        
        long bottom = y + time;
        if (bottom > n) {
            long dy = Math.abs(bottom-n);
            total -= dy*dy;
            long over = dy - x;
            if (over >= 1) {
                total += (1L + over) * over / 2; 
            }
            over = dy - ((n + 1) - x);
            if (over >= 1) {
                total += (1L + over) * over / 2; 
            }
        }
        
        long left = x - time;
        if (left <= 0) {
            long dy = Math.abs(left)+1;
            total -= dy*dy;
        }

        long right = x + time;
        if (right > n) {
            long dy = Math.abs(right-n);
            total -= dy*dy;
        }
        return total;
    }

    public static void debug(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
import java.io.*;
import java.util.*;

public class B {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	long f(int x, int y, int sz) {
		if (x > y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		if (sz <= x)
			return (long) sz * (sz + 1) / 2;
		if (sz >= x + y - 1)
			return (long) x * y;
		long val = x * (x + 1) / 2;
		if (sz <= y)
			return val + (long) (sz - x) * x;

		long rest = x + y - 1 - sz;
		return (long) x * y - (long) rest * (rest + 1) / 2;
	}

	long count(int x, int y, int n, int time) {
		long DL = f(x + 1, y + 1, time + 1);
		long DR = f(n - x, y + 1, time + 1);
		long UL = f(x + 1, n - y, time + 1);
		long UR = f(n - x, n - y, time + 1);
//		if (time == 1)
//			System.err.println(DL + " " + DR + " " + UL + " " + UR);
		long L = Math.min(x + 1, time + 1);
		long R = Math.min(n - x, time + 1);
		long U = Math.min(n - y, time + 1);
		long D = Math.min(y + 1, time + 1);
//		if (time == 1)
//			System.err.println(L + " " + R + " " + U + " " + D);
		return DL + DR + UL + UR - L - R - U - D + 1;
	}

	void solve() throws IOException {
		int n = nextInt();
		int x = nextInt() - 1;
		int y = nextInt() - 1;
		long need = nextLong();

		if (need == 1) {
			out.println(0);
			return;
		}

		int low = 0;
		int high = Math.max(x, n - 1 - x) + Math.max(y, n - 1 - y);
		
//		for (int i = 0; i <= 100; i++)
//			System.err.println(count(x, y, n, i));

		while (low < high - 1) {
			int mid = (int) (((long) low + high) / 2);
			if (count(x, y, n, mid) >= need)
				high = mid;
			else
				low = mid;
		}

		out.println(high);

	}

	B() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new B();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Proj implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer str;

	public void solve() throws IOException {
		long l = nextLong();
		long r = nextLong();
                int g = 0;
		long x = l ^ r;
		long i = 1;
		while (x >= i) {
			i = i * 2;
		}
		if (x >= i) {
			out.println(x);
		} else
			out.println(i - 1);
	}

	public String nextToken() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(in.readLine());
		}
		return str.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
		}
	}

	public static void main(String[] args) {
		new Thread(new Proj()).start();
	}
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
/**
 * Created with IntelliJ IDEA.
 * User: brzezinsky
 * Date: 12/16/12
 * Time: 7:44 PM
 * To change this template use File | Settings | File Templates.
 */


import java.io.*;
import java.util.*;
import java.util.StringTokenizer;

public class E extends Thread {
    public E(String inputFileName, String outputFileName) {
        try {
            if (inputFileName != null) {
                this.input = new BufferedReader(new FileReader(inputFileName));
            } else {
                this.input = new BufferedReader(new InputStreamReader(System.in));
            }
            if (outputFileName != null) {
                this.output = new PrintWriter(outputFileName);
            } else {
                this.output = new PrintWriter(System.out);
            }
            this.setPriority(Thread.MAX_PRIORITY);
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        }
    }

    private void solve() throws Throwable {
        long l = nextLong(), r = nextLong();
        output.println(Math.max(Long.highestOneBit(l ^ r) * 2 - 1, 0L));
    }



    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.close();
        }
    }

    public static void main(String... args) {
        new E(null, null).start();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    private String next() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private StringTokenizer tokens;
    private BufferedReader input;
    private PrintWriter output;
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import static java.lang.Math.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Character.*;
import static java.lang.String.*;
@SuppressWarnings("unused")

public class round169D {
    static PrintWriter out = new PrintWriter(System.out);
    static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
    static StringTokenizer st = new StringTokenizer("");
    static int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    static String next() throws Exception {
        while (true) {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            st = new StringTokenizer(s);
        }
    }
    public static void main(String[] args)throws Exception {        
        long l = parseLong(next());
        long r = parseLong(next());
        long [] min = new long [61];
        for(int i = 1 ; i <= 60 ; ++i){//(2^i)-1 is obtained by min[i]^min[i]+1
            min[i] = (long) pow(2, i - 1) - 1;          
        }
        for(int i = 60 ; i >= 0 ; --i){//try to get 2^i-1 as answer.                
            if(min[i] >= r)
                continue;
            if(min[i] >= l && min[i] + 1 <= r){             
                out.println((1L << i) - 1);
                out.flush();
                return;
            }
            if(min[i] < l){
                long one_jump = (long) pow(2, i);
                long  jumps = (long) ceil((l - min[i]) / (one_jump * 1.0));             
                long cur = min[i] + (jumps * one_jump);
                if(cur >= l && cur + 1 <= r){                                       
                    out.println((1L << i) - 1);
                    out.flush();
                    return;
                }               
            }
        }
        out.println(0);
        out.flush();
    }
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn


import java.util.Scanner;

public class D {
    static long max;

    public static long[] getOneRange(long min, long max,int bit) {
        long st=(min&(((1l<<63)-1)&~((1l<<(bit+1))-1)))|(1l<<bit);
        long end=st|((1l<<(bit+1))-1);
        long interSt=Math.max(st,min);
        long interEnd=Math.min(end, max);
        if(interSt>interEnd) return null;
        return new long[]{interSt,interEnd};
    }

    public static long[] getZeroRange(long min, long max,int bit) {
        long st=min&(((1l<<63)-1)&~((1l<<(bit+1))-1));
        long end=st|((1l<<bit)-1);
        long interSt=Math.max(st,min);
        long interEnd=Math.min(end, max);
        if(interSt>interEnd) return null;
        return new long[]{interSt,interEnd};
    }

    public static void solve(int bitPosition, long min1, long max1, long min2,
            long max2, long curNum) {
        if (bitPosition == -1) {
            max = Math.max(max, curNum);
            return;
        }
        long[] firZeroRange = getZeroRange(min1, max1,bitPosition);
        long[] secZeroRange = getZeroRange(min2, max2,bitPosition);
        long[] firOneRange = getOneRange(min1, max1,bitPosition);
        long[] secOneRange = getOneRange(min2, max2,bitPosition);
        if ((firOneRange != null && secZeroRange != null)
                || (firZeroRange != null && secOneRange != null)) {
            long newNum = curNum | (1l << bitPosition);
            if (firOneRange != null && secZeroRange != null&&
                    (firOneRange[1]-firOneRange[0]+1)==1l<<bitPosition&&
                    (secZeroRange[1]-secZeroRange[0]+1)==1l<<bitPosition) {
                solve(bitPosition - 1, firOneRange[0], firOneRange[1],
                        secZeroRange[0], secZeroRange[1], newNum);
                return;
            }
            if (firZeroRange != null && secOneRange != null&&
                    (firZeroRange[1]-firZeroRange[0]+1)==1l<<bitPosition&&
                    (secOneRange[1]-secOneRange[0]+1)==1l<<bitPosition) {
                solve(bitPosition - 1, firZeroRange[0], firZeroRange[1],
                        secOneRange[0], secOneRange[1], newNum);
                return;
            }
            if (firOneRange != null && secZeroRange != null) {
                solve(bitPosition - 1, firOneRange[0], firOneRange[1],
                        secZeroRange[0], secZeroRange[1], newNum);
            }
            if (firZeroRange != null && secOneRange != null) {
                solve(bitPosition - 1, firZeroRange[0], firZeroRange[1],
                        secOneRange[0], secOneRange[1], newNum);
            }
        } else {
            solve(bitPosition - 1, min1, max1, min2, max2, curNum);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();
        max = 0;
        solve(62, l, r, l, r, 0);
        System.out.println(max);
    }
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
    
    //Scanner input = new Scanner(new File("input.txt"));
    //PrintWriter out = new PrintWriter(new File("output.txt"));
    PrintWriter out = new PrintWriter(System.out);
    input.init(System.in);
    long a = input.nextLong(), b = input.nextLong();
    if(a==b)
    {
        out.println(0);
        out.close();
        return;
    }
    long res = 0;
    for(int i = 0; i<63; i++)
    {
        if(a%(1l<<i) >= b%(1l<<i))
            res += (1l<<i);
        else if(b/((1l<<i)) > a/((1l<<i)))
            res += (1l<<i);
    }
    out.println(res);
    out.close();
}
public static long gcd(long a, long b)
{
if(b == 0) return a;
return gcd(b, a%b);
}
public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
static class IT
{
    int[] left,right, val, a, b;
    IT(int n)
    {
        left = new int[3*n];
        right = new int[3*n];
        val = new int[3*n];
        a = new int[3*n];
        b = new int[3*n];
        init(0,0, n);
    }
    int init(int at, int l, int r)
    {
        a[at] = l;
        b[at] = r;
        if(l==r)
            left[at] = right [at] = -1;
        else 
        {
            int mid = (l+r)/2;
            left[at] = init(2*at+1,l,mid);
            right[at] = init(2*at+2,mid+1,r);
        }
        return at++;
    }
    //return the sum over [x,y]
    int get(int x, int y)
    {
        return go(x,y, 0);
    }
    int go(int x,int y, int at)
    {
        if(at==-1) return 0;
        if(x <= a[at] && y>= b[at]) return val[at];
        if(y<a[at] || x>b[at]) return 0;
        return go(x, y, left[at]) + go(x, y, right[at]);
    }
    //add v to elements x through y
    void add(int x, int y, int v)
    {
        go3(x, y, v, 0);
    }
    void go3(int x, int y, int v, int at)
    {
        if(at==-1) return;
        if(y < a[at] || x > b[at]) return;
        val[at] += (Math.min(b[at], y) - Math.max(a[at], x) + 1)*v;
        go3(x, y, v, left[at]);
        go3(x, y, v, right[at]);
    }
}
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zakhar Voit
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        out.println(solve(in.nextLong(), in.nextLong()));
        /*for (long l = 1; l < 500; l++) {
            for (long r = l; r < 500; r++) {
                if (badSolve(l, r) != solve(l, r)) {
                    out.println(l + " " + r);
                    return;
                }
            }
        }
        out.println("OK");*/
    }

    long solve(long l, long r) {
        if (l == r)
            return 0;
        long ans = l ^ (l + 1);

        for (int i = 0; i < 62; i++) {
            l |= (1l << i);
            if (l + 1 <= r)
                ans = (1l << (i + 2l)) - 1;
        }

        return ans;
    }
}

class Scanner {
    BufferedReader in;
    StringTokenizer tok;

    public Scanner(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
        tok = new StringTokenizer("");
    }

    public String nextToken() {
        if (!tok.hasMoreTokens()) {
            try {
                String newLine = in.readLine();
                if (newLine == null)
                    throw new InputMismatchException();
                tok = new StringTokenizer(newLine);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            return nextToken();
        }

        return tok.nextToken();
    }

    public long nextLong() {
        return Long.parseLong(nextToken());
    }

    }
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.io.*;
import java.util.*;

public class D {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	String toStr(long a) {
		String s = Long.toBinaryString(a);
		while (s.length() < 64)
			s = "0" + s;
		return s;
	}

	void solve() throws IOException {
		long a = nextLong();
		long b = nextLong();
		
		String sa = toStr(a);
		String sb = toStr(b);
		
		int i = 0;
		while (i < 64 && sa.charAt(i) == sb.charAt(i))
			i++;
		
		int left = 64 - i;
		out.println((1L << left) - 1);
	}

	D() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new D();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn

import java.util.Scanner;

public class D {
	public static void main(String [] args){
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		String sa = Long.toBinaryString(a);
		String sb = Long.toBinaryString(b);
		long ans = 0;
		if(sb.length()-sa.length()>0){
			for(int i = 0 ; i < sb.length() ; i++){
				ans += 1l<<i;
			}
			System.out.println(ans);
		}
		else{
			int num = -1 ;
			for(int i = 62 ; i >= 0 ; i--){
				if((b & 1l << i) != 0 && ((~a) & (1l << i)) != 0){
					num = i;
					break;
				}
			}
			ans = 0;
			if(num!=-1) for(int i = 0 ; i <= num ; i ++){
				ans += 1l<<i;
			}
			System.out.println(ans);
	}
	}

}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.util.Scanner;


public class Main3 {

    
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        
        long l = s.nextLong();
        long r = s.nextLong();
        
        String a = Long.toBinaryString(l);
        String b = Long.toBinaryString(r);
        while(a.length() < b.length()) a = "0" + a;
        while(b.length() < a.length()) b = "0" + b;
        
        String ans = "";
        
        int ix = -1;
        for (int i = 0; i < a.length(); i++) {
            
            if(a.charAt(i) != b.charAt(i)){
                break;
            }
            ans += a.charAt(i);
            ix++;
        }
//      System.out.println(a);
//      System.out.println(b);
        for (int i = ix + 1; i < a.length(); i++) {
            int c1 = a.charAt(i) - '0';
            int c2 = b.charAt(i) - '0';
            if(c1 == 0 && c2 == 0) ans += "1";
            else if(c1 == 1 && c2 == 1) ans += "0";
            else ans += (char)(c1 + '0');
        }
        long a1 = Long.parseLong(ans, 2);
        long a2 = Long.parseLong(b,2);
//      System.out.println(ans);
//      System.out.println(b);
//      System.out.println();
        long xor = a1 ^ a2;
        System.out.println(xor);
    }

}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.util.Scanner;


public class d_169 {
public static void main(String[] args) {
	Scanner  sc = new Scanner(System.in);
	long x=sc.nextLong();
	long y=sc.nextLong();
	String s=Long.toBinaryString(x);
	String p=Long.toBinaryString(y);
	int id=p.length()-s.length();
	for (int i =1; i <=id; i++) {
		s="0"+s;
	}
	if(x==y){
		System.out.println(0);
		return;
	}
	for (int i = 0; i <p.length(); i++) {
		if(s.charAt(i)!=p.charAt(i)){
			System.out.println((long)Math.pow(2, s.length()-i)-1);
			return;
	}
}
}
}
// Problem: 276_D. Little Girl and Maximum XOR
// Time complexity: logn
import java.io.*;
import java.util.*;

public class D {
    public static void main(String[] args) throws IOException {
        new D().solve();
    }

    void solve() throws IOException {
        Scanner sc = new Scanner(System.in);
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] sp;

        long L = sc.nextLong();
        long R = sc.nextLong();
        if (L == R) {
            System.out.println(0);
        } else {
            System.out.println(Long.highestOneBit(R ^ L) * 2 - 1);
        }
    }
}

//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//