codeparrot/codecomplex huggingface dataset:
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.util.*;
import static java.lang.Math.*;

public final class FollowTrafficRules {
    private static double[] acce(double i, double a, double v) {
        double[] r = new double[2];
        r[0] = (v - i)/a;
        r[1] = 1d/2d * a * pow(r[0], 2) + i * r[0];
        return r;
    }

    private static double solve(double i, double a, double l) {
        double e = sqrt(pow(i, 2) + 2d * a * l);
        e = a > 0 ? e : -1d * e;
        return (e - i)/a;
    }

    private static double time(double i, double a, double v, double l) {
        double[] r = acce(i, a, v);
        if (r[1] >= l) return solve(i, a, l);
        return r[0] + (l - r[1])/v;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double v = sc.nextDouble();
        double l = sc.nextDouble();
        double d = sc.nextDouble();
        double w = sc.nextDouble();

        double t = 0d;
        double[] r = acce(0, a, w);
        if (v <= w || r[1] >= d) t = time(0, a, v, l);
        else {
            t += r[0];
            t += 2d * time(w, a, v, (d - r[1])/2d);
            t += time(w, a, v, l - d);
        }

        System.out.println(t);
    }
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.io.*;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main {

	private BufferedReader in;
	private BufferedWriter out;

	double time(double a, double l, double v0, double v) {
		double t = (v - v0) / a;
		double s = a * t * t / 2 + v0 * t;
		if (s <= l) {
			return t + (l - s) / v;
		}

		double B = v0, C = -l;
		double D = Math.sqrt(B * B - 2 * a * C);
		return (-B + D) / a;
	}

	// )(()()))(())))
	public void solve() throws Exception {
		StreamTokenizer st = new StreamTokenizer(in);
		st.nextToken();
		double a = st.nval;
		st.nextToken();
		double v = st.nval;
		st.nextToken();
		double l = st.nval;
		st.nextToken();
		double d = st.nval;
		st.nextToken();
		double w = st.nval;

		double ttt = Math.sqrt(2 * d / a);
		double ans = 0.0;

		if (w > v || ttt * a < w) {
			ans = time(a, l, 0, v);
		} else {
			double B = 2 * w / a, C = -w * w / (a * a) - 4 * d / a;
			double D = Math.sqrt(B * B - 4 * C);
			ans = (-B + D) / 2;
			if ((a * ans + w) / 2.0 > v) {
				double t1 = v / a;
				double t2 = (v - w) / a;
				double s = (a * t1 * t1 / 2.0) + (v * t2 - a * t2 * t2 / 2.0);
				ans = t1 + t2 + (d - s) / v;
			}
			ans += time(a, l - d, w, v);
		}
		DecimalFormat df = new DecimalFormat("0.000000000");
		out.write(df.format(ans) + "\n");
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {
		}
		new Main().run();
	}
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {
        double a = in.nextInt();
        double v = in.nextInt();
        double l = in.nextInt();
        double d = in.nextInt();
        double w = in.nextInt();

        if (w * w / (a * 2) > d || v < w) {
            if (v * v / (a * 2) > l) {
                out.println(Math.sqrt(l * 2 / a));
            }
            else {
                double t = v / a;
                double s = l - t * v / 2;
                t = t + s / v;
                out.println(t);
            }
            return;
        }
        double t = solveD(a, v, w, d);
        if ((v + w) * (v - w) / (a * 2) > l - d) {
            double dis = w * w + a * (l - d) * 2;
            double t1 = (Math.sqrt(dis) - w) / a;
            System.out.println(t + t1);
        }
        else {
            double t1 = (v - w) / a;
            double s = l - d - (v + w) * t1 / 2;
            double t2 = s / v;
            System.out.println(t + t1 + t2);
        }
    }

    public double solveD(double a, double vMax, double wBound, double s) {
        double v = Math.sqrt(a * s + wBound * wBound / 2);
        if (v > vMax) {
            v = vMax;
        }
        double t1 = v / a;
        double t2 = (v - wBound) / a;
        double s1 = v * t1 / 2;
        double s2 = (v + wBound) * t2 / 2;
        double sr = s - s1 - s2;
        double tr = sr / v;
        return t1 + t2 + tr;

    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            solve();
            out.close();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                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());
        }
    }

    public static void main(String[] arg) {
        new Main().run();
    }
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant

import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author madis
 */
public class Rules {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a = in.nextInt();
        double v = in.nextInt();
        double l = in.nextInt();
        double d = in.nextInt();
        double w = in.nextInt();

        if (v <= w) {
            double t = v / a;
            if (0.5 * t * t * a > l) {
                t = Math.sqrt(2 * l / a);
            } else {
                t += (l - 0.5 * t * t * a) / v;
            }
            System.out.printf("%.5f", t);

        } else {
            double total = 0.0;
            double t = v / a;
            double t2 = (v - w) / a;
            double tempt = Math.sqrt(2.0 * d / a);
            if (tempt * a <= w) {
                total += tempt;
                w = tempt*a;
            } else if (0.5 * t * t * a +v*t2 - 0.5 * t2 * t2 * a > d) {
                double as = 2.0*a;
                double bs = 4.0*w;
                double cs = ((w * w) / (a) - 2.0 * d );

                double delta = bs * bs - 4.0 * as * cs;
                double root = (-bs + Math.sqrt(delta)) / (2.0 * as);
                if (root < 0.0) {
                    root = (-bs - Math.sqrt(delta)) / (2.0 * as);
                }
                total += (2.0 * root + w / a);
            } else {
                total += t + t2;
                double smd = (d - 0.5 * t * t * a - v*t2 + 0.5 * t2 * t2 * a) / v;
                total += smd;
            }
            double t3 = (v - w) / a;
            if (w * t3 + 0.5 * t3 * t3 * a > l - d) {
                double as = 0.5 * a;
                double bs = w;
                double cs = d - l;

                double delta = bs * bs - 4.0 * as * cs;
                double root = (-bs + Math.sqrt(delta)) / (2.0 * as);
                if (root < 0.0) {
                    root = (-bs - Math.sqrt(delta)) / (2.0 * as);
                }
                total += root;
            } else {
                total += t3;
                double t4 = (l - (w * t3 + 0.5 * t3 * t3 * a) - d) / v;
                total += t4;
            }
            System.out.printf("%.5f", total);
        }
    }
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.io.*;
import java.util.*;
import java.math.*;

public class Solution implements Runnable {
	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;
	private Random rnd;
	
	double Vend;
	
	private double calcFirstSegment(double a, double Vmax, double Vend, double l) {
		double Vl = 0, Vr = Vmax;
		
		for(int it = 0; it < 256; it++) {
			double Vm = (Vl + Vr) / 2.0;
			
			double tFirst = Vm / a;
			
			double tSecond = 0;
			if(Vend < Vm) tSecond = (Vm - Vend) / a;
			
			double firstPart = a * tFirst * tFirst / 2.0;
			double secondPart = Vm * tSecond - a * tSecond * tSecond / 2.0;
			
			double res = firstPart + secondPart;
			
			if(res < l) Vl = Vm;
			else Vr = Vm;
		}
		
		this.Vend = Math.min(Vl, Vend);
		
		double res = 0.0;
		
		{
			double Vm = Vl;
			
			double tFirst = Vm / a;
			double tSecond = 0;
			if(Vend < Vm) tSecond = (Vm - Vend) / a;
			
			//out.println(tSecond);
			
			double firstPart = a * tFirst * tFirst / 2.0;
			double secondPart = Vm * tSecond - a * tSecond * tSecond / 2.0;
			
			double remain = l - firstPart - secondPart;
			
			res = tFirst + tSecond + (remain / Vm);
		}
		
		return res;
	}
	
	private double calcSecondPart(double a, double Vmax, double Vstart, double l) {
		double Vl = Vstart, Vr = Vmax;
		
		//out.println(Vstart);
		
		for(int it = 0; it < 256; it++) {
			double Vm = (Vl + Vr) / 2.0;
			double t = (Vm - Vstart) / a;
			
			double s = Vstart * t + a * t * t / 2.0;
			
			if(s < l) Vl = Vm;
			else Vr = Vm;
		}
		
		double res = 0.0;
		
		{
			double Vm = (Vl + Vr) / 2.0;
			double t = (Vm - Vstart) / a;
			
			double s = Vstart * t + a * t * t / 2.0;
			
			double remain = l - s;
			
			res = t + (remain / Vmax);
		}
		
		return res;
	}
	
	public void solve() throws IOException {
		double a = nextDouble(), v = nextDouble(), l = nextDouble(), d = nextDouble(), w = nextDouble();
		
		double res = calcFirstSegment(a, v, w, d);
		res += calcSecondPart(a, v, Vend, l - d);
		
		out.println(res);
	}
		
	public static void main(String[] args) {
		new Solution().run();
	} 
	
	public void run() {
		try {
			//in = new BufferedReader(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
			
			in = new BufferedReader(new InputStreamReader((System.in)));
			out = new PrintWriter(System.out);
			
			st = null;
			rnd = new Random();
			
			solve();
			
			out.close();
		} catch(IOException e) {
			e.printStackTrace();
		}	
	}
	
	private String nextToken() throws IOException, NullPointerException {
		while(st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		
		return st.nextToken();
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * @author Egor Kulikov (egor@egork.net)
 *         Created on 14.03.2010
 */
public class Rules implements Runnable {
	private Scanner in = new Scanner(System.in);
	private PrintWriter out = new PrintWriter(System.out);
	private double a, v, l, d, w;
	private double ans;

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

	public void run() {
		read();
		solve();
		write();
		out.close();
	}

	private void read() {
		a = in.nextInt();
		v = in.nextInt();
		l = in.nextInt();
		d = in.nextInt();
		w = in.nextInt();
	}

	private double remaining(double v0, double dst) {
		double t = (v - v0) / a;
		double d = a * t * t / 2 + t * v0;
		if (d > dst)
			return (Math.sqrt(v0 * v0 + 2 * a * dst) - v0) / a;
		return t + (dst - d) / v;
	}

	private void solve() {
		if (w * w >= 2 * a * d || w >= v) {
			ans = remaining(0, l);
			return;
		}
		{
			double t1 = v / a;
			double t2 = (v - w) / a;
			double dd = a * t1 * t1 / 2 + a * t2 * t2 / 2 + w * t2;
			if (dd < d) {
				ans = t1 + t2 + (d - dd) / v + remaining(w, l - d);
				return;
			}
		}
		double t1 = w / a;
		double rd = d - t1 * t1 * a / 2;
		double t2 = (Math.sqrt(w * w + a * rd) - w) / a;
		ans = t1 + 2 * t2 + remaining(w, l - d);
	}

	private void write() {
		out.printf("%.7f\n", ans);
	}
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant

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

public class D {

	static Scanner in = new Scanner(new BufferedInputStream(System.in));
	static PrintWriter out = new PrintWriter(System.out);

	static double getTime(double v, double a, double l, double r) {
		return (-v + Math.sqrt(v * v - 2 * a * (l - r))) / a;
	}

	static double getVelocity(double v, double t, double l, double r) {
		return t == 0 ? v : (2 * (r - l)) / t - v;
	}

	public static void main(String[] args) throws IOException {
		double a = in.nextDouble(), v = in.nextDouble(), l = in.nextDouble(),
				d = in.nextDouble(), w = Math.min(v, in.nextDouble());

		double x = v * v / (2 * a), y = d - (v * v - w * w) / (2 * a),
				z = d + (v * v - w * w) / (2 * a);
		//out.println(x + " " + y + " " + z);
		double L, R, T = 0, V = 0, t;

		//OX
		L = 0;
		R = x;
		if (x > y && x < z) {
			R = (x + y) / 2;
		} else if (x > l) {
			R = l;
		}
		t = getTime(V, a, L, R);
		V = getVelocity(V, t, L, R);
		//out.println("l: " + L + ", r: " + R + ", t: " + t + ", v: " + V);
		T += t;

		//XY
		if (x < y) {
			T += (y - x) / v;
		}
		//out.println("t: " + (T - t));

		//YD
		L = y;
		R = d;
		if (x > y && x < z) {
			L = (x + y) / 2;
		} else if (x >= z) {
			L = R;
		}
		t = getTime(V, -a, L, R);
		V = getVelocity(V, t, L, R);
		T += t;
		//out.println("l: " + L + ", r: " + R + ", t: " + t + ", v: " + V);

		//DZ
		L = d;
		R = z;
		if (x >= z) {
			R = L;
		} else if (z > l) {
			R = l;
		}
		t = getTime(V, a, L, R);
		V = getVelocity(V, t, L, R);
		T += t;
		//out.println("l: " + L + ", r: " + R + ", t: " + t + ", v: " + V);

		//ZL
		L = z;
		R = l;
		if (x > z) {
			L = x;
		}
		if (L < R) {
			T += (R - L) / v;
		}

		out.format(Locale.US, "%.12f%n", T);
		out.close();
	}
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
import java.math.BigInteger;

public class Main {
	final int INF = 1000000000;
	final int MAXN = 100100;	
	
	Scanner input = new Scanner(System.in);
	BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	double a, v;
	double l, d, w;
	
	void run() throws IOException {
		a = input.nextDouble();
		v = input.nextDouble();
		l = input.nextDouble();
		d = input.nextDouble();
		w = input.nextDouble();
		if (v <= w) {
			out.println(timeTravel(l, 0));
		} else {
			double tw = w / a;
			double dw = dist(tw, 0);
			if (dw >= d) {
				out.println(timeTravel(l, 0));
			} else {
				double tSym = timeTravel((d - dw) / 2, w);
				out.println(tw + 2 * tSym + timeTravel(l - d, w));
			}
		}
		out.close();
	}	
	
	double dist(double time, double speed) {
		return speed * time + a * time * time / 2; 
	}
	
	double timeTravel(double distance, double speed) {
		double delta = speed * speed + 2 * a * distance;
		double tAll = (Math.sqrt(delta) - speed) / a;
		double tMax = (v - speed) / a;
		if (tMax >= tAll) {
			return tAll;
		} else {
			return tMax + (distance - dist(tMax, speed)) / v;
		}
	}
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.util.Scanner;


public class Task5d {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double v = sc.nextDouble();
		double l = sc.nextDouble();
		double d = sc.nextDouble();
		double w = sc.nextDouble();
		double t = 0;
		if (w >= v) {
			double t1 = v / a;
			double s1 = a * t1 * t1 / 2;
			if (s1 > l) {
				t = Math.sqrt(2 * l / a);
			} else {
				t = t1 + (l - s1) / v;
			}
		} else {
			double t2 = Math.sqrt(2 * d / a);
			if (a * t2 <= w) {
				double t1 = v / a;
				double s1 = a * t1 * t1 / 2;
				if (s1 > l) {
					t = Math.sqrt(2 * l / a);
				} else {
					t = t1 + (l - s1) / v;
				}
			} else {
				double tup = v / a;
				double tdown = (v - w) / a;
				double sup = a * tup * tup / 2;
				double sdown = v * tdown - a * tdown * tdown / 2;
				if (sup + sdown <= d) {
					double tmax = (d - sup - sdown) / v;
					t = tup + tmax + tdown;					
				} else {
					double tw = w / a;
					double sw = a * tw * tw / 2;
					double sl = (d - sw) / 2;
					double dis = w * w + 2 * a * sl;
					double tu1 = (- w - Math.sqrt(dis)) / a;
					if (tu1 < 0) {
						tu1 = (- w + Math.sqrt(dis)) / a;
					}
					t = tw + 2 * tu1;
				}
				double sreup = w * tdown + a * tdown * tdown / 2;
				if (sreup <= l - d) {
					t += tdown;
					t += (l - d - sreup) / v;
				} else {
					double dis = w * w - 2 * a * (d - l);
					double tu1 = (- w - Math.sqrt(dis)) / a;
					if (tu1 < 0) {
						tu1 = (- w + Math.sqrt(dis)) / a;
					}
					t += tu1;
				}
			}
		}
		System.out.println(t);
	}

}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D5 implements Runnable {

	final double eps = 1e-9;

	private void Solution() throws IOException {
		double a = nextDouble(), v = nextDouble();
		double l = nextDouble(), d = nextDouble(), w = nextDouble();
		double t = 0;
		if (w + eps > v) {
			double s = v * v / (2 * a);
			if (s + eps > l)
				t = Math.sqrt(2 * l / a);
			else {
				double ta = v / a;
				double sa = a * ta * ta / 2;
				t = ta + (l - sa) / v;
			}
		} else {
			double sv = v * v / (2 * a);
			double sw = w * w / (2 * a);
			if (sw + eps > d) {
				if (sv + eps > l)
					t = Math.sqrt(2 * l / a);
				else {
					double ta = v / a;
					double sa = a * ta * ta / 2;
					t = ta + (l - sa) / v;
				}
			} else {
				double sd = (w * w - v * v) / (-2 * a);
				if (sv + sd < eps + d)
					t = v / a + (d - sv - sd) / v + (v - w) / a;
				else {
					double f = Math.sqrt(d * a + w * w / 2);
					t = f / a + (f - w) / a;
				}
				if (sd + eps > l - d) {
					double lv = Math.sqrt((l - d) * 2 * a + w * w);
					t += (lv - w) / a;
				} else {
					t += (v - w) / a + (l - d - sd) / v;
				}
			}
		}
		out.printf("%.12f", t);
	}

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

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... obj) {
		for (int i = 0; i < obj.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(obj[i]);
		}
	}

	void println(Object... obj) {
		print(obj);
		print("\n");
	}

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

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

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(next());
	}

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

	String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}
}
// Problem: 5_D. Follow Traffic Rules
// Time complexity: constant
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class D5 {
    
    static StringTokenizer st;
    static BufferedReader in;
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        double a = nextInt();
        double v = nextInt();
        double L = nextInt();
        double d = nextInt();
        double w = nextInt();
        double ans = 0;
        if (w >= v)
            ans = go(0, a, L, v);
        else {
            ans = go(Math.min(w, Math.sqrt(2*a*d)), a, L-d, v);
            if (2*a*d < w*w)
                ans += Math.sqrt(2*d/a);
            else {
                if (d-v*v/(2*a) >= (v*v-w*w)/(2*a))
                    ans += v/a+(v-w)/a+(d-v*v/(2*a)-(v*v-w*w)/(2*a))/v;
                else {
                    double x = Math.sqrt((w*w+2*a*d)/2);
                    ans += x/a+(x-w)/a;
                }
            }
        }
        System.out.println(ans);
        pw.close();
    }
    
    private static double go(double v0, double a, double s, double vmax) {
        double t = (vmax-v0) / a;
        if (v0*t+a*t*t/2 < s)
            return t+(s-v0*t-a*t*t/2) / vmax;
        else {
            double D = v0*v0+2*a*s;
            return (-v0+Math.sqrt(D))/a;
        }
    }
    
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    
    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }
    
    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
    
    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
    
}