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 rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	int h,m;
	rep(i,0,n){
		scanf("%d:%d",&h,&m);
		if(h>=12) h-=12;
		h=30*h+0.5*m;
		m=6*m;
		double ans=abs(h-m);
		if(ans>180) ans=360-ans;
		if(ans<30) o("alert");
		else if(ans>=90) o("safe");
		else o("warning");
	}
}

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

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

main(){
  int i,j,n,h,m;
  double rh,rm,ans;
  cin >> n;
  for(int z=0;z<n;z++){
    scanf("%d:%d",&h,&m);
    rh = rm = 0.0;
    for(i=0;i<h;i++) rh += 30.0;
    for(i=0;i<m;i++) rm += 6.0;
    rh += (double)m * 0.5;
    if(rh >= rm) ans = rh - rm;
    else ans = rm - rh;
    if(ans > 180.0) ans = 360.0 - ans;

    if(ans >= 90.0 && ans <= 180.0) cout << "safe" << endl;
    else if(ans >= 0.0 && ans < 30.0) cout << "alert" << endl;
    else cout << "warning" << endl;
  }
  return 0;
}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		int h, m;
		scanf("%d%*c%d", &h, &m);
		double theta_l = h * 30 + (double)m / 2;
		double theta_s = m * 6;
		double theta = fabs(theta_l - theta_s);
		if(theta > 180)
		{
			theta = 360 - theta;
		}
		if(0 <= theta && theta < 30)
		{
			cout << "alert" << endl;
		}
		else if(30 <= theta && theta < 90)
		{
			cout << "warning" << endl;
		}
		else
		{
			cout << "safe" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double EPS = 1e-10;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int h = stoi(s.substr(0, 2)), m = stoi(s.substr(3, 2));
    double argh = 360. * h / 12 + 30. * m / 60, argm = 360. * m / 60;
    double diff = min(abs(argh - argm), 360 - abs(argh - argm));
    if (diff < 30) cout << "alert" << endl;
    else if (diff >= 90) cout << "safe" << endl;
    else cout << "warning" << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,h,m,i,y;
char c;
cin>>n;
for(i=0;i<n;i++){
cin>>h>>c>>m;
y=m*11-h*60;
if(y>360)y=720-y;
else if(y<0)y=-y;
if(y<60)cout<<"alert"<<endl;
else if(y>=180)cout<<"safe"<<endl;
else cout<<"warning"<<endl;
}
return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;

	long double h, m;
	while (n--){
		scanf("%Lf:%Lf", &h, &m);
		long double hh = 360 * (h / 12);
		long double mm = 360 * (m / 60);
		long double diff = abs(hh - mm - 1);
		// cout << diff << endl;
		if (0 <= diff && diff < 30){
			cout << "alert" << endl;
		}
		else if (90 <= diff && diff <= 180){
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

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

int main(){
	//Input
	int N;
	std::cin >> N;

	int H, M;
	while(N--){
		scanf("%d:%d",&H,&M);
		//Processing
		//ツ角ツ度ツづーツ仰づ淞づゥ
		double aH = 30 * H + 1 / 2 * M, aM = 6 * M, a;
		//std::cout << aH << "," << aM << std::endl;
		if(aH > aM){
			a = aH - aM;
		}
		else{
			a = aM - aH;
		}

		//ツ甘ォツ個ッツつウツづーツ板サツ津ィ
		std::string res;
		if(a >= 0 && a < 30){
			res = "alert";
		}
		else if(a >= 90 && a <= 180){
			res = "safe";
		}
		else{
			res = "warning";
		}

		std::cout << res << std::endl;
	}
}

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

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

string func(int M, int H){
	/*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";*/
	double h = H*30.0 + M/2.0, m = M*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
}

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

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

int h,m;

void solve() {
  double longhand,shorthand,theta;
  longhand = (30*h + (30.0/60.0)*m);
  shorthand = 6*m;
  //  cout << longhand << " " << shorthand << endl;
  theta = min(abs( longhand - shorthand),360-abs( longhand - shorthand));
  //  cout << theta << endl;
  if(theta < 30.0) {
    cout << "alert" << endl;
  }
  else if(theta <= 180 && 90 <= theta) {
    cout << "safe" << endl;
  }
  else {
    cout << "warning" << endl;
  }
}

int main() {
  int n;
  cin >> n;
  for(int i=0;i<n;i++) {
    scanf("%d:%d\n",&h,&m);
    solve();
  }
}

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

using namespace std;

int different( double h, double m )
{

	h += m / 12;
	double a = h - m;
	if( a < 0 ) a = -a;
	
	if( 360 - a < a ) a = 360 - a;

	return a;
}

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

	cin >> n;

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

		h *= 30;
		m *= 6;

		double answer = different( h, m );


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