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

public class ProblemA {
	public static void main(String[] args) throws Exception{
			BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = new StringTokenizer(bf.readLine());
			StringTokenizer st1 = new StringTokenizer(bf.readLine());
			int n = Integer.parseInt(st.nextToken());
			int r = Integer.parseInt(st.nextToken());
			int[] xcoords = new int[n];
			for(int i = 0;i<n;i++){
				xcoords[i] = Integer.parseInt(st1.nextToken());
			}
			double[] ycoords = new double[n];
			
			for(int i = 0;i<n;i++){
				ArrayList<Integer> nodes = new ArrayList<Integer>();
				for(int j = 0;j<i;j++){
					if (Math.abs(xcoords[j] - xcoords[i]+0.0) <= 2*r)
						nodes.add(j);
				}
				if (nodes.isEmpty()){
					ycoords[i] = r;
					continue;
				}
				else{
					double min = -1;
					for(int k = 0;k<nodes.size();k++){
						double tmp = ycoords[nodes.get(k)] + Math.sqrt(4*r*r - (xcoords[i] - xcoords[nodes.get(k)])*(xcoords[i] - xcoords[nodes.get(k)]));
						if (tmp > min){
							min = tmp;
						}
					}
					ycoords[i] = min;
				}
			}
			for(int i = 0;i<ycoords.length;i++){
				System.out.print(ycoords[i] + " ");
			}
			
	}
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class C {

    public static void main(String[] args) {

        MyScanner in = new MyScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int r = in.nextInt();

        double[] y = new double[n];
        int[] x = new int[n];

        for(int i=0;i<n;++i){
            x[i] = in.nextInt();
            double bestY = r;
            for(int j=0;j<i;++j){
                if(Math.abs(x[i]-x[j]) <= 2*r){
                    double ny = y[j] + Math.sqrt(4*r*r - (x[i]-x[j])*(x[i]-x[j]));
                    if(ny > bestY){
                        bestY = ny;
                    }
                }
            }
            y[i] = bestY;
        }

        for(int i=0;i<n;++i){
            out.println(y[i]);
        }

        out.close();

    }


    // -----------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: 908_C. New Year and Curling
// Time complexity: quadratic

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

public class Solution2 {


    private void solve() throws IOException {
        int n = in.nextInt();
        double r = in.nextDouble();
        List<Double> xes = new ArrayList<>(n);
        List<Double> yes = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            xes.add(in.nextDouble());
        }
        for (int i = 0; i < n; i++) {
            double max = r;
            for (int j = 0; j < i; j++) {
                double x = xes.get(j);
                double y = yes.get(j);
                if (xes.get(i) <= x + 2 * r && xes.get(i) >= x - 2 * r) {
                    max = Math.max(max, y + Math.sqrt(4 * r * r - Math.abs(x - xes.get(i))* Math.abs(x - xes.get(i))));
                }
            }
            yes.add(max);
        }
        for (double y : yes) {
            System.out.print(y + " ");
        }
        System.out.println();
        System.out.flush();
    }

    private static String filename = "";
    private PrintWriter out;
    private MyScanner in;

    private void run() throws IOException {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    private class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        MyScanner() throws IOException {
            this.br = new BufferedReader(new InputStreamReader(System.in));
        }

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle));
        }

        public String nextLine() throws IOException {
            String s = br.readLine();
            return s == null ? "-1" : s;
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return "-1";
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public Integer nextInt() throws IOException {
            return Integer.parseInt(this.next());
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(this.next());
        }

        public Double nextDouble() throws IOException {
            return Double.parseDouble(this.next());
        }

        void close() throws IOException {
            this.br.close();
        }
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Solution2().run();
    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C {

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

		int n = sc.nextInt();
		int r = sc.nextInt();
		
		double ans[] = new double[n];
		
		int[] x = new int[n];
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			ans[i] = r;
			for (int j = 0; j < i; j++) {
				int d = Math.abs(x[i] - x[j]);
				if(d <= 2 * r) {
					ans[i] = Math.max(ans[i], ans[j] + Math.sqrt(4 * r * r - d * d));
				}
			}
			
			out.print(ans[i] + " ");
		}
		out.println();
		
		out.flush();
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

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

public class C {

	public static void main(String[] args) {
		FastScanner in = new FastScanner();
		int n = in.nextInt();
		double r = in.nextInt();
		double x[] = new double[n];
		for(int i = 0; i < n; i++)
			x[i] = in.nextDouble();
		
		double y[] = new double[n];
		y[0] = r;
		
		for(int i = 1; i < n; i++){
			double miny = r;
			for(int j = 0; j < i; j++){
				double dx = Math.abs(x[i]-x[j]);
				if(dx > r*2) continue;
				double yy = Math.sqrt(4*r*r-dx*dx);
				miny = Math.max(miny, yy+y[j]);
			}
			y[i] = miny;
		}
		for(int i = 0; i < n; i++){
			System.out.print(y[i]+" ");
		}
		

	}

	
	
	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(String s) {
			try{
				br = new BufferedReader(new FileReader(s));
			}
			catch(FileNotFoundException e) {
				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) {
					e.printStackTrace();
				}			
			}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(nextToken());
		}
		long nextLong() {
			return Long.parseLong(nextToken());
		}
		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
		String next() {
			return nextToken();
		}
		
	}
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.util.*;
import java.io.*;

public class test {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		StringTokenizer st = new StringTokenizer(s.nextLine());
		int n = Integer.parseInt(st.nextToken());
		int r = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(s.nextLine());
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = Integer.parseInt(st.nextToken());
		}
		ArrayList<State> list = new ArrayList<State>();
		for (int i = 0; i < n; i++) {
			double currY = r;
			for (int j = 0; j < list.size(); j++) {
				double xDiff = Math.abs(list.get(j).getX() - array[i]);
				if (xDiff <= 2 * r) {
					if (currY < list.get(j).getY() + Math.sqrt(4 * r * r - xDiff * xDiff)) {
						currY = list.get(j).getY() + Math.sqrt(4 * r * r - xDiff * xDiff);
					}
				}
			}
			list.add(new State(array[i], currY));
			System.out.print(currY + " ");
		}
		s.close();
	}

	static class State {
		double x;
		double y;

		public State(double a, double b) {
			x = a;
			y = b;
		}

		public double getX() {
			return x;
		}

		public double getY() {
			return y;
		}
	}
}
// 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.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		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 = new int[n];
			for (int i = 0; i < n; i++) {
				x[i] = in.nextInt();
			}
			double res = 0;
			double[] y = new double[n];

			for (int i = 0; i < n; i++) {
				double curY = r;
				for (int j = 0; j < i; j++) {
					int d = Math.abs(x[i] - x[j]);
					if (d <= 2 * r) {
						int a2 = 4 * r * r - d * d;
						curY = Math.max(curY, y[j] + Math.sqrt(a2));
					}
				}
				y[i] = curY;
				out.printf("%.14f", y[i]);
				if (i < n - 1) {
					out.print(" ");
				} else {
					out.println();
				}
			}
		}

	}

	static class InputReader {
		final InputStream is;
		final byte[] buf = new byte[1024];
		int pos;
		int size;

		public InputReader(InputStream is) {
			this.is = is;
		}

		public int nextInt() {
			int c = read();
			while (isWhitespace(c))
				c = read();
			int sign = 1;
			if (c == '-') {
				sign = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = read();
			} while (!isWhitespace(c));
			return res * sign;
		}

		int read() {
			if (size == -1)
				throw new InputMismatchException();
			if (pos >= size) {
				pos = 0;
				try {
					size = is.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (size <= 0)
					return -1;
			}
			return buf[pos++] & 255;
		}

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

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

public class C {

	public static void main(String[] args){
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt(), r = scan.nextInt();
		int[] x = scan.nextIntArray(n);
		double[] y = new double[n];
		for(int i = 0; i < n; i++) {
			double best = 0;
			for(int j = 0; j < i; j++) {
				if(Math.abs(dist(x[i], y[j], x[j], y[j])-2*r) <= 1e-7) {
					best = Math.max(best, y[j]);
					continue;
				}
				double lo = y[j]-r-r, hi = y[j]+r+r;
				for(int bs = 0; bs < 200; bs++) {
					double mid = (lo+hi)/2.0;
					if(dist(x[i], mid, x[j], y[j])-2*r <= 1e-7) lo = mid;
					else hi = mid;
				}
				if(dist(x[i], lo, x[j], y[j])-2*r <= 1e-7) best = Math.max(best, lo);
			}
			if(best == 0) y[i] = r;
			else y[i] = best;
		}
		for(int i = 0; i < n; i++) out.printf("%.6f ", y[i]);
		out.close();
	}

	static double dist(double x, double y, double xx, double yy) {return Math.sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

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

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

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

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}

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

		public long[] nextLongArray(int n){
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}

		public double[] nextDoubleArray(int n){
			double[] a = new double[n];
			for(int i = 0; i < n; i++) a[i] = nextDouble();
			return a;
		}

		public char[][] nextGrid(int n, int m){
			char[][] grid = new char[n][m];
			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
			return grid;
		}
	}


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

import java.util.Scanner;

/**
 *
 * @author msagimbekov
 */
public class Codeforces908C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        int[] x = new int[n];
        double[] res = new double[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            res[i] = (double)r;
            for (int j = i - 1; j >= 0; j--) {
                int diff = x[j] - x[i];
                if (Math.abs(x[j] - x[i]) <= 2 * r) {
                    res[i] = Math.max(res[i], res[j] + Math.sqrt(4 * r * r - diff * diff));
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            System.out.print(res[i] + " ");
        }
        System.out.println("");
    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic

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

public class NewYearCurling908C {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int n = in.nextInt();
        
        double r = (double) in.nextInt();
        double[] answers = new double[n];
        double[] xCoords = new double[n];
        for (int i = 0; i < n; i++) xCoords[i] = (double) in.nextInt();
        
        answers[0] = r;
        for (int i = 1; i < n; i++) {
            double bound = r;
            for (int j = 0; j < i; j++) {
                double xDif = xCoords[i] - xCoords[j];
                double y = answers[j];
                double yNew = y + Math.sqrt(4 * r * r - xDif * xDif);
                if (yNew > bound) bound = yNew;
            }
            answers[i] = bound;
        }
        for (int i = 0; i < n; i++) System.out.print(answers[i] + " ");
        System.out.println();
    }

    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();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

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

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

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		int d = 2 * r;
		int[] xCoordinates = new int[n];
		double[] yCoordinates = new double[n];
		for (int i = 0; i < n; i++)
			yCoordinates[i] = r;
		for (int i = 0; i < n; i++)
			xCoordinates[i] = sc.nextInt();
		double y = 0;
		for (int i = 0; i < n; i++) {
			y = r;
			for (int j = 0; j < i; j++) {
				if (Math.abs(xCoordinates[i] - xCoordinates[j]) <= 2 * r) {
					int dx = Math.abs(xCoordinates[i] - xCoordinates[j]);
					double dy = Math.sqrt(d * d - dx * dx);
					if (dy + yCoordinates[j] > y)
						y = dy + yCoordinates[j];
				}
			}
			yCoordinates[i]=y;
		}
		for (int i = 0; i < n; i++)
			System.out.print(yCoordinates[i] + " ");
		sc.close();
	}

}
// Problem: 908_C. New Year and Curling
// Time complexity: quadratic
import java.util.*;
import java.io.*;
public class C
{
   static long time = System.currentTimeMillis();
   public static void main(String[] args) throws IOException
   {
      //FastReader infile = new FastReader("test.txt");
      FastReader infile = new FastReader(System.in);
      int N = infile.nextInt();
      int R = infile.nextInt();
      double[] xPos = new double[N];
      for(int x = 0; x < N; x++)
         xPos[x] = infile.nextDouble();
      double[] yPos = new double[N];
      Arrays.fill(yPos, R);
      for(int x = 1; x < N; x++)
      {
         for(int y = 0; y < x; y++)
            if(Math.abs(xPos[x]-xPos[y])<=2*R)
            {
               yPos[x] = Math.max(yPos[x], yPos[y]+Math.sqrt((2*R)*(2*R)-Math.abs(xPos[x]-xPos[y])*Math.abs(xPos[x]-xPos[y])));
            }
      }
      System.out.print(yPos[0]);
      for(int x = 1; x < N; x++)
         System.out.print(" "+yPos[x]);
      //System.out.println(System.currentTimeMillis()-time);
   }
}
class FastReader
{
   BufferedReader br;
   StringTokenizer st;

   public FastReader(String file) throws IOException
   {
      br = new BufferedReader(new FileReader(file));
   }
 
   public FastReader(InputStream i) throws IOException
   {
      br = new BufferedReader(new InputStreamReader(System.in));
   }
   boolean hasNext()
   {
      while (st == null || !st.hasMoreElements())
      {
         try
         {
            st = new StringTokenizer(br.readLine());
         }
         catch (Exception  e)
         {
            return false;
         }
      }
      return true;
   }
 
   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;
   }
}