There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates $$$(0, 0)$$$, and coordinate axes are left and bottom sides of the table, then the bottom left corner of the white sheet has coordinates $$$(x_1, y_1)$$$, and the top right — $$$(x_2, y_2)$$$.After that two black sheets of paper are placed on the table. Sides of both black sheets are also parallel to the sides of the table. Coordinates of the bottom left corner of the first black sheet are $$$(x_3, y_3)$$$, and the top right — $$$(x_4, y_4)$$$. Coordinates of the bottom left corner of the second black sheet are $$$(x_5, y_5)$$$, and the top right — $$$(x_6, y_6)$$$.     Example of three rectangles. Determine if some part of the white sheet can be seen from the above after the two black sheets are placed. The part of the white sheet can be seen if there is at least one point lying not strictly inside the white sheet and strictly outside of both black sheets.

The first line of the input contains four integers $$$x_1, y_1, x_2, y_2$$$ $$$(0 \le x_1 < x_2 \le 10^{6}, 0 \le y_1 < y_2 \le 10^{6})$$$ — coordinates of the bottom left and the top right corners of the white sheet. The second line of the input contains four integers $$$x_3, y_3, x_4, y_4$$$ $$$(0 \le x_3 < x_4 \le 10^{6}, 0 \le y_3 < y_4 \le 10^{6})$$$ — coordinates of the bottom left and the top right corners of the first black sheet. The third line of the input contains four integers $$$x_5, y_5, x_6, y_6$$$ $$$(0 \le x_5 < x_6 \le 10^{6}, 0 \le y_5 < y_6 \le 10^{6})$$$ — coordinates of the bottom left and the top right corners of the second black sheet. The sides of each sheet of paper are parallel (perpendicular) to the coordinate axes.

If some part of the white sheet can be seen from the above after the two black sheets are placed, print "YES" (without quotes). Otherwise print "NO".

NoteIn the first example the white sheet is fully covered by black sheets.In the second example the part of the white sheet can be seen after two black sheets are placed. For example, the point $$$(6.5, 4.5)$$$ lies not strictly inside the white sheet and lies strictly outside of both black sheets.

#include<stdio.h>
int max(int a,int b)
{
	if(a>b)return a;
	else return b;
}
int min(int a,int b)
{
	if(a>b)return b;
	else return a;
}
int main()
{
	int flag=0;
	int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4,&x5,&y5,&x6,&y6);
	for(int i=x1+1;i<=x2;i++)
	{
		flag=0;
		if(x4>=i&&x3<i&&x6>=i&&x5<i)
		{
			if(max(y4,y6)>=y2&&min(y5,y3)<=y1)
			{
				if(max(y4,y6)==y4)
				{
					if(y6>=y3)flag=1;
					else
					{
						if(y3<=y1)flag=1;
						else if(y6>=y2)flag=1;
					}
				}
				else if(max(y4,y6)==y6)
				{
					if(y4>=y5)flag=1;
					else
					{
						if(y5<=y1)flag=1;
						else if(y4>=y2)flag=1;
					}
				}
			}
		}
		else if(x4>=i&&x3<i)
		{
			if(y4>=y2&&y3<=y1)flag=1;
		}
		else if(x6>=i&&x5<i)
		{
			if(y6>=y2&&y5<=y1)flag=1;
		}
		if(flag!=1)
		{
			flag=-1;
			break;
		}
	}
	if(flag==-1)printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

#define UL 0
#define UR 1
#define BL 2
#define BR 3
#define h 1
//printf("here! line: %d ", __LINE__); fflush(stdout)
typedef unsigned long long	ult;

typedef struct	s_po
{
	int x, y;
}				t_po;

typedef struct	s_sq
{
	int surface, width, height;
	t_po corner[4];
}				t_sq;

t_sq	make_square(int x1, int y1, int x2, int y2);
int		c_inshape(t_po p, t_sq s);

void	check_periphery(t_sq s1, t_sq s2, t_sq s3)
{
	t_sq s = make_square(s2.corner[UL].x - 1, s2.corner[UL].y - 1, s2.corner[BR].x + 1, s2.corner[BR].y + 1);
	t_po c1, c2;
	t_po inc[4];
	inc[UL].x = 1;
	inc[UL].y = 0;
	inc[UR].x = 0;
	inc[UR].y = 1;
	inc[BR].x = -1;
	inc[BR].y = 0;
	inc[BL].x = 0;
	inc[BL].y = -1;
	int i = -1;
	h;
	//printf("\n");
	while (++i < 4)
	{
		c1 = s.corner[i];
		c2 = s.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
		while (c1.x != c2.x || c1.y != c2.y)
		{
			if (c_inshape(c1, s1) && !c_inshape(c1, s3))
			{
				printf("YES\n");
				exit(0);
			}
			c1.x += inc[i].x;
			c1.y += inc[i].y;
			//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
		}
	}
	h;
}

int		c_inshape(t_po p, t_sq s)
{
	if (p.x >= s.corner[UL].x && p.x <= s.corner[BR].x &&
		p.y >= s.corner[UL].y && p.y <= s.corner[BR].y)
		return (1);
	return (0);
}

t_sq	make_square(int x1, int y1, int x2, int y2)
{
	t_sq ret;

	ret.corner[UL].x = x1;
	ret.corner[UL].y = y1;
	ret.corner[UR].x = x2;
	ret.corner[UR].y = y1;
	ret.corner[BR].x = x2;
	ret.corner[BR].y = y2;
	ret.corner[BL].x = x1;
	ret.corner[BL].y = y2;
	ret.height = y2 - y1;
	ret.width = x2 - x1;
	ret.surface = ret.height * ret.width;
	return (ret);
}

int		main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	scanf(" %d %d %d %d", &x3, &y3, &x4, &y4);
	scanf(" %d %d %d %d", &x5, &y5, &x6, &y6);
	t_sq s1, s2, s3;
	t_po p;
	s1 = make_square(x1 * 2, y1 * 2, x2 * 2, y2 * 2);
	s2 = make_square(x3 * 2, y3 * 2, x4 * 2, y4 * 2);
	s3 = make_square(x5 * 2, y5 * 2, x6 * 2, y6 * 2);
	h;
	// if (s3.surface + s2.surface < s1.surface)
	// {
	// 	printf("YES\n");
	// 	return 0;
	// }
	// else
	// {
	// 	h;
		// if ((c_inshape(s1.corner[UL], s2) || c_inshape(s1.corner[UL], s3)) &&
		// 	(c_inshape(s1.corner[UR], s2) || c_inshape(s1.corner[UR], s3)) &&
		// 	(c_inshape(s1.corner[BL], s2) || c_inshape(s1.corner[BL], s3)) &&
		// 	(c_inshape(s1.corner[BR], s2) || c_inshape(s1.corner[BR], s3)))
		// {
			t_sq s = make_square(s1.corner[UL].x, s1.corner[UL].y, s1.corner[BR].x, s1.corner[BR].y);
			t_po c1, c2;
			t_po inc[4];
			inc[UL].x = 1;
			inc[UL].y = 0;
			inc[UR].x = 0;
			inc[UR].y = 1;
			inc[BR].x = -1;
			inc[BR].y = 0;
			inc[BL].x = 0;
			inc[BL].y = -1;
			int i = -1;
			h;
			//printf("\n");
			//printf("s.corner[UL] = (%d, %d), s.corner[BR] = (%d, %d)\n", s.corner[UL].x, s.corner[UL].y, s.corner[BR].x, s.corner[BR].y);
			while (++i < 4)
			{
				c1 = s.corner[i];
				c2 = s.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
				while (c1.x != c2.x || c1.y != c2.y)
				{
					//printf("checking point (%d, %d)\n", c1.x, c1.y);
					if (!c_inshape(c1, s2) && !c_inshape(c1, s3))
					{
						printf("YES\n");
						return (0);
					}
					c1.x += inc[i].x;
					c1.y += inc[i].y;
					//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
				}
			}
		// }
		// else
		// {
		// 	printf("YES\n");
		// 	return 0;
		// }
	// }
	printf("NO\n");
}

#include<stdio.h>

long long int fun(int x1,int y1,int X1,int Y1,int x2,int y2,int X2,int Y2)
{
	long long int A=0;
	if(y2<Y1 && y1<Y2 && x2<X1 && x1<X2)
	{
		if(y2<y1) y2=y1;
		if(Y1<Y2) Y2=Y1;
		if(x2<x1) x2=x1;
		if(X1<X2) X2=X1;
		A=(long long int)(X2-x2)*(Y2-y2);
	}
	return A;
}

int main()
{
	int x1,y1,X1,Y1,x2,y2,X2,Y2,x3,y3,X3,Y3;
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&y1,&X1,&Y1,&x2,&y2,&X2,&Y2,&x3,&y3,&X3,&Y3);
	if(y2<y1) y2=y1;
	if(Y1<Y2) Y2=Y1;
	if(x2<x1) x2=x1;
	if(X1<X2) X2=X1;
	if(y3<y1) y3=y1;
	if(Y1<Y3) Y3=Y1;
	if(x3<x1) x3=x1;
	if(X1<X3) X3=X1;
	long long int A1=fun(x1,y1,X1,Y1,x2,y2,X2,Y2);
	long long int A2=fun(x1,y1,X1,Y1,x3,y3,X3,Y3);
	long long int A3=fun(x2,y2,X2,Y2,x3,y3,X3,Y3);
	long long int A=(long long int)(X1-x1)*(Y1-y1);
	A=A-A1-A2+A3;
//	printf("%lld\n%lld\n%lld\n%lld\n",A,A1,A2,A3);
	if(A>0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include <stdio.h>
double wXF, wYF, wXS, wYS;
double aXF, aYF, aXS, aYS;
double bXF, bYF, bXS, bYS;
double sX[6];
int xC = 0;
double sY[6];
int yC = 0;
char C(double dX, double dY, double xA, double yA, double xB, double yB)
{
    char mark = 0;
    if (dX >= xA && dX <= xB)
    {
        if (dY >= yA && dY <= yB)
        {
            mark = 1;
        }
    }
    return mark;
}
char cE(double dX, double dY)
{
    char mark = 0;
    if (C(dX, dY, aXF, aYF, aXS, aYS) == 0 && C(dX, dY, bXF, bYF, bXS, bYS) == 0)
    {
        if (C(dX, dY, wXF, wYF, wXS, wYS))
        {
            mark = 1;
        }
    }
    return mark;
}
int main()
{
    int i;
    int a, b;
    scanf("%lf %lf %lf %lf", &wXF, &wYF, &wXS, &wYS);
    sX[xC] = wXF;
    xC++;
    sY[yC] = wYF;
    yC++;
    sX[xC] = wXS;
    xC++;
    sY[yC] = wYS;
    yC++;
    scanf("%lf %lf %lf %lf", &aXF, &aYF, &aXS, &aYS);
    sX[xC] = aXF;
    xC++;
    sY[yC] = aYF;
    yC++;
    sX[xC] = aXS;
    xC++;
    sY[yC] = aYS;
    yC++;
    scanf("%lf %lf %lf %lf", &bXF, &bYF, &bXS, &bYS);
    sX[xC] = bXF;
    xC++;
    sY[yC] = bYF;
    yC++;
    sX[xC] = bXS;
    xC++;
    sY[yC] = bYS;
    yC++;
    for (a = 0; a < xC; a++)
    {
        for (b = 0; b < yC; b++)
        {
            if (cE(sX[a] - 0.5, sY[b]))
            {
                printf("YES");
                break;
            }
            else if (cE(sX[a] + 0.5, sY[b]))
            {
                printf("YES");
                break;
            }
            else if (cE(sX[a], sY[b] - 0.5))
            {
                printf("YES");
                break;
            }
            else if (cE(sX[a], sY[b] + 0.5))
            {
                printf("YES");
                break;
            }
        }
        if (b < yC)
        {
            break;
        }
    }
    if (a == xC)
    {
        printf("NO");
    }
    return 0;
}

#include<stdio.h>
struct mystuct{
	int x1,y1,x2,y2;
};
int main(void)
{
	struct mystuct input1,input2,input3;
	scanf("%d %d %d %d",&input1.x1,&input1.y1,&input1.x2,&input1.y2);
	scanf("%d %d %d %d",&input2.x1,&input2.y1,&input2.x2,&input2.y2);
	scanf("%d %d %d %d",&input3.x1,&input3.y1,&input3.x2,&input3.y2);
	getchar();
	if(input2.x1 <= input1.x1 && input2.y1 <= input1.y1 &&
	   input2.x2 >= input1.x2 && input2.y2 >= input1.y2) printf("NO"); //b全覆盖a
	else if(input3.x1 <= input1.x1 && input3.y1 <= input1.y1 &&
	   	 	input3.x2 >= input1.x2 && input3.y2 >= input1.y2) printf("NO"); //c全覆盖a
	else if(input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.x1 <= input1.x1 && input3.x1 <= input2.x2 &&
			input3.x2 >= input1.x2) printf("NO"); //b,c左右覆盖
	else if(input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.x1 <= input1.x1 && input2.x1 <= input3.x2 &&
			input2.x2 >= input1.x2) printf("NO"); //c,b左右覆盖
	else if(input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.y2 >= input3.y1) printf("NO"); //b,c上下覆盖
	else if(input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.y2 >= input2.y1) printf("NO"); //c,b上下覆盖
	else printf("YES"); //还有白色部分露出
	return 0;
}

#include <stdio.h>
#include <string.h>

typedef struct{
    int x;
    int y;
} point;

typedef struct{
    point BL;
    point TR;
} square;

int inside (point w1, point w2, point b1, point b2){
    if (w1.x >= b1.x && w1.y >= b1.y && w2.x <= b2.x && w2.y <= b2.y){
        return 1;
    }
    else {
        return 0;
    }
}

int main(){
    square w1, b1, b2;
    square left, right, top, bottom;
    scanf("%d %d %d %d", &w1.BL.x, &w1.BL.y, &w1.TR.x, &w1.TR.y);
    scanf("%d %d %d %d", &b1.BL.x, &b1.BL.y, &b1.TR.x, &b1.TR.y);
    scanf("%d %d %d %d", &b2.BL.x, &b2.BL.y, &b2.TR.x, &b2.TR.y);

    left = (b1.BL.x<b2.BL.x)?b1:b2;
    right = (b1.BL.x<b2.BL.x)?b2:b1;
    top = (b1.TR.y<b2.TR.y)?b2:b1;
    bottom = (b1.TR.y<b2.TR.y)?b1:b2;

    if (w1.BL.x>=b1.BL.x && w1.TR.x<=b1.TR.x
     && w1.BL.y>=b1.BL.y && w1.TR.y<=b1.TR.y ||
     w1.BL.x>=b2.BL.x && w1.TR.x<=b2.TR.x
     && w1.BL.y>=b2.BL.y && w1.TR.y<=b2.TR.y){
        printf("NO\n");
    } else if (left.TR.x>=right.BL.x && w1.BL.y>=b1.BL.y && w1.BL.y>=b2.BL.y
     && w1.TR.y<=b1.TR.y && w1.TR.y<=b2.TR.y
     && w1.BL.x>=left.BL.x && w1.TR.x<=right.TR.x
     ) {
        printf("NO\n");
    } else if (top.BL.y<=bottom.TR.y && w1.BL.x>=b1.BL.x && w1.BL.x>=b2.BL.x
     && w1.TR.x<=b1.TR.x && w1.TR.x<=b2.TR.x
     && w1.BL.y>=bottom.BL.y && w1.TR.y<=top.TR.y
     ) {
        printf("NO\n");
    } else {
        printf("YES\n");
    }

    return 0;
}

#include<stdio.h>
int max(int a,int b)
{
	if(a>b)return a;
	else return b;
}
int min(int a,int b)
{
	if(a>b)return b;
	else return a;
}
int main()
{
	int flag=0;
	int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4,&x5,&y5,&x6,&y6);
	for(int i=x1;i<=x2;i++)
	{
		flag=0;
		if(x4>=i&&x3<i&&x6>=i&&x5<i)
		{
			if(max(y4,y6)>=y2&&min(y5,y3)<=y1)
			{
				if(max(y4,y6)==y4)
				{
					if(y6>=y3)flag=1;
					else
					{
						if(y3<=y1)flag=1;
						else if(y6>=y2)flag=1;
					}
				}
				else if(max(y4,y6)==y6)
				{
					if(y4>=y5)flag=1;
					else
					{
						if(y5<=y1)flag=1;
						else if(y4>=y2)flag=1;
					}
				}
			}
		}
		else if(x4>=i&&x3<i)
		{
			if(y4>=y2&&y3<=y1)flag=1;
		}
		else if(x6>=i&&x5<i)
		{
			if(y6>=y2&&y5<=y1)flag=1;
		}
		if(flag!=1)
		{
			flag=-1;
			break;
		}
	}
	if(flag==-1)printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

#define UL 0
#define UR 1
#define BL 2
#define BR 3
#define h 1
//printf("here! line: %d ", __LINE__); fflush(stdout)
typedef unsigned long long	ult;

typedef struct	s_po
{
	int x, y;
}				t_po;

typedef struct	s_sq
{
	int surface, width, height;
	t_po corner[4];
}				t_sq;

t_sq	make_square(int x1, int y1, int x2, int y2);
int		c_inshape(t_po p, t_sq s);

void	check_periphery(t_sq s1, t_sq s2, t_sq s3)
{
	t_sq s = make_square(s2.corner[UL].x - 1, s2.corner[UL].y - 1, s2.corner[BR].x + 1, s2.corner[BR].y + 1);
	t_po c1, c2;
	t_po inc[4];
	inc[UL].x = 1;
	inc[UL].y = 0;
	inc[UR].x = 0;
	inc[UR].y = 1;
	inc[BR].x = -1;
	inc[BR].y = 0;
	inc[BL].x = 0;
	inc[BL].y = -1;
	int i = -1;
	h;
	//printf("\n");
	while (++i < 4)
	{
		c1 = s2.corner[i];
		c2 = s2.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
		while (c1.x != c2.x || c1.y != c2.y)
		{
			if (c_inshape(c1, s1) && !c_inshape(c1, s3))
			{
				printf("YES\n");
				exit(0);
			}
			c1.x += inc[i].x;
			c1.y += inc[i].y;
			//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
		}
	}
	h;
}

int		c_inshape(t_po p, t_sq s)
{
	if (p.x >= s.corner[UL].x && p.x <= s.corner[BR].x &&
		p.y >= s.corner[UL].y && p.y <= s.corner[BR].y)
		return (1);
	return (0);
}

t_sq	make_square(int x1, int y1, int x2, int y2)
{
	t_sq ret;

	ret.corner[UL].x = x1;
	ret.corner[UL].y = y1;
	ret.corner[UR].x = x2;
	ret.corner[UR].y = y1;
	ret.corner[BR].x = x2;
	ret.corner[BR].y = y2;
	ret.corner[BL].x = x1;
	ret.corner[BL].y = y2;
	ret.height = y2 - y1;
	ret.width = x2 - x1;
	ret.surface = ret.height * ret.width;
	return (ret);
}

int		main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	scanf(" %d %d %d %d", &x3, &y3, &x4, &y4);
	scanf(" %d %d %d %d", &x5, &y5, &x6, &y6);
	t_sq s1, s2, s3;
	t_po p;
	s1 = make_square(x1, y1, x2, y2);
	s2 = make_square(x3, y3, x4, y4);
	s3 = make_square(x5, y5, x6, y6);
	h;
	if (s3.surface + s2.surface < s1.surface)
	{
		printf("YES\n");
		return 0;
	}
	else
	{
		h;
		if ((c_inshape(s1.corner[UL], s2) || c_inshape(s1.corner[UL], s3)) &&
			(c_inshape(s1.corner[UR], s2) || c_inshape(s1.corner[UR], s3)) &&
			(c_inshape(s1.corner[BL], s2) || c_inshape(s1.corner[BL], s3)) &&
			(c_inshape(s1.corner[BR], s2) || c_inshape(s1.corner[BR], s3)))
		{
			check_periphery(s1, s2, s3);
		}
		else
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

#include <stdio.h>
#include <stdlib.h>

#define UL 0
#define UR 1
#define BL 2
#define BR 3
#define h 1
//printf("here! line: %d ", __LINE__); fflush(stdout)
typedef unsigned long long	ult;

typedef struct	s_po
{
	int x, y;
}				t_po;

typedef struct	s_sq
{
	int surface, width, height;
	t_po corner[4];
}				t_sq;

t_sq	make_square(int x1, int y1, int x2, int y2);
int		c_inshape(t_po p, t_sq s);

void	check_periphery(t_sq s1, t_sq s2, t_sq s3)
{
	t_sq s = make_square(s2.corner[UL].x - 1, s2.corner[UL].y - 1, s2.corner[BR].x + 1, s2.corner[BR].y + 1);
	t_po c1, c2;
	t_po inc[4];
	inc[UL].x = 1;
	inc[UL].y = 0;
	inc[UR].x = 0;
	inc[UR].y = 1;
	inc[BR].x = -1;
	inc[BR].y = 0;
	inc[BL].x = 0;
	inc[BL].y = -1;
	int i = -1;
	h;
	//printf("\n");
	while (++i < 4)
	{
		c1 = s.corner[i];
		c2 = s.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
		while (c1.x != c2.x || c1.y != c2.y)
		{
			if (c_inshape(c1, s1) && !c_inshape(c1, s3))
			{
				printf("YES\n");
				exit(0);
			}
			c1.x += inc[i].x;
			c1.y += inc[i].y;
			//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
		}
	}
	h;
}

int		c_inshape(t_po p, t_sq s)
{
	if (p.x >= s.corner[UL].x && p.x <= s.corner[BR].x &&
		p.y >= s.corner[UL].y && p.y <= s.corner[BR].y)
		return (1);
	return (0);
}

t_sq	make_square(int x1, int y1, int x2, int y2)
{
	t_sq ret;

	ret.corner[UL].x = x1;
	ret.corner[UL].y = y1;
	ret.corner[UR].x = x2;
	ret.corner[UR].y = y1;
	ret.corner[BR].x = x2;
	ret.corner[BR].y = y2;
	ret.corner[BL].x = x1;
	ret.corner[BL].y = y2;
	ret.height = y2 - y1;
	ret.width = x2 - x1;
	ret.surface = ret.height * ret.width;
	return (ret);
}

int		main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	scanf(" %d %d %d %d", &x3, &y3, &x4, &y4);
	scanf(" %d %d %d %d", &x5, &y5, &x6, &y6);
	t_sq s1, s2, s3;
	t_po p;
	s1 = make_square(x1, y1, x2, y2);
	s2 = make_square(x3, y3, x4, y4);
	s3 = make_square(x5, y5, x6, y6);
	h;
	if (s3.surface + s2.surface < s1.surface)
	{
		printf("YES\n");
		return 0;
	}
	else
	{
		h;
		if ((c_inshape(s1.corner[UL], s2) || c_inshape(s1.corner[UL], s3)) &&
			(c_inshape(s1.corner[UR], s2) || c_inshape(s1.corner[UR], s3)) &&
			(c_inshape(s1.corner[BL], s2) || c_inshape(s1.corner[BL], s3)) &&
			(c_inshape(s1.corner[BR], s2) || c_inshape(s1.corner[BR], s3)))
		{
			check_periphery(s1, s2, s3);
		}
		else
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

#include <stdio.h>
#include <stdlib.h>

#define UL 0
#define UR 1
#define BL 2
#define BR 3
#define h 1
//printf("here! line: %d ", __LINE__); fflush(stdout)
typedef unsigned long long	ult;

typedef struct	s_po
{
	int x, y;
}				t_po;

typedef struct	s_sq
{
	int surface, width, height;
	t_po corner[4];
}				t_sq;

t_sq	make_square(int x1, int y1, int x2, int y2);
int		c_inshape(t_po p, t_sq s);

void	check_periphery(t_sq s1, t_sq s2, t_sq s3)
{
	t_sq s = make_square(s2.corner[UL].x - 1, s2.corner[UL].y - 1, s2.corner[BR].x + 1, s2.corner[BR].y + 1);
	t_po c1, c2;
	t_po inc[4];
	inc[UL].x = 1;
	inc[UL].y = 0;
	inc[UR].x = 0;
	inc[UR].y = 1;
	inc[BR].x = -1;
	inc[BR].y = 0;
	inc[BL].x = 0;
	inc[BL].y = -1;
	int i = -1;
	h;
	//printf("\n");
	while (++i < 4)
	{
		c1 = s.corner[i];
		c2 = s.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
		while (c1.x != c2.x || c1.y != c2.y)
		{
			if (c_inshape(c1, s1) && !c_inshape(c1, s3))
			{
				printf("YES\n");
				exit(0);
			}
			c1.x += inc[i].x;
			c1.y += inc[i].y;
			//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
		}
	}
	h;
}

int		c_inshape(t_po p, t_sq s)
{
	if (p.x >= s.corner[UL].x && p.x <= s.corner[BR].x &&
		p.y >= s.corner[UL].y && p.y <= s.corner[BR].y)
		return (1);
	return (0);
}

t_sq	make_square(int x1, int y1, int x2, int y2)
{
	t_sq ret;

	ret.corner[UL].x = x1;
	ret.corner[UL].y = y1;
	ret.corner[UR].x = x2;
	ret.corner[UR].y = y1;
	ret.corner[BR].x = x2;
	ret.corner[BR].y = y2;
	ret.corner[BL].x = x1;
	ret.corner[BL].y = y2;
	ret.height = y2 - y1;
	ret.width = x2 - x1;
	ret.surface = ret.height * ret.width;
	return (ret);
}

int		main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	scanf(" %d %d %d %d", &x3, &y3, &x4, &y4);
	scanf(" %d %d %d %d", &x5, &y5, &x6, &y6);
	t_sq s1, s2, s3;
	t_po p;
	s1 = make_square(x1, y1, x2, y2);
	s2 = make_square(x3, y3, x4, y4);
	s3 = make_square(x5, y5, x6, y6);
	h;
	if (s3.surface + s2.surface < s1.surface)
	{
		printf("YES\n");
		return 0;
	}
	else
	{
		h;
		if ((c_inshape(s1.corner[UL], s2) || c_inshape(s1.corner[UL], s3)) &&
			(c_inshape(s1.corner[UR], s2) || c_inshape(s1.corner[UR], s3)) &&
			(c_inshape(s1.corner[BL], s2) || c_inshape(s1.corner[BL], s3)) &&
			(c_inshape(s1.corner[BR], s2) || c_inshape(s1.corner[BR], s3)))
		{
			t_sq s = make_square(s1.corner[UL].x, s1.corner[UL].y, s1.corner[BR].x, s1.corner[BR].y);
			t_po c1, c2;
			t_po inc[4];
			inc[UL].x = 1;
			inc[UL].y = 0;
			inc[UR].x = 0;
			inc[UR].y = 1;
			inc[BR].x = -1;
			inc[BR].y = 0;
			inc[BL].x = 0;
			inc[BL].y = -1;
			int i = -1;
			h;
			//printf("\n");
			//printf("s.corner[UL] = (%d, %d), s.corner[BR] = (%d, %d)\n", s.corner[UL].x, s.corner[UL].y, s.corner[BR].x, s.corner[BR].y);
			while (++i < 4)
			{
				c1 = s.corner[i];
				c2 = s.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
				while (c1.x != c2.x || c1.y != c2.y)
				{
					//printf("checking point (%d, %d)\n", c1.x, c1.y);
					if (!c_inshape(c1, s2) && !c_inshape(c1, s3))
					{
						printf("YES\n");
						return (0);
					}
					c1.x += inc[i].x;
					c1.y += inc[i].y;
					//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
				}
			}
		}
		else
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

#include<stdio.h>

long long int fun(int x1,int y1,int X1,int Y1,int x2,int y2,int X2,int Y2)
{
	long long int A=0;
	if(y2<Y1 && y1<Y2 && x2<X1 && x1<X2)
	{
		if(y2<y1) y2=y1;
		if(Y1<Y2) Y2=Y1;
		if(x2<x1) x2=x1;
		if(X1<X2) X2=X1;
		A=(long long int)(X2-x2)*(Y2-y1);
	}
	return A;
}

int main()
{
	int x1,y1,X1,Y1,x2,y2,X2,Y2,x3,y3,X3,Y3;
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&y1,&X1,&Y1,&x2,&y2,&X2,&Y2,&x3,&y3,&X3,&Y3);
	if(y2<y1) y2=y1;
	if(Y1<Y2) Y2=Y1;
	if(x2<x1) x2=x1;
	if(X1<X2) X2=X1;
	if(y3<y1) y3=y1;
	if(Y1<Y3) Y3=Y1;
	if(x3<x1) x3=x1;
	if(X1<X3) X3=X1;
	long long int A1=fun(x1,y1,X1,Y1,x2,y2,X2,Y2);
	long long int A2=fun(x1,y1,X1,Y1,x3,y3,X3,Y3);
	long long int A3=fun(x2,y2,X2,Y2,x3,y3,X3,Y3);
	long long int A=(long long int)(X1-x1)*(Y1-y1);
	A=A-A1-A2+A3;
//	printf("%lld\n%lld\n%lld\n%lld\n",A,A1,A2,A3);
	if(A>0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include <stdio.h>
int wXF, wYF, wXS, wYS;
int aXF, aYF, aXS, aYS;
int bXF, bYF, bXS, bYS;
int sX[6];
int xC = 0;
int dX[6];
int sY[6];
int yC = 0;
int dY[6];
char cB(int dX, int dY, int xA, int yA, int xB, int yB)
{
    char mark = 0;
    if (dX > xA && dX < xB)
    {
        if (dY > yA && dY < yB)
        {
            mark = 1;
        }
    }
    return mark;
}
char cW(int dX, int dY, int xA, int yA, int xB, int yB)
{
    char mark = 0;
    if (dX >= xA && dX <= xB)
    {
        if (dY >= yA && dY <= yB)
        {
            mark = 1;
        }
    }
    return mark;
}
char cE(int dX, int dY)
{
    char mark = 0;
    if (cB(dX, dY, aXF, aYF, aXS, aYS) == 0 && cB(dX, dY, bXF, bYF, bXS, bYS) == 0)
    {
        if (cW(dX, dY, wXF, wYF, wXS, wYS))
        {
            mark = 1;
        }
    }
    return mark;
}
void mS(int s[], int d[], int o, int t)
{
    int i, j, k;
    int c = (o + t) / 2;
    if (o < c)
    {
        mS(d, s, o, c);
    }
    if (c + 1 < t)
    {
        mS(d, s, c + 1, t);
    }
    i = o;
    j = c + 1;
    k = o;
    while (i <= c && j <= t)
    {
        if (s[i] < s[j])
        {
            d[k] = s[i];
            i++;
        }
        else
        {
            d[k] = s[j];
            j++;
        }
        k++;
    }
    while (i <= c)
    {
        d[k] = s[i];
        i++;
        k++;
    }
    while (j <= t)
    {
        d[k] = s[j];
        j++;
        k++;
    }
}
int main()
{
    int i;
    int a, b;
    scanf("%d %d %d %d", &wXF, &wYF, &wXS, &wYS);
    sX[xC] = wXF;
    xC++;
    sY[yC] = wYF;
    yC++;
    sX[xC] = wXS;
    xC++;
    sY[yC] = wYS;
    yC++;
    scanf("%d %d %d %d", &aXF, &aYF, &aXS, &aYS);
    sX[xC] = aXF;
    xC++;
    sY[yC] = aYF;
    yC++;
    sX[xC] = aXS;
    xC++;
    sY[yC] = aYS;
    yC++;
    scanf("%d %d %d %d", &bXF, &bYF, &bXS, &bYS);
    sX[xC] = bXF;
    xC++;
    sY[yC] = bYF;
    yC++;
    sX[xC] = bXS;
    xC++;
    sY[yC] = bYS;
    yC++;
    for (i = 0; i < 6; i++)
    {
        dX[i] = sX[i];
    }
    for (i = 0; i < 6; i++)
    {
        dY[i] = sY[i];
    }
    mS(sX, dX, 0, 5);
    mS(sY, dY, 0, 5);
    sX[0] = dX[0];
    xC = 1;
    for (i = 1; i < 6; i++)
    {
        if (dX[i] > sX[xC - 1])
        {
            sX[xC] = dX[i];
            xC++;
        }
    }
    sY[0] = dY[0];
    yC = 1;
    for (i = 1; i < 6; i++)
    {
        if (dY[i] > sY[yC - 1])
        {
            sY[yC] = dY[i];
            yC++;
        }
    }
    for (a = 0; a < xC - 1; a++)
    {
        for (b = 0; b < yC - 1; b++)
        {
            if (cE(sX[a], sY[b]))
            {
                if (cE(sX[a + 1], sY[b]) && cE(sX[a], sY[b + 1]))
                {
                    printf("YES");
                    break;
                }
            }
        }
        if (b < yC - 1)
        {
            break;
        }
    }
    if (a == xC - 1)
    {
        printf("NO");
    }
    return 0;
}

#include <stdio.h>
int wXF, wYF, wXS, wYS;
int aXF, aYF, aXS, aYS;
int bXF, bYF, bXS, bYS;
int sX[6];
int xC = 0;
int dX[6];
int sY[6];
int yC = 0;
int dY[6];
char cB(int dX, int dY, int xA, int yA, int xB, int yB)
{
    char mark = 0;
    if (dX > xA && dX < xB)
    {
        if (dY > yA && dY < yB)
        {
            mark = 1;
        }
    }
    return mark;
}
char cW(int dX, int dY, int xA, int yA, int xB, int yB)
{
    char mark = 0;
    if (dX >= xA && dX <= xB)
    {
        if (dY >= yA && dY <= yB)
        {
            mark = 1;
        }
    }
    return mark;
}
char cE(int dX, int dY)
{
    char mark = 0;
    if (cB(dX, dY, aXF, aYF, aXS, aYS) == 0 && cB(dX, dY, bXF, bYF, bXS, bYS) == 0)
    {
        if (cW(dX, dY, wXF, wYF, wXS, wYS))
        {
            mark = 1;
        }
    }
    return mark;
}
void mS(int s[], int d[], int o, int t)
{
    int i, j, k;
    int c = (o + t) / 2;
    if (o < c)
    {
        mS(d, s, o, c);
    }
    if (c + 1 < t)
    {
        mS(d, s, c + 1, t);
    }
    i = o;
    j = c + 1;
    k = o;
    while (i <= c && j <= t)
    {
        if (s[i] < s[j])
        {
            d[k] = s[i];
            i++;
        }
        else
        {
            d[k] = s[j];
            j++;
        }
        k++;
    }
    while (i <= c)
    {
        d[k] = s[i];
        i++;
        k++;
    }
    while (j <= t)
    {
        d[k] = s[j];
        j++;
        k++;
    }
}
int main()
{
    int i;
    int a, b;
    scanf("%d %d %d %d", &wXF, &wYF, &wXS, &wYS);
    sX[xC] = wXF;
    xC++;
    sY[yC] = wYF;
    yC++;
    sX[xC] = wXS;
    xC++;
    sY[yC] = wYS;
    yC++;
    scanf("%d %d %d %d", &aXF, &aYF, &aXS, &aYS);
    sX[xC] = aXF;
    xC++;
    sY[yC] = aYF;
    yC++;
    sX[xC] = aXS;
    xC++;
    sY[yC] = aYS;
    yC++;
    scanf("%d %d %d %d", &bXF, &bYF, &bXS, &bYS);
    sX[xC] = bXF;
    xC++;
    sY[yC] = bYF;
    yC++;
    sX[xC] = bXS;
    xC++;
    sY[yC] = bYS;
    yC++;
    for (i = 0; i < 6; i++)
    {
        dX[i] = sX[i];
    }
    for (i = 0; i < 6; i++)
    {
        dY[i] = sY[i];
    }
    mS(sX, dX, 0, 5);
    mS(sY, dY, 0, 5);
    sX[0] = dX[0];
    xC = 1;
    for (i = 1; i < 6; i++)
    {
        if (dX[i] > sX[xC - 1])
        {
            sX[xC] = dX[i];
            xC++;
        }
    }
    sY[0] = dY[0];
    yC = 1;
    for (i = 1; i < 6; i++)
    {
        if (dY[i] > sY[yC - 1])
        {
            sY[yC] = dY[i];
            yC++;
        }
    }
    if (xC > 2 || yC > 2)
    {
        for (a = 0; a < xC - 1; a++)
        {
            for (b = 0; b < yC - 1; b++)
            {
                if (cE(sX[a], sY[b]))
                {
                    if (cE(sX[a + 1], sY[b]) && cE(sX[a], sY[b + 1]))
                    {
                        printf("YES");
                        break;
                    }
                }
            }
            if (b < yC - 1)
            {
                break;
            }
        }
        if (a == xC - 1)
        {
            printf("NO");
        }
    }
    else
    {
        printf("NO");
    }
    return 0;
}

#include <stdio.h>
int sX[6];
int xC = 0;
int dX[6];
int sY[6];
int yC = 0;
int dY[6];
char cB(int dX, int dY, int xA, int yA, int xB, int yB)
{
    char mark = 0;
    if (dX > xA && dX < xB)
    {
        if (dY > yA && dY < yB)
        {
            mark = 1;
        }
    }
    return mark;
}
char cW(int dX, int dY, int xA, int yA, int xB, int yB)
{
    char mark = 0;
    if (dX >= xA && dX <= xB)
    {
        if (dY >= yA && dY <= yB)
        {
            mark = 1;
        }
    }
    return mark;
}
void mS(int s[], int d[], int o, int t)
{
    int i, j, k;
    int c = (o + t) / 2;
    if (o < c)
    {
        mS(d, s, o, c);
    }
    if (c + 1 < t)
    {
        mS(d, s, c + 1, t);
    }
    i = o;
    j = c + 1;
    k = o;
    while (i <= c && j <= t)
    {
        if (s[i] < s[j])
        {
            d[k] = s[i];
            i++;
        }
        else
        {
            d[k] = s[j];
            j++;
        }
        k++;
    }
    while (i <= c)
    {
        d[k] = s[i];
        i++;
        k++;
    }
    while (j <= t)
    {
        d[k] = s[j];
        j++;
        k++;
    }
}
int main()
{
    int i;
    int a, b;
    int wXF, wYF, wXS, wYS;
    int aXF, aYF, aXS, aYS;
    int bXF, bYF, bXS, bYS;
    scanf("%d %d %d %d", &wXF, &wYF, &wXS, &wYS);
    sX[xC] = wXF;
    xC++;
    sY[yC] = wYF;
    yC++;
    sX[xC] = wXS;
    xC++;
    sY[yC] = wYS;
    yC++;
    scanf("%d %d %d %d", &aXF, &aYF, &aXS, &aYS);
    sX[xC] = aXF;
    xC++;
    sY[yC] = aYF;
    yC++;
    sX[xC] = aXS;
    xC++;
    sY[yC] = aYS;
    yC++;
    scanf("%d %d %d %d", &bXF, &bYF, &bXS, &bYS);
    sX[xC] = bXF;
    xC++;
    sY[yC] = bYF;
    yC++;
    sX[xC] = bXS;
    xC++;
    sY[yC] = bYS;
    yC++;
    for (i = 0; i < 6; i++)
    {
        dX[i] = sX[i];
    }
    for (i = 0; i < 6; i++)
    {
        dY[i] = sY[i];
    }
    mS(sX, dX, 0, 5);
    mS(sY, dY, 0, 5);
    sX[0] = dX[0];
    xC = 1;
    for (i = 1; i < 6; i++)
    {
        if (dX[i] > sX[xC - 1])
        {
            sX[xC] = dX[i];
            xC++;
        }
    }
    sY[0] = dY[0];
    yC = 1;
    for (i = 1; i < 6; i++)
    {
        if (dY[i] > sY[yC - 1])
        {
            sY[yC] = dY[i];
            yC++;
        }
    }
    for (a = 0; a < xC - 1; a++)
    {
        for (b = 0; b < yC; b++)
        {
            if (cB(sX[a], sY[b], aXF, aYF, aXS, aYS) == 0 && cB(sX[a], sY[b], bXF, bYF, bXS, bYS) == 0)
            {
                if (cW(sX[a], sY[b], wXF, wYF, wXS, wYS))
                {
                    if (cB(sX[a + 1], sY[b], aXF, aYF, aXS, aYS) == 0 && cB(sX[a + 1], sY[b], bXF, bYF, bXS, bYS) == 0)
                    {
                        if (cW(sX[a + 1], sY[b], wXF, wYF, wXS, wYS))
                        {
                            printf("YES");
                            break;
                        }
                    }
                }
            }
        }
        if (b < yC)
        {
            break;
        }
    }
    if (a == xC - 1)
    {
        printf("NO");
    }
    return 0;
}

#include<stdio.h>
struct mystuct{
	int x1,y1,x2,y2;
};
int main(void)
{
	struct mystuct input1,input2,input3;
	scanf("%d %d %d %d",&input1.x1,&input1.y1,&input1.x2,&input1.y2);
	scanf("%d %d %d %d",&input2.x1,&input2.y1,&input2.x2,&input2.y2);
	scanf("%d %d %d %d",&input3.x1,&input3.y1,&input3.x2,&input3.y2);
	getchar();
	if(input2.x1 <= input1.x1 && input2.y1 <= input1.y1 &&
	   input2.x2 >= input1.x2 && input2.y2 >= input1.y2) printf("NO"); //b全覆盖a
	else if(input3.x1 <= input1.x1 && input3.y1 <= input1.y1 &&
	   	 	input3.x2 >= input1.x2 && input3.y2 >= input1.y2) printf("NO"); //c全覆盖a
	else if(input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.x1 <= input1.x1 && input3.x1 <= input2.x2 &&
			input3.x2 >= input1.x2) printf("NO"); //b,c左右覆盖
	else if(input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.x1 <= input1.x1 && input2.x1 <= input3.x2 &&
			input2.x2 >= input1.x2) printf("NO"); //c,b左右覆盖
	else if(input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.y1 >= input1.y2 && input3.y1 >= input2.y1 &&
			input3.y2 >= input1.y2 && input2.y2 >= input1.y2) printf("NO"); //b,c上下覆盖
	else if(input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.y1 >= input1.y2 && input2.y1 >= input3.y1 &&
			input2.y2 >= input1.y2 && input3.y2 >= input1.y2) printf("NO"); //c,b上下覆盖
	else printf("YES"); //还有白色部分露出
	return 0;
}

#include <stdio.h>
#include <string.h>

typedef struct{
    int x;
    int y;
} point;

typedef struct{
    point BL;
    point TR;
} square;

int inside (point w1, point w2, point b1, point b2){
    if (w1.x >= b1.x && w1.y >= b1.y && w2.x <= b2.x && w2.y <= b2.y){
        return 1;
    }
    else {
        return 0;
    }
}

int main(){
    square w1, b1, b2;
    square left, right, top, bottom;
    scanf("%d %d %d %d", &w1.BL.x, &w1.BL.y, &w1.TR.x, &w1.TR.y);
    scanf("%d %d %d %d", &b1.BL.x, &b1.BL.y, &b1.TR.x, &b1.TR.y);
    scanf("%d %d %d %d", &b2.BL.x, &b2.BL.y, &b2.TR.x, &b2.TR.y);

    left = (b1.BL.x<b2.BL.x)?b1:b2;
    right = (b1.BL.x<b2.BL.x)?b2:b1;
    top = (b1.TR.y<b2.TR.y)?b2:b1;
    bottom = (b1.TR.y<b2.TR.y)?b1:b2;

    if (w1.BL.x>=b1.BL.x && w1.TR.x<=b1.TR.x
     && w1.BL.y>=b1.BL.y && w1.TR.y<=b1.TR.y ||
     w1.BL.x>=b2.BL.x && w1.TR.x<=b2.TR.x
     && w1.BL.y>=b2.BL.y && w1.TR.y<=b2.TR.y){
        printf("NO\n");
    } else if (left.TR.x==right.BL.x && w1.BL.y>=b1.BL.y && w1.BL.y>=b2.BL.y
     && w1.TR.y<=b1.TR.y && w1.TR.y<=b2.TR.y
     && w1.BL.x>=left.BL.x && w1.TR.x<=right.TR.x
     ) {
        printf("NO\n");
    } else if (top.BL.y==bottom.TR.y && w1.BL.x>=b1.BL.x && w1.BL.x>=b2.BL.x
     && w1.TR.x<=b1.TR.x && w1.TR.x<=b2.TR.x
     && w1.BL.y>=bottom.BL.y && w1.TR.y<=top.TR.y
     ) {
        printf("NO\n");
    } else {
        printf("YES\n");
    }

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>

int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;

void swap(int *a, int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

char inside(int x, int y, int x1, int y1, int x2, int y2)
{
    if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
        return 1;
    return 0;
}

int main()
{
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    scanf("%d%d%d%d", &x3, &y3, &x4, &y4);
    scanf("%d%d%d%d", &x5, &y5, &x6, &y6);

    if (!(inside(x1, y1, x3, y3, x4, y4) || inside(x1, y1, x5, y5, x6, y6))) {
        printf("YES");
        return 0;
    }
    if (!(inside(x2, y2, x3, y3, x4, y4) || inside(x2, y2, x5, y5, x6, y6))) {
        printf("YES");
        return 0;
    }
    if (!(inside(x1, y2, x3, y3, x4, y4) || inside(x1, y2, x5, y5, x6, y6))) {
        printf("YES");
        return 0;
    }
    if (!(inside(x2, y1, x3, y3, x4, y4) || inside(x2, y1, x5, y5, x6, y6))) {
        printf("YES");
        return 0;
    }

    if (x5 < x3) {
        swap(&x3, &x5);
        swap(&x4, &x6);
        swap(&y3, &y5);
        swap(&y4, &y6);
    }
    if (x4 + 1 <= x5 && x4 + 1 >= x1 && x4 + 1 <= x2) {
        printf("YES");
        return 0;
    }

    if (y6 > y4) {
        swap(&x3, &x5);
        swap(&x4, &x6);
        swap(&y3, &y5);
        swap(&y4, &y6);
    }
    if (y3 - 1 >= y6 && y3 - 1 <= y2 && y3 - 1 >= y1) {
        printf("YES");
        return 0;
    }

    printf("NO");

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>

int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;

void swap(int *a, int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

char inside(int x, int y, int x1, int y1, int x2, int y2)
{
    if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
        return 1;
    return 0;
}

int main(int argc, char *argv[])
{
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    scanf("%d%d%d%d", &x3, &y3, &x4, &y4);
    scanf("%d%d%d%d", &x5, &y5, &x6, &y6);

    if (!(inside(x1, y1, x3, y3, x4, y4) || inside(x1, y1, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }
    if (!(inside(x2, y2, x3, y3, x4, y4) || inside(x2, y2, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }
    if (!(inside(x1, y2, x3, y3, x4, y4) || inside(x1, y2, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }
    if (!(inside(x2, y1, x3, y3, x4, y4) || inside(x2, y1, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }

    if (x5 < x3) {
        swap(&x3, &x5);
        swap(&x4, &x6);
        swap(&y3, &y5);
        swap(&y4, &y6);
    }
    if ((x4 + 1 <= x5 || x4 + 1 >= x6) && x4 + 1 >= x1 && x4 + 1 <= x2) {
        printf("YES\n");
        return 0;
    }

    if (y6 > y4) {
        swap(&x3, &x5);
        swap(&x4, &x6);
        swap(&y3, &y5);
        swap(&y4, &y6);
    }
    if ((y3 - 1 >= y6 || y3 - 1 >= y5) && y3 - 1 <= y2 && y3 - 1 >= y1) {
        printf("YES\n");
        return 0;
    }

    printf("NO\n");

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>

int x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;

void swap(int *a, int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

char inside(int x, int y, int x1, int y1, int x2, int y2)
{
    if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
        return 1;
    return 0;
}

int main(int argc, char *argv[])
{
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    scanf("%d%d%d%d", &x3, &y3, &x4, &y4);
    scanf("%d%d%d%d", &x5, &y5, &x6, &y6);

    if (!(inside(x1, y1, x3, y3, x4, y4) || inside(x1, y1, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }
    if (!(inside(x2, y2, x3, y3, x4, y4) || inside(x2, y2, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }
    if (!(inside(x1, y2, x3, y3, x4, y4) || inside(x1, y2, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }
    if (!(inside(x2, y1, x3, y3, x4, y4) || inside(x2, y1, x5, y5, x6, y6))) {
        printf("YES\n");
        return 0;
    }

    if (x5 < x3) {
        swap(&x3, &x5);
        swap(&x4, &x6);
        swap(&y3, &y5);
        swap(&y4, &y6);
    }
    if (x4 + 1 <= x5 && x4 + 1 > x1 && x4 + 1 < x2) {
        printf("YES\n");
        return 0;
    }

    if (y6 > y4) {
        swap(&x3, &x5);
        swap(&x4, &x6);
        swap(&y3, &y5);
        swap(&y4, &y6);
    }
    if (y3 - 1 >= y6 && y3 - 1 < y2 && y3 - 1 > y1) {
        printf("YES\n");
        return 0;
    }

    printf("NO\n");

    return 0;
}


To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well).Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer.All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind.

The first line contains four integers — n, a, b, c (1 ≤ n ≤ 10000, 0 ≤ a, b, c ≤ 5000).

Print the unique number — the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0.

#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef long long ll;

int main ()
{
    int n, a, b, c; scanf ("%d%d%d%d", &n, &a, &b, &c);
    n <<= 1;
    int ans = 0;
    for (int ta = 0; ta <= a; ta++)
    {
        for (int tb = 0; tb <= b; tb++)
        {
            int cnt = ta + (tb << 1);
            if (cnt > n) continue;
            if ((n - cnt) % 4) continue;
            int tc = (n - cnt) / 4;
            if (tc <= c)
                ans++;
        }
    }
    printf ("%d\n", ans);

    return 0;
}

#include <stdio.h>
int main()
{
    int n, a, b, c;
    scanf("%d %d %d %d", &n, &a, &b, &c);
    int cnt = 0;
    for(int i = 0; i <= a/2; i++)
    {
        for(int j = 0; j <= c; j++)
        {
            int val = n-i-j*2;
            if(val >= 0 && val <= b)
                cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main ()
{
	int N, A, B, C;
	scanf("%d %d %d %d",&N,&A,&B,&C);
	N *= 2;
	int res = 0;
	int x, y;
	int rem;
	for (x = 0; x <= B; x++)
	{
		for (y = 0; y <= C; y++)
		{
			rem = N - 2 * x - 4 * y;
			if ((rem >= 0) && (rem <= A)) res++;
		}
	}
	printf("%d\n",res);
	return 0;
}

#include <stdio.h>

int main(void) {
    int n, a, b, c, i, j, ans = 0;
    scanf("%d %d %d %d", &n, &a, &b, &c);

    for (i = 0; i <= c; i++) {
        for (j = 0; j <= b; j++) {
            int k = 2*n - 4*i - 2*j;
            if (0 <= k && k <= a) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

// Cola

#include <stdio.h>
#include <string.h>

#define ll long long

int count[20000];

void deal(int n, int a, int b, int c)
{
    int i, j;
    ll ans = 0;
    memset(count, 0, sizeof(count));
    for (i = 0; i <= b; i++)
    {
/*      if (i > n)
        {
            break;
        }*/
        for (j = 0; j <= c; j++)
        {
/*          if (i + 2 * j > n)
            {
                break;
            }*/
            count[i + 2 * j]++;
        }
    }
    for (i = 0; i <= a; i += 2)
    {
        if (n - i / 2 < 0)
        {
            break;
        }
        ans += count[n - i / 2];
    }
    printf("%lld\n", ans);
}

int main(int argc, char **argv)
{
    int a, b, c, n;
    while (scanf("%d%d%d%d", &n, &a, &b, &c) == 4)
    {
        deal(n, a, b, c);
    }
    return 0;
}

// Cola

#include <stdio.h>
#include <string.h>

#define ll long long

int count[20000];

void deal(int n, int a, int b, int c)
{
    int i, j;
    ll ans = 0;
    memset(count, 0, sizeof(count));
    for (i = 0; i <= b; i++)
    {
        if (i > n)
        {
            break;
        }
        for (j = 0; j <= c; j++)
        {
            if (i + 2 * j > n)
            {
                break;
            }
            count[i + 2 * j]++;
        }
    }
    for (i = 0; i <= a; i += 2)
    {
        if (n - i / 2 < 0)
        {
            break;
        }
        ans += count[n - i / 2];
    }
    printf("%lld\n", ans);
}

int main(int argc, char **argv)
{
    int a, b, c, n;
    while (scanf("%d%d%d%d", &n, &a, &b, &c) == 4)
    {
        deal(n, a, b, c);
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int n, a, b, c, i, j, res, N, rem;
    while(scanf("%d%d%d%d", &n, &a, &b, &c)==4)
    {
        res=0;
        rem=0;
        N=2*n;
        for(i=0; i<=b; i++)
        {
            for(j=0; j<=c; j++)
            {
                rem=N-2*i-4*j;
                if(rem>=0 && rem<=a)
                    res++;
            }
        }
        printf("%d\n", res);
    }
    return 0;
}

#include<stdio.h>
int main()
{

    int n,a,b,c,sum;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    int count =0;
    int i,j;
    for(i=0;i<=a;i++)
    {
        if(i%2)
            continue;
        for(j=0;j<=b;j++)
        {
            sum=0;
            sum=(n)-(int)(i*0.5)-(j*1);
           if(sum<0)
            continue;
            if((sum%2 ==0)&&((sum/2)<=c))
                count++;
        }
    }
    printf("%d",count);
    return 0;
}

#include<stdio.h>
int main()

{
    int n,a,b,c,i,count=0,j,k;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    if(2*c>n)c=n/2;
    if(b>n)b=n;
    if(c/2>n)c=2*n;
    for(i=c;i>=0;i--)
    {
        if(2*i==n){count++;
        continue;
        }
        for(j=b;j>=0;j--)
        {
            if(2*i+j==n)
            {
                count++;
                continue;
            }
            k=2*n-4*i-2*j;
            if(0<=k &&k<=a)count++;
        }

    }printf("%d",count);
    return 0;
}

// Cola

#include <stdio.h>
#include <string.h>

#define ll long long

int count[20000];

void deal(int n, int a, int b, int c)
{
    int i, j;
    ll ans = 0;
    memset(count, 0, sizeof(count));
    for (i = 0; i <= b; i++)
    {
        for (j = 0; j <= c; j++)
        {
            count[i + 2 * j]++;
        }
    }
    for (i = 0; i <= a; i += 2)
    {
        ans += count[n - i / 2];
    }
    printf("%lld\n", ans);
}

int main(int argc, char **argv)
{
    int a, b, c, n;
    while (scanf("%d%d%d%d", &n, &a, &b, &c) == 4)
    {
        deal(n, a, b, c);
    }
    return 0;
}

#include<stdio.h>
int main()
{

    int n,a,b,c,sum;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    int count =0;
    int i,j;
    for(i=0;i<=a;i++)
    {
        if(i%2)
            continue;
        for(j=0;j<=b;j++)
        {
            sum=0;
            sum=(n)-(int)(i*0.5)-(j*1);
            if((sum%2 ==0)&&((sum/2)<=c))
                count++;
        }
    }
    printf("%d",count);
    return 0;
}