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 <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

/*
  AOJ :: 0100
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
 */

typedef long long ll;

int main(){
    int n,num,tanka,count,i;
    vector<int> ans;
    set<int> S;

    while( cin >> n, n ){
        // init
        S.clear(); ans.clear();

        rep(i,n){
            cin >> num >> tanka >> count;
            if( (ll)tanka * (ll)count >= 1000000 && S.count(num) == 0 ){
                S.insert(num);
                ans.push_back(num);
            }
        }

        if( ans.size() == 0 ){
            puts("NA");
        }
        else{
            rep(i,ans.size()){
                printf("%d\n",ans[i]);
            }
        }
    }

    return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    map<int,long long int> emps;
    vector<int> ids;
    int id,cost,amount,n;
    while(cin >> n,n){
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(emps.find(id)!=emps.end()){
                emps[id]+=cost*amount;
            }else{
                emps[id]=cost*amount;
                ids.push_back(id);
            }
        }
        for(int i=0;i<ids.size();i++){
            if(emps.at(ids[i])>=1000000) cout << ids[i] << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main() {

	long long int n, num, p, q, c;
	deque<int> x;

	while(cin >> n) {
		if(n==0)
			break;
		c=0;
		for(int i=0; i<n; i++) {
			int f=1;
			cin >> num >> p >> q;
			if(p*q>=1000000) {
				for(int j=0; j<x.size(); j++) {
					if(x[j]==num)
						f=0;
				}
				if(f)
					x.push_back(num);
			}
		}
		int f=1;
		for(int i=0; i<x.size(); i++) {
			cout << x[i] << endl;
			f=0;
		}
		if(f)
			cout << "NA" << endl;
	}
		
	return 0;

}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
int main(){
int n;
while(cin>>n,n){
long long ta[5000]={0};long long x[5000]={0};
long long cnt=0,a,b,c;
	for(int i=0;i<n;i++){
	cin>>a>>b>>c;
	ta[a]+=b*c;
	bool f=1;
	for(int j=0;j<i;j++)if(x[j]==a)f=0;
	if(f)x[cnt++]=a;
	}
	bool f=1;
	for(int i=0;i<n-1;i++){
	//cout<<x[i]<<" "<<ta[x[i]]<<endl;
	if(ta[x[i]]>=1000000){cout<<x[i]<<endl;f=0;}
	}
	if(f)cout<<"NA"<<endl;
}
	return 0;
}

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

int main() {
	int n;
	std::cin >> n;
	while (n != 0) {
		bool flag{ true };
		std::vector<int> crue(4000 + 1, 0);
		for (auto i = 0; i < n; ++i) {
			int id, value, size;
			std::cin >> id >> value >> size;
			crue.at(id) += value * size;
		}
		for (auto i = 1; i <= 4000; ++i) {
			if (crue.at(i) >= 1000000) {
				std::cout << i << "\n";
				flag = false;
			}
		}
		if (flag) {
			std::cout << "NA\n";
		}
		std::cin >> n;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
??
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
??
using namespace std;
typedef long long int lint;
??
bool AOJ0100() {
????????lint n, e, p, q;
????????cin >> n;
????????if (n == 0) return false;
??
????????lint* data = new lint[4001];
????????for (int i = 0; i <= 4000; i++) data[i] = 0;
??
????????for (lint i = 0; i < n; i++) {
????????????????cin >> e >> p >> q;
????????????????data[e] += p * q;
????????}
??
????????bool flag = false;
????????for (int i = 1; i <= 4000; i++) {
????????????????if (data[i] >= 1000000) {
????????????????????????flag = true;
????????????????????????cout << i << endl;
????????????????}
????????}
????????if (!flag) cout << "NA" << endl;
??
????????delete[] data;
????????return true;
}
??
int main()
{
????????while (AOJ0100()) {
????????}
????????return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int lint;

bool AOJ0100() {
	lint n, e, p, q;
	cin >> n;
	if (n == 0) return false;

	lint* data = new lint[4001];
	for (int i = 0; i <= 4000; i++) data[i] = 0;

	for (lint i = 0; i < n; i++) {
		cin >> e >> p >> q;
		data[e] += p * q;
	}

	bool flag = false;
	for (int i = 1; i <= 4000; i++) {
		if (data[i] >= 1000000) {
			flag = true;
			cout << i << endl;
		}
	}
	if (!flag) cout << "NA" << endl;

	delete[] data;
	return true;
}

int main()
{
	while (AOJ0100()) {
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
 
int main()
{
    int n;
     
    while (cin >> n, n) {
        int cnt = 0;
        unsigned long long int s[4002] = {0}, gs[4002] = {0};

        int t, cost, num;

        for (int i = 0; i < n; i++) {
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
         
	for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if(gs[i] == gs[j] && i < j) {
                    gs[j] = 4001;
                }
            }
        }
         
        for (int i = 0; i < n; i++) {
            if (s[gs[i]] >= 1000000) {
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if (!cnt) cout << "NA" << endl;
    }
    return 0;
}

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

long long int sale[4001];

int main(){
	int p;
	while(cin >> p, p){
		for(int i=0; i < 4001; i++) sale[i] = 0;
		int id, price, num, result=0;

		for(int i=0; i < p; i++){
			cin >> id >> price >> num;
			sale[id] += price * num;
		}
		for(int i=0; i < 4001; i++){
			if(1000000 <= sale[i]){
				cout << i << endl;
				result++;
			}
		}
		if(result == 0) cout << "NA" << endl;
	}
}

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

using namespace std;
typedef long long Int;
Int n, b, c, num[4320];
Int sum[4320];
int main(){
	while(cin >> n, n){
		fill(sum, sum + 4320, 0);
		for(int i = 0;i < n;i++){
			cin >> num[i] >> b >> c;
			sum[num[i]] += b * c;
		}
		bool na = true;
		for(int i = 0;i < n;i++){
			if(sum[num[i]] >= 1000000){
				na = false;
				cout << num[i] << endl;
				sum[num[i]] = 0;
			}
		}
		if(na)cout << "NA" << endl;
	}
	return 0;
}