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 <map>
#include <string>
#include <vector>
using namespace std;

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long> m;
		vector <string> data;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			if (!m[str]) data.push_back(str);
			m[str] += (num * a);
		}
		bool flag = true;
		for (int i = 0; i < data.size(); i++){
			if (1000000 <= m[data[i]]){
				cout << data[i] << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<cstdio>

int main(){
int a,i;
bool fl;
unsigned long int b,c;
while(1){
scanf("%d",&i);
fl=false;
for(int j=0;j<i;j++){


 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%d",&b);
 scanf("%d",&c);
if(a*c>=1000000) {
 fl=true;
 printf("%d\n",a);
}
if(fl==false) pritnf("NA\n");
}
}
}

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

using namespace std;

long long int n,a,b,c;



int main(){
    
        
    while(cin >> n){
        if(n==0)break;
        
        long long int ans[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            if(b>=1000&&c>=1000)ans[a]=1000000;
            if(ans[a]<1000000)ans[a]+=b*c;
        }
        
        for(int i=1; i<=4000; i++){
            if(ans[i]>=1000000){
                cout<<i<<endl;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}

C++: #include<stdio.h>


int main(){
	int n;
	int id[4000],cid;
	long long int price,num,sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			scanf("%d",&cid);
			scanf("%lld",&price);
			scanf("%lld",&num);

			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}

		}



		for(i=0;i<idcount;i++){
			if(sale[i]>1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

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

int main(){
  int n,sn,p,c;
  std::vector<int> v;
  while(std::cin>>n){
    if(!n)return 0;
    for(;n;n--){
      std::cin>>sn>>p>>c;
      std::vector<int>::iterator it=find(v.begin(),v.end(),sn);
      if(p*c>=1000000){
	if(it==v.end()){
	  v.push_back(sn);
	}
    }
    if(v.empty())std::cout<<"NA"<<std::endl;
    else{
    std::vector<int>::iterator it = v.begin();
    while(it!=v.end()){
      std::cout<<*it<<std::endl;
      it++;
    }
    v.clear();
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    std::map<int, long long int> map;
    std::deque<int> ans;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            int e;
            long long int p,q;
            map.clear();
            ans.clear();
            for (int i=0;i<n;i++) {
                cin>>e>>p>>q;
                if (map[e]==0) {
                    ans.emplace_back(e);
                }
                map[e]+=p*q;
            }
            int flag=0;
            for (int i=0;i<n;i++) {
                if (map[ans[i]]>=1000000) {
                    cout<<ans[i]<<endl;
                    flag=1;
                }
            }
            if (flag==0) {
                cout<<"NA"<<endl;
            }
        }
    }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
int main() {
	std::vector<int> v;
	while (1) {
		int count=0;
		int n;
		std::cin >> n;
		if (n == 0) {
			break;
		}
		std::vector<std::vector<int>> a(n, std::vector<int>(3));
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j) {
				std::cin >> a[i][j];
			}
		}
		std::vector<int>num(n);
		for (int i = 0; i < n; ++i) {
			for (int j = 1; j < n; ++j) {
				if (a[i][0] == a[j][0]) {
					num[i] += a[i][1] * a[i][2] + a[j][1] * a[j][2];
					++count;
					break;
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			if (count == 0) {
				v.push_back(0);
			}
			if (num[i] >= 1000000) {
				if (count >= 2) {
					sort(num.begin(), num.end());
				}
				v.push_back(num[i]);
			}
		}
	}
	for (int i = 0; i < v.size(); ++i) {
		if (v[i] == 0) {
			std::cout << "NA" << std::endl;
		}
		else {
			std::cout << v[i] << std::endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve100(int n) {
    long officer[4001] = {0};
    long o, p, q;
    REP(i,n) {
        cin >> o >> p >> q;
        officer[o] += p * q;
    }
    int cnt = 0;
    REP(i,4001) {
        if (officer[i] >= 1000000) {
            cnt++;
            cout << i << endl;
        }
    }
    if (cnt == 0) cout << "NA" << endl;
}

int main() {
    int n;
    while(cin >> n, n) {
        solve100(n);
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	int n;
	while(cin >> n && n!=0){
		map<int, ll> ans;
		vector<int> idx;
		int id, price, num;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> num;
			if(!ans.count(id)) idx.push_back(id);
			ans[id] += (ll)price*num;
		}

		vector<int> ans_id;
		for(int i = 0; i < idx.size(); i++){
			if(ans[idx[i]]>=1000000) ans_id.push_back(idx[i]);
		}
		if(ans_id.size()==0){
			cout << "NA" << endl;
		}else{
			for(int i = 0; i < ans_id.size(); i++){
				cout << ans_id[i] << endl;
			}
		}
	}
	return 0;
}