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 <cstdio>   /* printf, scanf */
#include <utility>  /* pair, make_pair */
#include <vector>   /* vector */

using namespace std;
int GetContainsNumber(const vector<pair<int, int>> v, const int e) {

    int i = 0;
    for (vector<pair<int, int>>::const_iterator it = v.begin(); it != v.end(); it++) {
        if (e == it->first) {
            return i;
        }
        i++;
    }
    return -1;
}

int main()
{
    int n = 0, e = 0, p = 0, q = 0;
    vector<pair<int, int>> vec;
    while (true) {
        scanf("%d", &n);
        if(0 == n)
            break;

        bool isFind = false;
        for (int i = 0; i < n; i++) {
            scanf("%d%d%d", &e, &p, &q);
            int idx = GetContainsNumber(vec, e);
            if (-1 == idx) {
                vec.push_back(make_pair(e, p * q));
            }
            else {
                vec[idx].second += p * q;
            }
        }

        for (vector<pair<int, int>>::iterator it = vec.begin(); it != vec.end(); it++) {
            if (1000000 <= it->second) {
                printf("%d\n", it->first);
                isFind = true;
            }
        }

        if (!isFind) {
            printf("NA\n");
        }
        vec.clear();
    }

    return 0;
}

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

using namespace std;

int main(){
  int n, i, p, q;
  while(true){
    cin >> n;
    if(n==0)
      break;

    map<int,int> mop;
    vector<int> ord;
    bool check = true;

    for(int j=0; j<n; j++){
      cin >> i >> p >> q;
      if(mop.find(i) == mop.end()){
	mop[i] = p*q;
	ord.push_back(i);
      }
      else if(mop[i] < 1000000){
	mop[i] += p*q;
      }
    }
    
    for(int j=0; j<ord.size(); j++){
      if(mop[ord[j]] >= 1000000){
	cout << ord[j] << endl;
	check = false;
      }
    }
    if(check)
      cout << "NA\n";
  }
  return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
   	int n;
    
    int number, perPrice, amount;
    
    bool isUsed;
    //long long valueCheck[4000];
    vector<long long> valueCheck(4000, 0);
    queue<int> que;
    
    while(true)
    {
        isUsed = false;
        
        cin>>n;
        
        if (n == 0)
        {
            break;
        }
        
        while(n--)
        {
            cin>>number>>perPrice>>amount;
            
            valueCheck[number] += perPrice * amount;
            que.push(number);
        }
        
        while (!que.empty()) //if empty return true
        {
            if (valueCheck[que.front()] >= 1000000) //check the first element
            {
                cout<<que.front()<<endl;
                
                isUsed = true;
            }
            
            valueCheck[que.front()] = 0;
            
            que.pop(); //delete the beginning element, do the next judgement
        }
        
        if (!isUsed)
        {
            cout<<"NA"<<endl;
        }
        
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include <stdio.h>
 
int n,num[4000];
long long int tanka[4000],sale_num[4000],sale_all[4001];
bool judge[4001];
 
int main(void)
{
int i,j,k;
     
while(scanf("%d",&n),n){
    for(i=0;i<n;i++){
        scanf("%lld %lld %lld",&num[i],&tanka[i],&sale_num[i]);
    }
    k=0;
    for(j=0;j<4001;j++){
    judge[j]=0;
    sale_all[i]=0;
    }
    for(i=0;i<n;i++){
        sale_all[num[i]] += tanka[i]*sale_num[i];
    }
    for(i=0; i < n; i++){
        if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
            printf("%d\n",num[i]);
            judge[num[i]]=1;
            k=1;
        }
    }
    if(k!=1)printf("NA\n");
}
 
    return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    map<int,long long> emps;
    vector<int> ids;
    bool exist=false;
    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;
                exist=true;
            }
        }
        if(exist) cout << "NA" << endl;

    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
typedef 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;
}

C++: #include <stdio.h>
  
int n,num[4000];
long long int tanka[4000],sale_num[4000],sale_all[4001];
short judge[4001];
  
int main(void){
	int i,j,k;
	
	while(scanf("%d",&n),n){
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka[i],&sale_num[i]);
		}
		k=0;
		for(j=0;j<4001;j++){
			judge[j]=0;
			sale_all[i]=0;
		}
		for(i=0;i<n;i++){
			sale_all[num[i]] += tanka[i]*sale_num[i];
		}
		for(i=0; i < n; i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		if(k!=1)printf("NA\n");
	}

    return 0;
}

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

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long> m;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			m[str] += (num * a);
		}
		map <string, long> ::iterator it;
		bool flag = true;
		/*
		for (it = m.begin(); it != m.end(); it++){
			cout << it->first << " -- " << it->second << endl;
		}*/
		
		for (it = m.begin(); it != m.end(); it++){
			if (1000000 <= it->second){
				cout << it->first << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		long long number[4000]={};
		for(int i=0;i<n;i++){
		int e,p,q;
		cin>>e>>p>>q;
		number[e-1]+=p*q;
			}
		vector<int>v;
		for(int i=0;i<4000;i++){
			if(number[i]>=1000000){
				v.push_back(i+1);
				}
			}
			
		if(v.empty()){cout<<"NA"<<endl;}
		else{
			for(int i=0;i<v.size();i++){
				cout<<v[i]<<endl;
				}
			}		
		
		}
		return 0;
	}