using System;
using System.Collections.Generic;
using System.Text;

namespace CodeForcesApp
{
    class E
    {
        #region Shortcuts
        static string RL() { return Console.ReadLine(); }
        static string[] RSA() { return RL().Split(' '); }
        static int[] RIA() { return Array.ConvertAll<string, int>(RSA(), int.Parse); }
        static int RInt() { return int.Parse(RL()); }
        static long RLong() { return long.Parse(RL()); }
        static double RDouble() { return double.Parse(RL()); }
        static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }
        static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }
        static void RInts4(out int p1, out int p2, out int p3, out int p4) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; p4 = a[3]; }

        static void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        static void Fill<T>(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }
        static void Fill<T>(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }
        #endregion

        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            //SolutionTester tester = new SolutionTester(CodeForcesTask.E);
            //tester.Test();

            Task task = new Task();
            task.Solve();
        }

        public class Task
        {
            public void Solve()
            {
                int xv, yv, xp, yp, xw1, yw1, xw2, yw2, xm1, ym1, xm2, ym2;
                RInts2(out xv, out yv);
                RInts2(out xp, out yp);
                RInts4(out xw1, out yw1, out xw2, out yw2);
                RInts4(out xm1, out ym1, out xm2, out ym2);

                Point p = new Point(xp, yp);

                Segment view = new Segment(xv, yv, xp, yp);
                Segment wall = new Segment(xw1, yw1, xw2, yw2);
                Segment mirror = new Segment(xm1, ym1, xm2, ym2);

                Point rp = p.Reflect(mirror.ToLine());

                Segment rview = new Segment(xv, yv, rp.x, rp.y);

                Point pt1, pt2;

                if (!view.Intersects(wall, out pt1, out pt2) ||
                    (rview.Intersects(mirror, out pt1, out pt2) && !rview.Intersects(wall, out pt1, out pt2)))
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }

        public class GeometryUtils
        {
            public const double EPS = 10e-8;

            public static double SqrDist(double x1, double y1, double x2, double y2)
            {
                return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
            }

            public static double Dist(double x1, double x2)
            {
                return Math.Abs(x1 - x2);
            }

            public static double Dist(double x1, double y1, double x2, double y2)
            {
                return Math.Sqrt(SqrDist(x1, y1, x2, y2));
            }

            public static double Determinant(
                double a11, double a12,
                double a21, double a22)
            {
                return a11 * a22 - a21 * a12;
            }

            public static double Determinant(
                double a11, double a12, double a13,
                double a21, double a22, double a23,
                double a31, double a32, double a33
                )
            {
                return a11 * Determinant(a22, a23, a32, a33) - a21 * Determinant(a12, a13, a32, a33) + a31 * Determinant(a12, a13, a22, a23);
            }

            public static int Sign(double val)
            {
                if (Math.Abs(val) <= EPS)
                    return 0;

                if (val > EPS)
                    return 1;

                return -1;
            }

        }

        public class Point
        {
            public double x;
            public double y;

            #region Constructors

            public Point()
            {
            }

            public Point(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            #endregion

            #region Public Methods

            public Vector ToVector()
            {
                return new Vector(x, y);
            }

            public int Orientation(Point q, Point r)
            {
                return Orientation(this, q, r);
            }

            public double Area(Point q, Point r)
            {
                return Area(this, q, r);
            }

            public double SqrDist(Point q)
            {
                return GeometryUtils.SqrDist(x, y, q.x, q.y);
            }

            public double Distance()
            {
                return GeometryUtils.Dist(x, y, 0, 0);
            }

            public double Distance(Point q)
            {
                return GeometryUtils.Dist(x, y, q.x, q.y);
            }

            public double XDist(Point q)
            {
                return GeometryUtils.Dist(x, q.x);
            }

            public double YDist(Point q)
            {
                return GeometryUtils.Dist(y, q.y);
            }

            public Point Translate(double _x, double _y)
            {
                return new Point(x + _x, y + _y);
            }

            public Point Translate(Vector v)
            {
                return new Point(x + v.x, y + v.y);
            }

            // Находит проекцию точки на прямую
            public Point Project(Line line)
            {
                Line ort = new Line(this, line.NormalVector);
                Point pt;
                line.Intersects(ort, out pt);
                return pt;
            }

            public Point Reflect(Line line)
            {
                Point pr = Project(line);
                Vector v = (pr - this).Scale(2);
                return this.Translate(v);
            }

            #endregion

            #region Static Members

            public static Vector operator -(Point p1, Point p2)
            {
                return new Vector(p1.x - p2.x, p1.y - p2.y);
            }

            public static int Orientation(Point p, Point q, Point r)
            {
                double det = GeometryUtils.Determinant(p.x, p.y, 1, q.x, q.y, 1, r.x, r.y, 1);
                if (det > 0) return 1;
                if (det < 0) return -1;
                return 0;
            }

            public static double Area(Point p, Point q, Point r)
            {
                return GeometryUtils.Determinant(q.x - p.x, q.y - p.y, r.x - p.x, r.y - p.y);
            }

            #endregion
        }

        public class Vector
        {
            public double x;
            public double y;

            public Vector()
            {
            }

            public Vector(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            public Vector Translate(double a, double b)
            {
                return new Vector(x + a, y + b);
            }

            public Vector Translate(Vector v)
            {
                return new Vector(x + v.x, y + v.y);
            }

            public Vector Scale(double d)
            {
                return new Vector(x * d, y * d);
            }
        }

        public class Segment
        {
            private Point start;
            private Point end;

            #region Constructors

            public Segment()
                : this(new Point(), new Point())
            {
            }

            public Segment(Point s, Point e)
            {
                start = s;
                end = e;
            }

            public Segment(double x1, double y1, double x2, double y2)
                : this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            #endregion

            #region Public Properties

            public Point Start
            {
                get { return start; }
                set { start = value; }
            }

            public Point End
            {
                get { return end; }
                set { end = value; }
            }

            public double x1
            {
                get { return start.x; }
                set { start.x = value; }
            }

            public double y1
            {
                get { return start.y; }
                set { start.y = value; }
            }

            public double x2
            {
                get { return end.x; }
                set { end.x = value; }
            }

            public double y2
            {
                get { return end.y; }
                set { end.y = value; }
            }

            public Vector Direction
            {
                get { return End - Start; }
            }

            #endregion

            #region Public Methods

            public Line ToLine()
            {
                return new Line(this);
            }

            public bool Intersects(Segment seg, out Point p1, out Point p2)
            {
                p1 = new Point();
                p2 = new Point();

                double minx1 = Math.Min(Start.x, End.x);
                double maxx1 = Math.Max(Start.x, End.x);
                double miny1 = Math.Min(Start.y, End.y);
                double maxy1 = Math.Max(Start.y, End.y);

                double minx2 = Math.Min(seg.Start.x, seg.End.x);
                double maxx2 = Math.Max(seg.Start.x, seg.End.x);
                double miny2 = Math.Min(seg.Start.y, seg.End.y);
                double maxy2 = Math.Max(seg.Start.y, seg.End.y);

                if (minx1 > maxx2 || maxx1 < minx2 || miny1 > maxy2 || maxy1 < miny2)
                    return false;  // boundary rectangles not intersected

                Line this_line = this.ToLine();
                Line seg_line = seg.ToLine();

                if (this_line.Parallel(seg_line))
                {
                    if (this_line.Equivalent(seg_line))
                    {
                        p1.x = Math.Max(minx1, minx2);
                        p1.y = Math.Max(miny1, miny2);
                        p2.x = Math.Min(maxx1, maxx2);
                        p2.y = Math.Min(miny1, miny2);
                        return true; // intersection by segment
                    }
                    else
                        return false; // parallel
                }

                Point pt;
                if (!this_line.Intersects(seg_line, out pt))
                    return false;

                if (pt.x >= minx1 && pt.x <= maxx1 &&
                    pt.y >= miny1 && pt.y <= maxy1 &&
                    pt.x >= minx2 && pt.x <= maxx2 &&
                    pt.y >= miny2 && pt.y <= maxy2)
                {
                    p1.x = pt.x;
                    p1.y = pt.y;
                    p2.x = pt.x;
                    p2.y = pt.y;
                    return true; // in one point
                }

                return false;
            }

            public double Distance(Point p)
            {
                Line line = this.ToLine();
                double[] cc = line.Coeffs;
                double A = cc[0];
                double B = cc[1];
                double C = cc[2];

                double d = (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
                d = Math.Min(d, p.Distance(Start));
                d = Math.Min(d, p.Distance(End));
                return d;
            }

            #endregion

        }

        public class Line
        {
            #region Private Members

            private Point bp;
            private Vector dir;

            #endregion

            #region Constructors

            public Line()
                : this(new Point(), new Vector(1, 0))
            {
            }

            public Line(Point p, Vector v)
            {
                bp = p;
                dir = v;
            }

            public Line(Point p1, Point p2)
                : this(p1, p2 - p1)
            {

            }

            public Line(double x1, double y1, double x2, double y2) :
                this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            public Line(Segment s) :
                this(s.Start, s.Direction)
            {

            }

            #endregion

            #region Public Properties

            public Point BasePoint { get { return bp; } }
            public Vector Direction { get { return dir; } }
            public Vector NormalVector { get { return new Vector(-dir.y, dir.x); } }
            public double[] Coeffs
            {
                get
                {
                    return new double[3]
                {
                    dir.y,
                    -dir.x,
                    dir.x * bp.y - dir.y * bp.x
                };
                }
            }

            public double A { get { return dir.y; } }
            public double B { get { return -dir.x; } }
            public double C { get { return dir.x * bp.y - dir.y * bp.x; } }

            #endregion

            #region Public Methods

            public bool Intersects(Line line, out Point pt)
            {
                pt = new Point();

                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                if (GeometryUtils.Sign(d) == 0)
                    return false;

                pt.x = -GeometryUtils.Determinant(C, B, line.C, line.B) / d;
                pt.y = -GeometryUtils.Determinant(A, C, line.A, line.C) / d;

                return true;
            }

            public bool Parallel(Line line)
            {
                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                return GeometryUtils.Sign(d) == 0;
            }

            public bool Equivalent(Line line)
            {
                double d1 = GeometryUtils.Determinant(A, B, line.A, line.B);
                double d2 = GeometryUtils.Determinant(A, C, line.A, line.C);
                double d3 = GeometryUtils.Determinant(B, C, line.B, line.C);

                return GeometryUtils.Sign(d1) == 0 && GeometryUtils.Sign(d2) == 0 && GeometryUtils.Sign(d2) == 0;
            }

            public double Distance(Point p)
            {
                return (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
            }

            #endregion
        }

    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace CodeForcesApp
{
    class E
    {
        #region Shortcuts
        static string RL() { return Console.ReadLine(); }
        static string[] RSA() { return RL().Split(' '); }
        static int[] RIA() { return Array.ConvertAll<string, int>(RSA(), int.Parse); }
        static int RInt() { return int.Parse(RL()); }
        static long RLong() { return long.Parse(RL()); }
        static double RDouble() { return double.Parse(RL()); }
        static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }
        static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }
        static void RInts4(out int p1, out int p2, out int p3, out int p4) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; p4 = a[3]; }

        static void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        static void Fill<T>(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }
        static void Fill<T>(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }
        #endregion

        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            //SolutionTester tester = new SolutionTester(CodeForcesTask.E);
            //tester.Test();

            Task task = new Task();
            task.Solve();
        }

        public class Task
        {
            public void Solve()
            {
                int xv, yv, xp, yp, xw1, yw1, xw2, yw2, xm1, ym1, xm2, ym2;
                RInts2(out xv, out yv);
                RInts2(out xp, out yp);
                RInts4(out xw1, out yw1, out xw2, out yw2);
                RInts4(out xm1, out ym1, out xm2, out ym2);

                Point p = new Point(xp, yp);

                Segment view = new Segment(xv, yv, xp, yp);
                Segment wall = new Segment(xw1, yw1, xw2, yw2);
                Segment mirror = new Segment(xm1, ym1, xm2, ym2);

                Point rp = p.Reflect(mirror.ToLine());

                Segment rview = new Segment(xv, yv, rp.x, rp.y);

                Point pt1, pt2;

                if (!view.Intersects(wall, out pt1, out pt2) && !view.Intersects(mirror, out pt1, out pt2) ||
                    (rview.Intersects(mirror, out pt1, out pt2) && !rview.Intersects(wall, out pt1, out pt2)))
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }

        public class GeometryUtils
        {
            public const double EPS = 10e-12;

            public static double SqrDist(double x1, double y1, double x2, double y2)
            {
                return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
            }

            public static double Dist(double x1, double x2)
            {
                return Math.Abs(x1 - x2);
            }

            public static double Dist(double x1, double y1, double x2, double y2)
            {
                return Math.Sqrt(SqrDist(x1, y1, x2, y2));
            }

            public static double Determinant(
                double a11, double a12,
                double a21, double a22)
            {
                return a11 * a22 - a21 * a12;
            }

            public static double Determinant(
                double a11, double a12, double a13,
                double a21, double a22, double a23,
                double a31, double a32, double a33
                )
            {
                return a11 * Determinant(a22, a23, a32, a33) - a21 * Determinant(a12, a13, a32, a33) + a31 * Determinant(a12, a13, a22, a23);
            }

            public static int Sign(double val)
            {
                if (Math.Abs(val) <= EPS)
                    return 0;

                if (val > EPS)
                    return 1;

                return -1;
            }

        }

        public class Point
        {
            public double x;
            public double y;

            #region Constructors

            public Point()
            {
            }

            public Point(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            #endregion

            #region Public Methods

            public Vector ToVector()
            {
                return new Vector(x, y);
            }

            public int Orientation(Point q, Point r)
            {
                return Orientation(this, q, r);
            }

            public double Area(Point q, Point r)
            {
                return Area(this, q, r);
            }

            public double SqrDist(Point q)
            {
                return GeometryUtils.SqrDist(x, y, q.x, q.y);
            }

            public double Distance()
            {
                return GeometryUtils.Dist(x, y, 0, 0);
            }

            public double Distance(Point q)
            {
                return GeometryUtils.Dist(x, y, q.x, q.y);
            }

            public double XDist(Point q)
            {
                return GeometryUtils.Dist(x, q.x);
            }

            public double YDist(Point q)
            {
                return GeometryUtils.Dist(y, q.y);
            }

            public Point Translate(double _x, double _y)
            {
                return new Point(x + _x, y + _y);
            }

            public Point Translate(Vector v)
            {
                return new Point(x + v.x, y + v.y);
            }

            // Находит проекцию точки на прямую
            public Point Project(Line line)
            {
                Line ort = new Line(this, line.NormalVector);
                Point pt;
                line.Intersects(ort, out pt);
                return pt;
            }

            public Point Reflect(Line line)
            {
                Point pr = Project(line);
                Vector v = (pr - this).Scale(2);
                return this.Translate(v);
            }

            #endregion

            #region Static Members

            public static Vector operator -(Point p1, Point p2)
            {
                return new Vector(p1.x - p2.x, p1.y - p2.y);
            }

            public static int Orientation(Point p, Point q, Point r)
            {
                double det = GeometryUtils.Determinant(p.x, p.y, 1, q.x, q.y, 1, r.x, r.y, 1);
                if (det > 0) return 1;
                if (det < 0) return -1;
                return 0;
            }

            public static double Area(Point p, Point q, Point r)
            {
                return GeometryUtils.Determinant(q.x - p.x, q.y - p.y, r.x - p.x, r.y - p.y);
            }

            #endregion
        }

        public class Vector
        {
            public double x;
            public double y;

            public Vector()
            {
            }

            public Vector(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            public Vector Translate(double a, double b)
            {
                return new Vector(x + a, y + b);
            }

            public Vector Translate(Vector v)
            {
                return new Vector(x + v.x, y + v.y);
            }

            public Vector Scale(double d)
            {
                return new Vector(x * d, y * d);
            }
        }

        public class Segment
        {
            private Point start;
            private Point end;

            #region Constructors

            public Segment()
                : this(new Point(), new Point())
            {
            }

            public Segment(Point s, Point e)
            {
                start = s;
                end = e;
            }

            public Segment(double x1, double y1, double x2, double y2)
                : this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            #endregion

            #region Public Properties

            public Point Start
            {
                get { return start; }
                set { start = value; }
            }

            public Point End
            {
                get { return end; }
                set { end = value; }
            }

            public double x1
            {
                get { return start.x; }
                set { start.x = value; }
            }

            public double y1
            {
                get { return start.y; }
                set { start.y = value; }
            }

            public double x2
            {
                get { return end.x; }
                set { end.x = value; }
            }

            public double y2
            {
                get { return end.y; }
                set { end.y = value; }
            }

            public Vector Direction
            {
                get { return End - Start; }
            }

            #endregion

            #region Public Methods

            public Line ToLine()
            {
                return new Line(this);
            }

            public bool Intersects(Segment seg, out Point p1, out Point p2)
            {
                p1 = new Point();
                p2 = new Point();

                double minx1 = Math.Min(Start.x, End.x);
                double maxx1 = Math.Max(Start.x, End.x);
                double miny1 = Math.Min(Start.y, End.y);
                double maxy1 = Math.Max(Start.y, End.y);

                double minx2 = Math.Min(seg.Start.x, seg.End.x);
                double maxx2 = Math.Max(seg.Start.x, seg.End.x);
                double miny2 = Math.Min(seg.Start.y, seg.End.y);
                double maxy2 = Math.Max(seg.Start.y, seg.End.y);

                if (minx1 > maxx2 || maxx1 < minx2 || miny1 > maxy2 || maxy1 < miny2)
                    return false;  // boundary rectangles not intersected

                Line this_line = this.ToLine();
                Line seg_line = seg.ToLine();

                if (this_line.Parallel(seg_line))
                {
                    if (this_line.Equivalent(seg_line))
                    {
                        p1.x = Math.Max(minx1, minx2);
                        p1.y = Math.Max(miny1, miny2);
                        p2.x = Math.Min(maxx1, maxx2);
                        p2.y = Math.Min(miny1, miny2);
                        return true; // intersection by segment
                    }
                    else
                        return false; // parallel
                }

                Point pt;
                if (!this_line.Intersects(seg_line, out pt))
                    return false;

                if (pt.x >= minx1 && pt.x <= maxx1 &&
                    pt.y >= miny1 && pt.y <= maxy1 &&
                    pt.x >= minx2 && pt.x <= maxx2 &&
                    pt.y >= miny2 && pt.y <= maxy2)
                {
                    p1.x = pt.x;
                    p1.y = pt.y;
                    p2.x = pt.x;
                    p2.y = pt.y;
                    return true; // in one point
                }

                return false;
            }

            public double Distance(Point p)
            {
                Line line = this.ToLine();
                double[] cc = line.Coeffs;
                double A = cc[0];
                double B = cc[1];
                double C = cc[2];

                double d = (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
                d = Math.Min(d, p.Distance(Start));
                d = Math.Min(d, p.Distance(End));
                return d;
            }

            #endregion

        }

        public class Line
        {
            #region Private Members

            private Point bp;
            private Vector dir;

            #endregion

            #region Constructors

            public Line()
                : this(new Point(), new Vector(1, 0))
            {
            }

            public Line(Point p, Vector v)
            {
                bp = p;
                dir = v;
            }

            public Line(Point p1, Point p2)
                : this(p1, p2 - p1)
            {

            }

            public Line(double x1, double y1, double x2, double y2) :
                this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            public Line(Segment s) :
                this(s.Start, s.Direction)
            {

            }

            #endregion

            #region Public Properties

            public Point BasePoint { get { return bp; } }
            public Vector Direction { get { return dir; } }
            public Vector NormalVector { get { return new Vector(-dir.y, dir.x); } }
            public double[] Coeffs
            {
                get
                {
                    return new double[3]
                {
                    dir.y,
                    -dir.x,
                    dir.x * bp.y - dir.y * bp.x
                };
                }
            }

            public double A { get { return dir.y; } }
            public double B { get { return -dir.x; } }
            public double C { get { return dir.x * bp.y - dir.y * bp.x; } }

            #endregion

            #region Public Methods

            public bool Intersects(Line line, out Point pt)
            {
                pt = new Point();

                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                if (GeometryUtils.Sign(d) == 0)
                    return false;

                pt.x = -GeometryUtils.Determinant(C, B, line.C, line.B) / d;
                pt.y = -GeometryUtils.Determinant(A, C, line.A, line.C) / d;

                return true;
            }

            public bool Parallel(Line line)
            {
                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                return GeometryUtils.Sign(d) == 0;
            }

            public bool Equivalent(Line line)
            {
                double d1 = GeometryUtils.Determinant(A, B, line.A, line.B);
                double d2 = GeometryUtils.Determinant(A, C, line.A, line.C);
                double d3 = GeometryUtils.Determinant(B, C, line.B, line.C);

                return GeometryUtils.Sign(d1) == 0 && GeometryUtils.Sign(d2) == 0 && GeometryUtils.Sign(d2) == 0;
            }

            public double Distance(Point p)
            {
                return (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
            }

            #endregion
        }

    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Linq;
class Program
{
    class Point
    {
        public double x, y;
        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }
    }
    class Line
    {
        public double a, b, c;
        public Line(Point p1, Point p2)
        {
            a = p2.y - p1.y;
            b = p1.x - p2.x;
            c = a * p1.x + b * p1.y;
        }
        public  Line()
        {

        }

        public Line prep( Point p)
        {
            Line res=new Line();
            res.a = -b;
            res.b = a;
            res.c = res.a * p.x + res.b * p.y;
            return res;

        }
        public Point Intersect(Line l)
        {
            Point res = new Point(0,0);
            double d = a * l.b - b * l.a;
            res.x = (l.b * c - b * l.c) / d;
            res.y = (a * l.c - l.a * c) / d;
            return res;
        }

    }
    double eps = 1e-9;
    void solve()
    {
        Point p = new Point(nextInt(), nextInt());
        Point v=new Point(nextInt(),nextInt());
        Point[]w=new Point[2];

        for (int i = 0; i < 2; i++)
            w[i] = new Point(nextInt(), nextInt());
        Point[] mir = new Point[2];
        for (int i = 0; i < 2; i++)
            mir[i] = new Point(nextInt(), nextInt());

        bool ok = false;
        if (good(p, v, w[0], w[1]) && (good(p,v,mir[0],mir[1]) || sign(cross(mir[0],mir[1],p))==0))
        {
            ok = true;
        }
        else if (sign(cross(mir[0], mir[1], p)) * sign(cross(mir[0], mir[1], v)) == 1)
        {
            Line lm = new Line(mir[0], mir[1]);
            Line pr = lm.prep(p);
            Point inter = lm.Intersect(pr);
            Point other = new Point(inter.x + (inter.x - p.x), inter.y + (inter.y - p.y));
            {
                Line l = new Line(other, v);
                Point x = l.Intersect(lm);
                if (good(x, p, w[0], w[1]) && good(x, v, w[0], w[1]) && on(mir[0], mir[1], x))
                    ok = true;
            }

        }
        if (ok)
            println("YES");
        else
            println("NO");

    }

    private bool good(Point p1, Point p2, Point p3, Point p4)
    {
        double d1 = cross(p1, p2, p3);
        double d2 = cross(p1, p2, p4);
        double d3 = cross(p3, p4,p1);
        double d4 = cross(p3, p4, p2);
        int x1 = sign(d1);
        int x2 = sign(d2);
        int x3 = sign(d3);
        int x4 = sign(d4);
        if (x1 * x2 < 0 && x3 * x4 < 0)
            return false;
        if (x1 == 0)
        {
            if (on(p1, p2, p3))
                return false;
        }
        if (x2 == 0)
        {
            if (on(p1, p2, p4))
                return false;
        }
        if (x3 == 0)
        {
            if (on(p3, p4, p1))
                return false;
        }
        if (x4 == 0)
        {
            if (on(p3, p4, p2))
                return false;
        }

        return true;

    }

    private bool on(Point p1, Point p2, Point p3)
    {
        return on(p1.x, p2.x, p3.x) && on(p1.y, p2.y, p3.y);
    }

    private bool on(double x, double y, double z)
    {
        return z >= Math.Min(x, y) - eps && z <= Math.Max(x, y) + eps;
    }

    private int sign(double d1)
    {
        return Math.Abs(d1) < eps ? 0 : Math.Sign(d1);
    }

    private double cross(Point p1, Point p2, Point p3)
    {
        return (p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y);
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace CodeForcesApp
{
    class E
    {
        #region Shortcuts
        static string RL() { return Console.ReadLine(); }
        static string[] RSA() { return RL().Split(' '); }
        static int[] RIA() { return Array.ConvertAll<string, int>(RSA(), int.Parse); }
        static int RInt() { return int.Parse(RL()); }
        static long RLong() { return long.Parse(RL()); }
        static double RDouble() { return double.Parse(RL()); }
        static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }
        static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }
        static void RInts4(out int p1, out int p2, out int p3, out int p4) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; p4 = a[3]; }

        static void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        static void Fill<T>(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }
        static void Fill<T>(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }
        #endregion

        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            //SolutionTester tester = new SolutionTester(CodeForcesTask.E);
            //tester.Test();

            Task task = new Task();
            task.Solve();
        }

        public class Task
        {
            public void Solve()
            {
                int xv, yv, xp, yp, xw1, yw1, xw2, yw2, xm1, ym1, xm2, ym2;
                RInts2(out xv, out yv);
                RInts2(out xp, out yp);
                RInts4(out xw1, out yw1, out xw2, out yw2);
                RInts4(out xm1, out ym1, out xm2, out ym2);

                Point v = new Point(xv, yv);
                Point p = new Point(xp, yp);

                Segment view = new Segment(xv, yv, xp, yp);
                Segment wall = new Segment(xw1, yw1, xw2, yw2);
                Segment mirror = new Segment(xm1, ym1, xm2, ym2);

                Point rp = p.Reflect(mirror.ToLine());

                Segment rview = new Segment(xv, yv, rp.x, rp.y);
                Segment rdview = new Segment(rp.x, rp.y, xp, yp);

                Point pt1, pt2;

                if (!view.Intersects(wall, out pt1, out pt2) && !view.Intersects(mirror, out pt1, out pt2))
                {
                    Console.WriteLine("YES");
                    return;
                }

                Point rpm1, rpm2;
                if (rview.Intersects(mirror, out rpm1, out rpm2))
                {
                    Segment s1 = new Segment(v, rpm1);
                    Segment s2 = new Segment(rpm1, p);
                    if (!s1.Intersects(wall, out pt1, out pt2) && !s2.Intersects(wall, out pt1, out pt2))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
                Console.WriteLine("NO");
            }
        }

        public class GeometryUtils
        {
            public const double EPS = 10e-12;

            public static double SqrDist(double x1, double y1, double x2, double y2)
            {
                return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
            }

            public static double Dist(double x1, double x2)
            {
                return Math.Abs(x1 - x2);
            }

            public static double Dist(double x1, double y1, double x2, double y2)
            {
                return Math.Sqrt(SqrDist(x1, y1, x2, y2));
            }

            public static double Determinant(
                double a11, double a12,
                double a21, double a22)
            {
                return a11 * a22 - a21 * a12;
            }

            public static double Determinant(
                double a11, double a12, double a13,
                double a21, double a22, double a23,
                double a31, double a32, double a33
                )
            {
                return a11 * Determinant(a22, a23, a32, a33) - a21 * Determinant(a12, a13, a32, a33) + a31 * Determinant(a12, a13, a22, a23);
            }

            public static int Sign(double val)
            {
                if (Math.Abs(val) <= EPS)
                    return 0;

                if (val > EPS)
                    return 1;

                return -1;
            }

        }

        public class Point
        {
            public double x;
            public double y;

            #region Constructors

            public Point()
            {
            }

            public Point(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            #endregion

            #region Public Methods

            public Vector ToVector()
            {
                return new Vector(x, y);
            }

            public int Orientation(Point q, Point r)
            {
                return Orientation(this, q, r);
            }

            public double Area(Point q, Point r)
            {
                return Area(this, q, r);
            }

            public double SqrDist(Point q)
            {
                return GeometryUtils.SqrDist(x, y, q.x, q.y);
            }

            public double Distance()
            {
                return GeometryUtils.Dist(x, y, 0, 0);
            }

            public double Distance(Point q)
            {
                return GeometryUtils.Dist(x, y, q.x, q.y);
            }

            public double XDist(Point q)
            {
                return GeometryUtils.Dist(x, q.x);
            }

            public double YDist(Point q)
            {
                return GeometryUtils.Dist(y, q.y);
            }

            public Point Translate(double _x, double _y)
            {
                return new Point(x + _x, y + _y);
            }

            public Point Translate(Vector v)
            {
                return new Point(x + v.x, y + v.y);
            }

            // Находит проекцию точки на прямую
            public Point Project(Line line)
            {
                Line ort = new Line(this, line.NormalVector);
                Point pt;
                line.Intersects(ort, out pt);
                return pt;
            }

            public Point Reflect(Line line)
            {
                Point pr = Project(line);
                Vector v = (pr - this).Scale(2);
                return this.Translate(v);
            }

            #endregion

            #region Static Members

            public static Vector operator -(Point p1, Point p2)
            {
                return new Vector(p1.x - p2.x, p1.y - p2.y);
            }

            public static int Orientation(Point p, Point q, Point r)
            {
                double det = GeometryUtils.Determinant(p.x, p.y, 1, q.x, q.y, 1, r.x, r.y, 1);
                if (det > 0) return 1;
                if (det < 0) return -1;
                return 0;
            }

            public static double Area(Point p, Point q, Point r)
            {
                return GeometryUtils.Determinant(q.x - p.x, q.y - p.y, r.x - p.x, r.y - p.y);
            }

            #endregion
        }

        public class Vector
        {
            public double x;
            public double y;

            public Vector()
            {
            }

            public Vector(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            public Vector Translate(double a, double b)
            {
                return new Vector(x + a, y + b);
            }

            public Vector Translate(Vector v)
            {
                return new Vector(x + v.x, y + v.y);
            }

            public Vector Scale(double d)
            {
                return new Vector(x * d, y * d);
            }
        }

        public class Segment
        {
            private Point start;
            private Point end;

            #region Constructors

            public Segment()
                : this(new Point(), new Point())
            {
            }

            public Segment(Point s, Point e)
            {
                start = s;
                end = e;
            }

            public Segment(double x1, double y1, double x2, double y2)
                : this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            #endregion

            #region Public Properties

            public Point Start
            {
                get { return start; }
                set { start = value; }
            }

            public Point End
            {
                get { return end; }
                set { end = value; }
            }

            public double x1
            {
                get { return start.x; }
                set { start.x = value; }
            }

            public double y1
            {
                get { return start.y; }
                set { start.y = value; }
            }

            public double x2
            {
                get { return end.x; }
                set { end.x = value; }
            }

            public double y2
            {
                get { return end.y; }
                set { end.y = value; }
            }

            public Vector Direction
            {
                get { return End - Start; }
            }

            #endregion

            #region Public Methods

            public Line ToLine()
            {
                return new Line(this);
            }

            public bool Intersects(Segment seg, out Point p1, out Point p2)
            {
                p1 = new Point();
                p2 = new Point();

                double minx1 = Math.Min(Start.x, End.x);
                double maxx1 = Math.Max(Start.x, End.x);
                double miny1 = Math.Min(Start.y, End.y);
                double maxy1 = Math.Max(Start.y, End.y);

                double minx2 = Math.Min(seg.Start.x, seg.End.x);
                double maxx2 = Math.Max(seg.Start.x, seg.End.x);
                double miny2 = Math.Min(seg.Start.y, seg.End.y);
                double maxy2 = Math.Max(seg.Start.y, seg.End.y);

                if (minx1 > maxx2 || maxx1 < minx2 || miny1 > maxy2 || maxy1 < miny2)
                    return false;  // boundary rectangles not intersected

                Line this_line = this.ToLine();
                Line seg_line = seg.ToLine();

                if (this_line.Parallel(seg_line))
                {
                    if (this_line.Equivalent(seg_line))
                    {
                        p1.x = Math.Max(minx1, minx2);
                        p1.y = Math.Max(miny1, miny2);
                        p2.x = Math.Min(maxx1, maxx2);
                        p2.y = Math.Min(miny1, miny2);
                        return true; // intersection by segment
                    }
                    else
                        return false; // parallel
                }

                Point pt;
                if (!this_line.Intersects(seg_line, out pt))
                    return false;

                if (pt.x >= minx1 && pt.x <= maxx1 &&
                    pt.y >= miny1 && pt.y <= maxy1 &&
                    pt.x >= minx2 && pt.x <= maxx2 &&
                    pt.y >= miny2 && pt.y <= maxy2)
                {
                    p1.x = pt.x;
                    p1.y = pt.y;
                    p2.x = pt.x;
                    p2.y = pt.y;
                    return true; // in one point
                }

                return false;
            }

            public double Distance(Point p)
            {
                Line line = this.ToLine();
                double[] cc = line.Coeffs;
                double A = cc[0];
                double B = cc[1];
                double C = cc[2];

                double d = (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
                d = Math.Min(d, p.Distance(Start));
                d = Math.Min(d, p.Distance(End));
                return d;
            }

            #endregion

        }

        public class Line
        {
            #region Private Members

            private Point bp;
            private Vector dir;

            #endregion

            #region Constructors

            public Line()
                : this(new Point(), new Vector(1, 0))
            {
            }

            public Line(Point p, Vector v)
            {
                bp = p;
                dir = v;
            }

            public Line(Point p1, Point p2)
                : this(p1, p2 - p1)
            {

            }

            public Line(double x1, double y1, double x2, double y2) :
                this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            public Line(Segment s) :
                this(s.Start, s.Direction)
            {

            }

            #endregion

            #region Public Properties

            public Point BasePoint { get { return bp; } }
            public Vector Direction { get { return dir; } }
            public Vector NormalVector { get { return new Vector(-dir.y, dir.x); } }
            public double[] Coeffs
            {
                get
                {
                    return new double[3]
                {
                    dir.y,
                    -dir.x,
                    dir.x * bp.y - dir.y * bp.x
                };
                }
            }

            public double A { get { return dir.y; } }
            public double B { get { return -dir.x; } }
            public double C { get { return dir.x * bp.y - dir.y * bp.x; } }

            #endregion

            #region Public Methods

            public bool Intersects(Line line, out Point pt)
            {
                pt = new Point();

                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                if (GeometryUtils.Sign(d) == 0)
                    return false;

                pt.x = -GeometryUtils.Determinant(C, B, line.C, line.B) / d;
                pt.y = -GeometryUtils.Determinant(A, C, line.A, line.C) / d;

                return true;
            }

            public bool Parallel(Line line)
            {
                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                return GeometryUtils.Sign(d) == 0;
            }

            public bool Equivalent(Line line)
            {
                double d1 = GeometryUtils.Determinant(A, B, line.A, line.B);
                double d2 = GeometryUtils.Determinant(A, C, line.A, line.C);
                double d3 = GeometryUtils.Determinant(B, C, line.B, line.C);

                return GeometryUtils.Sign(d1) == 0 && GeometryUtils.Sign(d2) == 0 && GeometryUtils.Sign(d2) == 0;
            }

            public double Distance(Point p)
            {
                return (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
            }

            #endregion
        }

    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace CodeForcesApp
{
    class E
    {
        #region Shortcuts
        static string RL() { return Console.ReadLine(); }
        static string[] RSA() { return RL().Split(' '); }
        static int[] RIA() { return Array.ConvertAll<string, int>(RSA(), int.Parse); }
        static int RInt() { return int.Parse(RL()); }
        static long RLong() { return long.Parse(RL()); }
        static double RDouble() { return double.Parse(RL()); }
        static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }
        static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }
        static void RInts4(out int p1, out int p2, out int p3, out int p4) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; p4 = a[3]; }

        static void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        static void Fill<T>(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }
        static void Fill<T>(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }
        #endregion

        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            //SolutionTester tester = new SolutionTester(CodeForcesTask.E);
            //tester.Test();

            Task task = new Task();
            task.Solve();
        }

        public class Task
        {
            public void Solve()
            {
                int xv, yv, xp, yp, xw1, yw1, xw2, yw2, xm1, ym1, xm2, ym2;
                RInts2(out xv, out yv);
                RInts2(out xp, out yp);
                RInts4(out xw1, out yw1, out xw2, out yw2);
                RInts4(out xm1, out ym1, out xm2, out ym2);

                Point v = new Point(xv, yv);
                Point p = new Point(xp, yp);

                Segment view = new Segment(xv, yv, xp, yp);
                Segment wall = new Segment(xw1, yw1, xw2, yw2);
                Segment mirror = new Segment(xm1, ym1, xm2, ym2);

                Point rp = p.Reflect(mirror.ToLine());

                Segment rview = new Segment(xv, yv, rp.x, rp.y);
                Segment rdview = new Segment(rp.x, rp.y, xp, yp);

                Point pt1, pt2;

                if (!view.Intersects(wall, out pt1, out pt2) && !view.Intersects(mirror, out pt1, out pt2))
                {
                    Console.WriteLine("YES");
                }

                Point rpm1, rpm2;
                if (rview.Intersects(mirror, out rpm1, out rpm2))
                {
                    Segment s1 = new Segment(v, rpm1);
                    Segment s2 = new Segment(rpm1, p);
                    if (!s1.Intersects(wall, out pt1, out pt2) && !s2.Intersects(wall, out pt1, out pt2))
                        Console.WriteLine("YES");
                }
                Console.WriteLine("NO");
            }
        }

        public class GeometryUtils
        {
            public const double EPS = 10e-12;

            public static double SqrDist(double x1, double y1, double x2, double y2)
            {
                return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
            }

            public static double Dist(double x1, double x2)
            {
                return Math.Abs(x1 - x2);
            }

            public static double Dist(double x1, double y1, double x2, double y2)
            {
                return Math.Sqrt(SqrDist(x1, y1, x2, y2));
            }

            public static double Determinant(
                double a11, double a12,
                double a21, double a22)
            {
                return a11 * a22 - a21 * a12;
            }

            public static double Determinant(
                double a11, double a12, double a13,
                double a21, double a22, double a23,
                double a31, double a32, double a33
                )
            {
                return a11 * Determinant(a22, a23, a32, a33) - a21 * Determinant(a12, a13, a32, a33) + a31 * Determinant(a12, a13, a22, a23);
            }

            public static int Sign(double val)
            {
                if (Math.Abs(val) <= EPS)
                    return 0;

                if (val > EPS)
                    return 1;

                return -1;
            }

        }

        public class Point
        {
            public double x;
            public double y;

            #region Constructors

            public Point()
            {
            }

            public Point(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            #endregion

            #region Public Methods

            public Vector ToVector()
            {
                return new Vector(x, y);
            }

            public int Orientation(Point q, Point r)
            {
                return Orientation(this, q, r);
            }

            public double Area(Point q, Point r)
            {
                return Area(this, q, r);
            }

            public double SqrDist(Point q)
            {
                return GeometryUtils.SqrDist(x, y, q.x, q.y);
            }

            public double Distance()
            {
                return GeometryUtils.Dist(x, y, 0, 0);
            }

            public double Distance(Point q)
            {
                return GeometryUtils.Dist(x, y, q.x, q.y);
            }

            public double XDist(Point q)
            {
                return GeometryUtils.Dist(x, q.x);
            }

            public double YDist(Point q)
            {
                return GeometryUtils.Dist(y, q.y);
            }

            public Point Translate(double _x, double _y)
            {
                return new Point(x + _x, y + _y);
            }

            public Point Translate(Vector v)
            {
                return new Point(x + v.x, y + v.y);
            }

            // Находит проекцию точки на прямую
            public Point Project(Line line)
            {
                Line ort = new Line(this, line.NormalVector);
                Point pt;
                line.Intersects(ort, out pt);
                return pt;
            }

            public Point Reflect(Line line)
            {
                Point pr = Project(line);
                Vector v = (pr - this).Scale(2);
                return this.Translate(v);
            }

            #endregion

            #region Static Members

            public static Vector operator -(Point p1, Point p2)
            {
                return new Vector(p1.x - p2.x, p1.y - p2.y);
            }

            public static int Orientation(Point p, Point q, Point r)
            {
                double det = GeometryUtils.Determinant(p.x, p.y, 1, q.x, q.y, 1, r.x, r.y, 1);
                if (det > 0) return 1;
                if (det < 0) return -1;
                return 0;
            }

            public static double Area(Point p, Point q, Point r)
            {
                return GeometryUtils.Determinant(q.x - p.x, q.y - p.y, r.x - p.x, r.y - p.y);
            }

            #endregion
        }

        public class Vector
        {
            public double x;
            public double y;

            public Vector()
            {
            }

            public Vector(double _x, double _y)
            {
                x = _x;
                y = _y;
            }

            public Vector Translate(double a, double b)
            {
                return new Vector(x + a, y + b);
            }

            public Vector Translate(Vector v)
            {
                return new Vector(x + v.x, y + v.y);
            }

            public Vector Scale(double d)
            {
                return new Vector(x * d, y * d);
            }
        }

        public class Segment
        {
            private Point start;
            private Point end;

            #region Constructors

            public Segment()
                : this(new Point(), new Point())
            {
            }

            public Segment(Point s, Point e)
            {
                start = s;
                end = e;
            }

            public Segment(double x1, double y1, double x2, double y2)
                : this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            #endregion

            #region Public Properties

            public Point Start
            {
                get { return start; }
                set { start = value; }
            }

            public Point End
            {
                get { return end; }
                set { end = value; }
            }

            public double x1
            {
                get { return start.x; }
                set { start.x = value; }
            }

            public double y1
            {
                get { return start.y; }
                set { start.y = value; }
            }

            public double x2
            {
                get { return end.x; }
                set { end.x = value; }
            }

            public double y2
            {
                get { return end.y; }
                set { end.y = value; }
            }

            public Vector Direction
            {
                get { return End - Start; }
            }

            #endregion

            #region Public Methods

            public Line ToLine()
            {
                return new Line(this);
            }

            public bool Intersects(Segment seg, out Point p1, out Point p2)
            {
                p1 = new Point();
                p2 = new Point();

                double minx1 = Math.Min(Start.x, End.x);
                double maxx1 = Math.Max(Start.x, End.x);
                double miny1 = Math.Min(Start.y, End.y);
                double maxy1 = Math.Max(Start.y, End.y);

                double minx2 = Math.Min(seg.Start.x, seg.End.x);
                double maxx2 = Math.Max(seg.Start.x, seg.End.x);
                double miny2 = Math.Min(seg.Start.y, seg.End.y);
                double maxy2 = Math.Max(seg.Start.y, seg.End.y);

                if (minx1 > maxx2 || maxx1 < minx2 || miny1 > maxy2 || maxy1 < miny2)
                    return false;  // boundary rectangles not intersected

                Line this_line = this.ToLine();
                Line seg_line = seg.ToLine();

                if (this_line.Parallel(seg_line))
                {
                    if (this_line.Equivalent(seg_line))
                    {
                        p1.x = Math.Max(minx1, minx2);
                        p1.y = Math.Max(miny1, miny2);
                        p2.x = Math.Min(maxx1, maxx2);
                        p2.y = Math.Min(miny1, miny2);
                        return true; // intersection by segment
                    }
                    else
                        return false; // parallel
                }

                Point pt;
                if (!this_line.Intersects(seg_line, out pt))
                    return false;

                if (pt.x >= minx1 && pt.x <= maxx1 &&
                    pt.y >= miny1 && pt.y <= maxy1 &&
                    pt.x >= minx2 && pt.x <= maxx2 &&
                    pt.y >= miny2 && pt.y <= maxy2)
                {
                    p1.x = pt.x;
                    p1.y = pt.y;
                    p2.x = pt.x;
                    p2.y = pt.y;
                    return true; // in one point
                }

                return false;
            }

            public double Distance(Point p)
            {
                Line line = this.ToLine();
                double[] cc = line.Coeffs;
                double A = cc[0];
                double B = cc[1];
                double C = cc[2];

                double d = (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
                d = Math.Min(d, p.Distance(Start));
                d = Math.Min(d, p.Distance(End));
                return d;
            }

            #endregion

        }

        public class Line
        {
            #region Private Members

            private Point bp;
            private Vector dir;

            #endregion

            #region Constructors

            public Line()
                : this(new Point(), new Vector(1, 0))
            {
            }

            public Line(Point p, Vector v)
            {
                bp = p;
                dir = v;
            }

            public Line(Point p1, Point p2)
                : this(p1, p2 - p1)
            {

            }

            public Line(double x1, double y1, double x2, double y2) :
                this(new Point(x1, y1), new Point(x2, y2))
            {
            }

            public Line(Segment s) :
                this(s.Start, s.Direction)
            {

            }

            #endregion

            #region Public Properties

            public Point BasePoint { get { return bp; } }
            public Vector Direction { get { return dir; } }
            public Vector NormalVector { get { return new Vector(-dir.y, dir.x); } }
            public double[] Coeffs
            {
                get
                {
                    return new double[3]
                {
                    dir.y,
                    -dir.x,
                    dir.x * bp.y - dir.y * bp.x
                };
                }
            }

            public double A { get { return dir.y; } }
            public double B { get { return -dir.x; } }
            public double C { get { return dir.x * bp.y - dir.y * bp.x; } }

            #endregion

            #region Public Methods

            public bool Intersects(Line line, out Point pt)
            {
                pt = new Point();

                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                if (GeometryUtils.Sign(d) == 0)
                    return false;

                pt.x = -GeometryUtils.Determinant(C, B, line.C, line.B) / d;
                pt.y = -GeometryUtils.Determinant(A, C, line.A, line.C) / d;

                return true;
            }

            public bool Parallel(Line line)
            {
                double d = GeometryUtils.Determinant(A, B, line.A, line.B);
                return GeometryUtils.Sign(d) == 0;
            }

            public bool Equivalent(Line line)
            {
                double d1 = GeometryUtils.Determinant(A, B, line.A, line.B);
                double d2 = GeometryUtils.Determinant(A, C, line.A, line.C);
                double d3 = GeometryUtils.Determinant(B, C, line.B, line.C);

                return GeometryUtils.Sign(d1) == 0 && GeometryUtils.Sign(d2) == 0 && GeometryUtils.Sign(d2) == 0;
            }

            public double Distance(Point p)
            {
                return (A * p.x + B * p.y + C) / Math.Sqrt(A * A + B * B);
            }

            #endregion
        }

    }
}


using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;

namespace Codeforces
{
    class Program : IDisposable
    {
        private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());
        private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());

        private void Solve()
        {
            var s = Console.ReadLine().Split(' ');
            var a = long.Parse(s[0]);
            var b = long.Parse(s[1]);
            var f = long.Parse(s[2]);
            var k = long.Parse(s[3]);

            long sum = f;
            long dist = k*a;
            var points = new List<long>() {0,f};
            var forw = 2*(a-f);
            var back = 2*f;
            var sw = true;
            while (sum<dist)
            {
                if (sw)
                {
                    sum += forw;
                    points.Add(sum);
                }
                else
                {
                    sum += back;
                    points.Add(sum);
                }
                sw = !sw;
            }
            points[points.Count-1] = dist;

            if (points[1] - points[0] > b)
            {
                Console.WriteLine(-1);
                return;
            }

            var cnt = 0;
            var r = b;
            for (int i = 1; i < points.Count; i++)
            {
                var d = points[i]-points[i-1];
                if (d > r)
                {
                    cnt++;
                    r = b;
                    if (r < d)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                }
               r -= d;
            }
            Console.WriteLine(cnt);
        }

        int BinarySearch(int[] arr, int q)
        {
            var l = 0;
            var r = arr.Length - 1;
            //int med = -1;
            while (l <= r)
            {
                var med = l + (r - l) / 2;
                if (arr[med] == q)
                {
                    return med;
                }
                if (q < arr[med])
                {
                    r = med - 1;
                }
                else
                {
                    l = med + 1;
                }
            }
            return -1;
        }

        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
            //Console.ReadLine();
            //p.Dispose();
            //////////////////////////////
        }

        #region Helpers

        private static int ReadInt()
        {
            return int.Parse(textReader.ReadLine());
        }

        private static long ReadLong()
        {
            return long.Parse(textReader.ReadLine());
        }

        private static int[] ReadIntArray()
        {
            return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion

        public void Dispose()
        {
            textReader.Close();
            textWriter.Close();
        }
    }

    //class Trie
    //{
    //    public TrieNode root;

    //    public Trie()
    //    {
    //        root = new TrieNode();
    //    }

    //    public void Insert(string s)
    //    {
    //        var current = root;
    //        for (int i = 0; i < s.Length; i++)
    //        {
    //            var ch = s[i];
    //            if (!current.Children.ContainsKey(ch))
    //                current.Children.Add(ch, new TrieNode());
    //            current = current.Children[ch];
    //        }
    //        current.IsEnd = true;
    //    }

    //    public bool Search(string word)
    //    {
    //        var current = root;
    //        for (int i = 0; i < word.Length; i++)
    //        {
    //            var ch = word[i];
    //            if (!current.Children.ContainsKey(ch))
    //                return false;
    //            current = current.Children[ch];
    //        }
    //        return current.IsEnd;
    //    }
    //}

    //class TrieNode
    //{
    //    public Dictionary<char, TrieNode> Children { get; set; }
    //    public bool IsEnd { get; set; }

    //    public TrieNode()
    //    {
    //        Children = new Dictionary<char, TrieNode>();
    //        IsEnd = false;
    //    }

    //}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tasks
{
    class Program
    {
        static void Main(string[] args)
        {
            //Ввод
            string[] input = Console.ReadLine().Split();

            int Distance = int.Parse(input[0]), CurrentFuel = int.Parse(input[1]), GasStation = int.Parse(input[2]), TotalRuns = int.Parse(input[3]);
            int MaxFuel = CurrentFuel;
            int Distance_B2GS = Distance - GasStation;
            int GasPerKm = 1;
            bool isForward = true;
            int count = 0;
            //Часть переменных для
            for (int i = 1; i <= TotalRuns; i++)
            {
                if (i != TotalRuns)
                {
                    //Если поездка вперед
                    if (isForward)
                    {
                        //Если недотягиваем даже до заправки, увы и ах
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasStation * GasPerKm) < 2 * GasPerKm * (Distance_B2GS))
                        {
                            CurrentFuel = MaxFuel - (Distance_B2GS) * GasPerKm;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;
                        }
                    }
                    else //едем назад
                    {
                        //Проверим, дотянем ли до заправки
                        if (CurrentFuel < GasPerKm * Distance_B2GS) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasPerKm * Distance_B2GS) < 2 * GasPerKm * (GasStation))
                        {
                            CurrentFuel = MaxFuel - GasPerKm * GasStation;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;

                        }
                    }
                    isForward = !isForward;
                }
                else
                {
                    //Последний круг, прямо
                    if (isForward)
                    {
                        if ((CurrentFuel < GasPerKm * GasStation)||(CurrentFuel<GasPerKm*Distance_B2GS)) { Console.WriteLine("-1");return; }
                        if (CurrentFuel < GasPerKm * Distance)
                            count++;
                    }
                    else
                    {
                        if (CurrentFuel < GasPerKm * Distance_B2GS)
                        { Console.WriteLine("-1"); return; }
                        if (CurrentFuel < GasPerKm * Distance) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] strInts = s.Split(new char[1] { ' ' });
            int a = int.Parse(strInts[0]);
            int b = int.Parse(strInts[1]);
            int f = int.Parse(strInts[2]);
            int k = int.Parse(strInts[3]);

            int kCurrent = 0;
            int bCurrent = b;
            int nextPoint = a;
            bool can = true;
            int tanked = 0;

            if (f > bCurrent)
            {
                can = false;
            }
            else
                bCurrent -= f;

            while (kCurrent!=k && can)
            {
                int Destantion = kCurrent==k-1? Math.Abs(f - nextPoint): 2 * Math.Abs(f - nextPoint);
                if (bCurrent >= Destantion)
                {
                    nextPoint = nextPoint == 0 ? a : 0;
                    bCurrent -= Destantion;
                    kCurrent++;
                }
                else
                {
                    if (bCurrent == b)
                    {
                        can = false;
                    }
                    else
                    {
                        bCurrent = b;
                        tanked++;
                    }

                }
            }

            if (kCurrent == k)
            {
                Console.WriteLine(tanked);
            }
            else
                Console.WriteLine(-1);
        }
    }
}


using System;

namespace CSharp
{
    class _864C
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            int a = int.Parse(tokens[0]);
            int b = int.Parse(tokens[1]);
            int f = int.Parse(tokens[2]);
            int k = int.Parse(tokens[3]);

            int remaining = b;
            int count = 0;

            for (int i = 0; i < k; i++)
            {
                if (i % 2 == 0)
                {
                    remaining -= f;

                    if (remaining < 0)
                    {
                        Console.WriteLine(-1);
                        return;
                    }

                    if (i + 1 < k ? remaining < 2 * (a - f) : remaining < a - f)
                    {
                        remaining = b;
                        count++;
                    }

                    remaining -= a - f;
                }
                else
                {
                    remaining -= a - f;

                    if (remaining < 0)
                    {
                        Console.WriteLine(-1);
                        return;
                    }

                    if (i + 1 < k ? remaining < 2 * f : remaining < f)
                    {
                        remaining = b;
                        count++;
                    }

                    remaining -= f;
                }

                if (remaining < 0)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
            var a = data[0];
            var b = data[1];
            var f = data[2];
            var k = data[3];

            if (b < f)
            {
                Console.WriteLine(-1);
                return;
            }

            var restB = b;
            var spent = 0;
            for(var i = 0; i <= k; i++)
            {
                if(i*a + restB >= a * k)
                {
                    break;
                }
                if(i%2 == 0)
                {
                    if(restB < f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if(restB < a + a - f)
                    {
                        spent++;
                        restB = b - a+f;
                        continue;
                    }
                } else
                {
                    if (restB < a-f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if (restB < a + f)
                    {
                        spent++;
                        restB = b -f;
                        continue;
                    }
                }
                restB -= a;
            }

            Console.WriteLine(spent);
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Bus
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int a = Next(), b = Next(), f = Next(), k = Next();

            if ((k > 2 && 2*f > b) || (k > 1 && 2*(a - f) > b) || (k == 1 && (f > b || a - f > b)))
            {
                writer.WriteLine("-1");
                writer.Flush();
                return;
            }

            int count = 0;
            int x = b;
            bool to = true;
            for (int i = 1; i <= k; i++)
            {
                if (to)
                {
                    if (i != k)
                    {
                        if (a + (a - f) <= x)
                        {
                            x -= a;
                        }
                        else
                        {
                            count++;
                            x = b - (a - f);
                        }
                    }
                    else
                    {
                        if (x < a)
                            count++;
                    }
                }
                else
                {
                    if (i != k)
                    {
                        if (a + f <= x)
                        {
                            x -= a;
                        }
                        else
                        {
                            count++;
                            x = b - f;
                        }
                    }
                    else
                    {
                        if (x < a)
                            count++;
                    }
                }
                to = !to;
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var a = data[0];
            var b = data[1];
            var f = data[2];
            var k = data[3];

            if (b < f)
            {
                Console.WriteLine(-1);
                return;
            }

            var restB = b;
            var spent = 0;
            for(var i = 0; i <= k; i++)
            {
                if(i*a + restB >= a * k)
                {
                    break;
                }
                if(i%2 == 0)
                {
                    if(restB < f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if(restB < a + a - f)
                    {
                        spent++;
                        restB = b + f;
                    }
                } else
                {
                    if (restB < a-f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if (restB < a + f)
                    {
                        spent++;
                        restB = b + a - f;
                    }
                }
                restB -= a;
            }

            Console.WriteLine(spent);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tasks
{
    class Program
    {
        static void Main(string[] args)
        {
            //Ввод
            string[] input = Console.ReadLine().Split();

            int Distance = int.Parse(input[0]), CurrentFuel = int.Parse(input[1]), GasStation = int.Parse(input[2]), TotalRuns = int.Parse(input[3]);
            int MaxFuel = CurrentFuel;
            int Distance_B2GS = Distance - GasStation;
            int GasPerKm = 1;
            bool isForward = true;
            int count = 0;
            //Часть переменных для
            for (int i = 1; i <= TotalRuns; i++)
            {
                if (i != TotalRuns)
                {
                    //Если поездка вперед
                    if (isForward)
                    {
                        //Если недотягиваем даже до заправки, увы и ах
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasStation * GasPerKm) < 2 * GasPerKm * (Distance_B2GS))
                        {
                            CurrentFuel = MaxFuel - (Distance_B2GS) * GasPerKm;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;
                        }
                    }
                    else //едем назад
                    {
                        //Проверим, дотянем ли до заправки
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasPerKm * Distance_B2GS) < 2 * GasPerKm * (GasStation))
                        {
                            CurrentFuel = MaxFuel - GasPerKm * GasStation;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;

                        }
                    }
                    isForward = !isForward;
                }
                else
                {
                    //Последний круг, прямо
                    if (isForward)
                    {
                        if ((CurrentFuel < GasPerKm * GasStation)) { Console.WriteLine("-1");return; }
                        if (CurrentFuel < GasPerKm * Distance)
                            count++;
                    }
                    else
                    {
                        if (CurrentFuel < GasPerKm * Distance_B2GS)
                        { Console.WriteLine("-1"); return; }
                        if (CurrentFuel < GasPerKm * Distance) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tasks
{
    class Program
    {
        static void Main(string[] args)
        {
            //Ввод
            string[] input = Console.ReadLine().Split();

            int Distance = int.Parse(input[0]), CurrentFuel = int.Parse(input[1]), GasStation = int.Parse(input[2]), TotalRuns = int.Parse(input[3]);
            int MaxFuel = CurrentFuel;
            int Distance_B2GS = Distance - GasStation;
            int GasPerKm = 1;
            bool isForward = true;
            int count = 0;
            //Часть переменных для
            for (int i = 1; i <= TotalRuns; i++)
            {
                if (i != TotalRuns)
                {
                    //Если поездка вперед
                    if (isForward)
                    {
                        //Если недотягиваем даже до заправки, увы и ах
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasStation * GasPerKm) < 2 * GasPerKm * (Distance_B2GS))
                        {
                            CurrentFuel = MaxFuel - (Distance_B2GS) * GasPerKm;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;
                        }
                    }
                    else //едем назад
                    {
                        //Проверим, дотянем ли до заправки
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasPerKm * Distance_B2GS) < 2 * GasPerKm * (GasStation))
                        {
                            CurrentFuel = MaxFuel - GasPerKm * GasStation;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;

                        }
                    }
                    isForward = !isForward;
                }
                else
                {
                    //Последний круг, прямо
                    if (isForward)
                    {
                        if ((CurrentFuel < GasPerKm * GasStation)||(CurrentFuel<GasPerKm*Distance_B2GS)) { Console.WriteLine("-1");return; }
                        if (CurrentFuel < GasPerKm * Distance)
                            count++;
                    }
                    else
                    {
                        if (CurrentFuel < GasPerKm * Distance_B2GS||CurrentFuel< GasPerKm * GasStation)
                        { Console.WriteLine("-1"); return; }
                        if (CurrentFuel < GasPerKm * Distance) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var a = data[0];
            var b = data[1];
            var f = data[2];
            var k = data[3];

            if (b < f)
            {
                Console.WriteLine(-1);
                return;
            }

            var restB = b;
            var spent = 0;
            for(var i = 0; i <= k; i++)
            {
                if(i*a + restB >= a * k)
                {
                    break;
                }
                if(i%2 == 0)
                {
                    if(restB < f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if(restB < a + a - f)
                    {
                        spent++;
                        restB = b + f;
                    }
                } else
                {
                    if (restB < a-f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if (restB < a + f)
                    {
                        spent++;
                        restB = b + f;
                    }
                }
                restB -= a;
            }

            Console.WriteLine(spent);
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Bus
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int a = Next(), b = Next(), f = Next(), k = Next();

            if (2*f > b || 2*(a - f) > b)
            {
                writer.WriteLine("-1");
                writer.Flush();
                return;
            }

            int count = 0;
            int x = b;
            bool to = true;
            for (int i = 1; i <= k; i++)
            {
                if (to)
                {
                    if (i != k)
                    {
                        if (a + (a - f) <= x)
                        {
                            x -= a;
                        }
                        else
                        {
                            count++;
                            x = b - (a - f);
                        }
                    }
                    else
                    {
                        if (x < a)
                            count++;
                    }
                }
                else
                {
                    if (i != k)
                    {
                        if (a + f <= x)
                        {
                            x -= a;
                        }
                        else
                        {
                            count++;
                            x = b - f;
                        }
                    }
                    else
                    {
                        if (x < a)
                            count++;
                    }
                }
                to = !to;
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tasks
{
    class Program
    {
        static void Main(string[] args)
        {
            //Ввод
            string[] input = Console.ReadLine().Split();

            int Distance = int.Parse(input[0]), CurrentFuel = int.Parse(input[1]), GasStation = int.Parse(input[2]), TotalRuns = int.Parse(input[3]);
            int MaxFuel = CurrentFuel;
            int Distance_B2GS = Distance - GasStation;
            int GasPerKm = 1;
            bool isForward = true;
            int count = 0;
            //Часть переменных для
            for (int i = 1; i <= TotalRuns; i++)
            {
                if (i != TotalRuns)
                {
                    //Если поездка вперед
                    if (isForward)
                    {
                        //Если недотягиваем даже до заправки, увы и ах
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasStation * GasPerKm) < 2 * GasPerKm * (Distance_B2GS))
                        {
                            CurrentFuel = MaxFuel - (Distance_B2GS) * GasPerKm;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;
                        }
                    }
                    else //едем назад
                    {
                        //Проверим, дотянем ли до заправки
                        if (CurrentFuel < GasPerKm * GasStation) { Console.WriteLine("-1"); return; }

                        if ((CurrentFuel - GasPerKm * Distance_B2GS) < 2 * GasPerKm * (GasStation))
                        {
                            CurrentFuel = MaxFuel - GasPerKm * GasStation;
                            count++;
                        }
                        else
                        {
                            CurrentFuel -= Distance * GasPerKm;

                        }
                    }
                    isForward = !isForward;
                }
                else
                {
                    //Последний круг, прямо
                    if (isForward)
                    {
                        if ((CurrentFuel < GasPerKm * GasStation)||(CurrentFuel<GasPerKm*Distance_B2GS)) { Console.WriteLine("-1");return; }
                        if (CurrentFuel < GasPerKm * Distance)
                            count++;
                    }
                    else
                    {
                        if (CurrentFuel < GasPerKm * Distance_B2GS)
                        { Console.WriteLine("-1"); return; }
                        if (CurrentFuel < GasPerKm * Distance) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var a = data[0];
            var b = data[1];
            var f = data[2];
            var k = data[3];

            if (b < f)
            {
                Console.WriteLine(-1);
                return;
            }

            var restB = b;
            var spent = 0;
            for(var i = 0; i <= k; i++)
            {
                if(i*a + restB >= a * k)
                {
                    break;
                }
                if(i%2 == 0)
                {
                    if(restB < f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if(restB < a + a - f)
                    {
                        spent++;
                        restB = b - a+f;
                        continue;
                    }
                } else
                {
                    if (restB < a-f)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    if (restB < a + f)
                    {
                        spent++;
                        restB = b -f;
                        continue;
                    }
                }
                restB -= a;
            }

            Console.WriteLine(spent);
        }
    }
}