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 <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  rep(i, in()){
    int h, m;
    scanf("%d:%d", &h, &m);
    h *= 30;
    m *= 6;
    int deg = min(abs(h - (360 - m)), abs(h - m));
    if (0 <= deg && deg < 30){
      puts("alert");
    }
    else if (90 <= deg && deg <= 180){
      puts("safe");
    }
    else {
      puts("warning");
    }
  }
  return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  int n;
  cin>> n;
  while(n--) {
    double l_hand, s_hand;
    double l_angle, s_angle;
    double angle;

    scanf("%d:%d",&l_hand, &s_hand);
    l_angle = l_hand*30 + s_hand*0.5;
    s_angle = s_hand*6;
    angle = abs(l_angle-s_angle);

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

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const string ALERT = "alert";
const string SAFE = "safe";
const string WARNING = "warning";

string solve( string s ) {
    replace( s.begin(), s.end(), ':', ' ' );
    ISS iss( s );
    int hh, mm;
    iss >> hh >> mm;

    double ang1 = hh / 12.0 * 360.0 + mm / 60.0 * 30.0;
    double ang2 = mm / 60.0 * 360.0;
    double diff = fabs( ang1 - ang2 );

    if ( diff > 180.0 ) diff = 360.0 - diff;
    if ( diff > 0.0 || fabs( diff ) < 1e-9 ) {
        if ( diff < 30.0 || fabs( diff - 30.0 ) < 1e-9 ) return ALERT;
    }
    if ( diff > 90.0 || fabs( diff - 90.0 ) < 1e-9 ) {
        if ( diff < 180.0 || fabs( diff - 180.0 ) < 1e-9 ) return SAFE;
    }
    return WARNING;
}

int main() {
    int n;
    cin >> n;
    for ( int i = 0; i < n; ++ i ) {
        string s;
        cin >> s;
        cout << solve( s ) << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int a, b, n;
double d, e, f;
char c;
int main() {
	cin >> n;
	while (cin >> a >> c >> 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 <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}


signed main()
{
  //ios::sync_with_stdio(false);
  int n;

  cin >> n;
  while (n--){
    int h, m;
    scanf("%d:%d", &h, &m);
    double maxD = max((h % 12 + m / 60.0) * (360 / 12.0), m * 360 / 60.0), 
           minD = min((h % 12 + m / 60.0) * (360 / 12.0), m * 360 / 60.0);
    double diff = maxD - minD;
    if (diff < 30.0){
      print("alert");
    } else if (diff < 90.0){
      print("warning");
    } else {
      print("safe");
    }
    //cout << "diff: " << diff << endl;
  }

  return (0);
}

C++: #include<bits//stdc++.h>
using namespace std;
int main() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

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

int main(){
  int T;
  cin>>T;
  while(T--){
  int h,m;
  scanf("%d:%d",&h,&m);
  double A=360*(h/12.0)+30*(m/60.0);
  double B=360*(m/60.0);
  double r=min(abs(A-B),360-abs(A-B));
  
  if(r<30)cout<<"alert"<<endl;
  else if(r<90)cout<<"warning"<<endl;
  else cout<<"safe"<<endl;
  
  }
  return 0;
}

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

int main(){
  int T;
  cin>>T;
  while(T--){
  int h,m;
  scanf("%d:%d",&h,&m);
  double A,B;
  A=360*(h/12.0);
  B=360*(m/60.0);
  double r=abs(A-B);
  if(r>180)r=360-r;
  if(r<=30)cout<<"alert"<<endl;
  else if(r<=90)cout<<"warning"<<endl;
  else cout<<"safe"<<endl;
  
  }
  return 0;
}

C++: main(n){double a,b;char m[3][8]={"alert","warning","safe"};for(scanf("%d",&n);n--;scanf("%lf:%lf",&a,&b),a=a+b/60-b/5,a=a>6?12-a:a,printf("%s\n",m[(a>=1)+(a>=3)]));}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int a,b;
	char d;
	cin>>a>>d>>b;
	double h=abs(30.5*a-6*b);
	//cout<<h<<endl;
	if(h<30||360-h<30)cout<<"alert"<<endl;
	else if(h>=90&&h<=270)cout<<"safe"<<endl;
	else cout<<"warning"<<endl;
  }
}

C++: #include <cstdio>
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main()
{
	int n; scanf("%d", &n);
	rep(i, n) {
		int h, m; scanf("%d:%d", &h, &m);
		int ah = 60 * h + m;
		int am = 12 * m;
		int diff = ah - am; if (diff < 0) diff = -diff;
		if (diff > 360) diff -= 360;

		if (0 <= diff && diff < 60) puts("alert");
		else if (diff < 180) puts("warning");
		else puts("safe");
	}
	return 0;
}