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++: //AOJ0100
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long 
int main(){
	int n;
	while(cin>>n,n!=0){
vector< pair<int,__int64> >ta;
ta.clear();
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
bool f=0;
int index=0;
for(int j=0;j<ta.size();j++)if(ta[j].first==a)f=1,index=j;
__int64 bc=b*c;
if(f==0)ta.push_back(pair<int,__int64>(a,bc));
else ta[index].second+=b*c;
}
bool f=0;
//cout<<"size "<<ta.size()<<endl;
for(int i=0;i<ta.size();i++){
	//cout<<ta[i].first<<"   "<<ta[i].second<<endl;
	if(ta[i].second>=1000000){cout<<ta[i].first<<endl;;f=1;}
}
	if(!f)cout<<"NA"<<endl;
}
	return 0;
}

C++: #include<iostream>
using namespace std;
main(){
	int n;
	while(cin>>n,n){
		int c=0,data[4000],no[n];
		for(int i=0;i<4000;++i)data[i]=0;
		for(int i=0;i<n;++i){
			no[i]=0;
			int n2,tan,num;
			cin>>n2>>tan>>num;
			if(!data[n2])no[i]=n2;
			data[n2]+=tan*num;
		}
		for(int i=0;i<n;++i){
			int n2=no[i];
			if(data[n2]>=1000000){
				cout<<n2<<endl;
				c++;
			}
		}
		if(!c)cout<<"NA"<<endl;
	}
}

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

using namespace std;
class MAN{
public:
	unsigned int uriage;
	short number;
};

int main(int argc, char const* argv[])
{
	MAN *person;
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		person  = new MAN[n];
		for( int i = 0;i < n;i++ ){
			int target;
			int a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
		delete[] person;
	}

	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;
typedef pair<int, int> P;

int main()
{
    int flag[4001];
    int n, c, num, val, sale, na;
    P hoge[4001];
    
    while (1) {
        cin >> n;
        if(n == 0) break;
        
        c = 1;
        na = 1;
        memset(flag, 0, sizeof(int)*4001);
        
        for(int i=0; i<n; i++){
            cin >> num >> val >> sale;
            if(flag[num] == 0){
                flag[num] = c;
                hoge[c].first = num;
                hoge[c].second = val * sale;
                c++;
            } else {
                hoge[flag[num]].second += val * sale;
            }
        }
        for(int i=1; i<c; i++){
            if(hoge[i].second >= 1000000){
                na = 0;
                cout << hoge[i].first << endl;
            }
        }
        if(na == 1) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int t[5000]={0};
  long long sum[5000]={0};
  bool NA=true;
  while(cin>>n,n){
    NA=true;
    for(int i=0;i<5000;i++){
      t[i]=0; sum[i]=0;
    }
    int a,b,c;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      for(int j=0;j<5000;j++){
	if(t[j]==a)break;
	if(t[j]==0){t[j]=a;break;}
      }
      sum[a]+=b*c;
    }
    for(int i=0;i<5000;i++){
      if(sum[t[i]]>=1000000){
	cout<<t[i]<<endl; NA=false;
      }
    }
    if(NA)cout<<"NA"<<endl;
  }
}

C++: #include <iostream>

#define NUM_MAX 4000

using namespace std;

int main(void){
  int s[NUM_MAX];
  bool ss[NUM_MAX + 1];
  int n;
  int in1, in2, in3;

  while(true){
    
    cin >> n;

    if(n == 0) break;

    for(int i = 0; i < NUM_MAX; i++){
      s[i] = 0;
    }

    for(int i = 0; i < NUM_MAX + 1; i++){
      ss[i] = false;
    }

    for(int i = 0; i < n; i++){
      cin >> in1 >> in2 >> in3;
      s[in1] += in2 * in3;
      if(s[in1] >= 1000000){
	ss[in1] = true;
	ss[NUM_MAX] = true;
      }
    }
    
    if(!ss[NUM_MAX]){
      cout << "NA" << endl;
      continue;
    }
    
    for(int i = 0; i < NUM_MAX; i++){
      if(ss[i]){
	cout << i << endl;
      }
    }
  }

  return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
const int MAXN = 4020;
typedef long long ll;
int i,p,q;
bool isfind = false;
map<int,ll> total;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)return 0;
    for(int k = 0;k < n;k++){
      cin >> i >> p >> q;
      total[i] += p*q;
    }
    for(map<int, ll>::iterator i = total.begin(); i != total.end(); ++i){
      if(i->second >= 1000000){
	isfind = true;
	cout << i->first << endl;
      }
    }
    if(!isfind)cout << "NA" << endl;
    total.clear();
    isfind =false;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>;
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)break;
		long long u[4010] = { 0 };
		vector<int>l;
		for (int i = 0; i < n; i++){
			long a, b, c;
			cin >> a >> b >> c;
			u[a] += b*c;
			if (u[a] >= 1000000 && find(l.begin(), l.end(), a) == l.end())l.push_back(a);
		}
		for (int i = 0; i < l.size(); i++){
			cout << l[i] << endl;
		}
		if (!l.size())cout << "NA" << endl;
	}
	return 0;
}