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 <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  while (n--) {
    int h, m;
    scanf("%d:%d", &h, &m);

    int diff = h * 300 - m * 55;
    if (diff < 0)
      diff *= -1;
    if (diff > 1800)
      diff = 3600 - diff;
    if (0 <= diff && diff < 300)
      puts("alert");
    else if (900 <= diff && diff <= 1800)
      puts("safe");
    else
      puts("warning");
  }
  return 0;
}

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

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		double sita=abs(tyousin-tansin);
		if(sita<30)cout<<"alert"<<endl;
		else if(sita>=90 &&sita<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

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

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		double s=0;
		string p;
		cin >> p;		
		s = ((p[0] - '0') * 10 + (p[1] - '0')) * 30 - ((p[3] - '0') * 10 + (p[4] - '0'))*5.5;
		if (s < 0)s = s - s * 2;
		if (s > 360 - s)s = 360 - s;
		cout << s << endl;
			if (s < 30)cout << "alert" << endl;
			else if (s < 90)cout << "warning" << endl;
			else cout << "safe" << endl;
	}
}

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

int main()
{
  int n;
  cin >> n;
  for (int dataset=0; dataset<n; dataset++)
  {
    char dummy;
    double hour,minutes;
    cin >> hour >> dummy >> minutes;

    double hour_angle = hour * 30 + minutes / 2;
    double minutes_angle = minutes * 6;
    double angle_diff = hour_angle - minutes_angle;
    if ( angle_diff < 0 ) angle_diff = -angle_diff;

    if ( 0 <= angle_diff && angle_diff < 30 )
    {
      cout << "alert" << endl;
    }
    else if ( 90 <= angle_diff && angle_diff <= 180 )
    {
      cout << "safe" << endl;
    }
    else
    {
      cout << "warning" <<endl;
    }
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	double n,h,t;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&t);
		t=t*6;
		h=h*30+(0.5*t);
		if(t<h)swap(t,h);
		if(0.0<=abs(h-t)&&abs(h-t)<=30.0){
			cout<<"alert"<<endl;
		}else if(90.0<=abs(h-t)&&abs(h-t)<180.0){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

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

const double pi = 3.14159265358979;

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0 ; i < n ; i++ ){
		int h, m;
		scanf("%d:%d", &h, &m);
		double hour_hand = (double)h / 6.0 * pi + m / 360.0 * pi + 2.0*pi ;
		double minute_hand = (double)m / 30.0 * pi + 2.0 * pi;
		double d = fabs( hour_hand - minute_hand );
		//cout << "h : " << (int) hour_hand / (2.0*pi) * 360 - 360 << endl;
		//cout << "m : " << (int) minute_hand / (2.0*pi) * 360 - 360 << endl;
		//cout << "d : " << (int) d / (2.0*pi) * 360 << endl;
		if( d < pi / 6.0 ){
			cout << "alert" << endl;
		}else if( d < pi / 2.0 ){
			cout << "warning" << endl;
		}else{
			cout << "safe" << endl;
		}
	}
}

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

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		int a,b; char c;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		double A =(double)a*30+b*0.5;
		double B =(double)b*6;
		
		double judge = abs(A-B);
		if(180<judge)judge = 360.0 - judge;
//		cout<<judge<<endl;
	
//		cout<<a<<" "<<b<<" "<<judge<<endl;
		if(0<=judge && judge<30)cout<<"alert"<<endl;
		else if(90<=judge && judge<180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

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

int main(){
	long n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		cout<<hh<<" "<<mm<<endl;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		double sita=abs(tyousin-tansin);
		cout<<sita<<endl;
		if(sita<30)cout<<"alert"<<endl;
		else if(sita>=90 && sita<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

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

string func(int s, int l){
	double a = l * 6;
	double b = s * 30.0 + l / 2.0;
	int m = abs(a - b);
	if(180 < m)m = 360 - m;
	if(0 <= m && m < 30)return "alert";
	if(90 <= m && m <= 180)return "safe";
	return "waring";
	/*if(m > 180)m = 360 - m;
	if(30 <= m){
		if(90 <= m)return "safe";
		return "warning";
	}
	return "alert";*/
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  cin>>n;
  while(n--){
    long double hh,mm;
    scanf("%Lf:%Lf",&hh,&mm);
    hh=30*hh+mm*0.5;
    
    mm*=6;
    //cout<<hh<<":"<<mm<<endl;
    long double diff=abs(hh-mm);
    if(mm>hh)diff=abs(mm-hh);
    if(diff>180)diff=360-diff;

    if(diff<=30)puts("alert");
    else if(diff>=90)puts("safe");
    else puts("warning");
  }
}

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

string func(int s, int l){
	double a = l * 6;
	double b = s * 30 + l / 2;
	int m = abs(a - b);
	if(180 < m)m = 360 - m;
	if(0 <= m && m < 30)return "alert";
	if(90 <= m && m <= 180)return "safe";
	return "waring";
	/*if(m > 180)m = 360 - m;
	if(30 <= m){
		if(90 <= m)return "safe";
		return "warning";
	}
	return "alert";*/
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
int main(){
    int n,i;
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        int h,m;
        double x;
        scanf("%d:%d",&h,&m);
        printf("%d %d\n",h,m);
        x=fmod(5.5*(60*h+m),360);
        if ((x>=0&&x<30)||x>330) {
            printf("alert\n");
        }else if (x>=90&&x<=270){
            printf("safe\n");
        }else{
            printf("warning\n");
        }
    }
    return 0;
}