codeparrot/codecomplex huggingface dataset:
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.math.BigInteger;
import java.util.Scanner;
public class ehsan 
{
	public static BigInteger f(BigInteger m,BigInteger n){
		BigInteger s,l;
		s=n.multiply(m.add(BigInteger.valueOf(1)));
		l=m.multiply(m.add(BigInteger.valueOf(1)));
		l=l.divide(BigInteger.valueOf(2));
		s=s.subtract(l);
		s=s.subtract(m);
		return s;
	}
	public static BigInteger bs(BigInteger a,BigInteger b,BigInteger n,BigInteger d){
		BigInteger c,e;
		c=a.add(b);
		c=c.divide(BigInteger.valueOf(2));
		e=f(c,n);
		if(e.equals(d))
			return c.add(BigInteger.valueOf(1));
		if(a.equals(b.add(BigInteger.valueOf(-1))))
			return b.add(BigInteger.valueOf(1));
		if(e.compareTo(d)>0)
			return bs(a,c,n,d);
		return bs(c,b,n,d);
	}
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
  		BigInteger bi1 = sc.nextBigInteger();
  		BigInteger bi2 = sc.nextBigInteger();
		BigInteger i,n=bi2;
		BigInteger i2=BigInteger.valueOf(1);
		BigInteger sum=BigInteger.valueOf(0);
		if(bi1.compareTo(bi2)<0){
			System.out.println(0);
			return;
		}
		if(bi1.compareTo(bi2)==0){
			System.out.println(1);
			return;
		}
		bi2=((n.multiply(n.add(BigInteger.valueOf(1)))).divide(BigInteger.valueOf(2))).subtract(n.subtract(BigInteger.valueOf(1)));
		if(bi1.compareTo(bi2)>0)
			System.out.println(-1);
		else{
			System.out.println(bs(BigInteger.valueOf(0),n.add(BigInteger.valueOf(-2)),n,bi1));
		}
  }
}
// Problem: 287_B. Pipeline
// Time complexity: logn
/**
 * Created with IntelliJ IDEA.
 * User: yuantian
 * Date: 3/24/13
 * Time: 2:18 AM
 * Copyright (c) 2013 All Right Reserved, http://github.com/tyuan73
 */

import java.util.*;

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

        long n = in.nextLong();
        long k = in.nextLong();

        if (n == 1) {
            System.out.println(0);
            return;
        }
        if (k >= n) {
            System.out.println(1);
            return;
        }

        long total = (k + 2) * (k - 1) / 2 - (k - 2);
        if (total < n) {
            System.out.println(-1);
            return;
        }

        /**
         * non-binary search version, O(n)
         * it will failed because of "over time limit erro" on this case:
         *  499999998500000001 1000000000   => 999955279
         *
         total = 1;
         for(int i = (int)k; i >= 2; i--) {
         total += i - 1;
         if(total >= n) {
         System.out.println(k-i+1);
         return;
         }
         }
         */

        /**
         * binary search search version. O(lgn)
         */
        int i = 2, j = (int) k;
        while (i < j) {
            int m = (i + j + 1) / 2;
            total = (k + m) * (k - m + 1) / 2 - (k - m);
            if (total < n)
                j = m - 1;
            else
                i = m;
        }
        System.out.println(k - i + 1);
    }
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.io.IOException;
import java.util.Scanner;

public class TC
{
    static long N;
    static int k;
    static long WHOLESUM;
    
    static long SUM( long k )
    {
        long res=k*( k+1 )/2;
        return res-1;
    }
    
    static long returnPipes( int mid )
    {
        long not=SUM( mid-1 );
        long totpipes=WHOLESUM-not;
        int number=k-mid+1;
        long res=totpipes-number+1;
        return res;
    }
    
    static long binarySearch( int lo, int hi )
    {
        int res=Integer.MAX_VALUE;
        int val=0;
        while( lo <= hi )
        {
            int mid=( lo+hi )/2;
            long cnt=returnPipes( mid );
            val=k-mid+1;;
          
            if( cnt  < N )
            {
                hi=mid-1;
                continue;
            }
            else
            {
                res=Math.min( val, res );
                lo=mid+1;
            }
        }
        
        if( res==Integer.MAX_VALUE )
            return -1;
        else
            return res;
        
    }
    

    public static void main( String[] args ) throws IOException
    {
        Scanner s=new Scanner( System.in );
        N=s.nextLong();
        k=s.nextInt();
        WHOLESUM=SUM( k );
        if( N<=1 )
            System.out.println(0 );
        else
            System.out.println( binarySearch( 2, k ) );
    }
    
    
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Dzmitry Paulenka
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        long n = in.nextLong();
        long k = in.nextLong();
        if (n == 1) {
            out.println(0);
            return;
        }
        if (k * (k - 1) < 2 * (n - 1)) {
            out.println(-1);
            return;
        }

        long sq2 = 4 * k * k - 4 * k + 1 - 4 * (2 * n - 2);
        long km = Math.max(2, (long) ((Math.sqrt(sq2) + 3) / 2.0) - 3);
        while (((km + k - 2)*(k - km + 1) >= 2*(n-1))) {
            ++km;
        }
        out.println(k - km + 2);
    }
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.util.Locale;
import java.util.Scanner;

public class PipelineSolver {

    private long n;

    private long k;

    public static void main(String[] args) {
        PipelineSolver solver = new PipelineSolver();

        solver.readData();
        int solution = solver.solve();
        solver.print(solution);
    }

    private int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    private int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }

    private void print(int[] values) {
        StringBuilder builder = new StringBuilder();

        for (int value : values) {
            builder.append(value);
            builder.append(" ");
        }

        print(builder);
    }

    private void print(Object value) {
        System.out.println(value);
    }

    private void print(boolean value) {
        System.out.println(value ? "YES" : "NO");
    }

    private void print(int value) {
        System.out.println(value);
    }

    private void print(long value) {
        System.out.println(value);
    }

    private void print(double value) {
        System.out.printf(Locale.ENGLISH, "%.10f", value);
    }

    private int[] getDigits(int number) {
        int[] digits = new int[10];
        int index = digits.length - 1;
        int digitsCount = 0;

        while (number > 0) {
            digits[index] = number % 10;
            number /= 10;
            index--;
            digitsCount++;
        }

        int[] result = new int[digitsCount];

        System.arraycopy(digits, digits.length - digitsCount, result, 0, digitsCount);

        return result;
    }

    private int[] readArray(Scanner scanner, int size) {
        int[] result = new int[size];

        for (int i = 0; i < size; i++) {
            result[i] = scanner.nextInt();
        }

        return result;
    }

    private void readData() {
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextLong();
        k = scanner.nextLong();
    }

    private int solve() {

        if (n == 1) {
            return 0;
        }
        if (n <= k) {
            return 1;
        }
        int result;
        long l;

        long d = (5 - 2 * k) * (5 - 2 * k) - 4 * (2 * n - 4 * k + 4);
        if (d < 0)
        {
            result = -1;
        } else {
            l = Math.min(Math.max((int)((2 * k - 3 - Math.sqrt(d)) / 2), 0), Math.max((int)((2 * k - 3 + Math.sqrt(d)) / 2), 0));

            long difference = n - k * (l + 1) + l * (l + 3) / 2;

            if (l > k - 2) {
                result = -1;
            } else if (l == k - 2) {
                result = difference == 0 ? (int) (l + 1) : -1;
            } else {
                result = (int) (l + 1 + (difference == 0 ? 0 : 1));
            }
        }

        return result;
    }
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Dzmitry Paulenka
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        long n = in.nextLong();
        long k = in.nextLong();
        if (n == 1) {
            out.println(0);
            return;
        }
        if (k * (k - 1) < 2 * (n - 1)) {
            out.println(-1);
            return;
        }

        long sq2 = 4 * k * k - 4 * k + 1 - 4 * (2 * n - 2);
        double sqrt = Math.sqrt(sq2);
        long sq = (long) sqrt;
        if ((sq + 1) * (sq + 1) == sq2) {
            sq = sq + 1;
        } else if ((sq - 1) * (sq - 1) == sq2) {
            sq = sq - 1;
        }

        if (sq*sq == sq2) {
            long kmin = (sq + 3) / 2;
            out.println(k - kmin + 1);
        } else {
            long km = Math.max(2, (long) ((sqrt + 3) / 2.0) - 2);
            while (((km + k - 2)*(k - km + 1) >= 2*(n-1))) {
                ++km;
            }
            out.println(k - km + 2);
        }
    }
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import static java.lang.Math.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Character.*;

@SuppressWarnings("unused")
public class round176B {
    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 n = parseLong(next());
        long k = parseLong(next());
        if(n == 1){
            System.out.println(0);
            return;
        }
        if (n <= k) {
            System.out.println(1);
            return;
        }
        if ((((k * (k + 1)) / 2) - 1) - (k - 2) < n) {
            System.out.println(-1);
        } else {
            long lo = 1;
            long hi = k + 1;
            int best = Integer.MAX_VALUE;
            while (lo < hi) {
                long mid = lo + ((hi - lo) / 2);
                long first = ((mid * (2 + (2 + (mid - 1)))) / 2) - (mid - 1);
                long last = ((mid * (k - mid + 1 + k)) / 2) - (mid - 1);                
                if (n < first) {
                    hi = mid;
                } else {
                    if (n >= first && n <= last) {
                        hi = mid;
                        best = min(best, (int) mid);
                    } else
                        lo = mid + 1;
                }
            }
            System.out.println(best);
        }
    }
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Pipeline
// 2013/03/23
public class P287B{
	Scanner sc=new Scanner(System.in);

	long n, k;

	void run(){
		n=sc.nextLong();
		k=sc.nextLong();
		solve();
	}

	void solve(){
		long left=-1, right=k+1;
		for(; right-left>1;){
			long m=(left+right)/2;
			long ub=k*(k+1)/2-(k-m)*(k-m+1)/2-(m-1);
			if(ub>=n){
				right=m;
			}else{
				left=m;
			}
		}
		println(""+(right>k?-1:right));
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new P287B().run();
	}
}
// Problem: 287_B. Pipeline
// Time complexity: logn


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		long n = sc.nextLong();
		int k = sc.nextInt();
		
		if(n==1){
			System.out.println(0);
			return;
		}
		n=n-1;
		int count = 0;
		long nextK = k-1;
		while(true){
			//System.out.println("n = " + n);
			
			if(nextK < 1 || (nextK <= 1 && n >1)){
				System.out.println(-1);
				return;
			}
			
			nextK = Math.min(n, nextK);
			if(n==nextK){
				System.out.println(count+1);
				return;
			}
			//System.out.println("nextK = " + nextK);
			
			//search for a of a...nextK 
			long bSum = nextK * (nextK+1)/2;
			long a = nextK;
			long decrement = 1;
			while(bSum - (a-1)*a/2 <= n && a>=1){
				a-= decrement;
				decrement *= 2;
			}
			a+=decrement/2;
			
			//System.out.println("a = " + a);
			
			count += nextK-a+1;
			//System.out.println("count = " + count);
			long nDecr = bSum-a*(a-1)/2;
			//System.out.println("bSum = " + bSum);
			//System.out.println("nDecr = " + nDecr);
			n -= nDecr;
			nextK = a-1;
			if(n==0){
				System.out.println(count);
				return;
			}
		}
	}
	
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}
// Problem: 287_B. Pipeline
// Time complexity: logn
import	java.util.*;
public	class	Main{
	public	static	void	main(String[]args){
		Scanner	cin=new	Scanner(System.in);
		long	z=cin.nextLong()-1<<1,n=cin.nextInt(),l=-1,r=1+n,m;
		while(l<(m=l+r>>1))	if(z>(m+n-1)*(n-m))	r=m;else	l=m;
		if(0<l)	l=n-l;
		System.out.print(l);
	}
}
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF256B extends PrintWriter {
	CF256B() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF256B o = new CF256B(); o.main(); o.flush();
	}

	long count(int n, int x, int y, int r) {
		long a = 2L * r * r + 2 * r + 1;
		int w;
		if ((w = 1 - (x - r)) > 0)
			a -= (long) w * w;
		if ((w = 1 - (y - r)) > 0)
			a -= (long) w * w;
		if ((w = (x + r) - n) > 0)
			a -= (long) w * w;
		if ((w = (y + r) - n) > 0)
			a -= (long) w * w;
		if ((w = r - 1 - (x - 1) - (y - 1)) > 0)
			a += (long) w * (w + 1) / 2;
		if ((w = r - 1 - (x - 1) - (n - y)) > 0)
			a += (long) w * (w + 1) / 2;
		if ((w = r - 1 - (n - x) - (y - 1)) > 0)
			a += (long) w * (w + 1) / 2;
		if ((w = r - 1 - (n - x) - (n - y)) > 0)
			a += (long) w * (w + 1) / 2;
		return a;
	}
	void main() {
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int c = sc.nextInt();
		int lower = -1, upper = c;
		while (upper - lower > 1) {
			int r = (lower + upper) / 2;
			if (count(n, x, y, r) >= c)
				upper = r;
			else
				lower = r;
		}
		println(upper);
	}
}
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
import java.io.*;
import java.util.*;

public class B {

	final String filename = new String("B").toLowerCase();

	int n;
	int r, c;

	void solve() throws Exception {
		n = nextInt();

		r = nextInt() - 1;
		c = nextInt() - 1;
		long count = nextLong();

		long left = -1, right = n * 2L;

		while (left < right - 1) {
			long mid = (left + right) / 2;

			if (getSq(n, r, c, mid) >= count) {
				right = mid;
			} else {
				left = mid;
			}
		}
		
//		for (int i = 0; i <= 10; i++) {
//			System.err.println(getSq(n, r, c, i));
//		}
		
		out.println(right);
	}
	
	long getSq(int n, int x, int y, long size) {
		long cur = (size + 1) * (size + 1) + size * size;
		
		cur -= get(x + size - (n - 1));
		cur -= get(y + size - (n - 1));
		cur -= get(-(x - size));
		cur -= get(-(y - size));
		
		cur += getCorner((x + 1) + (y + 1) - (size + 1));
		cur += getCorner((x + 1) + (n - y) - (size + 1));
		cur += getCorner((n - x) + (y + 1) - (size + 1));
		cur += getCorner((n - x) + (n - y) - (size + 1));
		
		return cur;
	}
	
	private long getCorner(long min) {
		if (min >= 0) {
			return 0;
		}
		min = -min;
		return min * (min + 1) / 2;
	}

	long get(long a) {
		if (a <= 0) {
			return 0;
		}
		return a * a;
	}

	void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			// in = new BufferedReader(new FileReader("input.txt"));
			// out = new PrintWriter("output.txt");

			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

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

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

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

	double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

	public static void main(String[] args) {
		new B().run();
	}

}
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
import java.util.Scanner;
public class Problem {
    
    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        int side = input.nextInt()-1;
        int x = input.nextInt()-1;
        int y = input.nextInt()-1;
        long target = input.nextLong();
        
        
        int[] to_sides = {y, side - x, side - y, x};
        int[] to_corners = {(y+1)+(side-x+1),(side-x+1)+(side-y+1),(side-y+1)+(x+1),
            (x+1)+(y+1)};
        int min = Math.min(Math.min(y, x), Math.min(side - x, side - y));
        int[] after_pass = {1, 1, 1, 1};
        int[] corner_share = {1,1,1,1};
        int steps = 0 , i;
        long init = 1 ;
        int grown = 4;
        while (init < target) {
            init += grown;
            steps++;
            if (steps >= min) {
                for (i = 0; i < 4; i++) {
                    if (steps > to_sides[i]) {
                        init -= after_pass[i];
                        after_pass[i] += 2;
                    }
                    if (steps >= to_corners[i]){
                        init += corner_share[i]++;
                        //corner_share[i]++;
                    }
                }
            }
            grown += 4;
        }
        System.out.println(steps);
    }
}
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
import java.util.Scanner;


public class B {
	public static final boolean DEBUG = false;
	Scanner sc;
	
	public void debug(Object o) {
		if (DEBUG) {
			int ln = Thread.currentThread().getStackTrace()[2].getLineNumber();
			String fn = Thread.currentThread().getStackTrace()[2].getFileName();
			System.out.println("(" + fn + ":" + ln+ "): " + o);
		}
	}
	
	public void pln(Object o) {
		System.out.println(o);
	}
	
	long getNumber(int x, int y, int n, int m) {
		int n1 = Math.max(0, x + m - n);
		int n2 = Math.max(0, y + m - n);
		int n3 = Math.max(0, 1 - (x - m));
		int n4 = Math.max(0, 1 - (y - m));
		
		int n12 = Math.max(0, n1 + n2 - m - 1);
		int n23 = Math.max(0, n2 + n3 - m - 1);
		int n34 = Math.max(0, n3 + n4 - m - 1);
		int n41 = Math.max(0, n4 + n1 - m - 1);
		
//		debug(n1 + " " + n2 + " " + n3 + " " + n4);
//		debug(n12 + " " + n23 + " " + n34 + " " + n41);
		
		int m1 = m+1;
		long nr = 1 + ((long)m1)*m1*2 - m1*2;
		nr -= ((long)n1)*n1 + ((long)n2)*n2 + ((long)n3)*n3 + ((long)n4)*n4;
		nr += ((long)n12)*(n12+1)/2 + ((long)n23)*(n23+1)/2 + ((long)n34)*(n34+1)/2 + ((long)n41)*(n41+1)/2;
		
		return nr;
	}
	public void run() {
//		pln(getNumber(1, 1, 10000, 10000000));
//		pln(getNumber(1000, 1000, 1000, 1000000));
//		if (true) return;

		sc = new Scanner(System.in);		
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int c = sc.nextInt();
		
		if (c <= 1) {
			pln(0);
			return;
		}
		
		int ll = 0;
		int rr = 2*n+20;
		
		while(true) {
			int m = (ll+rr) / 2;
			if (getNumber(x, y, n, m) >= c) {
				rr = m;
			}
			else {
				ll = m;
			}
//			debug(ll + " " + rr);
			
			if (rr - ll < 3) {
				for (int m2=ll; m2<=rr; m2++) {
					if (getNumber(x, y, n, m2) >= c) {
						pln(m2);
						return;
					}
				}
			}
		}
		
	}
	public static void main(String[] args) {
		B t = new B();
		t.run();
	}
}
// Problem: 256_B. Mr. Bender and Square
// Time complexity: logn
//package codeforces.cf156;
import java.io.*;
import java.util.Arrays;

public class ProblemB {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    long[] readInts() throws IOException {
        String[] strings = reader.readLine().split(" ");
        long[] ints = new long[strings.length];
        for(int i = 0; i < ints.length; i++) {
            ints[i] = Long.parseLong(strings[i]);
        }
        return ints;
    }

    long foo(long a) {
        return a > 0 ? a * a : 0;
    }
    long boo(long a) {
        return a <= 0 ? 0 : a * (a + 1) / 2;
    }

    void solve() throws IOException {
        long[] tt = readInts();
        long n = tt[0];
        long x = tt[1];
        long y = tt[2];
        long c = tt[3];
        long lo = -1, hi = 2 * 1000 * 1000 * 1000 + 2;
//        hi = 5;
        while(hi - lo > 1) {
            long m = (lo + hi) / 2;
            long s = 2 * m * m + 2 * m + 1;
            s -= foo(m - x + 1) + foo(m - y + 1) + foo(x + m - n) + foo(y + m - n);
            s += boo(m + 1 - (n + 1 + n + 1 - x - y)) + boo(m + 1 - (n + 1 - x + y)) + boo(m + 1 - (n + 1 - y + x))
                    + boo(m + 1 - (x + y));
            if(s < c) lo = m;
            else hi = m;
        }
        writer.println(hi);
        writer.flush();
    }

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