Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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


#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define repd(i, a, b) for(int i = a; i > b; i--)

#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

	typedef long long ll;

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		ll sale[4096] = { 0 };
		bool ok = true;
		rep(i, n) {
			ll s, h, u;
			cin >> s >> h >> u;
			if (sale[s] < 1000000) {
				sale[s] += h * u;
				if (sale[s] >= 1000000) {
					cout << s << endl;
					ok = false;
				}
			}
		}

		if (ok) cout << "NA" << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    bool f = false;
    REP(i,n){
      int a;
      ll b,c;
      cin>>a>>b>>c;
      if(b*c >= (ll)1000000){
	cout << a << endl;
	f = true;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;
ll amount;

const ll MAX = 1000000;

struct Mem {
    int index;
    int id;

    Mem(int _index, int _id) { index = _index; id = _id; }

    bool operator<(const Mem& m) const {
        return index < m.index;
    }
};

map<Mem, ll> m;
map<Mem, ll>::iterator it;
vector<int> ans;

int main(void) {
    freopen("i.in", "r", stdin);
    while(~scanf("%d", &n)) {
        if(n == 0) break;
        m.clear();
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d", &id, &p, &q);
            amount = p*q;
            Mem tmp(i, id);
            m[tmp] += amount;
        }
        ans.clear();
        for(it = m.begin(); it != m.end(); it++) {
            if((*it).second >= MAX) {
                ans.push_back((*it).first.id);
            }
        }
        if(ans.empty()) {
            printf("NA\n");
        } else {
            for(int i = 0; i < (int) ans.size(); i++) {
                printf("%d\n", ans[i]);
            }
        }
    }
    return 0;
}

C++: //Sale Result
//
//?????????????£?????????¨?£??????°???????¨????????????????????????????????????????????????????????£?????????¨?£??????°??????????????????????£???????????????????????????? 1, 000, 000 ?????\??????????????????????????????????????????????????°??????????????????????????????????????????????????°????????´????????????????????????????????\????????????????????????????????????????????????????????????????????????????????????????????????????????????????????´?????????NA?????¨???????????????????????????????????? 4000 ???????????¨??????1??????4000?????§?????????????????????????????????????????????????????????????????????????????¨?????????????????????????£?????????? 1, 000, 000 ?????\?????§????£??????°?????? 100, 000 ?????\?????¨????????????
//Input
//
//?????°???????????????????????????????????????????????\??????????????????0???????????????????????????????????\????????¨?????????
//
//???????????° n
//???????????? ????£??????? ?£??????°???(??´??°;????§????????????????)
//	:
//	:
//
//	Output
//
//	????????????????????????????????????????????????(??´??°)?????? ????????? NA(????§???±??§??????)
//	Sample Input
//
//	4
//	1001 2000 520
//	1002 1800 450
//	1003 1600 625
//	1001 200 1220
//	2
//	1001 100 3
//	1005 1000 100
//	2
//	2013 5000 100
//	2013 5000 100
//	0
//
//	Output for the Sample Input
//
//	1001
//	1003
//	NA
//	2013

#define _CRT_SECURE_NO_WARNINGS 1

using namespace std;

#include <stdio.h>
#include <map>

#define BASE_VALUE 1000000		// ?£?????????????

int main()
{
	int n = 0;							// ???????????°
	int no = 0;							// ????????????
	int price = 0;						// ????£???????
	int saleNum = 0;					// ?£??????°???
	bool flg = false;					// ????????????????????¨??????????????????
	map<int, int> proceed;				// ?£??????????map
	map<int, int>::iterator ite;		// ?£??????????map????????¬??????

	while (true)
	{
		// ?????????
		flg = false;
		proceed.clear();

		// ???????????°??\???
		scanf("%d", &n);

		if (0 == n)
		{// 0?????\??????????????°??????
			break;
		}

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %d %d", &no, &price, &saleNum);

			proceed[no] += price*saleNum;
		}

		for (ite = proceed.begin(); ite != proceed.end(); ++ite)
		{
			if (BASE_VALUE <= ite->second)
			{// ?£???????????????????????????? 1,000,000 ?????\????????????
				printf("%d\n", ite->first);
				flg = true;
			}
		}

		if (!flg)
		{// ????????????????????¨?????????
			printf("NA\n");
		}
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

#define INF 999999
#define MAX_V 999

using namespace std;

int main(){
	long int n, id, val, num;
	vector<long int> ans;
	vector<long long int> com(4000);
	while(cin>>n,n){
		ans.clear();
		rep(i,4000)	com[i]=0;
		rep(i,n){
			cin>>id>>val>>num;
			if(!com[id-1])	ans.push_back(id);
			com[id-1]+=val*num;
		}
		bool flag=true;
		rep(i,ans.size()){
			if(com[ans[i]-1]>=1000000){
				cout<<ans[i]<<endl;
				flag=false;
			}
		}
		if(flag){
			cout<<"NA"<<endl;
		}
	}
	return 0;
	
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

int main() {
    char id[1024];
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        int c = 0;
        rep (_, n) {
            int p, q;
            scanf("%s%d%d", id, &p, &q);
            if ((Int)p*q >= 1000000) {
                printf("%s\n", id);
                c++;
            }
        }
        if (c == 0) puts("NA");
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int number[4000];
	int tanka[4000];
	int ryou[4000];
	int goukei[4000];
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka[i];
			cin>>ryou[i];
			goukei[i]=tanka[i]*ryou[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
}