Muennighoff/xP3x-sample huggingface dataset:
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A implements Runnable {
    private void solve() throws IOException {
        String str = nextToken();
        for (int i=str.length()-1; i>=0; --i)
            for (int j=0; j+i<=str.length(); ++j)
                if (str.substring(j+1).contains(str.substring(j, j+i))) {
                    writer.println(i);
                    return;
                }
        writer.println(0);
    }

    public static void main(String[] args) {
        new Thread(new A()).start();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
} What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
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
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
        ArrayList<Integer>[] g;
        int n, m;
        boolean[][] have;
        int[] x;
        int[] y;
        boolean[] used;
        int stop;
        

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
                n = in.nextInt();
                g = new ArrayList[n];
                for (int i = 0; i < n; i++)
                        g[i] = new ArrayList<>();
                have = new boolean[n][n];
                m = in.nextInt();
                for (int i = 0; i < m; i++) {
                        int a = in.nextInt();
                        int b = in.nextInt();
                        --a;
                        --b;
                        g[a].add(b);
                        have[a][b] = true;
                }
                int res = Integer.MAX_VALUE;
                for (int center = 0; center < n; center++)
                        res = Math.min(res, solve(center));
                out.print(res);
        }

        int solve(int v) {
                stop = v;
                int withV = 0;
                int add = 0;
                for (int i = 0; i < n; i++)
                        if (i != v)
                                if (have[v][i])
                                        withV++;
                                else
                                        add++;
              ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: cubic
inputs: import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class A {

    int INF = 1 << 28;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long[] chores = new long[n];
        for(int i=0;i<n;i++) chores[i] = sc.nextLong();
        sort(chores);
        System.out.println(chores[b]-chores[b-1]);
    }

    public static void main(String[] args) {
        new A().run();
    }
}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: nlogn
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class ASimpleTask {

	static StreamTokenizer st;

	static int nextInt() {
		try {
			st.nextToken();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return (int) st.nval;
	}

	static int[][] edges;
	static long[][] dp;

	public static void main(String[] args) {
		st = new StreamTokenizer(new BufferedReader(new InputStreamReader(
				System.in)));

		int n = nextInt();
		int m = nextInt();

		edges = new int[n][n];

		for (int i = 0; i < m; i++) {
			int from = nextInt() - 1;
			int to = nextInt() - 1;
			edges[from][to] = edges[to][from] = 1;
		}

		dp = new long[(1 << n) + 1][n + 1];

		for (int mask = 1; mask < (1 << n); mask++) {
			for (int i = 0; i < n; i++) {
				if (Integer.bitCount(mask) == 1 && (mask & (1 << i)) != 0) {
					dp[mask][i] = 1;
					continue;
				}

				if (Integer.bitCount(mask) > 1 && (mask & (1 << i)) != 0
						&& first(mask, n) != i) {
					for (int j = 0; j < n; j++) {
						if (edges[i][j] == 1) {
							dp[mask][i] += dp[mask ^ (1 << i)][j];
						}
					}
				}
			}
		}

		long count = 0;
		for (int mask = 1; mask < (1 << n); mask++) {
			for (int i = 0; i < n; i++) {
				if (Integer.bitCount(mask) >= 3
						&& edges[i][first(mask, n)] != 0)
					count += dp[mask][i];
			}
		}

		System.out.println(count / 2);

	}

	static int first(int mask, int n) {
		for (int i = 0; i < n; i++) {
			if ((mask & (1 << i)) != 0)
				return i;
		}
		return -1;
	}

}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: np
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;
public class E16 {
	static double[][] grid;
	public static void main(String[] args) throws IOException	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		grid = new double[n][n];
		for(int i = 0; i < n; i++)	{
			StringTokenizer st = new StringTokenizer(br.readLine());
			for(int j = 0; j < n; j++)	{
				grid[i][j] = Double.parseDouble(st.nextToken());
			}
		}
		boolean[] seen = new boolean[1<<n];
		double[] prob = new double[1<<n];
		prob[(1<<n)-1] = 1;
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.add((1<<n)-1);
		while(!q.isEmpty())	{
			int curr = q.removeFirst();
			if(Integer.bitCount(curr) == 1)
				continue;
			for(int i = 0; i < n; i++)	{
				if((curr & (1 << i)) == 0)
					continue;
				for(int j = i+1; j < n; j++)		{
					if((curr & (1<<j)) == 0)
						continue;
					prob[curr-(1<<i)] += prob[curr] * grid[j][i];
					prob[curr-(1<<j)] += prob[curr] * grid[i][j];
					if(!seen[curr-(1<<i)])	{
						q.addLast(curr-(1<<i));
						seen[curr-(1<<i)] = true;
					}
					if(!seen[curr-(1<<j)])	{
						q.addLast(curr-(1<<j));
						seen[curr-(1<<j)] = true;
					}
				}
			}
			prob[curr] = 0;
		}
		double sum = 0;
		for(int i = 0; i < n; i++)		{
			sum += prob[1<<i];
		}
		for(int i = 0; i < n-1; i++)	{
			System.out.print(prob[1<<i]/sum + " ");
		}
		System.out.println(prob[1<<(n-1)]/sum);
	}
}
 Complexity:
targets: np
inputs: import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class C {


	static ArrayList<Integer> statements;
	static final int MOD = (int) 1e9 + 7;

	static int[][] memo;

	static int solve(int i, int c) {
		if(i == statements.size())
			return 1;
		if(memo[i][c] != -1)
			return memo[i][c];

		long ans = solve(i + 1, c + statements.get(i));
		if(c > 0)
			ans += solve(i, c - 1);
		return memo[i][c] = (int) (ans % MOD);

	}

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

		int n = sc.nextInt();
		statements = new ArrayList<>();

		char[] c = new char[n];
		for (int i = 0; i < n; i++) {
			c[i] = sc.next().charAt(0);
		}

		if(c[0] == 's')
			statements.add(0);
		else
			statements.add(1);

		for (int i = 1; i < n; i++) {
			if(c[i - 1] == 'f') {
				if(c[i] == 'f')
					statements.set(statements.size() - 1, statements.get(statements.size() - 1) + 1);
			}else {

				if(c[i] == 's')
					statements.add(0);
				else
					statements.add(1);
			}
		}


		memo = new int[statements.size()][n + 1];

		for(int[] a : memo)
			Arrays.fill(a, -1);
		out.println(solve(0, 0));
		out.flush();
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		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... What is the time complexity of the previous code?
targets: quadratic
inputs: //package round136;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class A2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0;i < n;i++)b[i] = a[i] = ni();
		
		b = radixSort(b);
		int ct = 0;
		for(int i = 0;i < n;i++){
			if(a[i] != b[i])ct++;
		}
		if(ct <= 2){
			out.println("YES");
		}else{
			out.println("NO");
		}
	}
	
	public static int[] radixSort(int[] f)
	{
		int[] to = new int[f.length];
		{
			int[] b = new int[65537];
			for(int i = 0;i < f.length;i++)b[1+(f[i]&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < f.length;i++)to[b[f[i]&0xffff]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < f.length;i++)b[1+(f[i]>>>16)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < f.length;i++)to[b[f[i]>>>16]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		return f;
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception
	{
		new A2().run();
	}
	
	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num ==... What is the time complexity of the previous code?
targets: nlogn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 
import java.util.Scanner;


public class CodeForces {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int k = sc.nextInt();
        int ans = 0;
        long x = n;
        x = x*(x+1)/2;
        while (x!=k) {
            x-=n;
            n--;
            ans++;
            k++;
        }
        System.out.println(ans);
    }
}
 Complexity:
targets: logn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;

public class a{
    static BufferedReader br;
    static PrintWriter pw;
    static int N, M, K;
    static ArrayList<Integer> graph[][];
    public static void main(String args[]) throws IOException{
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());
        N = Integer.parseInt(st.nextToken());
        M = Integer.parseInt(st.nextToken());
        K = Integer.parseInt(st.nextToken());
        if(K % 2 == 1){
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    pw.print("-1 ");
                }
                pw.println();
            }
            br.close(); pw.close();
            return;
        }
        graph = new ArrayList[N][M];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                graph[i][j] = new ArrayList<Integer>();
            }
        }
        for(int i = 0; i < N; i++){
            st = new StringTokenizer(br.readLine());
            for(int j = 0; j < M-1; j++){
                int w = Integer.parseInt(st.nextToken());
                graph[i][j].add(w);
            }
        }
        for(int i = 0; i < N; i++){
            graph[i][M-1].add(0);
        }
        for(int i = 0; i < N-1; i++){
            st = new StringTokenizer(br.readLine());
            for(int j = 0; j < M; j++){
                int w = Integer.parseInt(st.nextToken());
                graph[i][j].add(w);
            }
        }
        K /= 2;
        for(int i = 0; i < M; i++) graph[N-1][i].add(0);
        long ans[][][] = new long[K+1][N][M];
        for(int i = 0; i < N; i++){
            Arrays.fill(ans[0][i], 0);
        }
        for(int i = 1; i <= K; i++){
            for(int x = 0; x < N; x++){
                for(int y = 0; y < M; y++){
                    long cur = (long)1e17;
                    if(x < N-1){
                        cur =... Complexity:
targets: cubic
inputs: import java.util.Arrays;
import java.util.Scanner;

public class Solution {

    private static int[] a;

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

        int n = sc.nextInt(), m = sc.nextInt();

        a = new int[101];
        for (int i = 0; i < m; i++) {
            int type = sc.nextInt();
            a[type] = a[type] + 1;
        }

        int lo=1, hi=100, max=0;

        while (lo <= hi) {
            int mid = lo + (hi - lo)/2;
            if (check(n, mid)) {
                max = mid;
                lo = mid+1;
            } else {
                hi = mid -1;
            }
        }
        System.out.println(max);
    }

    public static boolean check(int n, int target) {
        int result = 0;
        for (int i=0; i <a.length; i++) {
            result = result + (a[i] / target);
        }
        if (result >= n) {return true;}
        return false;
    }
} Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: nlogn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        BPhoenixAndPuzzle solver = new BPhoenixAndPuzzle();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class BPhoenixAndPuzzle {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            if (n % 2 == 1) {
                out.println("NO");
                return;
            }
            n /= 2;
            if (n == 1 || (int) Math.sqrt(n) * (int) (Math.sqrt(n)) == n) {
                out.println("YES");
            } else {
                if (n % 2 == 0) {
                    n /= 2;
                    if ((int) Math.sqrt(n) * (int) (Math.sqrt(n)) == n) {
                        out.println("YES");
                        return;
                    }
                }
                out.println("NO");
            }
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())... Complexity:
targets: linear
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.Scanner;

public class SportMafia {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int next = 1;
		int current = 0;
		int result = 0;
		
		for(int i = 0; i < n; i++) {
			if(current < k) {
				current += next++;
			} else {
				current--;
				result++;
			}
		}
		
		System.out.println(result);
		
		sc.close();
	}
}
 Complexity:
targets: logn
inputs: import java.util.Scanner;

public class ChainReaction {
	
	public static void main(String [] args) {
		Scanner kb = new Scanner(System.in);
		int num = kb.nextInt();
		
		int[] beacons = new int[1000002];
		for (int i=0; i<num; i++) {
			beacons[kb.nextInt()] = kb.nextInt();
		}
		
		int [] dp = new int[1000002];
		int max = 0;
		if (beacons[0] != 0)
			dp[0] = 1;
		
		for (int i=1; i<dp.length; i++) {
			if (beacons[i] == 0) {
				dp[i] = dp[i-1];
			} else {
				int index = i-1-beacons[i];
				if (index<0)
					dp[i] = 1;
				else
					dp[i] = 1 + dp[index];
			}
			max = Math.max(max, dp[i]);
			//if (i<11)
				//System.out.println(i +" is "+dp[i]);
		}
		
		System.out.println(num-max);
	}

}
 Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: linear
inputs: import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class ques3 {
	static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                        numChars = stream.read(buf);
                } catch (IOException e) {
                        throw new InputMismatchException();
                }
                if (numChars <= 0) {
                        return -1;
                }
            }
            return buf[curChar++];
        }
 
        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }
 
        public interface SpaceCharFilter {
 
            public boolean isSpaceChar(int ch);
        }
 
        public String next() {
            return nextString();
        }
        
        public char nextChar(){
        	int c=read();
        	while (isSpaceChar(c)) {
                c = read();
            }
        	return (char)c;
        }
 
        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
 
        public int... What is the time complexity of the previous code?
targets: logn
inputs: import java.io.*;
import java.util.*;
 
public class digits {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long k = Long.parseLong(br.readLine());
        long temp = 9 * (int)Math.pow(10,0);
        int count = 0;
        long initial = 0;
        while(k > temp) {
            count++;
            initial = temp;
            temp += 9 * (long)Math.pow(10,count)*(count+1);
        }
        long index = (k-initial-1)%(count+1);
        long num = (long)Math.pow(10,count) + (k-initial-1)/(count+1);
        System.out.println((num+"").charAt((int)index));
    }
} What is the time complexity of the previous code?
targets: logn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class A {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
		int len=s.length();
		int ans=0;
		for (int i=0;i<len-1;i++) {
			for (int j=i+1;j<len;j++) {
				int score=0;
				boolean flag=true;
				for (int k=0;k+j<len && flag;k++) {
					if (s.charAt(i+k)==s.charAt(j+k)) {
						score++;
					} else {
						flag=false;
					}
				}
				if (score>ans) {
					ans=score;
				}
			}
		}
		System.out.println(ans);
	}
}
 Complexity:
targets: cubic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. //package round718;

import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Queue;

public class D2 {
	InputStream is;
	FastWriter out;
	String INPUT = "";//2 5 9 9 9 9 9 8 8 8 8 5 6 7 8 9";

	void solve()
	{
		int n = ni(), m = ni(), K = ni();
		int[][] a = new int[2*n+1][2*m+1];
		for(int i = 0;i < n;i++){
			int[] u = na(m-1);
			for(int j = 0;j < m-1;j++){
				a[2*i][2*j+1] = u[j];
			}
		}
		for(int i = 0;i < n-1;i++){
			int[] u = na(m);
			for(int j = 0;j < m;j++){
				a[2*i+1][2*j] = u[j];
			}
		}
		if(K % 2 == 1){
			for(int i = 0;i < n;i++){
				for(int j = 0;j < m;j++){
					out.print(-1 + " ");
				}
				out.println();
			}
			return;
		}

		int[][][] dp = new int[K/2+1][n][m];
		int[] dr = {1, 0, -1, 0};
		int[] dc = {0, 1, 0, -1};
		for(int i = 1;i <= K/2;i++){
			for(int j = 0;j < n;j++){
				for(int k = 0;k < m;k++){
					dp[i][j][k] = Integer.MAX_VALUE;
					for(int l = 0;l < 4;l++){
						int jj = j + dr[l], kk = k + dc[l];
						if(jj >= 0 && jj < n && kk >= 0 && kk < m){
							dp[i][j][k] = Math.min(dp[i][j][k], dp[i-1][jj][kk] + a[j+jj][k+kk]);
						}
					}
				}
			}
		}

		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				out.print(dp[K/2][i][j] * 2 + " ");
			}
			out.println();
		}
	}
	
	void run() throws Exception
	{
//		int n = 500, m = 500;
//		Random gen = new Random();
//		StringBuilder sb = new StringBuilder();
//		sb.append(n + " ");
//		sb.append(n + " ");
//		sb.append(20 + " ");
//		for (int i = 0; i < n; i++) {
//			for(int j = 0;j < m-1;j++) {
//				sb.append(gen.nextInt(200000) + " ");
//			}
//		}
//		for (int i = 0; i < n-1; i++) {
//			for(int j = 0;j < m;j++) {
//				sb.append(gen.nextInt(200000) + " ");
//			}
//		}
//		INPUT = sb.toString();


		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new FastWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void... Complexity:
targets: cubic
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import static java.lang.Math.*;
import java.util.*;
import java.util.function.*;
import java.lang.*;

public class Main {
    final static boolean debug = false;
    final static String fileName = "";
    final static boolean useFiles = false;

    public static void main(String[] args) throws FileNotFoundException {
        long start;
        if (debug)
            start = System.nanoTime();
        InputStream inputStream;
        OutputStream outputStream;
        if (useFiles) {
            inputStream = new FileInputStream(fileName + ".in");
            outputStream = new FileOutputStream(fileName + ".out");
        } else {
            inputStream = System.in;
            outputStream = System.out;
        }
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        if(debug)
            out.println((System.nanoTime() - start) / 1e+9);
        out.close();
    }
}
class Task {
    int[][] dist, pre;
    int[] x, y, d, prev;
    String[] leafDescription;
    String[] linerDescription;
    String[][] allDescriptions;
    int xs, ys, n;

    int dist(int i, int j) {
        return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
    }

    void go(int[] prev, String[] leafDescription, int[] d, int len, int add, String description){
        for (int mask = 0; mask < d.length; mask++) {
            if ((mask & add) != add)
                continue;
            int newValue = d[mask & (~add)] + len;
            if (d[mask] > newValue){
                d[mask] = newValue;
                leafDescription[mask] = description;
                prev[mask] = mask & (~add);
            }
        }
    }

    int rec(int mask) {
        if (d[mask] != -1)
            return d[mask];
        int lowest = 0;
        for (; ((1 << lowest) & mask) == 0; lowest++) ;

        int newMask = mask & (~(1 << lowest));
        d[mask] = rec(newMask) + dist[lowest][n];
    ... Complexity:
targets: np
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int T=fs.nextInt();
		for (int tt=0; tt<T; tt++) {
			int n=fs.nextInt();
			boolean isEven=n%2==0;
			while (n%2==0) n/=2;
			if (isSquare(n) && isEven) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
	
	static boolean isSquare(long n) {
		long sqrt=(long) Math.sqrt(n);
		for (int i=(int) Math.max(1, sqrt-5); i<=sqrt+5; i++)
			if (i*i==n)
				return true;
		return false;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}
 Complexity:
targets: linear
inputs: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class MainC {

    private FastScanner in;
    private PrintWriter out;

    private int N;
    private Dist[] dists;
    private int countDists;
    private int[][] minLeft;// startsFrom, count

    private int[] minOrder;
    private int minOrderCount = 10000000;

    public void solve() throws IOException {
        int xb = in.nextInt();
        int yb = in.nextInt();
        N = in.nextInt();
        int[] x, y;
        boolean isOdd;
        if (N % 2 == 0) {
            x = new int[N];
            y = new int[N];
            isOdd = false;
        }
        else {
            x = new int[N + 1];
            y = new int[N + 1];
            isOdd = true;
        }
        for (int i = 0; i < N; i++) {
            x[i] = in.nextInt() - xb;
            y[i] = in.nextInt() - yb;
        }
        if (N % 2 == 1) {
            N++;
            x[N - 1] = 0;
            y[N - 1] = 0;
        }

        countDists = N * (N - 1) / 2;
        dists = new Dist[countDists];
        int c = 0;
        int commonSum = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                dists[c] = new Dist();
                dists[c].from = i;
                dists[c].to = j;
                dists[c].dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j])
                                * (y[i] - y[j]);
                dists[c].dist = Math.min(dists[c].dist, x[i] * x[i] + y[i]
                                * y[i] + x[j] * x[j] + y[j] * y[j]);
                c++;
            }
            commonSum += x[i] * x[i] + y[i] * y[i];
        }

        Arrays.sort(dists);

        minLeft = new int[countDists][N + 1];
        for (int i = 0; i < countDists; i++) {
            int sum = 0;
            for (int j = 1; j <= N; j++) {
                if (i + j - 1 < countDists) {
   ... What is the time complexity of the previous code?
targets: np
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. 
import java.util.*;
import java.lang.Math.*;

public class Main {
	static Scanner in = new Scanner(System.in);
	static Coor[] p;
	static Coor ori;
	static int n;
	static int dp[];
	static Coor pre[];
	public static void main(String[] args) {
		ori = new Coor(in.nextInt(),in.nextInt());
		n = in.nextInt();
		p = new Coor[n];
		dp = new int[1<<n];
		pre = new Coor[1<<n];
		for (int i = 0;i < n;i++) {
			p[i] = new Coor(in.nextInt(),in.nextInt());
		}
		Arrays.fill(dp,-1);
		dp[0] = 0;
		System.out.println( getdp((1<<n)-1));
		//System.out.printf("%d",0);
		System.out.printf("%d",0);
		trace((1<<n)-1);
		System.out.println();
	}
	static void trace(int mask) {
		if (mask == 0) return;
		if (pre[mask].y == -1) {
			System.out.printf(" %d %d",pre[mask].x+1,0);
			trace( mask - ( 1<< pre[mask].x ) );
		} else {
			System.out.printf(" %d %d %d",pre[mask].x+1,pre[mask].y+1,0);
			trace( mask - ( 1<< pre[mask].x ) - (1<<pre[mask].y));
		}
	}
	static int getdp(int mask) {
		if (dp[mask] != -1) 
			return dp[mask];
		int fr = 0;
		for (int i = 0;i < n;i++) 
			if ( (mask & (1 << i)) != 0 ) {
				fr = i;
				break;
			}
		dp[mask] = getdp( mask - (1 << fr) ) + 2 * p[fr].dist(ori);
		pre[mask] = new Coor(fr,-1);
		for (int i = fr+1;i < n;i++) {
			int to = i;
			if ( (mask & (1 << i)) != 0) {
				int tmp = getdp( mask - (1<<fr) - (1<<i) ) + p[fr].dist(ori) + p[to].dist(ori) + p[fr].dist(p[to]);
				if (tmp < dp[mask]) {
					dp[mask] = tmp;
					pre[mask].y = i;
				}
			}
		}
		return dp[mask];
	}
}

class Coor {
	int x,y;
	Coor(int _x,int _y) {
		x = _x;y = _y;
	}
	int dist(Coor o) {
		return ( (x-o.x) * (x-o.x) + (y-o.y) * (y-o.y) );
	}
}
 Complexity:
targets: np
inputs: import java.io.*;
import java.util.*;

public class SolutionB {
   BufferedReader in;
   StringTokenizer str;
   PrintWriter out;
   String SK;
   String next() throws IOException {
      while ((str == null) || (!str.hasMoreTokens())) {
         SK = in.readLine();
         if (SK == null)
              return null;
         str = new StringTokenizer(SK);
      }
      return str.nextToken();
   }
   int nextInt() throws IOException {
      return Integer.parseInt(next());
   }
   double nextDouble() throws IOException {
      return Double.parseDouble(next());
   }
   long nextLong() throws IOException {
      return Long.parseLong(next());
   }
   char[] charArray() throws IOException{
      return next().toCharArray();
   }
   public static void main(String[] args) throws IOException {
      new SolutionB().run();
   }
   void run() throws IOException {
      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();
   }
   void solve() throws IOException {
      //out.println(Long.MAX_VALUE);
      long n = nextLong();
      long k = nextLong();
      long m=num1(k);
      if(m<n){
         out.println(-1);
         return;
      }
      if(m==n){
         out.println(k-1);
         return;
      }
      long ans=binS(n,k);
      out.println(k-ans);
   }
   long num1(long k){
      long r=k*(k+1)/2-1;
      r=r-(k-2);
      return r;
   }
   long num2(long k){
      return num1(k)-1;
   }
   long binS(long n, long k) {
      long start, end, mid;
      start = 2;
      end = k;
      long ret=-1;
      while (start <= end) {
         mid = (start + end) / 2;
         if (num1(k)-num2(mid) == n) {
            return mid;
         } else if (num1(k)-num2(mid) < n) {
            end = mid - 1;
         } else {
            ret=mid;
            start = mid + 1;
         }
      }
      return ret;
   }
}
   



 What is the time complexity of the previous code?
targets: logn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.util.Scanner;

public class Solution {

  public static void main(String[] args) throws Exception {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    if (n % 2 == 0)
      System.out.println("4 " + (n - 4));
    else
      System.out.println("9 " + (n - 9));
  }
}
 Complexity:
targets: constant
inputs: /**
 * author: derrick20
 * created: 3/19/21 11:57 PM
 */
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class E2_SquareFreeDivision2 {
    static FastScanner sc = new FastScanner();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
//        generate();
        int MAX = (int) 1e7;
        int[] spf = new int[MAX + 1];
        for (int i = 2; i <= MAX; i++) {
            if (spf[i] == 0) {
                spf[i] = i;
                for (int j = i + i; j <= MAX; j += i) {
                    if (spf[j] == 0) {
                        spf[j] = i;
                    }
                }
            }
        }
        int[] freq = new int[MAX + 1];
        int T = sc.nextInt();
        while (T-->0) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] a = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                a[i] = sc.nextInt();
                int canonical = 1;
                while (a[i] > 1) {
                    int factor = spf[a[i]];
                    int parity = 0;
                    while (a[i] % factor == 0) {
                        a[i] /= factor;
                        parity ^= 1;
                    }
                    if (parity == 1) {
                        canonical *= factor;
                    }
                }
                a[i] = canonical;
            }
            int[][] transition = new int[K + 1][N + 1];
//            HashMap<Integer, Integer> freq = new HashMap<>();
            for (int k = 0; k <= K; k++) {
                int l = N + 1;
                int duplicates = 0;
                for (int r = N; r >= 1; r--) {
                    while (l - 1 >= 1) {
                        int nextDuplicates = duplicates;
                        if (freq[a[l - 1]] >= 1) {
                            nextDuplicates++;
                        }
                        if (nextDuplicates <= k) {
                            duplicates =... What is the time complexity of the previous code?
targets: cubic
inputs: import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.InputStream;

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

class A {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        int[] hs = new int[n];
        for (int i=0;i<n;i++){
            hs[i]=in.readInt();
        }
        Arrays.sort(hs);
        out.println(hs[b]-hs[b-1]);
	}
}

class InputReader {
    BufferedReader in;

    public InputReader(InputStream stream) {
        in = new BufferedReader(new InputStreamReader(stream));
    }

    public int skipSpace() {
        int c;
        try {
            while (true) {
                c = in.read();
                if (c < 0) {
                    throw new InputMismatchException();
                }
                if (c > 32) {
                    break;
                }
            }
        } catch (IOException e) {
            throw new InputMismatchException();
        }
        return c;
    }

    public int readInt() {
        int res = 0;
        boolean sign = false;
        int c = skipSpace();
        try {
            if (c == '-') {
                sign = true;
                c = in.read();
            }
            while (true) {
                if (c >= '0' && c <= '9') {
                    res = res * 10 + c - '0';
                } else {
                    throw new InputMismatchException();
                }
                c =... What is the time complexity of the previous code?
targets: nlogn
inputs: import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int INF = 1000 * 1000 * 1000;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int x0 = in.readInt();
            int y0 = in.readInt();
            int n = in.readInt();
            int[] xs = new int[n + 1], ys = new int[n + 1];
            xs[0] = x0;
            ys[0] = y0;
            for (int i = 1; i <= n; i++) {
                xs[i] = in.readInt();
                ys[i] = in.readInt();
            }
            int[] one = new int[n];
            for (int i = 0; i < n; i++) one[i] = dist(0, i + 1, xs, ys) * 2;
            int[][] two = new int[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    two[i][j] = dist(0, i + 1, xs, ys) + dist(0, j + 1, xs, ys) + dist(i + 1, j + 1, xs, ys);
                }
            }
            int[] dp = new int[(1 << n)];
            Arrays.fill(dp, INF);
            dp[0] = 0;
            int[] prev = new int[(1 << n)];
            for (int mask = 0; mask < (1 << n); mask++) {
                for (int i = 0; i < n; i++) {
                    if (((mask >> i) & 1) != 0) continue;
               ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: np
inputs: 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();
    }
} What is the time complexity of the previous code?
targets: logn
inputs: Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.math.BigInteger;
import java.util.*;
public class C {
    
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long s = sc.nextLong();
        
        BigInteger k = findFirst(BigInteger.valueOf(s));
        if (BigInteger.valueOf(n).compareTo(k) >= 0)
        {
            System.out.println(n - k.longValue() + 1);
        }
        else
        {
            System.out.println("0");
        }
    }
    
    public static BigInteger findFirst(BigInteger s) // first number where sum of digs >= s
    {
        BigInteger b = BigInteger.ZERO;
        while (cd(b).compareTo(b.subtract(s)) > 0)
        {
            BigInteger c = BigInteger.ONE;
            while (cd(b.add(c)).compareTo(b.add(c).subtract(s)) > 0) {
                c = c.multiply(BigInteger.TEN);
            }
            // possibly overshot
            c = c.divide(BigInteger.TEN);
            if (c.compareTo(BigInteger.TEN) < 0) c = BigInteger.TEN; // always add at least 10
            b = b.add(c);
        }
        return b;
    }
    
    public static BigInteger cd(BigInteger n)
    {
        BigInteger t = BigInteger.ZERO;
        while (n.compareTo(BigInteger.ZERO) > 0)
        {
            t = t.add(n.mod(BigInteger.TEN));
            n = n.divide(BigInteger.TEN);
        }
        return t;
    }
}
 Complexity:
targets: logn
inputs: import java.util.*;
import java.io.*;
public class EdA {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[0];
	public static MyScanner sc;
    public static PrintWriter out;

	public static void main(String[] omkar) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		out = new PrintWriter(System.out);
 		
	 	int n = sc.nextInt();
	 	int m = sc.nextInt();
	 	int[][]cnt = new int[m][m];
	 	String s = sc.next();
	 	for(int j =0;j<n-1;j++){
	 		if (s.charAt(j) != s.charAt(j+1)){
	 		cnt[s.charAt(j)-'a'][s.charAt(j+1)-'a']++;
	 		cnt[s.charAt(j+1)-'a'][s.charAt(j)-'a']++;
	 		}
	 	}
	 	int[] st = new int[m+1];
	 	for(int j = 0;j<=m;j++){
	 		st[j] = (1<<j);
	 	}
	 	int[][] arr = new int[m][1<<m];
	 	for(int j = 0;j<m;j++){
	 		for(int k = 1;k<(1<<m);k++){
	 			int z = Integer.lowestOneBit(k);
	 			int count = 0;
	 			while(z!=0 && z%2==0){
	 				z/=2;
	 				count++;
	 			}
	 			arr[j][k] = arr[j][k^(Integer.lowestOneBit(k))] + cnt[j][count];
	 		}
	 	}
	 	int[] dp = new int[1<<m];
	 	Arrays.fill(dp,  Integer.MAX_VALUE);
	 	dp[0] = 0;
	 	for(int j = 1;j<st[m];j++){
	 		
	 		for(int k = 0;k<m;k++){
	 			int y = st[k];
	 			if ((y&j) != 0){
	 				int sum = 2*arr[k][j] - arr[k][(1<<m)-1];
//	 				for(int t = 0;t<m;t++){
//	 					if (t!= k){
//		 					if ((st[t]&j) != 0)
//		 						sum+=cnt[t][k];
//		 					else
//		 						sum-=cnt[t][k];
//	 					}
//	 				}
	 				dp[j] = Math.min(dp[j],  dp[y^j]+sum*Integer.bitCount(j));
	 			}
	 		}
	 	}
	 	out.println(dp[(1<<m)-1]);
 		out.close();	
 	}
	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<Integer>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
   ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?
targets: np