codeparrot/codecomplex huggingface dataset:
// Problem: 915_B. Browser
// Time complexity: constant
import java.io.BufferedReader;
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.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;
import java.util.Stack;


import java.util.StringTokenizer;


 public class Test
 {
    
     static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int p = Reader.nextInt();
        int L = Reader.nextInt();
        int R = Reader.nextInt();
        int a = 1;
        int b = n;
        int res = 0;
        
        if(a == L && b == R)
        {
            res = 0;
        }
        else if(L != a && R != b && p >= L && p <= R)
        {
            res = Math.min(p-L, R-p);
            res += R- L + 2;
        }
        else if(L != a && R != b && p < L )
        {
            res += L-p + 1;
            res += R - L +1;
        }
        else if(L != a && R != b && p > R)
        {
            res += p-R + 1;
            res += R - L +1;
        }
        else if(a == L && p >=L && p<=R)
        {
            res += R - p + 1;
        }
        else if(R == b && p>=L && p<=R)
        {
            res += p - L + 1;
        }
        else if(a == L && p > R)
        {
            res += p - R + 1;
        }
        else if(R == b && p<L)
        {
            res += L - p + 1;
        }
            
            
        pw.print(res);
        pw.close();
 
    }
        
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

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

    static int nextInt() throws IOException {
        return pars(next());
    }

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

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}
// Problem: 980_B. Marlin
// Time complexity: linear

import java.math.BigInteger;
import java.util.Scanner;


public class Main {
	static Scanner sc = new Scanner (System.in);
    public static void main(String[] args) {
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	char str[][] = new char[5][n];
        for(int i = 0;i < 4;i ++){
        	for(int j = 0;j < n;j ++)
                str[i][j] = '.';
        }
        if(k % 2 == 0){
            k /= 2;
            for(int i = 1;i <= 2;i++){
                for(int j = 1;j <= k;j++)
                     str[i][j] = '#'; 
            }
        }
        else{
            str[1][n / 2] = '#';
            if(k != 1){
                int tmp = n / 2;
                if(k <= n - 2){
                    for(int i = 1;i<= (k - 1) / 2;i++){
                        str[1][i] = '#';
                        str[1][n - 1 - i] = '#';
                    }
                }
                else{
                    for(int i = 1;i <= n - 2;i++) str[1][i] = '#';
                    k -= n - 2;
                    for(int i = 1;i <= k/2;i++){
                        str[2][i] = '#';
                        str[2][n - 1 - i]='#';
                    }
                }
     
            }
        }
        System.out.println("YES");
        for(int i = 0;i < 4;i ++){
        	System.out.println(str[i]);
        }
    }
 }
// Problem: 608_B. Hamming Distance Sum
// Time complexity: linear
import java.util.Scanner;

public class HammingDistancesSum {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String  a = sc.nextLine(), b = sc.nextLine();
		long sum = 0;
		int frequency[][] = new int[200010][2];
		for (int i = 1; i <= b.length(); i++) {
	        for (int j = 0; j < 2; j++)
	            frequency[i][j] = frequency[i - 1][j];
	        frequency[i][Character.getNumericValue((b.charAt(i - 1)))]++;
	    }
	   
	    for (int i = 0; i < a.length(); i++) {
	        int c = Character.getNumericValue(a.charAt(i));
	        for (int j = 0; j < 2; j++) {
	        	int flippingTerm = Math.abs(c - j);
	        	int endOfWindowValue = frequency[b.length() - a.length() + i + 1][j];
	        	int startOfWindowOffset = frequency[i][j];
	            sum += flippingTerm * (endOfWindowValue - startOfWindowOffset);
	        }
	    }
		System.out.println(sum);
		sc.close();
	}
}
// Problem: 1011_B. Planning The Expedition
// Time complexity: nlogn
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Solution solution = new Solution();
		System.out.println(solution.solve());
	}

	private int solve() {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();

		int[] a = new int[m];
		for (int i = 0; i < m; ++i) a[i] = in.nextInt();

		if (n > m) return 0;

		Map<Integer, Integer> map = new HashMap<>();
		for (int k: a) map.put(k, map.getOrDefault(k, 0) + 1);

		List<Integer> keySet = new ArrayList<>(map.keySet());
		int end = m / n;

		keySet.sort((u, v) -> -Integer.compare(u, v));
		do {
			int count = 0;
			for (int k: keySet) {
				count += map.get(k) / end;
				if (count >= n) return end;
			}
		} while (--end > 0);

		return 0;
	}
}
// Problem: 1056_D. Decorate Apple Tree
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

public class B {
	static ArrayList<Integer> [] adj;
	static int [] num;
	static int dfs(int u, int p){
		int cnt = 0;
		for(int v:adj[u]){
			if(v != p)
				cnt += dfs(v, u);
		}
		if(adj[u].size() == 1 && u != 0 || u == 0 && adj[0].size() == 0)
			cnt++;
		num[cnt]++;
		return cnt;
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		adj = new ArrayList[n];
		for (int i = 0; i < adj.length; ++i) {
			adj[i] = new ArrayList<>();
		}
		for (int i = 1; i < n; ++i) {
			int p = sc.nextInt()-1;
			adj[p].add(i);
			adj[i].add(p);
		}
		num = new int[n+1];
		dfs(0, -1);
		for (int i = 1; i < num.length; ++i) {
			num[i] += num[i-1];
		}
		int cur = 1;
		for (int i = 0; i < num.length; ++i) {
			while(cur <= num[i]){
				out.print(i + " ");
				++cur;
			}	
		}
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

}
// Problem: 1000_C. Covered Points Count
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CoveredPointsCount {
	
	//UPSOLVE
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
	        
		int n = Integer.parseInt(st.nextToken());
	     
		long[] myArray = new long[2 * n];
	        
			for (int i = 0; i < n; i++)  {
	        	StringTokenizer st1 = new StringTokenizer(br.readLine());
	        	myArray[2 * i] = Long.parseLong(st1.nextToken()) * 2;
	        	myArray[2 * i + 1] = Long.parseLong(st1.nextToken()) * 2 + 1;
	        }  
	        
	        Arrays.sort(myArray);
	        long[] ans = new long[n + 1];
	        int cnt = 0;
	       
	        for (int i = 0; i < 2 * n - 1; i++)   {
	            if (myArray[i] % 2 == 0) cnt++; else cnt--;
	            ans[cnt] += (myArray[i + 1] + 1) / 2 - (myArray[i] + 1) / 2;
	        }   
	        
	        StringBuilder answer = new StringBuilder();
	        
	        for (int i = 1; i < n + 1; i++) {
	        	answer.append(ans[i]);
	        	answer.append(" ");
	        }  
	        
	        System.out.println(answer);

	}

}
// Problem: 913_B. Christmas Spruce
// Time complexity: linear

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] P = new int[n];
        int[] check=new int[n];
        for (int i = 1; i < n; i++) {

            P[i] = scanner.nextInt();
            P[i]--;
            check[P[i]]++;
        }
        int[] leaves = new int[n];


        for (int i=0;i<n;i++) {
            if(check[i]==0){
                leaves[P[i]]++;
            }
        }


        for (int i = 0; i < n; i++) {

            if (check[i]>0&&leaves[i]<3) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}
// Problem: 1075_A. The King's Race
// Time complexity: constant
import java .util.*;
import java .io.*;
public class Main{
	public static void main(String[]YAHIA_MOSTAFA){
		Scanner sc =new Scanner(System.in);
		long n=sc.nextLong(),x=sc.nextLong(),y=sc.nextLong();
		long xb,xw,yb,yw;
		xw=x-1;yw=y-1;xb=n-x;yb=n-y;
		if (x==n&&y==n){
			System.out.println("Black");return;
		}
		long c1=0,c2=0;
		long f =Math.max(xb,yb);
		long h =Math.max(xw,yw);
		//System.out.println(h+" "+f+" "+(h-f));
		if (h<=f)
			System.out.println("White");
		else
			System.out.println("Black");
	}
}
// Problem: 908_E. New Year and Entity Enumeration
// Time complexity: quadratic
import java.io.*;
import java.util.*;

public class Main {
	static final int MAXN= 1005;
	static final long MOD =1_000_000_007;
	static final boolean DEBUG= false;
	static int  n, m;
	static long stlr[][]= new long[MAXN][MAXN],bell[]= new long[MAXN],occ[];
	static PrintStream cerr=System.err;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Readin();
		stlr[0][0]= bell[0] =1;
		for (int i=1; i<=m; i++)
			for (int j=1;j<=i;j++) {
				stlr[i][j]= (stlr[i-1][j-1]+stlr[i-1][j]*(long)j)%MOD;
				bell[i]= (bell[i]+stlr[i][j])%MOD;
			}
		if (DEBUG)
			for (int i=1; i<=m; i++) cerr.println("Bell["+i+"] ="+bell[i]);
		Arrays.sort(occ);
		if (DEBUG) {
			cerr.println("After Sorting");
			for (int i=0;i<m; i++) cerr.println(occ[i]+" ");}
		long ans=1;
		for (int i=0,j=0; i<m; i=j) {
			for (j=i+1; j<m && occ[i]==occ[j];j++);
			ans= (ans*bell[j-i])%MOD;
		}
		System.out.println(ans);
	}
	static void Readin() {
		Scanner  cin;
		if ( !DEBUG)cin= new Scanner(System.in);
		else {
			try {
				cin = new Scanner(new File("input.txt"));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				if ( DEBUG)cerr.println("Not Fount input.txt");
				return ;
			}
		}
		m = cin.nextInt(); n=cin.nextInt();
		occ= new long[m];
		for (int i=0; i<n; i++) {
			String s= cin.next();
			for (int j=0;j <m; j++)
				occ[j]|=((long)(s.charAt(j)-'0'))<<i;
		}
		cin.close();
	}
}
// Problem: 1088_D. Ehab and another another xor problem
// Time complexity: logn

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class EhabAndAnotherAnotherXorProblem implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int initial = ask(0, 0);
    int a = 0, b = 0;
    if (initial == 0) {
      for (int i = 0; i < 30; i++) {
        int response = ask(1 << i, 0);
        if (response == -1) {
          a |= (1 << i);
        }
      }
      b = a;
    } else {
      for (int i = 29; i >= 0; i--) {
        int response = ask(a | (1 << i), b | (1 << i));
        if (response != initial) {
          if (response == 1) {
            b |= (1 << i);
          } else {
            a |= (1 << i);
          }
          initial = ask(a, b);
        } else {
          response = ask(a | (1 << i), b);
          if (response == -1) {
            a |= (1 << i);
            b |= (1 << i);
          }
        }
        
      }
    }
    answer(a, b);
  }

  private int ask(int c, int d) {
    out.printf("? %d %d\n", c, d);
    out.flush();
    return in.ni();
  }

  private void answer(int a, int b) {
    out.printf("! %d %d\n", a, b);
    out.flush();
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  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 int ni() {
      return Integer.parseInt(next());
    }

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

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (EhabAndAnotherAnotherXorProblem instance = new EhabAndAnotherAnotherXorProblem()) {
      instance.solve();
    }
  }
}
// Problem: 987_A. Infinity Gauntlet
// Time complexity: constant
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);
        int n=sc.nextInt();
        HashMap<String,Integer> map=new HashMap<String,Integer>();
        for(int i=0;i<n;i++) {
            map.put(sc.next(), 1);
        }
        ArrayList<String> list=new ArrayList<String>();
        int count=0;
        if(!map.containsKey("purple")) {
            count++;
            list.add("Power");
        }
if(!map.containsKey("green")) {
    count++;
    list.add("Time");
        }

if(!map.containsKey("blue")) {
    count++;
    list.add("Space");
}

if(!map.containsKey("orange")) {
    count++;
    list.add("Soul");
}

if(!map.containsKey("red")) {
    count++;
    list.add("Reality");
}

if(!map.containsKey("yellow")) {
    count++;
    list.add("Mind");
}System.out.println(count);
    for(String s:list) {
        System.out.println(s);
    }
    }
}

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: 1180_A. Alex and a Rhombus
// Time complexity: constant
import java.util.Scanner;

public class AlexAndARhombus {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		System.out.println(n*n+(n-1)*(n-1));
		sc.close();
	}

}
// Problem: 1062_D. Fun with Integers
// Time complexity: linear
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main
{
    static final long mod=(int)1e9+7;
    public static void main(String[] args) throws Exception
    {
    	FastReader in=new FastReader();
    	PrintWriter pw=new PrintWriter(System.out);
    	int n=in.nextInt();
    	long ans=0;
    	for(int i=2;2*i<=n;i++)
    	{
    		ans+=i*(n/i-1);
    	}
    	ans*=4;
    	pw.print(ans);
    	pw.flush();
    }
}

class pair
{
	int f,s;
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;
 
    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }
 
    public String next() throws IOException
    {
        if(st==null || !st.hasMoreElements())
        {
            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());
    }
}
// Problem: 1061_A. Coins
// Time complexity: constant
import java.io.*;
import java.util.*;

public class A {
    public static void main(String args[]) {
        FastScanner scn = new FastScanner();
        int n = scn.nextInt();
        int s = scn.nextInt();
        if (s <= n) {
            System.out.println(1);
        } else if (s > n) {
            if(s%n == 0){
                System.out.println(s/n);
            } else {
                System.out.println(s/n + 1);
            }
        }

    }

    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: 958_D1. Hyperspace Jump (easy)
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Code {

	public static void main(String[] args) throws IOException{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 int n = Integer.parseInt(br.readLine());
		 HashMap<Double,Integer>h = new HashMap<>();
		 double [] temp = new double[n];
		 int m = 0;
		 for(int i=0;i<n;i++) {
			 String l = br.readLine();
			 int[] x = new int[4];
			 int k=0;
			 boolean t = false;
			 for(int j=0;j<l.length();j++) {
				 if(l.charAt(j)=='(' || l.charAt(j)=='+' || l.charAt(j)==')' || l.charAt(j)=='/')
					 x[k++] = j;
			 }
			 double a = Integer.parseInt(l.substring(x[0]+1,x[1]));
			 double b = Integer.parseInt(l.substring(x[1]+1, x[2]));
			 double c = Integer.parseInt(l.substring(x[3]+1));
			 temp[m++] = (a+b)/c;
			 //System.out.print((a+b)/c + " ");
			if(h.containsKey((a+b)/c))
					h.put((a+b)/c, h.get((a+b)/c)+1);
			else
				h.put((a+b)/c, 1);
		 }
		 //System.out.println(h);
		 for(int i=0;i<n;i++) {
			 System.out.print(h.get(temp[i]) + " ");
		 }
	}
	}
// Problem: 964_A. Splits
// Time complexity: constant
import java.util.*;
import java.io.*;

public class programA {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		if(n%2 == 0)System.out.println(n/2 +1);
		else System.out.println((int)Math.ceil((double)n/2));
	}
}