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<bits/stdc++.h>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


typedef long long ll;

vector<int> hoge;
map<int,int> sums;

bool input(){
  hoge.clear();
  sums.clear();
  int n;
  cin>>n;
  if(n==0)return false;
  rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    sums[a] += b*c;

  }

  for(auto i:sums){
    if(i.second>=1000000)hoge.push_back(i.first);
  }
  return true;
}

void solve(){

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

int main(){
  while(input()){
    //cout<<solve()<<endl;
    solve();
  }
}

C++: g#include <iostream>
#include <vector>
#include <utility>
#include <map>

using namespace std;

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

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int n,a,b,c;



int main(){
    
        
    while(cin >> n){
        if(n==0)break;
        
        long long int ans[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            if(b>=1000&&c>=1000)ans[a]=1000000;
            else if(b>=1000000)ans[a]=1000000;
            else if(ans[a]<1000000)ans[a]+=b*c;
        }
        
        for(int i=1; i<=4000; i++){
            if(ans[i]>=1000000){
                cout<<i<<endl;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}

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

int main()
{
  int n;
  while (std::cin >> n) {
    if (n == 0) break;
    
    bool na = true;
    std::map<int, long long> id_sales_map;

    for (int i = 0; i < n; ++i) {
      int ID;
      long long price, number;
      std::cin >> ID >> price >> number;

      if (id_sales_map[ID] < 1000000) {
        id_sales_map[ID] += price * number;
        if (id_sales_map[ID] >= 1000000) {
          std::cout << ID << std::endl;
          na = true;
        }
      }
    }

    if (na) {
      std::cout << "NA" << std::endl;
    }
  }

  return 0;
}

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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int n; ll en, price, qty, check[4001]; qi que;

int main()
{
    while(cin >> n) {
       if (n == 0) break;
       
       for(int i=0; i < n; ++i) {
           cin >> en >> price >> qty;
           if (check[en] >= 0) check[en] += price*qty;
           if (check[en] >= lim) {
               que.push(en);
               check[en]=-1;
           }
       }
        
       if (que.empty()) cout << "NA" << "\n";
       else {
           for(int i=0,len=que.size(); i < len; ++i) {
               cout << que.front() << "\n";
               que.pop();
           }
       }
    }

    return 0;
}

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

int main(){
	int n;
	while( cin >> n, n ){
		map<int, int> worker;
		queue<int> order;
		for( int i = 0; i < n; i++ ){
			int id, price, num;
			cin >> id >> price >> num;
			if( worker.find(id) == worker.end() ){
				order.push(id);
			}
			worker[id] += (price * num);
		}
		bool flag = true;
		while( !order.empty() ){
			if( worker[order.front()] >= 1000000 ){
				cout << order.front() << endl;
				flag = false;
			}
			order.pop();
		}
		if( flag ){
			cout << "NA" << endl;
		}
	}
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n, no[4000], t[4000], num[4000], a[4000], i, j;
	while (cin >> n && n)
	{
		for (i = 0, j = 0; i < n; i++)
		{
			cin >> no[i] >> t[i] >> num[i];
			if (t[i] * num[i] >= 1000000)
				a[j] = no[i], j++;
		}
		if (j == 0)
			cout << "NA" << endl;
		else
			for (i = 0; i < j; i++)
				cout << a[i] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

typedef map<int, pair<int, long long> > mipill;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		mipill data;
		rep(i, n){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			long long sum = ((long long)b) * c;
			if(data.count(a))
				data[a].second += sum;
			else
				data[a] = make_pair(data.size(), sum);
		}

		vector<pii> v;
		for(mipill::iterator itr = data.begin(); itr != data.end(); ++itr){
			if(itr->second.second >= 1000000ll)
				v.push_back(pii(itr->second.first, itr->first));
		}

		sort(v.begin(), v.end());
		rep(i, v.size()){
			printf("%d\n", v[i].second);
		}
		if(v.empty())
			puts("NA");
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
typedef unsigned long long ll;
int main(){
  int n,val,num,inindex;
  vector<int> Index;
  map<int,ll> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    List.clear();
    Index.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(!List[inindex]){
	Index.push_back(inindex);
      }
      List[inindex]+=val*num;
    }
    bool NAf=true;
    for(int i=0;i<Index.size();i++){
      if(List[Index[i]] >= 1000000){
	printf("%d\n",Index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}