codeparrot/codecomplex huggingface dataset:
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.io.*;
import java.util.*;

public class A {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int d = in.nextInt();
			int a[] = new int[n];
			int c[] = new int[2 * n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				c[2 * i] = a[i] - d;
				c[2 * i + 1] = a[i] + d;
			}
			Arrays.sort(c);
			int ans = 0;
			for (int i = 0; i < 2 * n; i++) {
				if (i != 0 && c[i] == c[i - 1]) continue;
				int mind = d + 1;
				for (int j = 0; j < n; j++)
					mind = Math.min(mind, Math.abs(a[j] - c[i]));
				if (mind == d) {
					ans += 1;
				}
			}
			out.println(ans);
		}
	}

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

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

	}
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        long d = reader.nextLong();
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
            a[i] = reader.nextInt();
        Arrays.sort(a);
        int ans = 2;
        for(int i = 0; i < n - 1; i++){
            if(a[i + 1] - a[i] > 2 * d) {
                ans += 2;
            }
            else if(a[i + 1] - a[i] == 2 * d)
                ans++;
        }
        System.out.println(ans);
    }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear


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

public class Test5 {

    static StreamTokenizer st = new StreamTokenizer(new InputStreamReader(System.in));
    static int[] m;

    public static void main(String[] z) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        Scanner s = new Scanner(System.in);
        int a = ni(), b=ni(), o=2;
        m = new int[a];
        for(int q=0; q<a; q++) m[q] = ni();
        Arrays.sort(m);
        for(int q=1; q<a; q++){
            if(m[q]-m[q-1]==b*2) o++;
            else if(m[q]-m[q-1]>b*2) o+=2;
        }
        System.out.println(o);
        pw.flush();
    }

    static int ni() throws Exception{
        st.nextToken();
        return (int)st.nval;
    }

    static String ns() throws Exception{
        st.nextToken();
        return st.sval;
    }

    static long gcd(long a, long b){
        for(; a>0 && b>0;)
            if(a>b) a%=b;
        else b%=a;
        return a+b;
    }

    static class PyraSort {

        private static int heapSize;

        public static void sort(int[] a) {
            buildHeap(a);
            while (heapSize > 1) {
                swap(a, 0, heapSize - 1);
                heapSize--;
                heapify(a, 0);
            }
        }

        private static void buildHeap(int[] a) {
            heapSize = a.length;
            for (int i = a.length / 2; i >= 0; i--) {
                heapify(a, i);
            }
        }

        private static void heapify(int[] a, int i) {
            int l = 2 * i + 2;
            int r = 2 * i + 1;
            int largest = i;
            if (l < heapSize && a[i] < a[l]) {
                largest = l;
            }
            if (r < heapSize && a[largest] < a[r]) {
                largest = r;
            }
            if (i != largest) {
                swap(a, i, largest);
                heapify(a, largest);
            }
        }

        private static void swap(int[] a, int i, int j) {
            a[i] ^= a[j] ^= a[i];
            a[j] ^= a[i];
        }
    }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class ProblemA {

	String fileName = "prizes";

	public void solve() throws IOException {
		int n = nextInt();
		int d = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int ans = 2;
		for (int i = 1; i < n; i++) {
			if (a[i] - a[i - 1] == 2 * d)
				ans++;
			if (a[i] - a[i - 1] > 2 * d)
				ans += 2;

		}
		out.println(ans);
	}

	public void run() {
		try {

			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out, true);

			// out = new PrintWriter(fileName + ".out");
			// br = new BufferedReader(new FileReader(fileName + ".in"));
			// out = new PrintWriter(fileName + ".out");
			solve();

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

	BufferedReader br;
	StringTokenizer in;
	static PrintWriter out;

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

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

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

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

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

}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {
	// write your code here
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] s = reader.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int d = Integer.parseInt(s[1]);

        List<Integer> list = new ArrayList<>();
        s = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            list.add(Integer.parseInt(s[i]));
        }

        HashSet<Integer> set = new HashSet<>();
        for (Integer i : list) {
            set.add(i - d);
            set.add(i + d);
        }

        HashSet<Integer> set2 = new HashSet<>();

        for (Integer i : set) {
            for (Integer x : list) {
                if (Math.abs(i - x) < d) {
                    set2.add(i);
            }
            }
        }

        set.removeAll(set2);
        System.out.println(set.size());

    }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.util.*;
import java.io.*;
public class Main {
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

        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 boolean ready() throws IOException {
            return br.ready();
        }
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);PrintWriter pw = new PrintWriter(System.out);
        int n=sc.nextInt(),d=sc.nextInt();int[] a = new int[n];int ans=2;a[0]=sc.nextInt();
        for (int i=1;i<n;i++){
            a[i]=sc.nextInt();
            if (a[i]-a[i-1]==2*d)ans++;
            else if (a[i]-a[i-1]>2*d)ans+=2;
        }
        System.out.println(ans);
    }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.util.*;
import java.io.*;

public class _1004_A {

	public static void main(String[] args) throws IOException {
		int N = readInt(), D = readInt(); long arr[] = new long[N+2]; arr[0] = -3000000000L; arr[N+1] = -arr[0];
		for(int i = 1; i<=N; i++) arr[i] = readInt();
		int cnt = 1; if(Math.abs(arr[2]-(arr[1] + D)) >= D) cnt++; for(int i = 2; i<=N; i++) {
			if(Math.abs(arr[i-1]-(arr[i] - D)) > D) cnt++;
			if(Math.abs(arr[i+1]-(arr[i] + D)) >= D) cnt++;
		}
		println(cnt); exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();
            int[] a = in.readIntArray(n);

            int ans = 1;
            for (int i = 0; i < a.length - 1; ++i) {
                int left = a[i] + d;
                int right = a[i + 1] - d;
                if (left < right) {
                    ans += 2;
                } else if (left == right)
                    ans++;
            }

            out.println(ans + 1);
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

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

        public Integer nextInt() {
            return Integer.valueOf(next());
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = nextInt();
            return array;
        }

    }
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.util.*;

public class A
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();   
        
        int odd = -1;
        int even = -1;
        int oc = 0;
        int ec = 0;
        
        for(int i=0;i < n;i++)
        {
            if(scan.nextInt() % 2 == 0)
            {
                ec++;
                even = i+1;
            }
            else
            {
                oc++;
                odd = i+1;
            }
        }
        
        if(ec == 1)
            System.out.println(even);
        else
            System.out.println(odd);
    }
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class A {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>(), list2;
		for (; n-- > 0;) {
			list.add(scan.nextInt());
		}
		list2 = new ArrayList<Integer>(list);
		Collections.sort(list2, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return o1 % 2 - o2 % 2;
			}
		});
		System.out.println(list.indexOf(list2.get(list2.get(1) % 2 > 0 ? 0
				: list2.size() - 1)) + 1);
	}
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class A25 {

	
	public void run() {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(in.readLine().trim());
			String[] toks = in.readLine().trim().split("[ ]+");
			int counter = 0;
			boolean even = true;
			int e = -1, o = -1;
			int ec = 0, oc = 0;
			for (int i = 0; i < toks.length; i++) {
				int x = Integer.parseInt(toks[i]);
				if (x % 2 == 0) {
					ec ++;
					if (e == -1) {
						e = i+1;
					}
				}
				else {
					oc ++;
					if (o == -1) {
						o = i+1;
					}
				}
			}
			if (ec == 1) {
				System.out.println(e);
			}
			else if (oc == 1) {
				System.out.println(o);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public static void main(String[] args) {
		new A25().run();
	}
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.util.Scanner;


public class R025A {
	int n;
	int[] nums;
	public R025A() {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		nums = new int[n];
		for(int i=0; i<n; i++) {
			nums[i] = scanner.nextInt();
		}
	}

	private void process() {
		int[] c = new int[2];
		int[] r = new int[2];
		for(int i=0; i<n; i++) {
			c[nums[i] % 2]++;
			if(r[nums[i] %2] == 0) {
				r[nums[i] % 2] = i+1;
			}
		}
		System.out.println(r[c[0]==1 ? 0 : 1]);
	}

	public static void main(String[] args) {
		new R025A().process();
	}
}
// Problem: 25_A. IQ test
// Time complexity: linear
//package;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;
import java.lang.*;
import java.io.*;
import java.awt.Point;

public class evenness {
	
	public static void main(String[] args){
	
    try{
	
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int i, n, temp=1;
      String str = "";
      int[] arr;
      int r;
      
      while (temp!= '\n'){
		temp = System.in.read();
		//if (temp=='\n')
			//break;
		str = str.concat(Character.toString((char)temp));
      }
	  str = str.replaceAll("[^0-9]", "");
      n = Integer.parseInt(str);
      temp=1;
      str="";
      
      arr = new int[n];
      
      for (i=0;i<n;i++){
		while (temp!=' ' && temp!=-1){
			temp = System.in.read();
			//if (temp==' ' || temp==-1)
				//break;
			str = str.concat(Character.toString((char)temp));
		}
		str = str.replaceAll("[^0-9]", "");
		arr[i] = Integer.parseInt(str);
		str="";
		temp=1;
      }
      
	  r=(arr[2]%2);
      if ((arr[0]%2)==(arr[1]%2)){
		r=(arr[0]%2);
      }
      
      for (i=0;i<n;i++){
		if ((arr[i]%2)!=r){
			System.out.println(i+1);
			break;
		}
      }
      
	}catch (Exception e){
		System.out.println("OH NOES " + e);
	}
  }
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.io.*;
import java.util.*;

public class a implements Runnable {

	private void solve() throws IOException {
		int n = nextInt();
		int oddcnt = 0, evencnt = 0;
		int odd = 0, even = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt();
			if (a % 2 == 0) {
				even = i + 1;
				evencnt++;
			} else {
				odd = i + 1;
				oddcnt++;
			}
		}
		if (oddcnt == 1) {
			System.out.println(odd);
		} else {
			System.out.println(even);
		}
	}

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

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

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(239);
		}
	}

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

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

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

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.io.*;

public class IQTest
{
    public static void main(String[] args)
    {
        try
        {
            BufferedReader in = new BufferedReader(
                new InputStreamReader(System.in));
            String str = in.readLine();
            int n = Integer.parseInt(str);
            int odd = -1, even = -1, odds = 0, evens = 0;
            //while (n-- > 0)
            //{
                str = in.readLine();
                String[] numbers = str.split(" ");
                int index = 1;
                for (String number: numbers)
                {
                    int i = Integer.parseInt(number);
                    if (i % 2 == 0)
                    {
                        ++evens;
                        if (even == -1)
                            even = index;
                    }
                    else
                    {
                        ++odds;
                        if (odd == -1)
                            odd = index;
                    }
                    ++index;
                }
            //}
            
            System.out.println((evens > odds ? odd : even));
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
// Problem: 25_A. IQ test
// Time complexity: linear
//package round25;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class A {
	private Scanner in;
	private PrintWriter out;
	private String INPUT = "";
	
	public void solve()
	{
		int n = ni();
		int[] u = new int[n];
		int fe = -1, fo = -1;
		int ne = -1, no = -1;
		for(int i = 0;i < n;i++){
			u[i] = ni();
			if(u[i] % 2 == 0){
				if(fe == -1){
					fe = i + 1;
				}else{
					ne = i + 1;
				}
			}else{
				if(fo == -1){
					fo = i + 1;
				}else{
					no = i + 1;
				}
			}
		}
		if(ne > 0){
			out.println(fo);
		}else{
			out.println(fe);
		}
	}
	
	public void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	
	public static void main(String[] args) throws Exception
	{
		new A().run();
	}
	
	private int ni() { return Integer.parseInt(in.next()); }
	private static void tr(Object... o) { System.out.println(o.length == 1 ? o[0] : Arrays.toString(o)); }
}
// Problem: 25_A. IQ test
// Time complexity: linear
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class A {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        String[] ss = br.readLine().split(" ");
        int n = ss.length;
        int[] a = new int[n];
        for (int i = 0; i < n; ++i)
            a[i] = Integer.parseInt(ss[i]);
        for (int i = 0; i < n; ++i) {
            boolean ok = true;
            for (int j = 0; j < n; ++j)
                if (j != i && a[j] % 2 == a[i] % 2)
                    ok = false;
            if (ok)
                System.out.println(i + 1);
        }
    }
}