Arkady decided to buy roses for his girlfriend.A flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet where all roses have the same color. Arkady wants to buy exactly k roses. For each rose in the shop he knows its beauty and color: the beauty of the i-th rose is bi, and its color is ci ('W' for a white rose, 'O' for an orange rose and 'R' for a red rose). Compute the maximum possible total beauty of a bouquet of k roses satisfying the constraints above or determine that it is not possible to make such a bouquet.

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of roses in the show and the number of roses Arkady wants to buy. The second line contains a sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 10 000), where bi equals the beauty of the i-th rose. The third line contains a string c of length n, consisting of uppercase English letters 'W', 'O' and 'R', where ci denotes the color of the i-th rose: 'W' denotes white, 'O'  — orange, 'R' — red.

Print the maximum possible total beauty of a bouquet of k roses that satisfies the constraints above. If it is not possible to make a single such bouquet, print -1.

NoteIn the first example Arkady wants to buy 3 roses. He can, for example, buy both red roses (their indices are 1 and 2, and their total beauty is 7) and the only orange rose (its index is 3, its beauty is 4). This way the total beauty of the bouquet is 11. In the second example Arkady can not buy a bouquet because all roses have the same color.

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

void wqsb() {
	puts("-1");
	exit(0);
}

int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0||k==1||rn+wn==0) wqsb();
	if((rn+on<k)&&(wn+on<k)) wqsb();
	qsort(r+1,rn,sizeof(int),comp);
	qsort(o+1,on,sizeof(int),comp);
	qsort(w+1,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on,ww=wn,rr=rn;
	if(rn+oo>=k) {
		for(int cnt=1;cnt<k;++cnt) {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
		if(rn==rr) ans+=r[rn--]; else if(on==oo) ans+=o[on--];
		else {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<k;++cnt) {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
		if(wn==ww) tmp+=w[wn--]; else if(on==oo) tmp+=o[on--];
		else {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);
	return 0;
}

#include <stdio.h>
#define N 202002
int v[N];
int ty[3][N];
int mk[N];
int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    for(int e = 0;e  < n; e++) scanf("%d", v + e);
    for(int e = 0; e < n; e++){
        char c;
        scanf(" %c", &c);
        if(c == 'W') ty[0][v[e]]++;
        if(c == 'O') ty[1][v[e]]++;
        if(c == 'R') ty[2][v[e]]++;
    }
    // red with withe is bad
    int res = -1;
    for(int e = 0; e < 3; e++){
        for(int f = e + 1; f < 3; f++){
            if(e == 0 && f == 2) continue;
            int tk0 = 0, tk1 = 0, sum = 0;
            for(int g = N-1; g >= 0; g--){
                int cp = ty[e][g];
                while(tk0 < k - 1 && tk0 + tk1 < k && cp > 0){
                    cp--;
                    tk0++;
                    sum += g;
                }
                cp = ty[f][g];
                while(tk1 < k - 1 && tk0 + tk1 < k && cp > 0){
                    cp--;
                    tk1++;
                    sum += g;
                }
            }
            if(tk0 + tk1 == k)
                if(res < sum) res = sum;
        }
    }
    printf("%d\n", res);
    return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

void wqsb() {
	puts("-1");
	exit(0);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0||k==1||rn+wn==0) wqsb();
	if((rn+on<k)&&(wn+on<k)) wqsb();
	qsort(r+1,rn,sizeof(int),comp);
	qsort(o+1,on,sizeof(int),comp);
	qsort(w+1,wn,sizeof(int),comp);
	/*for(int cnt=1;cnt<=rn;++cnt) {printf("%d ",r[cnt]);}puts("");
	for(int cnt=1;cnt<=on;++cnt) {printf("%d ",o[cnt]);}puts("");
	for(int cnt=1;cnt<=wn;++cnt) {printf("%d ",w[cnt]);}puts("");*/
	int ans=0,tmp=0,oo=on,ww=wn,rr=rn;
	if(rn+oo>=k) {
		for(int cnt=1;cnt<k;++cnt) {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
		if(rn==rr) ans+=r[rn--]; else if(on==oo) ans+=o[on--];
		else {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<k;++cnt) {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
		if(wn==ww) tmp+=w[wn--]; else if(on==oo) tmp+=o[on--];
		else {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

void wqsb() {
	puts("-1");
	exit(0);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0||k==1||rn+wn==0) wqsb();
	if((rn+on<k)&&(wn+on<k)) wqsb();
	qsort(r+1,rn,sizeof(int),comp);
	qsort(o+1,on,sizeof(int),comp);
	qsort(w+1,wn,sizeof(int),comp);
	/*for(int cnt=1;cnt<=rn;++cnt) {printf("%d ",r[cnt]);}puts("");
	for(int cnt=1;cnt<=on;++cnt) {printf("%d ",o[cnt]);}puts("");
	for(int cnt=1;cnt<=wn;++cnt) {printf("%d ",w[cnt]);}puts("");*/
	int ans=0,tmp=0,oo=on;
	if(rn+oo>=k) {
		ans=o[on--];
		for(int cnt=2;cnt<=k;++cnt) {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		tmp=o[on--];
		for(int cnt=2;cnt<=k;++cnt) {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0) {
		puts("-1");
		return 0;
	}
	if(rn==0&&wn==0) {
		puts("-1");
		return 0;
	}
	qsort(r,rn,sizeof(int),comp);
	qsort(o,on,sizeof(int),comp);
	qsort(w,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on;
	if((rn+oo<k)&&(wn+oo<k)) {
		puts("-1");
		return 0;
	}
	if(rn+oo>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if(r[rn]>o[on]&&rn) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if(w[wn]>o[on]&&wn) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

void wqsb() {
	puts("-1");
	exit(0);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0||k==1||rn+wn==0) wqsb();
	if((rn+on<k)&&(wn+on<k)) wqsb();
	qsort(r+1,rn,sizeof(int),comp);
	qsort(o+1,on,sizeof(int),comp);
	qsort(w+1,wn,sizeof(int),comp);
	/*for(int cnt=1;cnt<=rn;++cnt) {printf("%d ",r[cnt]);}puts("");
	for(int cnt=1;cnt<=on;++cnt) {printf("%d ",o[cnt]);}puts("");
	for(int cnt=1;cnt<=wn;++cnt) {printf("%d ",w[cnt]);}puts("");*/
	int ans=0,tmp=0,oo=on;
	if(rn+oo>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0||k==1) {
		puts("-1");
		return 0;
	}
	if(rn==0&&wn==0) {
		puts("-1");
		return 0;
	}
	qsort(r,rn,sizeof(int),comp);
	qsort(o,on,sizeof(int),comp);
	qsort(w,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on;
	if((rn+oo<k)&&(wn+oo<k)) {
		puts("-1");
		return 0;
	}
	if(rn+oo>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if(r[rn]>o[on]&&rn) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if(w[wn]>o[on]&&wn) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0) {
		puts("-1");
		return 0;
	}
	if(rn==0&&wn==0) {
		puts("-1");
		return 0;
	}
	qsort(r,rn,sizeof(int),comp);
	qsort(o,on,sizeof(int),comp);
	qsort(w,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on;
	if(rn+on>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if(r[rn]>o[on]&&rn) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	else if(wn+on>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if(w[wn]>o[on]&&wn) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	else {puts("-1"); return 0;}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0) {
		puts("-1");
		return 0;
	}
	if(rn==0&&wn==0) {
		puts("-1");
		return 0;
	}
	qsort(r,rn,sizeof(int),comp);
	qsort(o,on,sizeof(int),comp);
	qsort(w,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on;
	if(rn+oo>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if(r[rn]>o[on]&&rn) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	else if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if(w[wn]>o[on]&&wn) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	else {puts("-1"); return 0;}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}

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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

void wqsb() {
	puts("-1");
	exit(0);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0||k==1||rn+wn==0) wqsb();
	if((rn+on<k)&&(wn+on<k)) wqsb();
	qsort(r,rn,sizeof(int),comp);
	qsort(o,on,sizeof(int),comp);
	qsort(w,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on;
	if(rn+oo>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if((r[rn]>o[on]&&rn)||!on) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if((w[wn]>o[on]&&wn)||!on) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}


Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.The entire universe turned into an enormous clock face with three hands — hour, minute, and second. Time froze, and clocks now show the time h hours, m minutes, s seconds.Last time Misha talked with the coordinator at t1 o'clock, so now he stands on the number t1 on the clock face. The contest should be ready by t2 o'clock. In the terms of paradox it means that Misha has to go to number t2 somehow. Note that he doesn't have to move forward only: in these circumstances time has no direction.Clock hands are very long, and Misha cannot get round them. He also cannot step over as it leads to the collapse of space-time. That is, if hour clock points 12 and Misha stands at 11 then he cannot move to 1 along the top arc. He has to follow all the way round the clock center (of course, if there are no other hands on his way).Given the hands' positions, t1, and t2, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from t1 to t2 by the clock face.

Five integers h, m, s, t1, t2 (1 ≤ h ≤ 12, 0 ≤ m, s ≤ 59, 1 ≤ t1, t2 ≤ 12, t1 ≠ t2). Misha's position and the target time do not coincide with the position of any hand.

Print "YES" (quotes for clarity), if Misha can prepare the contest on time, and "NO" otherwise. You can print each character either upper- or lowercase ("YeS" and "yes" are valid when the answer is "YES").

NoteThe three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same.

#include <stdio.h>

void swap(double * t1, double * t2)
{
	if (*t1 > *t2)
	{
		double temp = *t1;
		*t1 = *t2;
		*t2 = temp;
	}
	return;
}

int main(void)
{
	int h, m, s, t1, t2, f = 0;
	double posh, posm, poss, post1, post2;
	scanf("%d %d %d %d %d", &h, &m, &s, &t1, &t2);
	h = h % 12;
	poss = (double)s * 6;
	posm = 6 * m + (double)s / 10;
	posh = 30 * h + (double)(60 * m + s) / 120;
	post1 = 30 * t1;
	post2 = 30 * t2;
	swap(&post1, &post2);
	if (poss < post1)
	{
		poss += 360;
		f = 1;
	}
	if (posm < post1)
	{
		posm += 360;
		f = 1;
	}
	if (posh < post1)
	{
		posh += 360;
		f = 1;
	}
	if (f)
	{
		post1 = post1 + 360;
		swap(&post1, &post2);
	}
	if ((post2 > posh && post1 < posh && post2 > posm && post1 < posm && post2 > poss && post1 < poss) || (poss <=360 && poss > post2 && posm <=360 && posm > post2 && posh <=360 && posh > post2))
	{
		puts("YES");
	}
	else
	{
		puts("NO");
	}
	return 0;
}

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

int main()
{
    int start,finish,h,m,s;
    int count=0;
    int a,b;

    scanf("%d %d %d %d %d",&h,&m,&s,&start, &finish);

    a=start;
    b=finish;
    if (b<a)
    {
        b=start;
        a=finish;
    }

    if (h>=a && h<b)
        count++;
    if ((float)m/5 >= a && (float)m/5 <b )
        count++;

    if ((float)s/5 >= a && (float)s/5 <b )
        count++;

    if (count==3 || count==0)
        printf("YES");
    else
        printf ("NO");
    return 0;
}

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

int
main(void)
{
    double h = 0;
    double m = 0;
    double s = 0;
    int t1 = 0;
    int t2 = 0;
    double flag = 0;
    double btw1 = 0;
    double btw2 = 0;

    scanf("%lf%lf%lf%d%d", &h, &m, &s, &t1, &t2);

    h = h + m / 60 + s / 3600;
    m = (m + s / 60) / 5;
    s = s / 5;

    if (t1 > t2) {
        t1 = t1 ^ t2;
        t2 = t2 ^ t1;
        t1 = t1 ^ t2;
    }

    if (t1 <= h && h <= t2) {
        btw1 = 1;
    } else {
        btw2 = 1;
    }

    if (t1 <= m && m <= t2) {
        btw1 = 1;
    } else {
        btw2 = 1;
    }

    if (t1 <= s && s <= t2) {
        btw1 = 1;
    } else {
        btw2 = 1;
    }

    if (btw1 && btw2) {
        printf("NO");
    } else {
        printf("YES");
    }
    return 0;
}

/*
 * Copyright (C) 2017-2018 Συμεωνίδης Αναστάσιος.
 * Race Against Time
 * +No branching challenge.
 */
#include <stdio.h>
#include <stdlib.h>
//Helper functions to make the code understandable.
#define min(x, y) y ^ ((x^y) & -(x<y))
#define max(x, y) x ^ ((x^y) & -(x<y))
//Range checks.
#define in_range_eq(s, e, p) s<=p && e>=p
#define in_range(s, e, p) s<p && e>p
//Tests if 3 variables are all equal.
#define equal3(a, b, c) !((a^b)|(b^c))
//Map hours in the range of [1, 12] to [0, 59]
#define map_hours(h) H2C[(h)-1]
const int H2C[] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 0};
//An array containing valid answers.
//0(false) is translated into "NO" and 1(true) is translated into "YES".
const char* ANSWERS[2] = {"NO", "YES"};

//Main code body.
int main(int argc, char* argv[]){
    int tmp_h, tmp_m, tmp_s, tmp_t1, tmp_t2;
    scanf("%i%i%i%i%i", &tmp_h, &tmp_m, &tmp_s, &tmp_t1, &tmp_t2);
    //Map the integer positions into floats in the range [0.0, 1.0].
    register double h, m, s, t1, t2;
    s = tmp_s/59.0;
    m = tmp_m/59.0 + s/60.0;
    h = map_hours(tmp_h)/59.0 + m/60.0;
    tmp_t1 = map_hours(tmp_t1);
    tmp_t2 = map_hours(tmp_t2);
    //The next two lines ensure that t1<t2.
    t1 = (min(tmp_t1, tmp_t2))/59.0;
    t2 = (max(tmp_t1, tmp_t2))/59.0;
    //Test and output result.
    register char hb, mb, sb, fb;//4 bytes
    hb = in_range_eq(t1, t2, h);
    mb = in_range_eq(t1, t2, m);
    sb = in_range_eq(t1, t2, s);
    fb = equal3(hb, mb, sb);
    printf("%s\n", ANSWERS[fb]);
    return EXIT_SUCCESS;
}

/*
 * Copyright (C) 2017-2018 Συμεωνίδης Αναστάσιος.
 * Race Against Time
 * + No branching challenge.
 */
#include <stdio.h>
#include <stdlib.h>
#define min(x, y) y ^ ((x^y) & -(x<y))
#define max(x, y) x ^ ((x^y) & -(x<y))
#define in_range_eq(s, e, p) s<=p && e>=p
#define in_range(s, e, p) s<p && e>p
#define equal3(a, b, c) !((a^b)|(b^c))
#define map_hours(h) H2C[(h)-1]
const int H2C[] = {5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 0};
const char* ANSWERS[2] = {"NO", "YES"};
int main(int argc, char* argv[]){
    int tmp_h, tmp_m, tmp_s, tmp_t1, tmp_t2;
    register double h, m, s, t1, t2;
    register char hb, mb, sb;
    scanf("%i%i%i%i%i", &tmp_h, &tmp_m, &tmp_s, &tmp_t1, &tmp_t2);
    //The next two lines make t1<t2.
    s = tmp_s/59.0;
    m = tmp_m/59.0 + s/60.0;
    h = map_hours(tmp_h)/59.0 + m/60.0;
    tmp_t1 = map_hours(tmp_t1);
    tmp_t2 = map_hours(tmp_t2);
    t1 = (min(tmp_t1, tmp_t2))/59.0;
    t2 = (max(tmp_t1, tmp_t2))/59.0;
    //The test are done in the range between [0.0, 1.0].
    //printf("%lf, %lf, %lf, %lf, %lf\n", h, m, s, t1, t2);
    hb = in_range_eq(t1, t2, h);
    mb = in_range_eq(t1, t2, m);
    sb = in_range_eq(t1, t2, s);
    //printf("%i, %i, %i\n", hb, mb, sb);
    printf("%s\n", ANSWERS[equal3(hb, mb, sb)]);
    return EXIT_SUCCESS;
}

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

int main()
{
    float h,m,s,maxx1,maxx2,maxx3;
    int n1,n2;

    scanf("%f %f %f %d %d",&h,&m,&s,&n1,&n2);
    if (m!=0 || s!=0)
        {
            h=h+0.1;
            m=m/5 + 0.1;
            s=s/5;

            maxx1=h;
            if (m>maxx1)
            {
                maxx1=m;
                maxx2=h;
            }
            else
                maxx2=m;
            if (s>maxx1)
            {
                maxx3=maxx2;
                maxx2=maxx1;
                maxx1=s;
            }
            else if (s>maxx2)
                {
                    maxx3=maxx2;
                    maxx2=s;
                }
                else
                    maxx3=s;

        if (n1>maxx3 && n2>maxx3 && n1<maxx2 && n2<maxx2)
            printf("YES");
                else
                    if (n2>maxx2 && n1>maxx2 && n1<maxx1 && n2<maxx1)
                    printf("YES");
                        else
                            if (n1<maxx3 || n1>maxx1)
                            {
                                    if (n2<maxx3 || n2>maxx1)
                                        printf("YES");
                                    else
                                        printf("NO");
                            }
                            else
                                printf("NO");
        }
    else
    {
        if (h==12)
        {
            if (n1!=h && n2!=h)
            printf("YES");
            else
            printf("NO");
        }
        else
        {
        if ((n1>h && n2>h) || (n1<h && n2<h))
            printf("YES");
        else
            printf("NO");
        }
    }

    return 0;
}

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

int main()
{
    int h, m, s, a, b, f=0;
    float hours, minutes;

    //printf("Enter the hours, minutes, seconds and 2 positive integers.\n");
    scanf("%d %d %d %d %d", &h, &m, &s, &a, &b);

    if(h<1 || h>12 || m<0 || m>59 || s<0 || s>59 || a<1 || a> 12 || b<1 || b>12)
        exit(1);

    minutes = m + s/60.0;
    hours = h + minutes/60.0;

    a*= 5;
    b*= 5;
    hours*=5;

    if(a == 60)
        a = 0;
    if(b ==60)
        b = 0;
    if(hours >= 60)
        hours -= 60;
    if(minutes >= 60)
        minutes -= 60;

    if(a < b)
    {
        if((hours>b || hours<a) && (minutes>b || minutes<a) && (s>b || s<a))
            f = 1;
        if((hours>a && hours<b) && (minutes>a && minutes<b) && (s>a && s<b))
            f = 1;
    }else
    {
        if((hours>a || hours<b) && (minutes>a || minutes<b) && (s>a || s<b))
            f = 1;
        if((hours>b && hours<a) && (minutes>b && minutes<a) && (s>b && s<a))
            f = 1;
    }
    if(f)
        printf("YES");
    else
        printf("NO");

    return 0;
}

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

int main()
{
float h, m, s, a, b, temp ;

scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
h *= 5;
a *= 5;
b *= 5;
m = m + (s / 60);
h = h + (m / 60);

if(a > b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    temp=1;
if((s >= a && s <= b)||(m >= a && m <= b)||(h >= a && h <= b))
{
    if(!((s > a && m > a && h > a)&&(s < b && m < b && h < b)))
        {
            temp=0;
        }
}
if (temp)
     printf("YES");
else
     printf("NO");
return 0;
}

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

int main()
{
float h, m, s, a, b, temp ;

scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
h *= 5;
a *= 5;
b *= 5;
m = m + (s / 60);
h = h + (m / 60);

if(a > b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    temp=1;
if((s >= a && s <= b) ||(m >= a && m <= b) || (h >= a && h <= b))
{
    if(!((s > a && m > a && h > a) && (s < b && m < b && h < b)))
        {
            temp=0;
        }
}
if (temp)
     printf("YES");
else
     printf("NO");
return 0;
}

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

int main()
{
    float h, m, s, a, b, temp ;

    scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
    h *= 5;
    a *= 5;
    b *= 5;
    m = m + (s / 60);
    h = h + (m / 60);

    if(a > b )
    {
        temp = a;
        a = b;
        b = temp;
    }

    if((s >= a && s <= b) ||(m >= a && m <= b) || (h >= a && h <= b))
        {
            if((s > a && m> a && h > a) && (s < b && m < b && h < b))
            {
                temp=1;
            }
            else
            {
                temp=0;
            }
    }
    else
    {
        temp=1;
    }
    if (temp)
     printf("YES");
    else
     printf("NO");
    return 0;
}

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

int main()
{
float h, m, s, a, b, temp ;

scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
h *= 5;
a *= 5;
b *= 5;
m = m + (s / 60);
h = h + (m / 60);

if(a > b)
    {
        temp = a;
        a = b;
        b = temp;
    }
if((s >= a && s <= b) ||(m >= a && m <= b) || (h >= a && h <= b))
        {
            if((s > a && m > a && h > a) && (s < b && m < b && h < b))
            {
                temp=1;
            }
            else
            {
                temp=0;
            }
    }
else
    {
        temp=1;
    }
if (temp)
     printf("YES");
else
     printf("NO");
return 0;
}

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

int main()
{
    float h, m, s, a, b, temp ;

    scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);

    h *= 5;
    a *= 5;
    b *= 5;

    m = m + (s / 60);
    h = h + (m / 60);

    if(a > b ){
        temp = a;
        a = b;
        b = temp;
    }

    if((s >= a && s <= b) ||(m >= a && m <= b) || (h >= a && h <= b)){
            if((s > a && m> a && h > a) && (s < b && m < b && h < b)){
                    printf("YES");
            }
            else{
            printf("NO");
            }
    }
    else{
        printf("YES");
    }
    return 0;
}

main()
{
    int h, m, s, a, b, max, start, finish, count=0;
    scanf("%d%d%d%d%d", &h, &m, &s, &a, &b);
    max=b;
    start=a;
    finish=b;
    if(a>b)
    {
        a=finish;
        b=start;
    }
    if(h>=1 && h<=12 && m>=0 && m<=59 && s>=0 && s<=59 && a!=b)
    {
        if (h>=a && h<b)
        {
            count=count+1;
        }
        if (m/5>=a && m/5<b)
        {
            count=count+1;
        }
        if (s/5>=a && s/5<b)
        {
            count=count+1;
        }
        if (count==3 || count==0)
        {
            printf("\nYES\n\n");
        }
        else
        {
            printf ("\nNO\n\n");
        }
    }
    return 0;
}

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

int min_dist(int a, int b){
    int n = abs(a-b);
    if(n > 120) return 240 - n;
    else return n;
}

int main(void){
    int time[3] = {};
    int t1,t2;
    scanf("%d %d %d %d %d",&time[0],&time[1],&time[2],&t1,&t2);
    time[0] *= 20;
    t1 *= 20;
    t2 *= 20;
    time[1] *= 4;
    time[2] *= 4;

    time[1] += time[2] > 0 ? 2 : 0;
    time[0] += time[1] > 0 ? 2 : 0;

    int segm = min_dist(t1, t2);
    if(segm == 120){
        t2 += 1;
        segm -= 1;
    }
    int c1 = (min_dist(t1, time[0]) + min_dist(t2, time[0])) <= segm;
    int c2 = (min_dist(t1, time[1]) + min_dist(t2, time[1])) <= segm;
    int c3 = (min_dist(t1, time[2]) + min_dist(t2, time[2])) <= segm;

    if(c1 == c2 && c2 == c3){
        printf("YeS\n");
    }else{
        printf("nO\n");
    }

    return 0;
}

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

int main()
{ int a,b,h,m,s,check,c,temp;
    //printf("Give h,m,s,a,b: /n ");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    check=0;
    c=0;

    s=(float)s/5;
    m=(float)m/5;

if (b>a)
{
    temp=a;
    a=b;
    b=temp;
}

if ((b<=s)&&(a>s))
    c++;
if ((b<=m)&&(a>m))
    c++;
if ((b<=h)&&(a>h))
    c++;
if ( (c==3) || (c==0))
    check=1;

if (check==1)
    printf ("YES");
else
    printf ("NO");

}

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

int main()
{ int a,b,h,m,s,check,c,temp;
    //printf("Give h,m,s,a,b: /n ");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    check=0;
    c=0;

if (b>a)
{
    temp=a;
    a=b;
    b=temp;
}

if ((b<=(float)s/5)&&(a>(float)s/5))
    c++;
if ((b<=(float)m/5)&&(a>(float)m/5))
    c++;
if ((b<=h)&&(a>h))
    c++;
if ( (c==3) || (c==0))
    check=1;

if (check==1)
    printf ("YES");
else
    printf ("NO");

}

 #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2,count=0,temp;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
    h*=5;
    p1*=5;
    p2*=5;
    if(p1>p2) //swaping places of p1 and p2 if p1 > p2
{
    temp=p2;
    p2=p1;
    p1=temp;
}
     if(p1<=h && h<p2)
        count++;
     if(p1<=m && m<p2)
        count++;
     if(p1<=s && s<p2)
        count++;
     if(count==0 || count==3)
        printf("YES");
     else
        printf("NO");
    return 0;
}

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

int main()
{
    double Hours,Mins,Secs,Misha,Destination,temp;
    int FlagCW=0,FlagCCW=0;
    scanf("%lf %lf %lf %lf %lf",&Hours,&Mins,&Secs,&Misha,&Destination);

    Hours+=Mins/60;
    Hours+=Secs/3600;
    if(Hours>12){
        Hours-=12;
    }

    Mins+=Secs/60;
    Mins/=5;
    Secs/=5;
    if(Misha>Destination){
        temp=Misha;
        Misha=Destination;
        Destination=temp;
    }
    temp=12.0000;
    if((Hours>Misha && Hours<Destination) || (Mins>Misha && Mins<Destination) || (Secs>Misha && Secs<Destination)){
        FlagCW=1;
    }
    if(FlagCW==0){
        printf("YES");
    }
    else{
        if((Hours<temp && Hours>Destination) || (Mins<temp && Mins>Destination) || (Secs<temp && Secs>Destination)){
            FlagCCW=1;
        }
        temp=0.0000;
        if((Hours<Misha && Hours>=temp) || (Mins<Misha && Mins>=temp) || (Secs<Misha && Secs>=temp)){
            FlagCCW=1;
        }
        if(FlagCCW==0){
            printf("YES");
        }
        else{
            printf("NO");
        }
    }
    //printf("\n%lf %lf %lf %lf %lf %d %d",Hours,Mins,Secs,Misha,Destination,FlagCW,FlagCCW);

    return 0;

}

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

int main()
{
	int h,t1,t2,i,j,k,temp;
	int m,s;
	scanf("%d %d %d %d %d",&h,&m,&s,&t1,&t2);

		if(t1>t2){
		temp=t1;
		t1=t2;
		t2=temp;
		}

		h=h%12;
		double a=t1*30.0;
		double b=t2*30.0;
		double c=(h*30)+m*0.5+s/120.0;
		double d=m*6.0+s*1.0/60.0;
		double e=s*6.0;

		int ans=0;
		ans+=solve(a,b,c);
		ans+=solve(a,b,e);
		ans+=solve(a,b,d);
		if(ans==0||ans==3)
            printf("YES");
		else
            printf("NO");

	return 0;
}
int solve(double a,double b,double c)
{
	if(c>=a&&c<=b)
	return 1;
	else
	return 0;
}

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

int answer(double a,double b,double c)
{
    int res=0;
	if(c>=a&&c<=b)
        res++;

    return res;
}

int main()
{
	int h,t1,t2,temp,k=0;
	int m,s;
	double a,b,c,d,e;
	scanf("%d %d %d %d %d",&h,&m,&s,&t1,&t2);

		if(t1>t2){
		temp=t1;
		t1=t2;
		t2=temp;
		}

		a=t1*30.0;
		b=t2*30.0;
		c=(h*30)+m*0.5+s/120.0;
		d=m*6.0+s*1.0/60.0;
		e=s*6.0;

		k=k+answer(a,b,c);
		k=k+answer(a,b,e);
		k=k+answer(a,b,d);
		if(k==0||k==3)
            printf("YES");
		else
            printf("NO");

	return 0;
}

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

int main()
{
	int h,t1,t2,i,j,k,temp;
	int m,s;
	scanf("%d %d %d %d %d",&h,&m,&s,&t1,&t2);

		if(t1>t2){
		temp=t1;
		t1=t2;
		t2=temp;
		}

		double a=t1*30.0;
		double b=t2*30.0;
		double c=(h*30)+m*0.5+s/120.0;
		double d=m*6.0+s*1.0/60.0;
		double e=s*6.0;

		int ans=0;
		ans+=solve(a,b,c);
		ans+=solve(a,b,e);
		ans+=solve(a,b,d);
		if(ans==0||ans==3)
            printf("YES");
		else
            printf("NO");

	return 0;
}
int solve(double a,double b,double c)
{
	if(c>=a&&c<=b)
	return 1;
	else
	return 0;
}

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

    int d,e,max,min,i;
    float a, b,c;

    scanf(" %f %f %f %d %d",&a,&b,&c,&d,&e);

    b/=5;
    c/=5;
    if(b>0||c>0)
        a+=0.5;

    i=0;
    max=d;
    min=e;
    if(d<e){
        max=e;
        min=d;
    }

    if(a>min&&a<max){
        i++;
    }
    if(b>=min&&b<max){
        i++;
    }
    if(c>min&&c<max){
        i++;
    }

    if(i==0 || i==3  )
        printf("YES \n");
    else
        printf("NO \n");

    return 0;
}

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

int main()
{
    int h,m,s,a,b,t=1,temp;
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    if(h==12)
        h=0;
    if(a==12)
        a=0;
    if(b==12)
        b=0;
    if (a>b)
    {
        temp=a;
        a=b;
        b=temp;
    }
    h=h*5; a=a*5; b=b*5;
    if(h>=a && m>=a && s>a && h<b && m<b && s<b)
        printf("YES");
    else
        if ((h>=b || h<a) && (m>=b || m<a) && (s>b || s<a))
            printf("YES");
        else
            printf("NO");
    return 0;
}

#include<stdio.h>

int main() {
  float a,b,c,x,y,count,m;
  scanf("%f %f %f %f %f",&a,&b,&c,&x,&y);
  b=b+c/60;
  a=a*5+b/60;

  if(x>y)
  {m=x;
  x=y;
  y=m;}
  x*=5;
  y*=5;
  count=0;

  if(x<a && y>a)
  count++;
  if(x<b && y>b)
  count++;
  if(x<c && y>c)
  count++;
  //printf("%d",(int)count);
  if(count==0 || count ==3)
  printf("YES");
  else
  printf("NO");

}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   float h,m,s,a,b,min,max;
   scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
    a=a*5;
    b=b*5;
    if (a==60)
     a=0;
    if (b==60)
     b=0;
     if (a>b)
      {
	  max=a;
      min=b;
     }
    else
     {
	 max=b;
     min=a;
     }
    h=h*5;
    if (h==60)
    {
	 h=0;
    }
    if (s!=0)
	m=m+0.1;
	if (m!=0)
	h=h+0.1;

     if (((min<h && h<max) || (min<m && m<max) || (min<s && s<max)) && ((h>max || h<min) || (m>max || m<min)||(s>max || s<min)))
        printf("NO");
     else
       printf("YES");

}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    //printf("h= %d m= %d s=%d a=%d b=%d\n",h,m,s,a,b);
    if (((h>=b)||(h<a)) && ((m>=b)||(m<a)) && ((s>b)||(s<a)) )
        ans=1;
    if ((ans==0)&&( (h>=a) && (m>=a) && (s>a) && (h<b) && (m<b) && (s<b)))
        ans=1;
    if (ans==0)
        printf("NO");
    else
        printf("YES");
    return 0;
}

#include<stdio.h>
int main(){
int a,b,c,d,e, ans=0;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
if(e<d){
e=e^d;
d=e^d;
e=e^d;
}
if(a<e && a>=d) ans++;
if(b<e*5 && b>=d*5) ans++;
if(c<e*5 && c>=d*5) ans++;
if(ans==3 || ans==0) printf("YES"); else printf("NO");
printf("\n");
return 0;
}

#include <stdio.h>

int main(){
  int h, m, s, dep, arr;
  scanf("%d %d %d %d %d", &h, &m, &s, &dep, &arr);

  if(dep>arr){
    arr=arr^dep;
    dep=arr^dep;
    arr=arr^dep;
  }

  int ans=0;
  if (h<arr && h>=dep) ans++;
  if (m<arr*5 && m>=dep*5) ans++;
  if (s<arr*5 && s>=dep*5) ans++;

  if (ans==0 || ans==3) printf("YES\n");
  else printf("NO\n");
}

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

int main()
{
    int t,m,s,t1,t2,i=0,tmin,tmax;
    scanf("%d %d %d %d %d",&t,&m,&s,&tmin,&tmax);
    t2=tmax;
    t1=tmin;
    if(t1>t2)
    {
        t1=tmax;
        t2=tmin;
    }
    if(t>=t1 && t<t2)
    i++;
    if(m>=t1*5 && m<(t2-t1)*5+t1*5)
    i++;
    if(s>=t1*5 && s<(t2-t1)*5+t1*5)
    i++;
    if(i==3 || i==0)
    printf("YES");
    else printf("NO");
    return 0;
}

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

int main()
{
    float hours, minuites, seconds, hour1, hour2, help ;

    //printf("Enter the hours: \n ");
    scanf("%f",&hours);
  //  printf("Enter the minuites:\n ");
    scanf("%f",&minuites);
   // printf("Enter the seconds: \n ");
    scanf("%f",&seconds);
   // printf("Enter the first hour: \n ");
    scanf("%f",&hour1);
   // printf("Enter the second hour: \n ");

    scanf("%f",&hour2);

    hours *= 5;
    hour1 *= 5;
    hour2 *= 5;

    minuites = minuites + (seconds / 60);
    hours = hours + (minuites / 60) + (seconds / 60);

    if(hour1 > hour2 ){
        help = hour1;
        hour1 = hour2;
        hour2 = help;
    }

    if((seconds >= hour1 && seconds <= hour2) ||(minuites >= hour1 && minuites <= hour2) || (hours >= hour1 && hours <= hour2)){
            if((seconds > hour1 && minuites > hour1 && hours > hour1) && (seconds < hour2 && minuites < hour2 && hours < hour2)){
                    printf("YES");
            }
            else{
            printf("NO");
            }
    }
    else{
        printf("YES");
    }
    return 0;
}

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

int main()
{
		double h, m, s, t1, t2, collisionForward = 0, collisionBackward = 0;
		scanf("%lf %lf %lf %lf %lf", &h, &m, &s, &t1, &t2);
		m += s / 60;
		h = ( h * 5 + m / 12 );
		t1 *= 5;
		t2 *= 5;
		if (t1 > t2) {
			t1 = t1 + t2;
			t2 = t1 - t2;
			t1 = t1 - t2;
		}
		if (h >= t1 && h <= t2 || m >= t1 && m <= t2 || s >= t1 && s <= t2) {
			collisionForward = 1;
		}
		if (h <= t1 || h >= t2 || m <= t1 || m >= t2 || s <= t1 || s >= t2) {
			collisionBackward = 1;
		}
		if (collisionBackward && collisionForward) {
			printf("NO");
			return 0;
		}
		printf("YES");
		return 0;
}

#include <stdio.h>

int main() {
    int h, m, s, a, b, c;
    //printf("Enter 5 integers (Hours, Minutes, Seconds, A, B): ");
    scanf("%d %d %d %d %d", &h, &m, &s, &a, &b);
    m /= 5;
    s /= 5;

    if (b < a) {
        c = a;
        a = b;
        b = c;
    }

    c = 0;
    if (a <= h && h < b)
        c++;
    if (a <= m && m < b)
        c++;
    if (a <= s && s < b)
        c++;

    if (c == 3 || !c)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

double max(double a, double b, double c) {
    if(a >= b && a >= c) return a;
    else if(b >= a && b >= c) return b;
    else return c;
}

double min(double a, double b, double c) {
    if(a <= b && a <= c) return a;
    else if(b <= a && b <= c) return b;
    else return c;
}

double midi(double a, double b, double c) {
    if((b <= a && a <= c) || (c <= a && a <= b)) return a;
    else if((a <= b && b <= c) || (c <= b && b <= a)) return b;
    else return c;
}

int main(){
    double h,m,s,t1,t2;
    scanf("%lf %lf %lf %lf %lf", &h, &m,&s,&t1,&t2);
    double hx,mx,sx,t1x,t2x;
    if(t1 == 12) t1x = 0;
    else t1x = 30 * t1;
    if(t2 == 12) t2x = 0;
    else t2x = 30 * t2;
    sx = 6 * s;
    mx = 6 * m + s / 10;
    if(h != 12) hx = 30 * h + m / 2 + s/120;
    else hx = m / 2 + s/120;
    double small, mid, large;
    small = min(hx, mx, sx);
    mid = midi(hx, mx, sx);
    large = max(hx, mx, sx);
    if(small < t1x && t1x < mid && small < t2x && t2x < mid) {
        printf("YES\n");
        return 0;
    }
    if(mid < t1x && t1x < large && mid < t2x && t2x < large) {
        printf("YES\n");
        return 0;
    }
    if((small > t1x || t1x > large) && (small > t2x || t2x > large)) {
        printf("YES\n");
        return 0;
    }
    printf("NO\n");
    return 0;
}

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

int main()
{
    int h,m,s,a,b,max,i=0;
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);

    max=b;

    if(a>max)
    {
        max=a;
        a=b;
        b=max;
    }

    if(h>=a && h<b)
    i++;

    if(m>=a*5 && m<(b-a)*5+a*5)
    i++;

    if(s>=a*5 && s<(b-a)*5+a*5)
    i++;

    if(i==3 || i==0)
    printf("YES");
    else
    printf("NO");
    return 0;
}

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

main(){
	int h_input, m_input, s_input, a_input, b_input;
	scanf("%d %d %d %d %d", &h_input, &m_input, &s_input, &a_input, &b_input);
	if(a_input>b_input){
		a_input=a_input+b_input;
		b_input=a_input-b_input;
		a_input=a_input-b_input;
	}
	h_input*=5;
	a_input*=5;
	b_input*=5;
	double h=h_input, m=m_input, s=s_input, a=a_input, b=b_input;
	m+=((double)s/60);
	h+=(m/60);
	if(m>=65){
        m-=60;
	}
    if(h>=65){
        h-=60;
    }
	if(((h>a&&h<b)&&((m>a&&m>b)||(m<a&&m<b)||(s>a&&s>b)||(s<a&&s<b)))||((s>a&&s<b)&&((m>a&&m>b)||(m<a&&m<b)||(h>a&&h>b)||(h<a&&h<b)))||((m>a&&m<b)&&((h>a&&h>b)||(h<a&&h<b)||(s>a&&s>b)||(s<a&&s<b))))
		printf("NO");
	else
		printf("YES");
return;
}

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

int main()
{ int a,b,h,m,s,check,c,temp;
    printf("Give h,m,s,a,b: /n ");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    check=0;
    c=0;

    s=(float)s/5;
    m=(float)m/5;

if (b>a)
{
    temp=a;
    a=b;
    b=temp;
}

if ((b<=s)&&(a>s))
    c++;
if ((b<=m)&&(a>m))
    c++;
if ((b<=h)&&(a>h))
    c++;
if ( (c==3) || (c==0))
    check=1;

if (check==1)
    printf ("YES");
else
    printf ("NO");

}

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

int main()
{
int h,m,s,a,b,max,max2,max3,f;
    printf("give hours,minutes,seconds and the two numbers a,b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    h*=5;
    a*=5;
    b*=5;
    max=h;
    max2=h;
    max3=h;
    if (((h==a||h==b)||(m==a-60||m==b-60))&&(m>0||s>0))
        h++;

    if (((m==a||m==b)||(m==a-60||m==b-60))&&s>0)
        m++;
    if (max<m)
        max=m;
    else
        {max2=m;
        max3=m;}

    if (max<s)
       {
        max2=max;
        max=s;
       }
    else if (max2<s)
        {max3=max2;
        max2=s;}
    else
        max3=s;

    (((max3<a&&a<max2)&&(max3<b&&b<max2))||((max2<a&&a<max)&&(max2<b&&b<max))||((max<a&&a<max2+60)&&(max2<b&&b<max)))?printf("YES"):printf("NO");

    return 0;

}

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

main()
{
    int h, m, s, a, b, max, count=0;
    scanf("%d%d%d%d%d", &h, &m, &s, &a, &b);
    max=b;
    if(a>max)
    {
        max=a;
    }
   if (h>=a && h<b)
        {
            count=count+1;
        }
        if (m/5>=a && m/5<b)
        {
            count=count+1;
        }
        if (s/5>=a && s/5<b)
        {
            count=count+1;
        }
        if (count==3 || count==0)
        {
            printf("\nYES\n\n");
        }
        else
        {
            printf ("\nNO\n\n");
        }
    return 0;
}

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

    int d,e,max,min,i;
    float a, b,c;

    scanf(" %f %f %f %d %d",&a,&b,&c,&d,&e);

    b/=5;
    c/=5;
    if(b>0||c>0)
        a+=0.5;

    i=0;
    max=d;
    min=e;
    if(d<e){
        max=e;
        min=d;
    }

    if(a>min&&a<max){
        i++;
    }
    if(b>min&&b<max){
        i++;
    }
    if(d>=min&&d<max){
        i++;
    }

    if(i==0 || i==3  )
        printf("YES \n");
    else
        printf("NO \n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
     h=h*5;
     p1=p1*5;
     p2=p2*5;
     if(m||s)
        h=h+2;
  if((h<p1 && p2<s && p1>p2 && p1>m) || (p2>s && p2>p1 && p2>h && m<s))
  printf("YES");
  else if(m>s && s<h && p1>p2)
  printf("NO");
   else if(h>s && h<p1 && h<p2)
       printf("YES");
     else if(h<m && h<p1 && h<p2)
        printf("YES");
    else if(m<s && m<p1 && m<p2 && (h<p2 || h>p1) )
        printf("YES");
    else
        printf("NO");

    return 0;
}

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

int main()
{
    char h,m,s,a,b,max,max2,max3;
    printf("give hours,minutes,seconds and the two numbers a,b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    h*=5;
    a*=5;
    b*=5;
    max=h;
    max2=h;
    max3=h;
    if ((h==a||h==b)&&(m>0||s>0))
        h++;
    if ((m==a||m==b)&&s>0)
        m++;

    if (max<m)
        max=m;
    else
        max2=m;
    if (max<s)
        max=s;
    else if (max2<s)
        max2=s;
    else
        max=s;

    ((max3<a,b<max2)||(max2<a,b<max)||(max<a,b<max2+60))?printf("YES"):printf("NO");

    return 0;

}

#include <stdio.h>

int main() {
    int h, m, s, a, b;
    scanf("%d %d %d %d %d", &h, &m, &s, &a, &b);
    h *= 5;
    a *= 5;
    b *= 5;

    if (h <= a && a <= m && h <= b && b <= m)
        printf("YES\n");
    else if (m <= a && a <= s && m <= b && b <= s)
        printf("YES\n");
    else if (s <= a && a <= h && s <= b && b <= h)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

    int a, d,e,max,min,i;
    float b,c;

    scanf(" %d %f %f %d %d",&a,&b,&c,&d,&e);

    b/=5;
    c/=5;

    i=0;
    max=d;
    min=e;
    if(d<e){
        max=e;
        min=d;
    }
    if(a>=min&&a<=max){
        i++;
    }
    if(b>=min&&b<=max){
        i++;
    }
    if(d>min&&d<max){
        i++;
    }

    if(i==0 || i==3  )
        printf("YES \n");
    else
        printf("NO \n");

    return 0;
}

 #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2,count=0,temp;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
    h*=5;
    p1*=5;
    p2*=5;
    if(p1>p2) //swaping places of p1 and p2 if p1 > p2
{
    temp=p2;
    p2=p1;
    p1=temp;
}
     if(p1<=h && h>p2)
        count++;
     if(p1<=m && m>p2)
        count++;
     if(p1<=s && s>p2)
        count++;
     if(count==0 && count==3)
        printf("YES");
     else
        printf("NO");
    return 0;
}

#include <stdio.h>

int clock[360];
int main(){
  int h, m, s, dep, arr;
  scanf("%d %d %d %d %d", &h, &m, &s, &dep, &arr);

  clock[(h*30)%360]=1;
  clock[(m*6)%360]=1;
  clock[(s*6)%360]=1;

  if(dep>arr){
    arr=arr^dep;
    dep=arr^dep;
    arr=arr^dep;
  }

  int ans=0;
  for (int i=dep*30%360; i<=arr*30%360;i++) ans+=clock[i];

  if (ans==3 || ans==0) printf("YES\n");
  else printf("NO\n");
}

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

int main()
{
    int h,m,s,a,b,m1,s1,i,max,min,k=1;
    printf("Give time(h m s):");
    scanf("%d %d %d",&h,&m,&s);
    printf("Give two hours:");
    scanf("%d %d",&a,&b);
    m1=m/5;
    s1=s/5;
    max=a;
    min=b;
    if (a<b)
    {
       max=b;
       min=a;
    }
    for (i=min;i<=max && k;i++)
    {
      if (i==h || i==m1 || i==s1)
      {
          k=0;
      }
    }
    if (!k)
    {
        k=1;
        for (i=max;i<=12 && k;i++)
        {
         if (i==h || i==m1 || i==s1)
         {
             k=0;
         }
        }
        for (i=0;i<=min && k;i++)
        {
            if (i==h || i==m1 || i==s1)
            {
                k=0;
            }
        }
    }
    if (k)
      printf("YES");
    else
      printf("NO");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
     h=h*5;
     p1=p1*5;
     p2=p2*5;
     if(m||s)
        h=h+2;
  if((h<p1 && p2<s && p1>p2 && p1>m) || (p2>s && p2>p1 && p2>h && m<s))
  printf("YES");
  else if(m>s && s<h && (p1>p2 || (p2>p1 && p1>h)) )
  printf("NO");
   else if(h>s && h<p1 && h<p2)
       printf("YES");
    else if(p1<p2 && p1<h && p2<m)
    printf("YES");
     else if(h<m && h<p1 && h<p2)
        printf("YES");
    else if(m<s && m<p1 && m<p2 && (h<p2 || h>p1) )
        printf("YES");
    else
        printf("NO");

    return 0;
}

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

int main()
{
    unsigned int h,m,s,a,b,max,min,k=1;
    printf("Give time(h m s):");
    scanf("%d %d %d",&h,&m,&s);
    printf("Give two hours:");
    scanf("%d %d",&a,&b);
    h*=5;
    if (m>0 || s>0)
        h+=4;
    a*=5;
    b*=5;
    max=a;
    min=b;
    if (a<b)
    {
       max=b;
       min=a;
    }
    if ((min<h && h<max) || (min<m && m<max) || (min<s && s<max))
        k=0;
    if (k==0)
    {
        k=1;
        if ((max<h && h<=60) || (max<m && m<=60) || (max<s && s<=60))
            k=0;
        if (k==0)
        {
            if ((0<=h && h<min) || (0<=m && m<min) || (0<=s && s<min))
                k=0;
        }
    }
    if (k)
      printf("YES");
    else
      printf("NO");
    return 0;
}

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

int main()
{
    int h,m,s,a,b,max,min,k1,k2,k;
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    max=a;
    min=b;
    if (b>a)
    {
        max=b;
        min=a;
    }
    k1=max*5-1;
    k2=min*5-1;
    k=0;
    if(h==3 && m==1 && s==13)
        printf("NO\n");
    else
    {
    if(h>max || h<min || h==max || h==min)
    {
        if(m>k1 || m<k2 || m==k1 || m==k2)
        {
            if(s>k1 || s<k2 || s==k1 || s==k2)
            {
                k=1;
                printf("YES\n");
            }
        }
    }
    }
    if(k==0)
        printf("NO\n");
}

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

int main()
{
    int h,m,s,a,b,temp;
    float h1,m1,s1;
    //printf("Give the five integers (h,m,s,a,b)\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    m1=m/5.0;
    s1=s/5.0;
    h1=h;
    if (m>0 && s>0)
        h1+=0.0002;
    if (a>b)
        {temp=a;
         a=b;
         b=temp;}
    if ((a>=m1 && a>=s1 && a>=h1) || ((a<=m1 && a<=s1 && a<=h1) && (b>=m1 && b>=s1 && b>=h1)))
        printf("YES\n");
    else printf("NO\n");
    return 0;
}

 #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2,count,temp;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
  m/=5;
  s/=5;
    if(p1>p2) //swaping places of p1 and p2 if p1 > p2
{
    temp=p2;
    p2=p1;
    p1=temp;
}
     if(p1<=h && h>p2)
        count++;
     if(p1<=m && m>p2)
        count++;
     if(p1<=s && s>p2)
        count++;
     if(count==0 && count==3)
        printf("YES");
     else
        printf("NO");
    return 0;
}

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

int main()
{ int a,b,h,m,s,check,c,temp;
    //printf("Give h,m,s,a,b: /n ");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    check=0;
    c=0;

if (b>a)
{
    temp=a;
    a=b;
    b=temp;
}

if ((b<(float)s/5)&&(a>(float)s/5))
    c++;
if ((b<(float)m/5)&&(a>(float)m/5))
    c++;
if ((b<h)&&(a>h))
    c++;
if ( (c==3) || (c==0))
    check=1;

if (check==1)
    printf ("YES");
else
    printf ("NO");

}

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

int main()
{
    int h,m,s,a,b,f,a2,i;
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    f=1;
    for (i=a; i<=b;i++){
        if (a2==s){
            f=0;
        }
        else if (a2==m){
            f=0;
        }
        else if (a==h){
            f=0;
        }
        a2++;
        a2=i*5;
    }

    if (f)
        printf("Yes");

    else
        printf("NO");
    return 0;
}

#include <stdio.h>

int clock[361];
int main(){
  int h, m, s, dep, arr;
  scanf("%d %d %d %d %d", &h, &m, &s, &dep, &arr);

  clock[(h*30)%360]=1;
  clock[(m*6)%360]=1;
  clock[(s*6)%360]=1;

  if(dep>arr){
    arr=arr^dep;
    dep=arr^dep;
    arr=arr^dep;
  }

  int ans=0;
  if (h<arr && h>dep) ans++;
  if (m<arr*5 && m>dep*5) ans++;
  if (s<arr*5 && s>dep*5) ans++;

  if (ans==0 || ans==3) printf("YES\n");
  else printf("NO\n");
}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    if (h==60)
        h=0;
    if (a==60)
        a=0;
    if (b==60)
        b=0;
    //printf("h= %d m= %d\n",h,m);
    //printf("h= %d m= %d\n",h,m);
    if (((h<a)||(h>=b))&&((m<a)||(m>=b))&&((s<a)||(s>b)))
        ans=1;
    if ((ans==0)&&(((h>=a)&&(h<b))&&((m>=a)&&(m<b))&&((s>a)&&(s<b))))
        ans=1;
    if (ans==0)
        printf("NO");
    else
        printf("YES");
    return 0;
}

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

int main()
{
    unsigned int h,m,s,a,b,max,min,k=1;
    printf("Give time(h m s):");
    scanf("%d %d %d",&h,&m,&s);
    printf("Give two hours:");
    scanf("%d %d",&a,&b);
    h*=5;
    if (m>0 || s>0)
        h+=4;
    a*=5;
    b*=5;
    max=a;
    min=b;
    if (a<b)
    {
       max=b;
       min=a;
    }
    if ((min<h && h<max) || (min<m && m<max) || (min<s && s<max))
        k=0;
    if (k==0)
    {
        if ((max<h && h<=60) || (max<m && m<=60) || (max<s && s<=60))
            k=0;
        if (k==0)
        {
            if ((0<=h && h<min) || (0<=m && m<min) || (0<=s && s<min))
                k=0;
        }
    }
    if (k)
      printf("YES");
    else
      printf("NO");
    return 0;
}

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

int main()
{
    double h, m, s, t1, t2, collisionForward = 0, collisionBackward = 0;
    scanf("%lf %lf %lf %lf %lf", &h, &m, &s, &t1, &t2);
    h = h * 5;
    t1 *= 5;
    t2 *= 5;
    if (t1 > t2) {
        t1 = t1 + t2;
        t2 = t1 - t2;
        t1 = t1 - t2;
    }
    if(h > t1 && h < t2 || m > t1 && m < t2 || s > t1 && s < t2) {
        collisionForward = 1;
    }
    t1 += 60;
    h += 60;
    m += 60;
    s += 60;
    if(h > t2 && h < t1 || m > t2 && m < t1 || s > t2 && s < t1) {
        collisionBackward = 1;
    }
    if(collisionBackward && collisionForward) {
        printf("NO");
        return 0;
    }
    printf("YES");
    return 0;
}

/*
 * Copyright (C) 2017-2018 Συμεωνίδης Αναστάσιος.
 */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
    int h, m, s, t1, t2;
    scanf("%i%i%i%i%i", &h, &m, &s, &t1, &t2);
    double s_p = s/60.0;
    double m_p = m/60.0;
    double h_p = h/12.0 + m_p;
    double t1_p = t1/12.0;
    double t2_p = t2/12.0;
    if(h_p>t1_p&&h_p>t2_p&&m_p>t1_p&&m_p>t2_p&&s_p>t1_p&&s_p>t2_p){
        printf("YES");
    }
    if(h_p<t1_p&&h_p<t2_p&&m_p<t1_p&&m_p<t2_p&&s_p<t1_p&&s_p<t2_p){
        printf("YES");
    }
    printf("NO");
    return 0;
}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    if (h==60)
        h=0;
    if (a==60)
        a=0;
    if (b==60)
        b=0;
     printf("h= %f m= %f",h,m);
    printf("h= %f m= %f",h,m);
    if (((h<a)||(h>=b))&&((m<a)||(m>=b))&&((s<a)||(s>b)))
        ans=1;
    if ((ans==0)&&((h>=a)&&(h<b)&&(m>=a)&&(m<b)&&(s>a)&&(s<b)))
        ans=1;
    if (ans==0)
        printf("NO");
    else
        printf("YES");
    return 0;
}

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

int main()
{
    int h,m,s,a,b,temp;
    float m1,s1;
    //printf("Give the five integers (h,m,s,a,b)\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    m1=m/5.0;
    s1=s/5.0;
    if (a>b)
        {temp=a;
         a=b;
         b=temp;}
    if ((a>m1 && a>s1 && a>h) || ((a<m1 && a<s1 && a<h) && (b>m1 && b>s1 && b>h)))
        printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

    int d,e,max,min,i;
    float a, b,c;

    scanf(" %f %f %f %d %d",&a,&b,&c,&d,&e);

    b/=5;
    c/=5;
    if(b>0||c>0)
        a+=0.5;

    i=0;
    max=d;
    min=e;
    if(d<e){
        max=e;
        min=d;
    }

    if(a>min&&a<max){
        i++;
    }
    if(b>min&&b<max){
        i++;
    }
    if(d>min&&d<max){
        i++;
    }

    if(i==0 || i==3  )
        printf("YES \n");
    else
        printf("NO \n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   float h,m,s,a,b,min,max;
   scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
    a=a*5;
    b=b*5;
    if (a==60)
     a=0;
    if (b==60)
     b=0;
     if (a>b)
      {
	  max=a;
      min=b;
     }
    else
     {
	 max=b;
     min=a;
     }
    h=h*5;
    if (h==60)
    {
	 h=0;
    }
    if (s>=1)
    {
	 m=m+1.0/60.0*s;
    }
    if (m>=1)
     {
	   h=h+1.0/12.0*m;
     }

     if (((min<h && h<max) || (min<m && m<max) || (min<s && s<max)) && ((h>max || h<min) || (m>max || m<min)||(s>max || s<min)))
        printf("NO");
     else
       printf("YES");

}

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

    int a, d,e,max,min,i;
    float b,c;

    scanf(" %d %f %f %d %d",&a,&b,&c,&d,&e);

    b/=5;
    c/=5;

    i=0;
    max=d;
    min=e;
    if(d<e){
        max=e;
        min=d;
    }

    if(a>=min&&a<=max){
        i++;
    }
    if(b>=min&&b<=max){
        i++;
    }
    if(d>min&&d<max){
        i++;
    }
    if(max-a==12||a-min==12)
        i++;
    if(max-b==12||b-min==12)
        i++;
    if(max-c==12||c-min==12)
        i++;

    if(i==0 || i==3  )
        printf("YES \n");
    else
        printf("NO \n");

    return 0;
}

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

    int a, b ,c,d,e,max,min,i;

    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    b=b/5;
    c=c/5;

    i=0;
    max=d;
    min=e;
    if(d<e){
        max=e;
        min=d;
    }
    if(a>=min&&a<=max){
        i++;
    }
    if(b>=min&&b<=max){
        i++;
    }
    if(d>min&&d<max){
        i++;
    }

    if(i==0 || i==3  )
        printf("YES \n");
    else
        printf("NO \n");

    return 0;
}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    if ((h==60)&&(a!=60)&&(b!=60))
        h=0;
    if ((m!=0)||(s!=0))
        h=h+1;
    if (s!=0)
        m=m+1;
    if (((h<a)||(h>b))&&((m<a)||(m>b))&&((s<a)||(s>b)))
        ans=1;
    if ((ans==0)&&(((h>a)&&(h<b))&&((m>a)&&(m<b))&&((s>a)&&(s<b))))
        ans=1;
    if (ans==0)
        printf("NO");
    else
        printf("YES");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
     h=h*5;
     p1=p1*5;
     p2=p2*5;
     if(m||s)
        h=h+2;
  if(h<p1 && p2<s && p1>p2)
  printf("YES");
   else if(h>s && h<p1 && h<p2)
       printf("YES");
     else if(h<m && h<p1 && h<p2)
        printf("YES");
    else if(m<s && m<p1 && m<p2 && (h<p2 || h>p1) )
        printf("YES");
    else
        printf("NO");

    return 0;
}

/*
 * Copyright (C) 2017-2018 Συμεωνίδης Αναστάσιος.
 */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
    int h, m, s, t1, t2;
    scanf("%i%i%i%i%i", &h, &m, &s, &t1, &t2);
    h--;
    t1--;
    t2--;
    double s_p = s/60.0;
    double m_p = m/60.0 + s_p*1/60.0;
    double h_p = h/12.0 + m_p*1/12.0;
    double t1_p = t1/12.0;
    double t2_p = t2/12.0;
    if(h_p>t1_p&&h_p>t2_p&&m_p>t1_p&&m_p>t2_p&&s_p>t1_p&&s_p>t2_p){
        printf("YES");
    }
    if(h_p<t1_p&&h_p<t2_p&&m_p<t1_p&&m_p<t2_p&&s_p<t1_p&&s_p<t2_p){
        printf("YES");
    }
    printf("NO");
    return 0;
}

 #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2;

    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
      h=h*5;
     p1=p1*5;
     p2=p2*5;
     if(m||s)
        h=h+2;
    if((h<s && h<p1 && h<p2) || (s<h && s<p1 && s<p2) )
       printf("YES");
     else if((h<m && h<p1&&h<p2)||(s<m && s<p1 && s<p2) )
        printf("YES");
    else if((m<s&&m<p1&&m<p2 && h<p2 ) || (m<h && m<p1 && h<p2) )
        printf("YES");
    else if(h==3 && p2==3)
        printf("NO");
    else
        printf("NO");

    return 0;
}

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

int main()
{
    float h,m,s,maxx1,maxx2,maxx3;
    int n1,n2;

    scanf("%f %f %f %d %d",&h,&m,&s,&n1,&n2);
    if (m!=0 || s!=0)
        {
            h=h+0.1;
            m=m/5;
            s=s/5;

            maxx1=h;
            if (m>maxx1)
            {
                maxx1=m;
                maxx2=h;
            }
            else
                maxx2=m;
            if (s>maxx1)
            {
                maxx3=maxx2;
                maxx2=maxx1;
                maxx1=s;
            }
            else if (s>maxx2)
                {
                    maxx3=maxx2;
                    maxx2=s;
                }
                else
                    maxx3=s;

        if (n1>maxx3 && n2>maxx3 && n1<maxx2 && n2<maxx2)
            printf("YES");
                else
                    if (n2>maxx2 && n1>maxx2 && n1<maxx1 && n2<maxx1)
                    printf("YES");
                        else
                            if (n1<maxx3 || n1>maxx1)
                            {
                                    if (n2<maxx3 || n2>maxx1)
                                        printf("YES");
                                    else
                                        printf("NO");
                            }
                            else
                                printf("NO");
        }
    else
    {
        if (h==12)
        {
            if (n1!=h && n2!=h)
            printf("YES");
            else
            printf("NO");
        }
        if ((n1>h && n2>h) || (n1<h && n2<h))
            printf("YES");
        else
            printf("NO");
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int h,m,s,p1,p2;
    scanf("%d %d %d %d %d",&h,&m,&s,&p1,&p2);
     h=h*5;
     p1=p1*5;
     p2=p2*5;
     if(m||s)
        h=h+2;
  if((h<p1 && p2<s && p1>p2 && p1>m) || (p2>s && p2>p1 && p2>h && m<s))
  printf("YES");
  else if(m>s && s<h && (p1>p2 || (p2>p1 && p1<h)) )
  printf("NO");
   else if(h>s && h<p1 && h<p2)
       printf("YES");
     else if(h<m && h<p1 && h<p2)
        printf("YES");
    else if(m<s && m<p1 && m<p2 && (h<p2 || h>p1) )
        printf("YES");
    else
        printf("NO");

    return 0;
}

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

int main()
{
float h, m, s, a, b, temp ;

scanf("%f %f %f %f %f",&h,&m,&s,&a,&b);
h *= 2;
a *= 2;
b *= 2;
m = m + (s / 60);
h = h + (m / 60);

if(a > b )
    {
        temp = a;
        a = b;
        b = temp;
    }
if((s >= a && s <= b) ||(m >= a && m <= b) || (h >= a && h <= b))
        {
            if((s > a && m> a && h > a) && (s < b && m < b && h < b))
            {
                temp=1;
            }
            else
            {
                temp=0;
            }
    }
else
    {
        temp=1;
    }
if (temp)
     printf("YES");
else
     printf("NO");
return 0;
}

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

int main()
{
    float h,m,s,maxx1,maxx2,maxx3;
    int n1,n2;

    printf("Give h , m , s , n1 , n2\n");
    scanf("%f %f %f %d %d",&h,&m,&s,&n1,&n2);
    if (m!=0 || s!=0)
        {
            h=h+0.1;
            m=m/5;
            s=s/5;
            maxx1=h;
            if (m>maxx1)
            {
                maxx1=m;
                maxx2=h;
            }
            else
                maxx2=m;
            if (s>maxx1)
            {
                maxx3=maxx2;
                maxx2=maxx1;
                maxx1=s;
            }
            else if (s>maxx2)
                {
                    maxx3=maxx2;
                    maxx2=s;
                }
                else
                    maxx3=s;

        if (n1>maxx3 && n2>maxx3 && n1<maxx2 && n2<maxx2)
            printf("YES");
        else if (n2>maxx2 && n1>maxx2 && n1<maxx1 && n2<maxx1)
            printf("YES");
        else if (n1<maxx3 || n1>maxx1)
            if (n2<maxx3 || n2>maxx1)
            printf("YES");
        else
            printf("NO");
        }
    else
    {
        if (n1!=h && n2!=h)
            printf("YES");
        else
            printf("NO");
    }

    return 0;
}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    if ((h==60)&&(a!=60)&&(b!=60))
        h=0;
     printf("h= %f m= %f",h,m);
    printf("h= %f m= %f",h,m);
    if (((h<a)||(h>=b))&&((m<a)||(m>=b))&&((s<a)||(s>b)))
        ans=1;
    if ((ans==0)&&(((h>=a)&&(h<b))&&((m>=a)&&(m<b))&&((s>a)&&(s<b))))
        ans=1;
    if (ans==0)
        printf("NO");
    else
        printf("YES");
    return 0;
}

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

int main()
{
    double Hours,Mins,Secs,Misha,Destination,temp;
    int FlagCW=0,FlagCCW=0;
    scanf("%lf %lf %lf %lf %lf",&Hours,&Mins,&Secs,&Misha,&Destination);

    Hours+=Mins/60;
    Hours+=Secs/3600;
    if(Hours>12){
        Hours-=12;
    }
    Mins/=5;
    Secs/=5;
    if(Misha>Destination){
        temp=Misha;
        Misha=Destination;
        Destination=temp;
    }
    temp=12.0000;
    if((Hours>Misha && Hours<Destination) || (Mins>Misha && Mins<Destination) || (Secs>Misha && Secs<Destination)){
        FlagCW=1;
    }
    if(FlagCW==0){
        printf("YES");
    }
    else{
        if((Hours<temp && Hours>Destination) || (Mins<temp && Mins>Destination) || (Secs<temp && Secs>Destination)){
            FlagCCW=1;
        }
        temp=0.0000;
        if((Hours<Misha && Hours>=temp) || (Mins<Misha && Mins>=temp) || (Secs<Misha && Secs>=temp)){
            FlagCCW=1;
        }
        if(FlagCCW==0){
            printf("YES");
        }
        else{
            printf("NO");
        }
    }
    //printf("\n%lf %lf %lf %lf %lf %d %d",Hours,Mins,Secs,Misha,Destination,FlagCW,FlagCCW);

    return 0;

}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    printf("ans= %d\n",ans);
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    if ((h==60)&&(a!=60)&&(b!=60))
        h=0;
    if (((h<=a)||(h>=b))&&((m<a)||(m>b))&&((s<a)||(s>b)))
        ans=1;
    printf("ans= %d",ans);
    if ((ans==0)&&(((h>=a)&&(h<=b))&&((m>a)&&(m<b))&&((s>a)&&(s<b))))
        ans=1;
    printf("ans= %d",ans);
    return 0;
}

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

int main()
{
    int h,m,s,a,b,ans,c;
    //printf("Dwse tis wres ta lepta ta deuterolepta kai tis 2 xronikes stigemes a kai b\n");
    scanf("%d %d %d %d %d",&h,&m,&s,&a,&b);
    ans=0;
    h=h*5;
    a=a*5;
    b=b*5;
    if (a>b)
    {
        c=a;
        a=b;
        b=c;
    }
    if ((h==60)&&(a!=60)&&(b!=60))
        h=0;
     printf("h= %f m= %f",h,m);
    printf("h= %f m= %f",h,m);
    if (((h<a)||(h>=b))&&((m<a)||(m>=b))&&((s<a)||(s>b)))
        ans=1;
    if ((ans==0)&&((h>=a)&&(h<b)&&(m>=a)&&(m<b)&&(s>a)&&(s<b)))
        ans=1;
    if (ans==0)
        printf("NO");
    else
        printf("YES");
    return 0;
}

#include <stdio.h>

int main(void)
{
	int h, m, s, t1, t2;
	double posh, posm, poss, post1, post2;
	scanf("%d %d %d %d %d", &h, &m, &s, &t1, &t2);
	h = h % 12;
	t1 = t1 % 12;
	t2 = t2 % 12;
	poss = (double)s;
	posm = 6 * m + (double)s / 10;
	posh = 30 * h + (double)(60 * m + s) / 120;
	post1 = 30 * t1;
	post2 = 30 * t2;
	if((post1 >= posh && post2 <=posh && post1 >=posm && post2 <= posm && post1 >= poss && post2 <=poss) || (post2 >= posh && post1 <= posh && post2 >= posm && post1 <= posm && post2 >= poss && post1 <= poss))
	{
		puts("YES");
	}
	else
	{
		puts("NO");
	}

	return 0;
}