Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		input := strings.Split(scanner.Text(), ":")
		h, _ := strconv.Atoi(input[0])
		m, _ := strconv.Atoi(input[1])
		H, M := (30*h+(m/2))*2, (6*m)*2
		if m&1 == 1 {
			H++
		}
		a := H - M
		if a < 0 {
			a = -a
		}
		a2 := 720 - a
		if a2 < a {
			a = a2
		}
		if a < 60 {
			fmt.Println("alert")
		} else if a >= 180 && a <= 360 {
			fmt.Println("safe")
		} else {
			fmt.Println("warning")
		}
	}
}

C++: #include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	double h, m;
	char c;
	double a, b, d;
	for (int i = 0; i < n; i++) {
		cin >> h >> c >> m;
		b = 360.0 * m / 60.0;
		a = (360.0 * h / 12.0) + (30.0 * m / 60.0);
		d = fabs(a-b);
		if (d < 30.0) {
			cout << "alert" << endl;
		} else if (d >= 90.0) {
			cout << "safe" << endl;
		} else {
			cout << "warning" << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EPS (1e-8)

int getNum(string str, int pos) {
	return (str[pos] - '0') * 10 + str[pos + 1] - '0';
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + m / 2.0;
		double div = min(abs(angle1 - angle2), 360.0 - abs(angle1 - angle2));
		
		if (div >= 0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

C++: #include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    while(n--){
        int h,m;
        scanf("%d:%d",&h,&m);
        double h_angle,m_angle;
        h_angle = h/12.0 + m/720.0;
        m_angle = m/60.0;
        double d = fabs(h_angle - m_angle);
        if(d - (1.0/6) < 1e-8)cout<<"alert"<<endl;
        else if(d - (1.0/4) >= 0)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }


    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n; cin >> n;
	rep(i, n) {
		double h, m; scanf("%lf:%lf", &h, &m);
		double d = abs(h * 30 - 5.5 * m);
		if (0. <= d&&d < 30.)puts("alert");
		else if (90. <= d&&d <= 180.)puts("safe");
		else puts("warning");
	}
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	int n;
	cin>>n;
	int h,m;
	char co;
	for(int i=0;i<n;i++){
		double d=0;
	cin>>h>>co>>m;
		d=double(360)/12*h;
		d+=double(360)/12/60*m;
		d-=double(360)/60*m;
		d=abs(d);
		if(d>=0&&d<30)
			cout<<"alert"<<endl;
		else if(d>=90&&d<180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }



int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		double h, m;
		char k;
		
		cin >> h >> k >> m;
		
		h = (h * 30.0) + (m / 2.0);
		m *= 6.0;
		
		double d = (180.0 < abs(h - m) ? 360.0 - abs(h - m) : abs(h - m));
		
		cout << (d < 30.0 ? "aleart" : (d < 90.0 ? "warning" : "safe")) << endl;
	}
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int a, b, n;
double d, e, f;
char c;
int main() {
	cin >> n;
	while (scanf("%d:%d", a, b)) {
		d = b * 6;
		e = (a * 60 + b) / 2;
		f = abs(d - e);
		if (f > 180) { f = 360 - f; }
		if (f < 30) { cout << "alert" << endl; }
		else if (f < 90) { cout << "warning" << endl; }
		else { cout << "safe" << endl; }
	}
}

C++: #include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

int main(int argc, char const* argv[])
{
	int h,m;
	int n;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		scanf("%d:%d",&h,&m);

		h *= 30;
		m *= 6;

		if( abs( h - m ) >= 0 && abs( h - m ) <= 30 ) cout << "alert" << endl;
		else if( abs( h - m ) >= 90 && abs( h - m ) <= 180 ) cout << "safe" << endl;
		else cout << "warning" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;


int main(void)
{
	//入力変数(時間)
	int time = 0;
	//入力分変数
	int min = 0;
	//入力回数
	int n = 0; 

	cin >> n;

	//出力
	for (int i = 0; i < n; i++)
	{
		scanf("%d:%d" , &time , &min);

		time *= 5;

		time += min / 12;

		//両方足す(負数になると面倒)
		time += 60;
		min += 60;

		if (time + 5 >= min && time - 5 <= min)
		{
			cout << "alert";
		}
		else if (time + 15 <= min && time + 30 >= min || time - 15 >= min && time -30 <= min)
		{
			cout << "safe";
		}
		else
		{
			cout << "warning";
		}
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>

int main(){

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		int h, m;
		scanf("%d:%d", &h, &m);

		double ang ;
		ang = 6 * m - (30 * h + 30 * ((double)m / 60));
		ang = std::abs(ang);

		if (0 <= ang && ang < 30)printf("alert\n");
		else if (90 <= ang && ang <= 180)printf("safe\n");
		else printf("warning\n");
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        int h, m;
        scanf("%d:%d", &h,&m);
        double hAngle = (360/12)*h + (360.0/12/60)*m;
        double mAngle = (360/60)*m;
        double angle = min(abs(hAngle-mAngle), abs(mAngle-hAngle));
        if(angle >= 180) angle = 360-angle;
        if(0 <= angle && angle < 30) cout << "alert" << endl;
        else if(90 <= angle && angle <= 180) cout << "safe" << endl;
        else cout << "warning" << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int abs(int a){
	return (a<0)?-a:a;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		int h,m,hp,mp;
		scanf("%02d:%02d",&h,&m);
		hp=h*60+m;
		mp=m*12;
		if(abs(mp-hp)%(60*12)*360<(60*12)*30) cout<<"alert\n";
		else if(abs(mp-hp)%(60*12)*360>=(60*12)*90&&abs(mp-hp)%(60*12)*360<=(60*12)*270) cout<<"safe\n";
		else cout<<"warning\n";
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		string str;
		double lg,sh;
		cin>>str;
		lg=atoi(str.substr(0,2).c_str())*30;
		sh=((atoi(str.substr(3,2).c_str())))*6;
		lg+=((double)sh/120);
		double dis=abs(lg-sh);
		dis=min(dis,360-dis);
		if((dis>0||EQ(dis,0))&&dis<30){
			cout<<"alert"<<endl;
		}
		else if((dis>90||EQ(dis,90))&&(dis<180||EQ(dis,180))){
			cout<<"safe"<<endl;
		}
		else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}