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<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.0*a-6.5*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<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

signed main(){
	int N,H,M;
	cin>>N;
	for(int i=0;i<N;i++){
		scanf("%d:%d",&H,&M);
		double d;
		d = abs(360.0*((H%12)*60+M)/(12.0*60.0)-360.0*M/60.0);
		if(d>180.0) d = 360.0-d;
		if(d<30) puts("alert");
		else if(90<=d && d<=180) puts("safe");
		else puts("warning");
	}
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int T; cin >>T;
  REP(t, T){
    string s; cin >>s;
    int h = atoi(s.substr(0, 2).c_str());
    int m = atoi(s.substr(3).c_str());
    int d = abs((h * 30 + m * 0.5) - m * 6);
    cout <<(d < 30 ? "alert" : (d >= 90 && d <= 180 ? "safe" : "warning")) <<endl;
  }
  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


struct Edge {
    int to, cost, nm;
    Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

bool cmp(const pii& a, const pii& b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.first < b.first;
}

vector<string> matrix;
int main() {

    int n; cin >> n;
    for(int i=0; i<n; ++i){
        int hh, mm;
        scanf("%d:%d", &hh, &mm);
        double arg1 = (double)(hh*60 + mm)/2.0;
        double arg2 = (double)mm*6.0;

        double mini = fabs(arg1 - arg2);

        if(arg1 < arg2) arg1 += 360.0;
        else arg2 += 360.0;
        mini = min(mini, fabs(arg1 - arg2));
        if(mini < 30.0){
            cout << "alert" << endl;
        }else if(mini >= 90.0){
            cout << "safe" << endl;
        }else{
            cout << "warning" << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n,h,m;
int a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+(m/12)*6;
    b=m*6;
    
   
    c=max(a,b)-min(a,b);
    if(c>180){
      c=min(a,b)+360-max(a,b);
    }

    //cout << a<< ' '<<b<<' '<<c<<endl;
    
    if(0<=c&&c<=30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
    
  }
  return 0;
}

C++: //Name: Clock Short Hand and Long Hand
//Level: 2
//Category: 数学
//Note: 

/**
 * 2PI = 1としてから全体を720倍すると、整数のみで計算できる。
 */
#include <iostream>
#include <algorithm>

using namespace std;

bool solve(bool first) {
    int H, M;
    cin >> H;
    cin.ignore();
    cin >> M;

    //const double ha = 2*PI * (H/12 + M/12/60);
    //const double ma = 2*PI * M/60;
    const int ha = 60*H + M;
    const int hb = 12*M;
    const int diff = min(abs(ha-hb), abs(720-abs(ha-hb)));
    if(diff < 60) {
        cout << "alert" << endl;
    } else if(diff >= 180) {
        cout << "safe" << endl;
    } else {
        cout << "warning" << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    int N;
    cin >> N;
    while(N-- && solve(first)) {
        first = false;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    while (n--) {
        cin >> s;
        int h = (s[0] - '0') * 10 + (s[1] - '0');
        int m = (s[3] - '0') * 10 + (s[4] - '0');
        if (abs(60 * h - 11 * m) < 60) {
            cout << "alert" << endl;
        } else if (abs(60 * h - 11 * m) < 180) {
            cout << "warning" << endl;
        } else {
            cout << "safe" << endl;
        }
    }
    return 0;
}