Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	m500 := []float64{35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, 1000.0}
	m1000 := []float64{71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 1000.0}
	classes := []string{"AAA", "AA", "A", "B", "C", "D", "E", "NA"}
	for scanner.Scan() {
		input := strings.Split(scanner.Text(), " ")
		t500, _ := strconv.ParseFloat(input[0], 64)
		t1000, _ := strconv.ParseFloat(input[1], 64)
		for i := 0; i < len(m500); i++ {
			if t500 < m500[i] && t1000 < m1000[i] {
				fmt.Println(classes[i])
				break
			}
		}
	}
}

C++: #include<iostream>

int main(){

	double a, b;
	while (std::cin >> a >> b){

		if (a < 35.5&&b < 71.0){
			std::cout << "AAA" << std::endl;
		}
		else if (a < 37.5&&b < 77.0){
			std::cout << "AA" << std::endl;
		}
		else if (a < 40.0&&b < 83.0){
			std::cout << "A" << std::endl;
		}
		else if (a < 43.0&&b < 89.0){
			std::cout << "B" << std::endl;
		}
		else if (a < 50.0&&b < 105.0){
			std::cout << "C" << std::endl;
		}
		else if (a < 55.0&&b < 116.0){
			std::cout << "D" << std::endl;
		}
		else if (a < 70.0&&b < 148.0){
			std::cout << "E" << std::endl;
		}
		else std::cout << "NA" << std::endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	double a,b;

		while(scanf("%lf %lf",&a,&b)!=EOF) {
			if(35.50>a && 71.00>b){
				printf("AAA\n");
			}
			else if (37.50>a && 77.00>b){
				printf("AA\n");
			}
			else if (40.00>a && 83.00>b){
				printf("A\n");
			}
			else if (43.00>a && 89.00>b){
				printf("B\n");
			}
			else if(50.00>a && 105.00>b){
				printf("C\n");
			}
			else if(55.00>a && 116.00>b){
				printf("D\n");
			}
			else if(70.00>a && 148.00>b){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		return 0;
}

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

男子   500M  1000M
AAA級  35秒50  1分11秒00
AA級   37秒50  1分17秒00
A級  40秒00  1分23秒00
B級  43秒00  1分29秒00
C級  50秒00  1分45秒00
D級  55秒00  1分56秒00
E級 1分10秒00 2分28秒00

*/

int main(){
  double a,b;
  while(cin>>a>>b){
    if(a<35.5 && b<71){
      cout<<"AAA"<<endl;
    }else if(a<37.5 && b<77){
      cout<<"AA"<<endl;
    }else if(a<40 && b<83){
      cout<<"A"<<endl;
    }else if(a<43 && b<89){
      cout<<"B"<<endl;
    }else if(a<50 && b<105){
      cout<<"C"<<endl;
    }else if(a<55 && b<116){
      cout<<"D"<<endl;
    }else if(a<70 && b<148){
      cout<<"E"<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
}

C++: #include<bits/stdc++.h>
#define EPS 1e-9
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	double t1, t2;
	while (cin >> t1 >> t2) {
		if (t1 < 35.5&&t2 < 71.)puts("AAA");
		else if (t1 < 37.5&&t2 < 77.)puts("AA");
		else if (t1 < 40.&&t2 < 83.)puts("A");
		else if (t1 < 43.&&t2 < 89.)puts("B");
		else if (t1 < 50.&&t2 < 105.)puts("C");
		else if (t1 < 55.&&t2 < 116.)puts("D");
		else if (t1 < 70.&&t2 < 88.)puts("E");
		else puts("NA");
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  double t1,t2;
  string ch;
  while( cin >> t1 >> t2){

    if(t1 < 35.5 && t2 < 71){
      ch = "AAA";
    }else if(t1 < 37.5 && t2 < 77){
      ch = "AA";
    } else if(t1 < 40 && t2 < 83){
      ch = "A";
    }else if(t1 < 43 && t2 < 89){
      ch = "B";
    }else if(t1 < 50 && t2 < 105){
      ch = "C";
    }else if(t1 < 55 && t2 < 116){
      ch = "D";
    }else if(t1 < 70 && t2 < 148){
      ch = "E";
    }else ch = "NA";
    cout << ch << endl;
  }
  return 0;
}

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

struct IND{string str,int page;};
int main()
{

struct IND N1[101]={};
string R;
int x,i=0;
while(scanf("%s %d",&R,&x)!=EOF){
N1[i].str=R;N1[i].page=x;i++;
}
for(int j=0;j<i;j++)
{
	for(int k=i;k>=j;k--)
	{
	*/
#include<stdio.h>
#include<iostream>
using namespace std;
void TR(double x,double y,int K,int H)
{
int t=0;
double X;
X=x*100;t=(int)X;
if(t<3550)K=0;
else if(t<3550)K=0;
else if(t<3750)K=1;
else if(t<4000)K=2;
else if(t<4300)K=3;
else if(t<5000)K=4;
else if(t<5500)K=5;
else if(t<7000)K=6;
else if(t>=7000)K=7;

X=y*100;t=(int)X;
if(t<3550)K=0;
else if(t<7100)H=0;
else if(t<7700)H=1;
else if(t<8300)H=2;
else if(t<8900)H=3;
else if(t<10500)H=4;
else if(t<11600)H=5;
else if(t<14800)H=6;
else if(t>=14800)H=7;
cout<<t;
}



int main(){
int K=0,H=0;
double x,y;
while(scanf("%lf %lf",&x,&y)!=EOF)
{K=0,H=0;

//TR(x,y,K,H);cout<<H<<K;
int t=0;
double X;
X=x*100;t=(int)X;

if(t<3550)K=0;
else if(t<3550)K=0;
else if(t<3750)K=1;
else if(t<4000)K=2;
else if(t<4300)K=3;
else if(t<5000)K=4;
else if(t<5500)K=5;
else if(t<7000)K=6;
else if(t>=7000)K=7;

X=y*100;t=(int)X;
if(t<3550)K=0;
else if(t<7100)H=0;
else if(t<7700)H=1;
else if(t<8300)H=2;
else if(t<8900)H=3;
else if(t<10500)H=4;
else if(t<11600)H=5;
else if(t<14800)H=6;
else if(t>=14800)H=7;


if(H<K)H=K;

switch(K){
case 0:
cout<<"AAA"<<endl;break;
case 1:
cout<<"AA"<<endl;break;
case 2:
cout<<"A"<<endl;break;
case 3:
cout<<"B"<<endl;break;
case 4:
cout<<"C"<<endl;break;
case 5:
cout<<"D"<<endl;break;
case 6:
cout<<"E"<<endl;break;
case 7:
cout<<"NA"<<endl;break;

}
}
return 0;
}

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

int main() {
  double r1, r2;
  double k1[] = {35.5, 37.5, 40., 43., 50., 55., 70.};
  double k2[] = {71., 77., 83., 89., 105., 116., 148.};
  const char *label[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
  double *p1, *p2;
  
  while (cin >> r1 >> r2) {
    p1 = upper_bound(k1, k1+7, r1);
    p2 = upper_bound(k2, k2+7, r2);
    cout << label[max(p1-k1, p2-k2)] << endl;
  }

  return 0;
}

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

int main(){
    double time[2];

    while(cin >> time[0] >> time[1]){
        if(time[0] < 35.5 && time[1] < 71.0) cout << "AAA" << endl;
        else if(time[0] < 37.5 && time[1] < 77.0) cout << "AA" << endl;
        else if(time[0] < 40.0 && time[1] < 83.0) cout << "A" << endl;
        else if(time[0] < 43.0 && time[1] < 89.0) cout << "B" << endl;
        else if(time[0] < 50.0 && time[1] < 105.0) cout << "C" << endl;
        else if(time[0] < 55.0 && time[1] < 116.0) cout << "D" << endl;
        else if(time[0] < 70.0 && time[1] < 148.0) cout << "E" << endl;
        else cout << "NA" << endl;
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#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 <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (int)(count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 100000 ;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

using namespace std;

int main()
{
	double a,b;
	while(~scanf("%lf %lf",&a,&b)){
		static double t5[] = {35.5,37.5,40,43,50,55,70};
		static double t10[] = {71,77,83,89,105,116,148};
		static string s[] = {"AAA","AA","A","B","C","D","E","NA"};
		int t5_r = upper_bound(t5,t5+7,a) - t5;
		int t10_r = upper_bound(t10,t10+7,b) - t10;

		int mx = max(t5_r,t10_r);
		cout << s[mx] << endl;
	}

	return 0;
}