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

int main(){
	int n, num, count, p, q;
	while (true) {
		vector<unsigned long long int> nu(4000,0);
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> num >> p >> q;
			nu[num-1] += p * q;
		}
		count = 0;
		for (int i = 0; i < 4000; i++) {
			if(nu[i]>=1000000){
				cout << i+1 << endl;
				count++;
			}
		}
		if (count==0){
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define HIGH 1000000
#define MEMBER_NUM 4001
#define INF -1
using namespace std;

int main(void) {
    int n;
    while(cin >> n, n != 0) {
        int data[MEMBER_NUM];
        memset(data, INF, sizeof(data));
        for(int r = 0; r < n; r++) {
            int no, tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no] != INF) {
                data[no] += tanka*quantity;
            } else {
                data[no] = tanka*quantity;
            }
        }
        bool update = false;
        for(int r = 0; r < MEMBER_NUM; r++) {
            if(data[r] >= HIGH) {
                cout << r << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    return(0);
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	
	int n;
	long long sn, x, y;
	long long p[4001] = { 0 };
	while (1){
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i <= 4000; i++)p[i] = 0;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			p[sn] += x*y;
		}
		int flag = 0;
		for (int i = 1; i <= 4000; i++){
			if (p[i] >= 1000000){
				cout << i << endl;
				flag++;
			}
		}
		if (flag == 0)cout << "NA" << endl;
	}
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		ll a[4001];
		rep(i, 4001) { a[i] = 0; }
		rep(i, n) {
			ll d, p, q;
			cin >>  d >> p >> q;
			a[d] += p*q;
		}
		bool flag = false;
		for (int i = 1; i < 4001; i++) {
			if (a[i] >= 1000000) {
				flag = true;
				cout << i << endl;
			}
		}
		if (!flag) { cout << "NA" << endl; }
	}
	return 0;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		ll a[4001];
		bool out[4001];
		rep(i, 4001) { a[i] = 0; out[i] = false; }
		bool flag = false;
		
		rep(i, n) {
			ll d, p, q;
			cin >> d >> p >> q;
			a[d] += p*q;
			if (a[d] >= 1000000 &&! out[d]) {
				flag = true;
				out[d] = true;
				cout << d << endl;
			}
		}
		/*for (int i = 1; i < 4001; i++) {
			if (a[i] >= 1000000) {
				flag = true;
				cout << i << endl;
			}
		}*/
		if (!flag) { cout << "NA" << endl; }
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
struct date{
    int num;
    int tanka;
    int uriage;
    long long int sum;
};
int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        date a[5000] = {0};
        int number;
        for(int i = 0; i < n; i++){
            cin >> number;
            cin >> a[number].tanka >> a[number].uriage;
            a[number].sum += a[number].tanka * a[number].uriage;
        }
        bool flg = 0;
        for(int i = 1; i <= 4000; i++){
            if(a[i].sum >= 1000000) cout << i << endl,flg = 1;
        }
        if(!flg) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
	int num;
	int data_set = 0;
	bool do_continue = true;
	std::vector<string> result;

	while (do_continue) {
		cin >> num;
		if ((num == 0) || (data_set > 50)) {
			do_continue = false;
		}
		else {
			bool na_flg = true;
			data_set++;
			std::map<int, int> e;
			std::vector<int> employee;
			int fst, snd, thd;

			for (int i = 0; i < num; i++) {
				cin >> fst >> snd >> thd;
				employee.push_back(fst);
				if (e.count(employee[i])) {
					e[employee[i]] += snd * thd;
				}
				else {
					e[employee[i]] = snd * thd;
				}
			}

			for (unsigned int j = 0; j < employee.size(); j++) {
				if (e[employee[j]] >= 1000000) {
					na_flg = false;
					result.push_back(to_string(employee[j]));
				}
			}

			if (na_flg) {
				result.push_back("NA");
			}
		}
	}

	for (unsigned int i = 0; i < result.size()-1; i++) {
		cout << result[i] << endl;
	}


	return 0;
}

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

int n;
int a[3];
int x[4001];

int main() {
	while (1) {
		std::cin >> n;
		if (n == 0)
			break;
		int count = 0;

		std::memset(x, 0, sizeof(x));

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j)
				std::cin >> a[j];
			x[a[0]] += a[1] * a[2];
		}
		for (int i = 1; i <= 4000; ++i) {
			if (x[i] >= 1000000) {
				std::cout << i << std::endl;
				++count;
			}
		}
		if (count==0)
			std::cout << "NA" << std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std; 
#define pb push_back
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef vector<int> Vi;

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    Vi v;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      if( m.find( a ) == m.end() ) {
	v.pb( a );
	m[a] = 0;
      }
      m[a] += b * c;
    }
    
    Rep(i, v.size()) {
      if( m[v[i]] >= 1000000 ) {
	cout << v[i] << endl;
	flag = true;
      }
    }

    if( !flag ) cout << "NA" << endl;
  }
}