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 <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
    int n;
    while (cin >> n && n) {
        unordered_map<int, int> pos;
        vector<pair<int, ll>> res(4001);
        for (int i=1; i<=n; ++i) {
            int no;
            ll price, quantity;
            cin >> no >> price >> quantity;
            if ( ! pos[no]) {
                pos[no] = i;
                res[pos[no]].first = no;
            }
            res[pos[no]].second += price * quantity;
        }

        bool NA = true;
        for (int i=0; i<(int)res.size(); ++i) {
            if (res[i].second >= 1000000) {
                cout << res[i].first << endl;
                NA = false;
            }
        }
        if (NA)
            cout << "NA" << endl;
    }
    return 0;
}

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

using namespace std;

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

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;
}