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>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    double a, b;
    int l, r;
    while(cin >> a >> b){
        if(a < 35.50){
            l = 1;
        }else if(a < 37.50){
            l = 2;
        }else if(a < 40.00){
            l = 3;
        }else if(a < 43.00){
            l = 4;
        }else if(a < 50.00){
            l = 5;
        }else if(a < 55.00){
            l = 6;
        }else if(a < 70.00){
            l = 7;
        }else{
            l = 8;
        }
        if(b < 71.00){
            r = 1;
        }else if(b < 77.00){
            r = 2;
        }else if(b < 83.00){
            r = 3;
        }else if(b < 89.00){
            r = 4;
        }else if(b < 105.00){
            r = 5;
        }else if(b < 116.00){
            r = 6;
        }else if(148.00){
            r = 7;
        }else{
            r = 8;
        }
        int ans = max(l,r);
        if(ans == 1)
            cout << "AAA" << endl;
        if(ans == 2)
            cout << "AA" << endl;
        if(ans == 3)
            cout << "A" << endl;
        if(ans == 4)
            cout << "B" << endl;
        if(ans == 5)
            cout << "C" << endl;
        if(ans == 6)
            cout << "D" << endl;
        if(ans == 7)
            cout << "E" << endl;
        if(ans == 8)
            cout << "NA" << endl;
    }
}

C++: #include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

double x,y;

int main(){
	while(cin>>x>>y){
		if(x<35&&y<71) cout<<"AAA"<<endl;
		else{
			if(x<37&&y<77) cout<<"AA"<<endl;
			else{
				if(x<40&&y<83) cout<<"A"<<endl;
				else{
					if(x<43&&y<89) cout<<"B"<<endl;
					else{
						if(x<50&&y<105) cout<<"C"<<endl;
						else{
							if(x<55&&y<116) cout<<"D"<<endl;
							else{
								if(x<70&&y<148) cout<<"E"<<endl;
								else cout<<"NA"<<endl;
							}
						}
					}
				}
			}
		}
	}
}

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

double a, b;
double A[7] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0};
double B[7] = {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};
string S[8] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};

int main() {
  while(cin >> a >> b) {
    int ra, rb;
    for(ra = 0; ra < 7 && !(a < A[ra]); ++ra);
    for(rb = 0; rb < 7 && !(b < B[rb]); ++rb);
        cout << S[max(ra,rb)] << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
/*
jq	 500M	 1000M
AAA	 35b50	 1ª11b00
AA	 37b50	 1ª17b00
A	 40b00	 1ª23b00
B	 43b00	 1ª29b00
C	 50b00	 1ª45b00
D	 55b00	 1ª56b00
E	1ª10b00	2ª28b00
*/
int main()
{
	const double t500m[] = { 
		0.00, 35.50, 37.50, 40.00, 43.00, 50.00, 55.00, 70.00, DBL_MAX };
	const double t1000m[] = {
		0.00, 71.00, 77.00, 83.00, 89.00, 105.00, 116.00, 148.00, DBL_MAX };
	const string cname[] = { "AAA", "AA", "A", "B", "C", "D", "E", "NA" };

//	cut here before submit 
//	freopen ("testcase.speedskat", "r", stdin );

	string str = "";
	int i,j;
	while (getline (cin, str ) ){
		double time1, time2;
		stringstream ss(str);
		ss >> time1 >> time2;

		int c500 = -1;
		int c1000 = -1;
		for (i = 0; i < sizeof(t500m)/sizeof(t500m[0]) - 1; ++i){
			if (time1 >= t500m[i] && time1 < t500m[i+1] ){
				c500 = i;
				break;
			} // end if
		} // end for

		for (j = 0; j < sizeof(t1000m)/sizeof(t1000m[0]) - 1; ++j){
			if (time2 >= t1000m[j] && time2 < t1000m[j+1] ){
				c1000 = j;
				break;
			} // end if
		} // end for

		int decide_class = max (c500, c1000);
		cout << cname[decide_class] << endl;

	} // end loop
		
	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)
{

double t;
t=x*100;
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;

t=y*100;
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;
double t=0;
double X;
t=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;

t=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(H){
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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }


int light[] = {35.5, 37.5, 40, 43, 50, 55, 70};
int heavy[] = {71, 77, 83, 89, 105, 116};
string cls[] = {"AAA", "AA", "A", "B", "C", "D", "E"};


string comp(double a, double b)
{
	rep(i, 7)
		if(a < light[i] && b < heavy[i])
			return cls[i];
	
	return "NA";
}

int main()
{
    double a, b;
	while(cin >> a >> b)
		cout << comp(a, b) << endl;
}