Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

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();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		vector<int> shine(4001, 0);
		queue<int> idx;
		rep(i,N) {
			int num, a, b;
			cin >> num >> a >> b;
			if(shine[num] == 0) {
				shine[num] = a * b;
				idx.push(num);
			} else {
				shine[num] += a * b;
			}
		}
		bool f = false;
		while(!idx.empty()) {
			int t = idx.front(); idx.pop();
			if(shine[t] >= 1000000) {
				cout << t << endl;
				f = true;
			}
		}
		if(!f) cout << "NA" << endl;
	}
	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 <map>
#include <utility>
#include <numeric>
#include <algorithm>
#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; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n)
	{
		if(!n) break;

		bool f = true;
		rep(i, n)
		{
			int a, s, num;
			cin >> num >> a >> s;

			if(1000000 <= a * s)
			{
				f = false;
				cout << num << endl;
			}
		}
		if(f) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>

std::vector<std::string> split(const std::string& ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num=0;
std::string str;
std::vector<std::string> ref;
std::vector<std::string> res;

std::cin >> str;
if(str!="") it_num=std::stoi(str);
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str,' ');
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num;
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}

C++: #include <stdio.h>
#define ull unsigned long long int
typedef struct{
	int o;
	ull val;
}pair;

ull hoge(pair crew[],ull t,ull s,int num){
	crew[num].val+=t*s;
	return crew[num].val;
}

int main(){
	pair crew[4000];
	ull t,s;
	int i,n,num,N=1000000;
	while(1){
		for(i=0;i<4000;i++) crew[i].val=0,crew[i].o=-1;
		i=0;
		scanf("%d",&n);
		if(!n) break;
		while(n--){
			scanf("%d%llu%llu",&num,&t,&s);
			if(N<=hoge(crew,t,s,num)) if(crew[num].o<0) crew[num].o=i++;
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<4000;k++) if(j==crew[k].o) printf("%d\n",k);
		}
		if(!i) printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <map>

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector< pair<int, long long> > members;
        for (int i = 0; i < n; i++) {
            pair<int, long long> member;
            int id;
            long long cost, count;
            cin >> id >> cost >> count;
            bool exist = false;
            for (int i = 0; i < members.size(); i++) {
                if (members[i].first == id) {
                    members[i].second += cost * count;
                    exist = true;
                }
            }
            if (!exist) {
                member.first = id;
                member.second = cost * count;
                members.push_back(member);
            }
        }
        bool exist = false;
        for (vector< pair<int, long long> >::iterator m_i = members.begin();
                m_i != members.end(); m_i++) {
            if (m_i->second >= 1000000) {
                cout << m_i->first << endl;
                exist = true;
            }
        }
        if (!exist) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define ll long long

int main(){
  int i,j,k,n;
  int id;
  ll a, b;

  while(scanf("%d",&n)){
    bool f = false;
    if(n == 0) break;

    while(n--){
      scanf("%d %lld %lld",&id,&a,&b);
      if(a * b >= 1000000){
        printf("%d\n",id);
        f = true;
      }
    }
    if(f) puts("NA");
  }

  return 0;
}

C++: #include <stdio.h>

int main(int argc, char *argv){
	int n, f;
	int ID, price, num;
	while(1){
		scanf("%d ", &n);
		if(!n) break;
		f=0;
		while(n--){
			scanf("%d %d %d ", &ID, &price, &num);
			if(1000000 <= price * num){
				printf("%d\n", ID);
				f = 1;
			}
		}
	}
	if(!f) printf("NA\n");
	return 0;
}

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>
using namespace std;
 
int main(){
	int N,A[100000],B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		bool NAflag=true,used[4001]={};
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("\t%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("\tNA");
	}
    return 0;
}