codeparrot/codecomplex huggingface dataset:
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
        var pw = new PrintWriter(System.out);
        
        int T = Integer.parseInt(sc.next());
        for(int t = 0; t < T; t++){
            int n = Integer.parseInt(sc.next());
            boolean ok = false;
            if(n%2 == 0){
                int a = n/2;
                int b = (int) Math.sqrt(a);
                if(b*b == a){
                    ok = true;
                }
            }
            if(n%4 == 0){
                int a = n/4;
                int b = (int) Math.sqrt(a);
                if(b*b == a){
                    ok = true;
                }
            }
            if(ok){
                pw.println("YES");
            }else{
                pw.println("NO");
            }
        }
        pw.flush();
    }
}
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
import java.util.Scanner;

public class B_14 {
	
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int t = input.nextInt();
		for(int test = 0; test < t; test++){
			int n = input.nextInt();
			if(n % 2 == 0){
				if(Math.sqrt(n / 2) == (int)(Math.sqrt(n / 2))){
					System.out.println("YES");
				}else if(n % 4 == 0 && Math.sqrt(n / 4) == (int)(Math.sqrt(n / 4))){
					System.out.println("YES");
				}else{
					System.out.println("NO");
				}
			}else{
				System.out.println("NO");
			}
		}
	}
		
}
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            if(n%2==1)
            {
                System.out.println("NO");
                continue;
            }
            // squares of 2
            int num=n/2;
            int root = (int)Math.sqrt(num);
            if(root*root==num)
            {
                System.out.println("YES");
                continue;
            }
            // squares of 4
            if(n%4!=0)
            {
                System.out.println("NO");
                continue;
            }
            num = n/4;
            root = (int) Math.sqrt(num);
            if(root*root==num)
            {
                System.out.println("YES");
            }
            else
            {
                System.out.println("NO");
            }
        }
    }
}
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
//package global14;

import java.util.Scanner;

public class B {

    public static void main(String[] args){

        Scanner in = new Scanner(System.in);

        int t = in.nextInt();
        while(t > 0){
            t --;
            int n = in.nextInt();
            if(n % 2 != 0){
                System.out.println("NO");
                continue;
            }
            int a = n / 2;
            int x = (int)Math.sqrt(a);
            if(x * x == a || (x + 1) * (x + 1) == a){
                System.out.println("YES");
                continue;
            }
            a = n / 4;
            if(n % 4 != 0){
                System.out.println("NO");
                continue;
            }
            x = (int)Math.sqrt(a);
            if(x * x == a || (x + 1) * (x + 1) == a){
                System.out.println("YES");
                continue;
            }
            System.out.println("NO");



        }


    }
}
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
//package codeforces;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
	public static void main(String[] args) {
		PrintWriter out=new PrintWriter(System.out);
    	Scanner s=new Scanner(System.in);  
    	int t=s.nextInt();
    	for(int tt=0;tt<t;tt++) {
    		long n=s.nextInt();
    		long x=(long)Math.sqrt(n/2);
    		long y=(long)Math.sqrt(n/4);
    		if(x*x*2==n || y*y*4==n) {
    			out.println("YES");
    		}else {
    			out.println("NO");
    		}
    	}
    	out.close();
	    s.close();
	}
	
	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);
	}
	
}
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
import java.io.*;
import java.util.*;
import java.math.*;

public class B {
	public static void main(String[] args) throws IOException {

		/**/
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		/*/
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream("src/b.in"))));
		/**/
		
		int t = sc.nextInt();
		for (int z = 0; z < t; ++z) {
			int n = sc.nextInt();
			if (n%2==1) {
				System.out.println("NO");
				continue;
			}
			n/=2;
			int sqrt = (int)Math.sqrt(n);
			if (sqrt*sqrt==n) {
				System.out.println("YES");
				continue;
			}
			if (n%2==1) {
				System.out.println("NO");
				continue;
			}
			n/=2;
			sqrt = (int)Math.sqrt(n);
			if (sqrt*sqrt==n) {
				System.out.println("YES");
				continue;
			}
			System.out.println("NO");
		}
	}
}
// Problem: 1515_B. Phoenix and Puzzle
// Time complexity: linear
import java.util.*;
import java.io.*;

public class _G14 {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = sc.nextInt();
        Set<Long> square = new HashSet<>();
        for (long i = 1; i <= (long) 1e5; i++) square.add(i * i);
        while (t-- > 0) {
            long n = sc.nextLong();
            if ((n % 2 ==0 && square.contains(n / 2))|| (n % 4 == 0 &&square.contains(n / 4))) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }
        out.close();
    }


    static void sort(int[] a) {
        ArrayList<Integer> q = new ArrayList<>();
        for (int i : a) q.add(i);
        Collections.sort(q);
        for (int i = 0; i < a.length; i++) a[i] = q.get(i);
    }

    static void sort(long[] a) {
        ArrayList<Long> q = new ArrayList<>();
        for (long i : a) q.add(i);
        Collections.sort(q);
        for (int i = 0; i < a.length; i++) a[i] = q.get(i);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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: 1004_A. Sonya and Hotels
// Time complexity: linear
/*
Keep solving problems.
*/

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

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    void solve() throws IOException {
        int n = nextInt();
        long d = nextInt();
        long[] arr = nextLongArr(n);
        Set<Long> res = new HashSet<>();
        for (long cur : arr) {
            if (findMin(cur - d, arr) == d) {
                res.add(cur - d);
            }
            if (findMin(cur + d, arr) == d) {
                res.add(cur + d);
            }
        }

        outln(res.size());
    }

    long findMin(long cur, long[] arr) {
        long res = Long.MAX_VALUE;
        for (long v : arr) {
            res = Math.min(res, Math.abs(v - cur));
        }

        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        outln(String.format("%.9f%n", val));
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}
// 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 s = new Scanner(System.in);
		int n = s.nextInt(), d = s.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = s.nextInt();
		}
		Arrays.sort(arr);
		int count = 0;
		for(int i = 1; i < n; i++){
			int dist = arr[i] - arr[i - 1];
			if(dist > 2 * d){
				count += 2;
			}else if(dist == 2 * d){
				count++;
			}
				
		}
		System.out.println(count + 2);

	}

}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {


  private static void solve() {
    int n = ni();
    int d = ni();
    int[] a = na(n);
    Arrays.sort(a);

    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < n; i ++) {
      int cand1 = a[i] - d;
      int cand2 = a[i] + d;
      int d1 = d;
      int d2 = d;
      for (int j = 0; j < n; j ++) {
        d1 = Math.min(d1, Math.abs(a[j] - cand1));
        d2 = Math.min(d2, Math.abs(a[j] - cand2));
      }
      if (d1 == d) {
        set.add(cand1);
      }
      if (d2 == d) {
        set.add(cand2);
      }
    }
    System.out.println(set.size());
  }
  
  
  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

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

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
// package CF;

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.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class F {

	public static void main(String[] args) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), d = sc.nextInt();
		int [] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 0; i < a.length; i++) {
			int tmp = a[i] - d;
			if(i == 0 || tmp > a[i-1] && tmp - a[i-1] >= d)
				set.add(tmp);
			tmp = a[i] + d;
			if(i == n-1 || tmp < a[i+1] && a[i+1] - tmp >= d)
				set.add(tmp);
 		}
		out.println(set.size());
		out.flush();
		out.close();
	}

	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();
		}
	}
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
//package contests.CF495;

import java.io.*;
import java.util.HashSet;
import java.util.StringTokenizer;

public class A {

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

        int n = sc.nextInt();
        int d = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < arr.length; i++) {
            set.add(arr[i]+d);
            set.add(arr[i]-d);
        }

        int cnt = 0;
        for (int loc: set) {
            int minDist = (int)2e9;
            for (int i = 0; i < n; i++) {
                minDist = Math.min(minDist, Math.abs(arr[i]-loc));
            }

            if(minDist == d)
                cnt++;
        }

        pw.println(cnt);

        pw.flush();
        pw.close();
    }



    static int[][] packD(int n, int[] from, int[] to) {
        int[][] g = new int[n][];
        int[] p = new int[n];
        for (int f : from) if(f != -1) p[f]++;
        for (int i = 0; i < n; i++) g[i] = new int[p[i]];
        for (int i = 0; i < from.length; i++) if(from[i] != -1) {g[from[i]][--p[from[i]]] = to[i];}
        return g;
    }

    static void shuffle(int[] a)
    {
        int n = a.length;
        for(int i = 0; i < n; i++)
        {
            int r = i + (int)(Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    static class Scanner
    {
        StringTokenizer st; BufferedReader br;
        public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
        public Scanner(String s) throws FileNotFoundException {	br = new BufferedReader(new FileReader(new File(s)));}
        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();}
    }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.util.*;
import java.io.*;

public class A6 
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int d = in.nextInt();
		int ans=2;
		
		int[] a = new int[n];
		
		for(int i=0;i<n;i++)
			a[i] = in.nextInt();
		
		for(int i=1;i<n;i++)
		{
			if(a[i]-a[i-1]>2*d)
			{
				ans += 2;
			}
			else if(a[i]-a[i-1]==2*d)
				ans += 1;
		}
		
		System.out.println(ans);
	}

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

public class A {
    String fileName = "<name>";

    public TreeSet<Integer> set = new TreeSet<>();

    public int getLowerDist(int x) {
        Integer higher = set.higher(x);
        Integer lower = set.lower(x);
        if (higher == null)
            return lower;
        if (lower == null)
            return higher;
        if (Math.abs(x - higher) < Math.abs(x - lower)) {
            return higher;
        } else {
            return lower;
        }
    }

    public void solve() throws IOException {
        int n = nextInt();
        int d = nextInt();
        int[] a = new int[n];
        Set<Integer> ans = new HashSet<>((int) 1e6, 1f);
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            set.add(a[i]);
        }
        for (int i = 0; i < n; i++) {
            int pos1 = a[i] + d;
            int pos2 = a[i] - d;
            if (!set.contains(pos1) && Math.abs(pos1 - getLowerDist(pos1)) == d) {
                ans.add(pos1);
            }
            if (!set.contains(pos2) && Math.abs(pos2 - getLowerDist(pos2)) == d) {
                ans.add(pos2);
            }
        }
        out.print(ans.size());
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

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

    BufferedReader br;
    StringTokenizer in;
    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 {
        Locale.setDefault(Locale.US);
        new A().run();
    }
}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.util.*;
public class Hotels {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] cities = new int[n];
		int d = input.nextInt();
		for (int i = 0; i<n; i++) {
			cities[i] = input.nextInt();
		}
		int possibilities = 0;
		ArrayList<Integer> newHotels = new ArrayList<Integer>();
		for (int i = 0; i<n; i++) {
			int plusD = cities[i]+d;
			if (newHotels.indexOf(cities[i]+d)==-1 && minDist(plusD,cities)==d) {
				possibilities++;
				newHotels.add(cities[i]+d);
			}
			if (newHotels.indexOf(cities[i]-d)==-1 && minDist(cities[i]-d,cities)==d) {
				possibilities++;
				newHotels.add(cities[i]-d);
			}
		}
		System.out.println(possibilities);
	}
	public static int minDist(int a, int[] arr) {
		int minDist = Integer.MAX_VALUE;
		for (int i=0; i<arr.length; i++) {
			minDist = Math.min(Math.abs(arr[i]-a), minDist);
	}
		return minDist;
	}

}
// Problem: 1004_A. Sonya and Hotels
// Time complexity: linear
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class main {
    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int n = nextInt();
        int d = nextInt();
        int ans = 2;
        int b[] = new int [n];
        Arrays.sort(b);
        for (int i = 0; i < n; i++) {
            b[i] = nextInt();
        }
        for (int i = 1; i < n; i++) {
            if (b[i] - b[i - 1] >= d * 2) {
                ans++;
            }
            if (b[i] - b[i - 1] > d * 2) {
                ans++;
            }
        }
        pw.println(ans);
        pw.close();
    }
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");

    public static int nextInt() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }
    public static String next() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    public static double nextDouble() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Double.parseDouble(st.nextToken());
    }
    public static long nextLong() throws IOException {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}