codeparrot/codecomplex huggingface dataset:
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BSportMafia {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();
            long b = 2 * n + 3;
            long c = n * n - 2 * k + n;
            long d = b * b - 4 * c;
            long val = (b - (long) Math.sqrt(d)) / 2;

            out.println(val);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class CF1195B {

    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
    private static StringTokenizer st;

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(reader.readLine());
        long n = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        long put = (-3 + (long)Math.sqrt((long)9 + 8 * k + 8 * n)) / 2;
        long eat = n - put;
        writer.write(Long.toString(eat));
        writer.newLine();
        writer.flush();
    }

}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.io.*;
public class cf5722{
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		long n=Long.parseLong(st.nextToken());
		long k=Long.parseLong(st.nextToken());
		
		long ans=((-3-(long)Math.sqrt(9+4*(1*2*(n+k))))/2);
		long ans1=((-3+(long)Math.sqrt(9+4*(1*2*(n+k))))/2);
		if(ans>0)
			System.out.println(n-ans);
		else{
			System.out.println(n-ans1);
		}


	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.lang.Math; 

public class Main{   
	
	public static void main(String[] args){ 
		Scanner ak=new Scanner(System.in);
		long n,k,x;
		n=ak.nextLong();
		k=ak.nextLong();
		x=(long)((-3+Math.sqrt(9+8*(n+k)))/2);
		System.out.println(n-x);
	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.io.*;

public class candies {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int actions = file.nextInt();
		int left = file.nextInt();
		int start = 0;
		int c = 1;
		while (true) {
			start += c;
			if (c + (start - left) == actions) break;
			c++;
		}
		System.out.println(start - left);
	}

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

}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
// CodeForces Round #914 B train done

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SportMafia {
	
	int n,k;
	int nCand;

	private void readData(BufferedReader bin) throws IOException {
		String s = bin.readLine();
		String []ss = s.split(" ");
		n = Integer.parseInt(ss[0]);
		k = Integer.parseInt(ss[1]);
	}

	void printRes() {
		System.out.println(nCand);
	}	
	
	private void calculate() {
		// count napitki
		double p;
		p = -1.5 + Math.sqrt(2.25 + 2.0*(n+k));
		nCand = (int)Math.round(n-p);
	}
	
	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(
				new InputStreamReader(System.in));
		SportMafia l = new SportMafia();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
    static int inf = (int) 1e9;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        int n = nextInt();
        int k = nextInt();
        long l = -1;
        long r = 100000;
        while(l != r - 1) {
            long mid = (l + r) / 2;
            if (mid * (mid + 1) / 2 - (n - mid) > k) r = mid;
            else l = mid;
        }
        pw.println(n - l);
        pw.close();
    }

    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");
    static PrintWriter pw;

    static String next() throws IOException {
        while (!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    static Double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.Scanner;

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

    long res = solve(n, k);
    System.out.println(res);
  }

  private static long solve(long n, long k) {
    return solveEq(1, -3 - 2 * n, n * n + n - 2 * k);
  }

  private static long solveEq(long a, long b, long c) {
    long delta = b * b - 4 * a * c;
    return (-b - (long)Math.sqrt(delta)) / (2 * a);
  }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*; 
import java.util.*; 


public class b{
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

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

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

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

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

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

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}

	public static void main(String[] args) 
	{ 
        FastReader sc = new FastReader(); 
        //PrintWriter out = new PrintWriter(System.out); 
        double n = (double)sc.nextLong();
        double k = (double)sc.nextLong();
        
        double div = 9+8*n+8*k;
        double ss = Math.sqrt(div);
        //System.out.println(ss);

        ss =  (ss-3)/2;
        System.out.println( (int)(n-ss) );
	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    static int n, k;

    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        n = sc.nextInt();
        k = sc.nextInt();
        long l = 0;
        long r = n + 1;
        while (l + 1 != r) {
            long m = (r + l) / 2;
            if (check(m))
                l = m;
            else
                r = m;
        }
        pw.print(l * (l + 1L) / 2L - k);
        pw.close();
    }

    public static boolean check(long m) {
        return m * (m + 1) / 2 - (n - m) <= k;
    }
}

class FastScanner {
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");

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

    public String next() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.io.*;
import java.text.*;
public class B1195 {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long x =sc.nextInt();
		long y =sc.nextInt();
		long m = (-3+Math.round(Math.sqrt(9+8*(x+y))))/2;
		long e = x-m;
		pw.println(e);
		pw.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni(),k=ni();
        int puts=(int)Math.sqrt(2*k);
        int t=(puts*(puts+1))/2;
        puts++;
        while (t<k) { t+=puts; puts++; }
        
        int turns=puts-1;
        while (t-k!=n-turns) {
            t+=puts;
            puts++;
            turns++;
        }
        System.out.println(t-k);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.io.*;

public class R574B
{

	public static void main(String[] args)
	{
		JS scan = new JS();
		long n = scan.nextInt();
		long put = 1;
		long k = scan.nextInt();
		long have = 0;
		long moves = 0;
		while(have < k) {
			have += put;
			put++;
			moves++;
		}
		
		long ans = 0;
		moves += have-k;
		ans += have-k;
		long lo = 0;
		long hi = n-moves;
		long bs = 0;
		while(lo <= hi) {
			//could she have eaten mid candies?
			long mid = (lo+hi)/2;
			long left = (n-moves)-mid+put-1;
			long rr = tri(left)-tri(put);
			
			if(rr <= mid) {
				bs = mid;
				hi = mid-1;
			}
			else {
				lo = mid+1;
			}
		}
		System.out.println(ans+bs);
	}
	
	static long tri(long n) {
		return n*(n-1)/2;
	}
	
	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}				
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn

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

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

		StringTokenizer st = new StringTokenizer(sc.nextLine());
		long n = Integer.parseInt(st.nextToken());
		long k = Integer.parseInt(st.nextToken());
		long put = n / 2;
		long lower = 0;
		long upper = n;
		while (put * (put + 1) / 2 - (n - put) != k) {
			if (put * (put + 1) / 2 - (n - put) > k) {
				upper = put - 1;
				put = (lower + upper) / 2;
			} else {
				lower = put + 1;
				put = (lower + upper) / 2;
			}
		}
		System.out.println(n - put);

		sc.close();
	}
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn



import java.util.*;

public class Temppp {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
       
        long ans = (long) ((java.lang.Math.sqrt((9+(8*(n+k))))-3)/2);
        System.out.println(n-ans);
        
    }
    
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.util.*;
import java.lang.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
 
public class Main {
    
    public static void main(String[] args) throws Exception{
        FastReader sc=new FastReader(); 
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Main mm=new Main();
        long n=sc.nextLong();
        long k=sc.nextLong();
        long l=0;
        long r=1000000000;
        long ans=-1;
        while(l<=r) {
            long mid=(l+r)/2;
            if(n-mid<=0) {
                r=mid-1;
            }
            else {
                long temp=(n-mid)*(n-mid+1)-(2*mid);
                if(temp==2*k) {
                    ans=mid;
                    break;
                }
                else if(temp<2*k) {
                    r=mid-1;
                }
                else if(temp>2*k) {
                    l=mid+1;
                }
            }
        }
        System.out.println(ans);
    }  
}


class FastReader 
{ 
    BufferedReader br; 
    StringTokenizer st; 
 
    public FastReader() 
    { 
        br = new BufferedReader(new
                 InputStreamReader(System.in)); 
    } 
 
    String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
 
    int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 
 
    long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 
 
    double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 
 
    String nextLine() 
    { 
        String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;

public class B {
    final int INF = 1_000_000_000;
    void solve() {
        int n = readInt();
        int k = readInt();
        long l = 0;
        long r = INF;
        while(r - l > 1){
            long m = (r + l) >> 1;
            if(m * (m + 1) / 2 + m >= k + n) r = m;
            else l = m;
        }
        out.print(n - r);
    }

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

    private void run() {
        try {
            init();
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private BufferedReader in;
    private StringTokenizer tok = new StringTokenizer("");

    private PrintWriter out;

    private void init() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

//        try {
//            in = new BufferedReader(new FileReader("absum.in"));
//            out = new PrintWriter(new File("absum.out"));
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
    }

    private String readLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String readString() {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken();
    }

    private int readInt() {
        return Integer.parseInt(readString());
    }

    private long readLong() {
        return Long.parseLong(readString());
    }

    int[] readIntArray(int n){
        int[] res = new int[n];
        for(int i = 0;i<n;i++){
            res[i] = readInt();
        }
        return res;
    }

    long[] readLongArray(int n){
        long[] res = new long[n];
        for(int i = 0;i<n;i++){
            res[i] = readLong();
        }
        return res;
    }

    int[] castInt(List<Integer> list){
        int[] res = new int[list.size()];
        for(int i = 0;i<list.size();i++){
            res[i] = list.get(i);
        }
        return res;
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        long k = scan.nextLong();
        long D = 9 + 4 * (2 * k + 2 * n);
        long y = (- 3 + (long)Math.sqrt(D)) / 2;
        System.out.println(n - y);
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
/**
 * @Author Tran Quang Loc (darkkcyan)
 * BEFORE READING CODE:
 * Java is really lengthy (at least for Java 8). So I used the advantage of initialization block.
 * Basically, every initialization block run before the constructor and they run in the declaration order.
 * And as I understand, every properties (or global variables) is also counted as initialization block.
 */
import java.io.*;
import java.lang.*;
import java.util.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.*;
import static java.lang.System.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out, false);
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer stok = null;
    String next() {
        while (stok == null || !stok.hasMoreTokens())
            try {
                stok = new StringTokenizer(in.readLine());
            } catch (IOException e) { throw new RuntimeException(e); }
        return stok.nextToken();
    }

    public static void main(String args[]) throws IOException {
        if (args.length > 0) {
            setIn(new FileInputStream(args[0] + ".inp"));
            setOut(new PrintStream(args[0] + ".out"));
        }
        Main solver = new Main();
        solver.out.flush();  //  could be replace with a method, but nah, this is just competitive programming :p
    }

    ///// Actual solution below /////

    long n = parseLong(next()), k = parseLong(next());
    long delta = 9 + 8 * (n + k);
    long a = (-3 + (long)sqrt(delta)) / 2;
    long b = n - a;
    {
        out.println(b);
    }
}
// Problem: 1195_B. Sport Mafia
// Time complexity: logn
import java.io.*;

public class Alpha_Round {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] in = reader.readLine().split(" ");
        long n = Long.parseLong(in[0]);
        long k = Long.parseLong(in[1]);
        long D = 9 + 8*k + 8*n;
        long m = (long) ((-3 + Math.sqrt(D))/2);
        writer.write((n - m) + "");
        writer.close();
    }
}