codeparrot/codecomplex huggingface dataset:
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.*;
import java.util.StringTokenizer;


public class Main {
	public static String taskName = "";

	public class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int r = in.nextInt();
			int[] x = new int[n];
			for(int i = 0; i < n; i++)
				x[i] = in.nextInt();

			double[] y = new double[n];
			for(int i = 0; i < n; i++) {
				y[i] = r;
				for(int j = 0; j < i; j++) {
					int dx = Math.abs(x[i] - x[j]);
					if(dx <= 2 * r)
						y[i] = Math.max(y[i], y[j] + Math.abs(Math.sqrt(4 * r * r - dx * dx)));
				}
				System.out.print(y[i] + " ");
			}

			System.out.println();
		}
	}

	public static void main(String[] args) throws FileNotFoundException {
		if(!taskName.isEmpty()) {
			System.setIn(new BufferedInputStream(new FileInputStream(taskName + ".in")));
			System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream(taskName + ".out"))));
		}
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Main main = new Main();
		main.run(in, out);
		out.close();
	}

	public void run(InputReader in, PrintWriter out) {
		Task solver = new Task();
		solver.solve(1, in, out);
	}

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

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

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

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

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

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

		public double nextShort() {
			return Short.parseShort(next());
		}

		public double nextByte() {
			return Byte.parseByte(next());
		}

		public double nextFloat() {
			return Float.parseFloat(next());
		}
	}
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.util.*;
public class C {
	
	public static void main(String[] args) {
		Scanner qwe = new Scanner(System.in);
		int n = qwe.nextInt();
		double r = qwe.nextDouble();
		
		double[] fy = new double[n];
		Arrays.fill(fy, r);
		
		double[] xs = new double[n];
		for (int i = 0; i < xs.length; i++) {
			xs[i] = qwe.nextDouble();
		}
		
		for(int i =0; i < n; i++){
			
			for(int j = i+1; j < n; j++){
				double dx = xs[j]-xs[i];
				if(Math.abs(dx) > 2*r) continue;
				fy[j] = Math.max(fy[j], Math.sqrt(4*r*r-dx*dx)+fy[i]);
			}
			
		}
		
		StringBuilder stb = new StringBuilder();
		for (int i = 0; i < xs.length; i++) {
			stb.append(fy[i]+" ");
		}
		System.out.println(stb);
	}

}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class _908C {

 }

 */
public class _908C {
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int n = in.readInteger();
    double r = in.readInteger();

    double[] x = new double[n];

    for (int i = 0; i < n; i++) {
      x[i] = in.readInteger();
    }

    double[] ans = new double[n];

    ans[0] = r;

    for (int i = 1; i < n; i++) {
      double cans = r;
      for (int j = 0; j < i; j++) {
        double dis = Math.abs(x[j] - x[i]);

        if (dis <= 2 * r) {

          if (dis == 2 * r) {
            cans = Math.max(cans, ans[j]);
            continue;
          } else if (x[i] == x[j]) {
            cans = Math.max(cans, ans[j] + 2 * r);
            continue;
          }
          cans = Math.max(cans, ans[j] + Math.sqrt((4 * (r * r)) - dis * dis));
        }
      }

      ans[i] = cans;
    }

    for (int i = 0; i < n; i++) {
      System.out.print(ans[i] + " ");
    }

    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new _908C()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int r = in.nextInt();
            int[] xs = new int[n];
            for (int i = 0; i < n; i++) xs[i] = in.nextInt();
            double[] ys = new double[n];
            for (int i = 0; i < n; i++) {
                int x = xs[i];
                double y = r;
                for (int j = 0; j < i; j++) {
                    y = Math.max(y, calc(xs[j], ys[j], x, r));
                }
                ys[i] = y;
            }
            for (int i = 0; i < n; i++) {
                out.printf("%.10f ", ys[i]);
            }
            out.println();
        }

        private double calc(int x, double y, int x1, int r) {
            int dx = Math.abs(x - x1);
            if (dx > 2 * r) return 0;
            double dy = Math.sqrt(4 * r * r - dx * dx);
            return y + dy;
        }

    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in), 32768);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public boolean hasNext() {
            while (st == null || !st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            return st.nextToken();
        }

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

    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


public class Codeforces {
            
    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        final double eps = 1e-7;
        String toks[] = in.readLine().split(" ");
        int n = Integer.parseInt(toks[0]);
        double r = Double.parseDouble(toks[1]);
        double x[] = new double[n];
        toks = in.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            x[i] = Double.parseDouble(toks[i]);
        }
        double lo, hi, mid;
        double y[] = new double[n];
        y[0] = r;
        for (int i = 1; i < n; i++) {
            y[i] = r;
            for(int j=0; j<i; j++) {
                lo = y[j]; hi = 2000*2000;
                while( Math.abs(hi-lo) >= eps ) {
                    mid = (hi+lo)/2;
                    if( Math.sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[j]-mid)*(y[j]-mid) ) + eps > 2*r ) {
                        hi = mid;
                    } else {
                        lo = mid;
                    }
                }
                if(Math.sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[j]-lo)*(y[j]-lo) ) < 2*r + eps) {
                    y[i] = Math.max(y[i], lo);
                }
            }
        }
        for (double z : y) {
            System.out.printf(Locale.US, "%.7f ", z);
        }
    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic

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

public class C {

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

		int n = in.nextInt();
		double r = in.nextInt();
		double[] x = new double[n+1];
		double[] y = new double[n+1];
		for (int i = 1; i <= n; i++) {
			x[i] = in.nextInt();
		}
		
		int[] lastx = new int[1001];
		for (int i = 1; i <= n; i++) {
			double s = x[i] - r, e = x[i] + r;
			for (int j = (int)Math.max(0, s); j <= (int)Math.min(1000, e); j++) {
				if (lastx[j] == 0) {
					y[i] = Math.max(y[i], findY(x[i], x[i], 0 - r, 2 * r));
				}
				else {
					y[i] = Math.max(y[i], findY(x[lastx[j]], x[i], y[lastx[j]], 2 * r));
				}
				lastx[j] = i;
			}
		}
		
		for (int i = 1; i <= n; i++) {
			out.println(y[i]);
		}
		out.close();
	}
	
	public static double findY(double x1, double x2, double y1, double d) {
		return Math.max(y1 + Math.sqrt(-1 * Math.pow(x1, 2) + 2 * x1 * x2 + Math.pow(d, 2) - Math.pow(x2, 2)),
				y1 - Math.sqrt(-1 * Math.pow(x1, 2) + 2 * x1 * x2 + Math.pow(d, 2) - Math.pow(x2, 2)));
	}

	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		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++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

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

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

		public String next() {
			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 String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.math.BigInteger;
import java.util.Scanner;

public class c {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int num = in.nextInt();
		int rad = in.nextInt();
		
		int[] start = new int[num];
		for(int i=0; i<num; i++)
			start[i] = in.nextInt();
		
		// If you can hack doubles that's dumb
		double[] finalY = new double[num];
		double hyp = rad*2;
		
		for(int cur=0; cur<num; cur++){
			
			double stopAt = rad;
			for(int comp=0; comp<cur; comp++){
				if(Math.abs(start[comp]-start[cur]) > rad*2) continue;
				
				double base = Math.abs(start[comp]-start[cur]);
				double ny = Math.sqrt(hyp*hyp - base*base) + finalY[comp];
				
				stopAt = Math.max(ny, stopAt);
			}
			
			finalY[cur] = stopAt;
		}
		
		for(int i=0; i<num; i++)
			System.out.print(finalY[i]+" ");
		System.out.println();
	}

}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class USACO {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine()," ");
        int n= Integer.parseInt(st.nextToken());
        int r= Integer.parseInt(st.nextToken());
        StringTokenizer st2 = new StringTokenizer(reader.readLine()," ");
        double[][] coord = new double[n][2];
        for (int i=0;i<n;i++) {
            coord[i][0] = Integer.parseInt(st2.nextToken());
            double y=r;
            for (int j=0;j<i;j++) {
                if (coord[j][0]<=coord[i][0]+2*r&&coord[j][0]>=coord[i][0]-2*r) {
                    if (coord[j][1]+Math.sqrt(4*r*r-(coord[i][0]-coord[j][0])*(coord[i][0]-coord[j][0]))>y) {
                        y=coord[j][1]+Math.sqrt(4*r*r-(coord[i][0]-coord[j][0])*(coord[i][0]-coord[j][0]));
                    }
                }
            }
            coord[i][1]=y;
        }
        for (int i=0;i<n;i++) {
            System.out.print(coord[i][1]);
            if (i<n-1) {
                System.out.print(" ");
            } else {
                System.out.print("\n");
            }
        }
        reader.close();
    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
/**
 * Created by Ariana Herbst on 12/29/17.
 */

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

/**
 * Created by Ariana Herbst on 12/29/17
 */
public class GB2017C {
    static int n, r;
    static int[] x;
    static Map<Integer, Double> horo;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        StringBuilder sb = new StringBuilder();
        n = sc.nextInt();
        r = sc.nextInt();
        x = new int[n];
        horo = new HashMap<Integer, Double>();
        for (int x = 0; x <= r*2; x++) {
            double y = 2.0 *Math.sqrt(r * r - (r - x/2.0) * (r - x/2.0));
            horo.put(x, y);
        }
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        List<Double> y = new ArrayList<Double>();
        for (int i = 0; i < n; i++) {
            double max = r;
            for (int j = 0; j < y.size(); j++) {
                int dx = intersects(i, j);
                if (dx >= 0) {
                    double dy = horo.get(dx);
                    max = Math.max(max, dy + y.get(j));
                }
            }
            y.add(max);
        }
        for (int i = 0; i < n; i++) {
            sb.append(y.get(i) + " ");
        }
        System.out.println(sb);
    }

    static int intersects(int i, int j) {
        if (Math.abs(x[i] - x[j]) <= 2*r) {
            return 2*r - Math.abs(x[i] - x[j]);
        } else
            return -1;
    }


    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class C {

	private static double r, EPS=1e-10;
	
	public static void solve(FastScanner fs) {	
		int n=fs.nextInt();
		r=fs.nextInt();
		int[] xCoords=fs.readArray(n);
		
		ArrayList<Point> placed=new ArrayList<>();
		for (int x:xCoords) {
			double maxY=r;
			for (Point p:placed)
				maxY=Math.max(maxY, getNewY(p, x));
			placed.add(new Point(x, maxY));
		}
		for (Point p:placed) {
			System.out.printf("%.9f ", p.y);
		}
		
	}
	
	private static double getNewY(Point circleCenter, int x) {
		double dx=Math.abs(x-circleCenter.x);
		if (dx>r+r)
			return 0;
		if (dx<EPS)
			return circleCenter.y+r+r;
		double hypot=r+r;
		return circleCenter.y+Math.sqrt(hypot*hypot-(double)dx*dx);
	}

	
	static class Point {
		double x;
		double y;
		public Point(double x, double y) {
			this.x=x;
			this.y=y;
		}
 	}
	
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		FastScanner scanner = new FastScanner(System.in);
		solve(scanner);
	}
	

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(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;
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++)
				a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++)
				a[i]=nextLong();
			return a;
		}
	}
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int r = in.nextInt();
            int[] x = in.readIntArray(n);
            double[] y = new double[n];
            for (int i = 0; i < n; i++) {
                y[i] = r;
                for (int j = 0; j < i; j++) {
                    double d = Math.abs(x[j] - x[i]);
                    if (d <= 2 * r) {
                        double yy = Math.sqrt(4.0 * r * r - d * d);
                        y[i] = Math.max(y[i], y[j] + yy);
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                out.print(y[i] + " ");
            }
        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

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

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

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

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                    //tok = new StringTokenizer(in.readLine(), ", \t\n\r\f"); //adds commas as delimeter
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static ArrayList<ArrayList<Integer>> list;
    static HashSet<Integer> hs;
    static ArrayList<Integer> tmp;
    //int n=Integer.parseInt(br.readLine());
    //int n=Integer.parseInt(st.nextToken());
    //StringTokenizer st = new StringTokenizer(br.readLine());
    public static double cal(int a,double b,int x,int r)
    {
        r*=2;
        double dis=(r*r) - Math.pow(Math.abs(a-x),2);
        
        dis=Math.sqrt(dis);
        
        dis+=b;
        
        return dis;
        
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    int n,r;
	    StringTokenizer st = new StringTokenizer(br.readLine());
	    n=Integer.parseInt(st.nextToken());
	    r=Integer.parseInt(st.nextToken());
	    
	    int arr[] = new int[n+1];
	    double cen[] = new double[n+1];
	    
	    int i,j;
	    
	    for(i=1;i<=n;i++)
	    cen[i]=-1.0;
	    
	    st = new StringTokenizer(br.readLine());
	    for(i=1;i<=n;i++)arr[i]=Integer.parseInt(st.nextToken());
	    
	    for(i=1;i<=n;i++)
	    {
	        int f=0;
	        double max=-1.0;
	        for(j=1;j<=n;j++)
	        {
	            if(i!=j && cen[j]!=-1.0 && (Math.abs(arr[i]-arr[j])<=2*r))
	            {
	                max=Math.max(max,cal(arr[j],cen[j],arr[i],r));
	                f=1;
	                
	            }
	        }
	       // System.out.println(i+" "+max);
	        if(f==1)
	        cen[i]=max;
	        else
	        cen[i]=r*1.0;
	    }
	    for(i=1;i<=n;i++)
	    System.out.print(cen[i]+" ");
	}
}