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>
using namespace std;

int main(void)
{
	map<long long, long long> result;

	while(1)
	{
		int n;
		cin >> n;
		if(n == 0)break;

		result.clear();
		for(int i=0; i<n; i++)
		{
			int id, p, q;
			cin >> id >> p >> q;
			result[id] += p*q;
		}

		bool exist=false;
		map<long long, long long>::iterator i=result.begin();
		for(i; i!=result.end(); i++)
		{
			if((*i).second >= 1000000)
			{
				cout << (*i).first << endl;
				exist=true;
			}
		}
		if(!exist)cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5 + 1;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int main() {
	int n;
	while(cin >> n && n){
		bool check[4096] = {0};
		LL sum[4096] = {0};
		vector<int> data;
		REP(i,n){
			int id, money, num; 
			scanf("%d%d%d", &id, &money, &num);
			if(!check[id]){
				check[id] = true;
				data.PB(id);
			}
			sum[id] += money * num;
		}
		bool ok = false;
		REP(i,data.size()){
			if(sum[data[i]] >= 1000000){
				printf("%d\n", data[i]);
				ok = true;
			}
		}
		if(!ok)
			cout << "NA" << endl;
	}
	return 0;
}

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

int N, M;

int main() {
	long long goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long v[4000];
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			int e, p, q;
			cin >> e >> p >> q;
			v[e - 1] += p*q;
		}
		bool flag = false;
		for (int i = 0; i < 4000; i++) {
			if (v[i] >= goal) {
				flag = true;
				cout << i + 1 << endl;

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

	return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  bool f;
  vector<pair<int, long long int> > v;
  int n, a, b, c;
  while (cin >> n && n > 0) {
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      f = 0;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first == a) {
          v[j].second += b * c;
          f = 1;
        }
      }
      if (!f) {
        v.push_back(pair<int, int>(a, b * c));
      }
    }
    f = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        cout << v[i].first << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

class CMem {
public :
	CMem() { m_check = false; m_sale = 0; }
	void Idata(long long sale) { m_sale += sale; m_check = true; }
	bool Ocheck() { return m_check; }
	long long Osale() { return m_sale; }
private :
	bool m_check;
	long long m_sale;
};

int main(void)
{
	while(1) {
		CMem member[4001];
		bool NA = true;
		int n, id, asale, scale;
		long long sale;

		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; i++) {
			cin >> id >> asale >> scale;
			sale = asale * scale;

			member[id].Idata(sale);
		}

		for(int i = 1; i <= 4000; i++) {
			if(member[i].Ocheck() == true && member[i].Osale() >= 1000000) {
				cout << i << endl;
				NA = false;
			}
		}

		if(NA == true) cout << "NA" << endl;
	}
	return 0;
}

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

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        long long int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        long long int t,cost;
        int 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){
                    s[gs[i]] += s[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<stdio.h>

int main(){
int N;
int n,m,p;
long P[4003][3]={};
long PT[4003][4]={};

while(1){
scanf("%d",&N);if(N==0)break;

for(int i=1;i<=N;i++){
scanf("%d %d %d",&n,&m,&p);
P[n][0]+=m*p;if(P[n][1]==0)P[n][1]=i;
}
int c=0;
for(int i=0;i<=4001;i++)
if(1000000<=P[i][0]){PT[c][0]=P[i][0];PT[c][1]=P[i][1];PT[c][2]=i;c++;}

for(int i=0;i<c;i++)
for(int j=c-1;j>i;j--)
if(PT[j][1]<PT[j-1][1])
{long TT=PT[j][1];PT[j][1]=PT[j-1][1];PT[j-1][1]=TT;
 long TTT=PT[j][2];PT[j][2]=PT[j-1][2];PT[j-1][2]=TTT;}

for(int i=0;i<c;i++)
printf("%ld\n",PT[i][2]);
if(c==0)printf("NA\n");
for(int i=0;i<=4001;i++)
{P[i][0]=0;P[i][1]=0;P[i][2]=0;
 PT[i][0]=0;PT[i][1]=0;PT[i][2]=0;PT[i][3]=0;}

}
return  0;
}

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

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

int main() {
	int n;
	while (cin >> n) {
		int count = 0;
		unordered_map<int, int> dic;
		int ids[n];
		for (int i = 0; i < n; i++) {
			int id, p, c;
			cin >> id >> p >> c;
			ids[i] = id;
			if (dic.find(id) == dic.end()) dic[id] = 0;
			dic[id] += p * c;
		}
		
		vector<int> printed;
		for (int i = 0; i < n; i++) {
			bool print = false;
			for (int j = 0; j < printed.size(); j++) {
				if (printed[j] == ids[i]) {
					print = true;
					break;
				}
			}
			if (print) continue;
			if (dic[ids[i]] >= 1000000) {
				cout << ids[i] << endl;
				printed.push_back(ids[i]);
				count++;
			}
		}
		if (count == 0 && n > 0) cout << "NA" << endl;
	}
	return 0;
}

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

int main(void){
	vector<int> vec1,vec2,vec3,number2;
	int n,count=0;
	cin >> n;
	for(int i=0;i<n;i++){
		int number,count,buy;
		cin >> number >> count >> buy;
		vec1.push_back(number);
		vec2.push_back(count);
		vec3.push_back(buy);
	}
	for(int i=0;i<n;i++){
		if(vec2[i]*vec3[i]>1000000){
			number2.push_back(vec1[i]);
			count++;
		}
	}
	if(count>0){
		for(int i=0;i<number2.size();i++){
			cout << number2[i] << endl;
		}
	}else{
		cout << "NA" << endl;
	}
	return 0;
}